Skip to content

Commit

Permalink
Revise CTest configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
beutlich committed Nov 16, 2024
1 parent 11a3981 commit d1f71b9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
8 changes: 8 additions & 0 deletions Modelica/Resources/BuildProjects/CMake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
25 changes: 13 additions & 12 deletions Modelica/Resources/BuildProjects/CMake/test.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
2 changes: 2 additions & 0 deletions Modelica/Resources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit d1f71b9

Please sign in to comment.