When using CMake to generate a Visual Studio 2019 project, the project can compile but fails to locate definitions
-
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?
-
C Christian Ehrlicher moved this topic from General and Desktop on
-
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?