| 1 |
# CMake module includes. |
| 2 |
include(SetupFGFSEmbeddedResources) |
| 3 |
include(SetupFGFSIncludes) |
| 4 |
include(SetupFGFSLibraries) |
| 5 |
include(SetupMSVCGrouping) |
| 6 |
|
| 7 |
# Add each test suite category. |
| 8 |
foreach(test_category |
| 9 |
gui_tests |
| 10 |
simgear_tests |
| 11 |
system_tests |
| 12 |
unit_tests |
| 13 |
fgdata_tests |
| 14 |
) |
| 15 |
add_subdirectory(${test_category}) |
| 16 |
endforeach(test_category) |
| 17 |
|
| 18 |
# Add the testing API. |
| 19 |
add_subdirectory(FGTestApi) |
| 20 |
|
| 21 |
# Add all test suite sources and headers. |
| 22 |
set(TESTSUITE_SOURCES |
| 23 |
${TESTSUITE_SOURCES} |
| 24 |
bootstrap.cxx |
| 25 |
dataStore.cxx |
| 26 |
fgCompilerOutputter.cxx |
| 27 |
fgTestListener.cxx |
| 28 |
fgTestRunner.cxx |
| 29 |
formatting.cxx |
| 30 |
logging.cxx |
| 31 |
testSuite.cxx |
| 32 |
) |
| 33 |
set(TESTSUITE_HEADERS |
| 34 |
${TESTSUITE_HEADERS} |
| 35 |
dataStore.hxx |
| 36 |
fgCompilerOutputter.hxx |
| 37 |
fgTestListener.hxx |
| 38 |
fgTestRunner.hxx |
| 39 |
formatting.hxx |
| 40 |
logging.hxx |
| 41 |
) |
| 42 |
|
| 43 |
# The test suite output directory. |
| 44 |
set(TESTSUITE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") |
| 45 |
|
| 46 |
# Get the CppUnit sources and headers to be built into the test suite. |
| 47 |
if (NOT SYSTEM_CPPUNIT) |
| 48 |
message(STATUS "CppUnit: Building the FlightGear supplied CppUnit library") |
| 49 |
|
| 50 |
get_property(CPPUNIT_SOURCES GLOBAL PROPERTY CPPUNIT_SOURCES) |
| 51 |
get_property(CPPUNIT_HEADERS GLOBAL PROPERTY CPPUNIT_HEADERS) |
| 52 |
|
| 53 |
|
| 54 |
add_library(CppUnitLib STATIC ${CPPUNIT_SOURCES} ${CPPUNIT_HEADERS}) |
| 55 |
|
| 56 |
target_include_directories(CppUnitLib PUBLIC "${PROJECT_SOURCE_DIR}/3rdparty/cppunit/include") |
| 57 |
elseif(NOT TARGET CppUnitLib) |
| 58 |
message(FATAL_ERROR "CppUnit: system CppUnit library not found correctly") |
| 59 |
else() |
| 60 |
message(STATUS "CppUnit: Linking to the system supplied CppUnit library") |
| 61 |
endif() |
| 62 |
|
| 63 |
#----------------------------------------------------------------------------- |
| 64 |
# Set up all test suites as CTests. |
| 65 |
|
| 66 |
# System test suites. |
| 67 |
add_test(AeroMeshSystemTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -s AeroMeshTests) |
| 68 |
#add_test(GPSSystemTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -s GPSTests) |
| 69 |
add_test(InstancedSubsystemSystemTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -s InstancedSubsystemTests) |
| 70 |
#add_test(NavaidsSystemTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -s NavaidsTests) |
| 71 |
add_test(NonInstancedSubsystemSystemTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -s NonInstancedSubsystemTests) |
| 72 |
|
| 73 |
# Unit test suites. |
| 74 |
add_test(AddonManagementUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u AddonManagementTests) |
| 75 |
add_test(AeroElementUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u AeroElementTests) |
| 76 |
add_test(AircraftPerformanceUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u AircraftPerformanceTests) |
| 77 |
add_test(AutosaveMigrationUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u AutosaveMigrationTests) |
| 78 |
add_test(FlightplanUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u FlightplanTests) |
| 79 |
add_test(FPNasalUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u FPNasalTests) |
| 80 |
add_test(GPSUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u GPSTests) |
| 81 |
add_test(HoldControllerUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u HoldControllerTests) |
| 82 |
if(ENABLE_HID_INPUT) |
| 83 |
add_test(HIDInputUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u HIDInputTests) |
| 84 |
endif() |
| 85 |
add_test(LaRCSimMatrixUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u LaRCSimMatrixTests) |
| 86 |
add_test(MktimeUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u MktimeTests) |
| 87 |
add_test(NasalSysUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u NasalSysTests) |
| 88 |
add_test(NasalSysUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u NasalLibTests) |
| 89 |
add_test(NavaidsUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u NavaidsTests) |
| 90 |
add_test(NavRadioUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u NavRadioTests) |
| 91 |
add_test(PosInitUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u PosInitTests) |
| 92 |
add_test(RNAVProcedureUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u RNAVProcedureTests) |
| 93 |
add_test(RouteManagerUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u RouteManagerTests) |
| 94 |
add_test(YASimAtmosphereUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -u YASimAtmosphereTests) |
| 95 |
|
| 96 |
# GUI test suites. |
| 97 |
|
| 98 |
# Simgear unit test suites. |
| 99 |
add_test(CanvasSimgearUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -m CanvasTests) |
| 100 |
add_test(MathGeodesySimgearUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -m MathGeodesyTests) |
| 101 |
add_test(SimgearPropsSimgearUnitTests ${TESTSUITE_OUTPUT_DIR}/fgfs_test_suite --ctest -m SimgearPropsTests) |
| 102 |
|
| 103 |
# FGData test suites. |
| 104 |
|
| 105 |
#----------------------------------------------------------------------------- |
| 106 |
# Set up the binary. |
| 107 |
|
| 108 |
# Set up the embedded resources. |
| 109 |
setup_fgfs_embedded_resources() |
| 110 |
|
| 111 |
# Sort the sources and headers for MSVC. |
| 112 |
setup_msvc_grouping() |
| 113 |
|
| 114 |
# most object files come from fgfsObjects target: this property |
| 115 |
# contains all the sources which need to be compiled seperately |
| 116 |
# for the test-suite, becuase they depend on BUILDING_TESTSUTIE define |
| 117 |
# we setup below via target_compile_definitions |
| 118 |
|
| 119 |
get_property(TEST_SOURCES GLOBAL PROPERTY FG_TEST_SOURCES) |
| 120 |
|
| 121 |
# Set up the separate executable for running the test suite. |
| 122 |
add_executable(fgfs_test_suite |
| 123 |
${TEST_SOURCES} |
| 124 |
${TESTSUITE_SOURCES} |
| 125 |
${TESTSUITE_HEADERS} |
| 126 |
$<TARGET_OBJECTS:fgfsObjects> |
| 127 |
) |
| 128 |
|
| 129 |
add_dependencies(fgfs_test_suite buildId) |
| 130 |
set_target_properties(fgfs_test_suite |
| 131 |
PROPERTIES |
| 132 |
RUNTIME_OUTPUT_DIRECTORY "${TESTSUITE_OUTPUT_DIR}" |
| 133 |
) |
| 134 |
if(ENABLE_AUTOTESTING) |
| 135 |
set(TEST_SUITE_COMMAND "fgfs_test_suite") |
| 136 |
set(TEST_SUITE_COMMENT "Running the full FlightGear test suite") |
| 137 |
else() |
| 138 |
set(TEST_SUITE_COMMENT "Building the FlightGear test suite.") |
| 139 |
endif(ENABLE_AUTOTESTING) |
| 140 |
|
| 141 |
# Set up the target links. |
| 142 |
setup_fgfs_libraries(fgfs_test_suite) |
| 143 |
# Additional search paths for includes. |
| 144 |
setup_fgfs_includes(fgfs_test_suite) |
| 145 |
|
| 146 |
# test codce includes its headers as test_suite/foo.h, so we need this |
| 147 |
target_include_directories(fgfs_test_suite PUBLIC ${PROJECT_SOURCE_DIR}) |
| 148 |
|
| 149 |
target_compile_definitions(fgfs_test_suite PUBLIC BUILDING_TESTSUITE) |
| 150 |
|
| 151 |
# Additional libraries just for the test suite. |
| 152 |
target_link_libraries(fgfs_test_suite CppUnitLib) |
| 153 |
|
| 154 |
# target to run the tests |
| 155 |
if (MSVC) |
| 156 |
file(TO_NATIVE_PATH "${FG_QT_BIN_DIR}" _qt_bin_dir_native) |
| 157 |
file(TO_NATIVE_PATH "${FINAL_MSVC_3RDPARTY_DIR}/bin" _msvc_3rdparty_bin_dir) |
| 158 |
file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" _install_bin_dir) |
| 159 |
|
| 160 |
set(CMAKE_MSVCIDE_RUN_PATH "${_install_bin_dir};${_msvc_3rdparty_bin_dir};${_qt_bin_dir_native}") |
| 161 |
endif() |
| 162 |
|
| 163 |
if (FG_QT_ROOT_DIR) |
| 164 |
# for QtPlatformHeaders |
| 165 |
target_include_directories(fgfs_test_suite PRIVATE ${FG_QT_ROOT_DIR}/include) |
| 166 |
endif() |
| 167 |
|
| 168 |
|
| 169 |
add_custom_target(test_suite |
| 170 |
${TEST_SUITE_COMMAND} |
| 171 |
DEPENDS fgfs_test_suite |
| 172 |
COMMENT ${TEST_SUITE_COMMENT} |
| 173 |
) |