diff --git a/Modelica/Resources/BuildProjects/CMake/options.cmake b/Modelica/Resources/BuildProjects/CMake/options.cmake index cce1c91723..19ac14c7b6 100644 --- a/Modelica/Resources/BuildProjects/CMake/options.cmake +++ b/Modelica/Resources/BuildProjects/CMake/options.cmake @@ -21,3 +21,11 @@ option( # Option whether to install ModelicaExternalC option(MODELICA_INSTALL_EXTC "Install ModelicaExternalC library" OFF) + +# Option to enable testsuite +option(MODELICA_BUILD_TESTING "Build testing" ON) + +set(BUILD_TESTING OFF) +if(MODELICA_BUILD_TESTING) + set(BUILD_TESTING ON) +endif() diff --git a/Modelica/Resources/BuildProjects/CMake/test.cmake b/Modelica/Resources/BuildProjects/CMake/test.cmake index 0e57ddb6c4..b6c8929724 100644 --- a/Modelica/Resources/BuildProjects/CMake/test.cmake +++ b/Modelica/Resources/BuildProjects/CMake/test.cmake @@ -1,9 +1,8 @@ -include(CTest) - -if(BUILD_TESTING) +if(MODELICA_BUILD_TESTING) set(MODELICA_TEST_DIR_AUX "${MODELICA_RESOURCES_DIR}/../../.CI/Test") get_filename_component(MODELICA_TEST_DIR "${MODELICA_TEST_DIR_AUX}" ABSOLUTE) if(EXISTS "${MODELICA_TEST_DIR}") + enable_testing() set(MODELICA_TESTS FileSystem ModelicaStrings @@ -14,32 +13,34 @@ if(BUILD_TESTING) TablesFromTxtFile TablesNoUsertab ) - foreach(TEST ${MODELICA_TESTS}) - add_executable(Test${TEST} "${MODELICA_TEST_DIR}/${TEST}.c") - target_link_libraries(Test${TEST} + foreach(test_file ${MODELICA_TESTS}) + set(TEST_EXECUTABLE Test${test_file}) + add_executable(${TEST_EXECUTABLE} "${MODELICA_TEST_DIR}/${test_file}.c") + target_link_libraries(${TEST_EXECUTABLE} ModelicaExternalC ModelicaStandardTables ModelicaIO ModelicaMatIO ) if(MODELICA_BUILD_ZLIB) - target_link_libraries(Test${TEST} zlib) + target_link_libraries(${TEST_EXECUTABLE} zlib) else() - target_link_libraries(Test${TEST} z) + target_link_libraries(${TEST_EXECUTABLE} z) endif() if(UNIX) - target_link_libraries(Test${TEST} m) + target_link_libraries(${TEST_EXECUTABLE} m) endif() + set_target_properties(${TEST_EXECUTABLE} PROPERTIES FOLDER "Test") add_test( - NAME Test${TEST} - COMMAND Test${TEST} + NAME ${TEST_EXECUTABLE} + COMMAND ${TEST_EXECUTABLE} WORKING_DIRECTORY "${MODELICA_TEST_DIR}" ) endforeach() else() message(WARNING " Testsuite not found in \"${MODELICA_TEST_DIR}\"." - " Set BUILD_TESTING to OFF to silence this warning." + " Set MODELICA_BUILD_TESTING to OFF to silence this warning." ) endif() endif() diff --git a/Modelica/Resources/CMakeLists.txt b/Modelica/Resources/CMakeLists.txt index 3497de7300..f3a3f37fac 100644 --- a/Modelica/Resources/CMakeLists.txt +++ b/Modelica/Resources/CMakeLists.txt @@ -9,6 +9,8 @@ endif() project(Modelica_Standard_Library_Tables C) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + include(BuildProjects/CMake/Modelica_platform.cmake) include(BuildProjects/CMake/Modelica_utilities.cmake)