diff --git a/CMakeLists.txt b/CMakeLists.txt index 19afa2882..1b989a589 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -377,6 +377,14 @@ if (ENABLE_QT) message(STATUS "Will enable Qt launcher GUI") set(HAVE_QT 1) include (Translations) + + # extract the Qt root direction, since we need it for a few things + if (TARGET Qt5::qmake) + get_target_property(_qt5_qmake_path Qt5::qmake LOCATION) + get_filename_component(FG_QT_BIN_DIR ${_qt5_qmake_path} DIRECTORY) + get_filename_component(FG_QT_ROOT_DIR ${FG_QT_BIN_DIR} DIRECTORY) + endif() + else() # don't try to build FGQCanvas if Qt wasn't found correctly set(ENABLE_FGQCANVAS OFF) diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index 3435a392e..18b1a8a41 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -136,13 +136,7 @@ if(ENABLE_METAR) endif() if (MSVC) - if (TARGET Qt5::qmake) - # property is the full path to qmake.exe - get_target_property(_qt5_qmake_path Qt5::qmake LOCATION) - get_filename_component(_qt5_bin_dir ${_qt5_qmake_path} DIRECTORY) - file(TO_NATIVE_PATH "${_qt5_bin_dir}" _qt5_bin_dir_native) - endif() - + file(TO_NATIVE_PATH "${FG_QT_BIN_DIR}" _qt5_bin_dir_native) file(TO_NATIVE_PATH "${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/bin" _msvc_3rdparty_bin_dir) file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" _install_bin_dir) @@ -150,11 +144,7 @@ if (MSVC) VS_GLOBAL_LocalDebuggerEnvironment "PATH=${_install_bin_dir};${_msvc_3rdparty_bin_dir};${_qt5_bin_dir_native}") endif() -if (TARGET Qt5::qmake) - get_target_property(_qt5_qmake_path Qt5::qmake LOCATION) - get_filename_component(_qt5_bin_dir ${_qt5_qmake_path} DIRECTORY) - get_filename_component(_qt5_root_dir ${_qt5_bin_dir} DIRECTORY) - +if (FG_QT_ROOT_DIR) # for QtPlatformHeaders - target_include_directories(fgfs PRIVATE ${_qt5_root_dir}/include) + target_include_directories(fgfs PRIVATE ${FG_QT_ROOT_DIR}/include) endif() diff --git a/test_suite/CMakeLists.txt b/test_suite/CMakeLists.txt index 9fdf38b90..77e0ba2cb 100644 --- a/test_suite/CMakeLists.txt +++ b/test_suite/CMakeLists.txt @@ -155,19 +155,19 @@ target_link_libraries(fgfs_test_suite ${CPPUNIT_LIBRARIES}) # target to run the tests if (MSVC) - if (TARGET Qt5::qmake) - # property is the full path to qmake.exe - get_target_property(_qt5_qmake_path Qt5::qmake LOCATION) - get_filename_component(_qt5_bin_dir ${_qt5_qmake_path} DIRECTORY) - file(TO_NATIVE_PATH "${_qt5_bin_dir}" _qt5_bin_dir_native) - endif() + file(TO_NATIVE_PATH "${FG_QT_BIN_DIR}" _qt5_bin_dir_native) + file(TO_NATIVE_PATH "${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/bin" _msvc_3rdparty_bin_dir) + file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" _install_bin_dir) - file(TO_NATIVE_PATH "${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/bin" _msvc_3rdparty_bin_dir) - file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" _install_bin_dir) - - set(CMAKE_MSVCIDE_RUN_PATH "${_install_bin_dir};${_msvc_3rdparty_bin_dir};${_qt5_bin_dir_native}") + set(CMAKE_MSVCIDE_RUN_PATH "${_install_bin_dir};${_msvc_3rdparty_bin_dir};${_qt5_bin_dir_native}") endif() +if (FG_QT_ROOT_DIR) + # for QtPlatformHeaders + target_include_directories(fgfs_test_suite PRIVATE ${FG_QT_ROOT_DIR}/include) +endif() + + add_custom_target(test_suite ${TEST_SUITE_COMMAND} DEPENDS fgfs_test_suite