When using CMake to generate a Visual Studio 2019 project, the project can compile but fails to locate definitions
-
wrote 22 days ago last edited by
When using CMake to generate a Visual Studio 2019 project, the project can compile but fails to locate definitions
Qt version: qt6.2.2
VS version: vs2019When creating a CMake project using QtCreator, the project compiles successfully, and pressing F2 can locate the definition of QWidget.
After converting the project to an sln solution using cmake-gui, the project still compiles successfully, but pressing F12 cannot find the definition of QWidget.I tried adding the following to CMakeLists.txt:
include_directories("E:/qt6/6.2.2msvc2019_64/include") target_include_directories(untitled PRIVATE "E:/qt6/6.2.2msvc2019_64/include")
Neither worked.
The issue is only resolved by manually adding the Qt path in the sln solution, but once modifying CMakeLists.txt requires editing the sln solution again, which is cumbersome.
Is there a way to modify CMakeLists.txt so that the definitions of Qt classes can be found?
-
-
When using CMake to generate a Visual Studio 2019 project, the project can compile but fails to locate definitions
Qt version: qt6.2.2
VS version: vs2019When creating a CMake project using QtCreator, the project compiles successfully, and pressing F2 can locate the definition of QWidget.
After converting the project to an sln solution using cmake-gui, the project still compiles successfully, but pressing F12 cannot find the definition of QWidget.I tried adding the following to CMakeLists.txt:
include_directories("E:/qt6/6.2.2msvc2019_64/include") target_include_directories(untitled PRIVATE "E:/qt6/6.2.2msvc2019_64/include")
Neither worked.
The issue is only resolved by manually adding the Qt path in the sln solution, but once modifying CMakeLists.txt requires editing the sln solution again, which is cumbersome.
Is there a way to modify CMakeLists.txt so that the definitions of Qt classes can be found?
@lyvvvv If symbols are not find then it means that a library is not found while linking.
Do you have this line in your CMakeLists.txt:find_package(Qt6 REQUIRED COMPONENTS Widgets)
?
-
wrote 21 days ago last edited by
This line of code has been added.
Without it, the project cannot be compiled.
-
@lyvvvv As far as I know Visual Studio supports CMake - why not using it directly instead of sln?
4/4