1
0
Fork 0

Move Qt root path variable to top-level CMakeList

This commit is contained in:
James Turner 2020-06-10 17:59:09 +01:00
parent c1afb053a1
commit 9326c88f9b
3 changed files with 21 additions and 23 deletions

View file

@ -377,6 +377,14 @@ if (ENABLE_QT)
message(STATUS "Will enable Qt launcher GUI") message(STATUS "Will enable Qt launcher GUI")
set(HAVE_QT 1) set(HAVE_QT 1)
include (Translations) 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() else()
# don't try to build FGQCanvas if Qt wasn't found correctly # don't try to build FGQCanvas if Qt wasn't found correctly
set(ENABLE_FGQCANVAS OFF) set(ENABLE_FGQCANVAS OFF)

View file

@ -136,13 +136,7 @@ if(ENABLE_METAR)
endif() endif()
if (MSVC) if (MSVC)
if (TARGET Qt5::qmake) file(TO_NATIVE_PATH "${FG_QT_BIN_DIR}" _qt5_bin_dir_native)
# 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 "${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/bin" _msvc_3rdparty_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) 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}") VS_GLOBAL_LocalDebuggerEnvironment "PATH=${_install_bin_dir};${_msvc_3rdparty_bin_dir};${_qt5_bin_dir_native}")
endif() endif()
if (TARGET Qt5::qmake) if (FG_QT_ROOT_DIR)
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)
# for QtPlatformHeaders # for QtPlatformHeaders
target_include_directories(fgfs PRIVATE ${_qt5_root_dir}/include) target_include_directories(fgfs PRIVATE ${FG_QT_ROOT_DIR}/include)
endif() endif()

View file

@ -155,19 +155,19 @@ target_link_libraries(fgfs_test_suite ${CPPUNIT_LIBRARIES})
# target to run the tests # target to run the tests
if (MSVC) if (MSVC)
if (TARGET Qt5::qmake) file(TO_NATIVE_PATH "${FG_QT_BIN_DIR}" _qt5_bin_dir_native)
# property is the full path to qmake.exe file(TO_NATIVE_PATH "${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/bin" _msvc_3rdparty_bin_dir)
get_target_property(_qt5_qmake_path Qt5::qmake LOCATION) file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" _install_bin_dir)
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 "${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/bin" _msvc_3rdparty_bin_dir) set(CMAKE_MSVCIDE_RUN_PATH "${_install_bin_dir};${_msvc_3rdparty_bin_dir};${_qt5_bin_dir_native}")
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}")
endif() 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 add_custom_target(test_suite
${TEST_SUITE_COMMAND} ${TEST_SUITE_COMMAND}
DEPENDS fgfs_test_suite DEPENDS fgfs_test_suite