CMake building precompiled headers can't find Qt stuff
-
2>1> 2>Building Custom Rule C:/Users/amonra/Documents/GitHub/DSS/DeepSkyStacker/CMakeLists.txt 2>cmake_pch.cxx 2>C:\Users\amonra\Documents\GitHub\DSS\DeepSkyStacker\stdafx.h(3,10): error C1083: Cannot open include file: 'QtWidgets': No such file or directory 2>(compiling source file 'CMakeFiles/DeepSkyStacker.dir/cmake_pch.cxx') 2>Done building project "DeepSkyStacker.vcxproj" -- FAILED.
I did:
find_package(Qt6 6.8 REQUIRED COMPONENTS Gui Widgets Network Charts) qt_standard_project_setup()
So thought that the Qt include dirs would be searched.
What have I missed?
-
2>1> 2>Building Custom Rule C:/Users/amonra/Documents/GitHub/DSS/DeepSkyStacker/CMakeLists.txt 2>cmake_pch.cxx 2>C:\Users\amonra\Documents\GitHub\DSS\DeepSkyStacker\stdafx.h(3,10): error C1083: Cannot open include file: 'QtWidgets': No such file or directory 2>(compiling source file 'CMakeFiles/DeepSkyStacker.dir/cmake_pch.cxx') 2>Done building project "DeepSkyStacker.vcxproj" -- FAILED.
I did:
find_package(Qt6 6.8 REQUIRED COMPONENTS Gui Widgets Network Charts) qt_standard_project_setup()
So thought that the Qt include dirs would be searched.
What have I missed?
@Perdrix said in CMake building precompiled headers can't find Qt stuff:
What have I missed?
At least the part on where you create the pch in the CMakeLists.txt
https://cmake.org/cmake/help/latest/command/target_precompile_headers.html
-
Since you as always fail to provide a minimal, compilable example - this works fine for me:
find_package(Qt6 COMPONENTS Widgets REQUIRED) add_executable(TestApp main.cpp ) target_link_libraries(TestApp PRIVATE Qt6::Widgets) target_precompile_headers(TestApp PRIVATE pre.h)
pre.h contains
#include <QDialog>
-
If I knew how to create a minimal example in this case I would have done so - its not for lack of trying.
I have specified:################################################################################ # Include directories ################################################################################ target_include_directories(DeepSkyStacker PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/. ${CMAKE_CURRENT_SOURCE_DIR}/../DeepSkyStackerKernel ${CMAKE_CURRENT_SOURCE_DIR}/GeneratedFiles/$<CONFIG> ${CMAKE_CURRENT_SOURCE_DIR}/GeneratedFiles ${CMAKE_CURRENT_SOURCE_DIR}/../LibRaw ${CMAKE_CURRENT_SOURCE_DIR}/../ZCLass ${CMAKE_CURRENT_SOURCE_DIR}/../Tools ${CMAKE_CURRENT_SOURCE_DIR}/../LibTiff ${CMAKE_CURRENT_SOURCE_DIR}/../CFitsIO ${CMAKE_CURRENT_SOURCE_DIR}/../Zlib $ENV{Boost_1_80_0} "$<$<CONFIG:Debug>:C:/Program Files (x86)/Visual Leak Detector/include>" )
to pick up my own include directories. If by doing that I have wiped out the ones set by:
find_package(Qt6 6.8 REQUIRED COMPONENTS Gui Widgets Network Charts) qt_standard_project_setup()
then I may have done that wrong - I thought target_include_directories appended to the ones already set, if not, how do I change that to append to the ones set by the Qt stuff.
D.
-
P Perdrix has marked this topic as solved on
-
I finally discovered that the includes for Qt are added when you do (for example):
target_link_libraries(DeepSkyStacker PRIVATE Qt6::Widgets Qt6::Network :
which is not at all obvious - once I added that, it worked.
@Perdrix said in CMake building precompiled headers can't find Qt stuff:
I finally discovered that the includes for Qt
That's not related to Qt but how imported targets in usually cmake work.
-
Not that in the Qt documentation of every class is written on how to use the Qt libs...
https://doc.qt.io/qt-6/qwidget.htmlCMake: find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets)