From 22de9d30b518646894ac190cc6b04371daa6d5c2 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 26 Sep 2019 13:00:23 +0100 Subject: [PATCH] Make the test_suite happier under MSBuild/VS Use the CMake target as the command to invoke, so various things get set automatically, and set the MSVCIDE_RUN_PATH so DLLs are found correctly. --- CMakeLists.txt | 8 -------- test_suite/CMakeLists.txt | 42 ++++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8186d0801..b54b97379 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -607,14 +607,6 @@ CONFIGURE_FILE( ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") - # The test suite. enable_testing() add_subdirectory(test_suite EXCLUDE_FROM_ALL) - -add_custom_target(test_suite - ${TEST_SUITE_COMMAND} - DEPENDS fgfs_test_suite - WORKING_DIRECTORY ${TEST_SUITE_WORKING_DIRECTORY} - COMMENT ${TEST_SUITE_COMMENT} -) diff --git a/test_suite/CMakeLists.txt b/test_suite/CMakeLists.txt index bafeae8c1..cf37d262d 100644 --- a/test_suite/CMakeLists.txt +++ b/test_suite/CMakeLists.txt @@ -127,32 +127,34 @@ set_target_properties(fgfs_test_suite RUNTIME_OUTPUT_DIRECTORY "${TESTSUITE_OUTPUT_DIR}" ) if(ENABLE_AUTOTESTING) - if(WIN32) - set(TEST_SUITE_COMMAND "fgfs_test_suite.exe") - set(TEST_SUITE_WORKING_DIRECTORY "${TESTSUITE_OUTPUT_DIR}/${CMAKE_BUILD_TYPE}") - else() - set(TEST_SUITE_COMMAND "fgfs_test_suite") - set(TEST_SUITE_WORKING_DIRECTORY "${TESTSUITE_OUTPUT_DIR}") - endif(WIN32) - set(TEST_SUITE_COMMENT "Running the full FlightGear test suite: ${TEST_SUITE_WORKING_DIRECTORY}/${TEST_SUITE_COMMAND}") + set(TEST_SUITE_COMMENT "Running the full FlightGear test suite") else() set(TEST_SUITE_COMMENT "Building the FlightGear test suite.") endif(ENABLE_AUTOTESTING) -set(TEST_SUITE_COMMAND - ${TEST_SUITE_COMMAND} - PARENT_SCOPE -) -set(TEST_SUITE_WORKING_DIRECTORY - ${TEST_SUITE_WORKING_DIRECTORY} - PARENT_SCOPE -) -set(TEST_SUITE_COMMENT - ${TEST_SUITE_COMMENT} - PARENT_SCOPE -) # Set up the target links. setup_fgfs_libraries(fgfs_test_suite) # Additional libraries just for the test suite. 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 "${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}") +endif() + +add_custom_target(test_suite + fgfs_test_suite + DEPENDS fgfs_test_suite + COMMENT ${TEST_SUITE_COMMENT} +)