Skip to content

Commit

Permalink
refs #4093 Also add support for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
beutlich committed Jan 26, 2024
1 parent fb2d0f5 commit 12494fd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions Modelica/Resources/BuildProjects/CMake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/Library/${MODELICA_PLATFORM_NA
include(compiler_options.cmake)
include(options.cmake)
include(src.cmake)
include(test.cmake)
16 changes: 8 additions & 8 deletions Modelica/Resources/BuildProjects/CMake/src.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,23 @@ if(MODELICA_BUILD_ZLIB)
endif()

if(MODELICA_DEBUG_TIME_EVENTS)
target_compile_definitions(ModelicaStandardTables PUBLIC -DDEBUG_TIME_EVENTS=1)
target_compile_definitions(ModelicaStandardTables PRIVATE -DDEBUG_TIME_EVENTS=1)
endif()
if(MODELICA_SHARE_TABLE_DATA)
target_compile_definitions(ModelicaStandardTables PUBLIC -DTABLE_SHARE=1)
target_compile_definitions(ModelicaStandardTables PRIVATE -DTABLE_SHARE=1)
endif()
if(NOT MODELICA_COPY_TABLE_DATA)
target_compile_definitions(ModelicaStandardTables PUBLIC -DNO_TABLE_COPY=1)
target_compile_definitions(ModelicaStandardTables PRIVATE -DNO_TABLE_COPY=1)
endif()
if(MODELICA_DUMMY_FUNCTION_USERTAB)
target_compile_definitions(ModelicaStandardTables PUBLIC -DDUMMY_FUNCTION_USERTAB=1)
if(MODELICA_DUMMY_FUNCTION_USERTAB OR BUILD_TESTING)
target_compile_definitions(ModelicaStandardTables PRIVATE -DDUMMY_FUNCTION_USERTAB=1)
endif()
if(MODELICA_BUILD_ZLIB AND (HAVE_WINAPIFAMILY_H OR HAVE_IO_H))
target_compile_definitions(zlib PUBLIC -DWINAPI_FAMILY=100)
target_compile_definitions(zlib PRIVATE -DWINAPI_FAMILY=100)
endif()
target_compile_definitions(ModelicaMatIO PUBLIC -DHAVE_ZLIB=1)
target_compile_definitions(ModelicaMatIO PRIVATE -DHAVE_ZLIB=1)
if(MSVC)
target_compile_options(ModelicaMatIO PUBLIC /wd4267)
target_compile_options(ModelicaMatIO PRIVATE /wd4267)
endif()

install(
Expand Down
21 changes: 21 additions & 0 deletions Modelica/Resources/BuildProjects/CMake/test.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
include(CTest)

if(BUILD_TESTING)
set(MODELICA_TESTS
FileSystem
ModelicaStrings
Streams
Tables
TablesFromCsvFile
TablesFromMatFile
TablesFromTxtFile
TablesNoUsertab
)
set(MODELICA_TEST_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../../../.CI/Test")
foreach(TEST ${MODELICA_TESTS})
add_executable(Test${TEST} "${MODELICA_TEST_SOURCE_DIR}/${TEST}.c")
target_link_libraries(Test${TEST} ModelicaExternalC ModelicaStandardTables ModelicaIO ModelicaMatIO zlib)
add_test(NAME Test${TEST} COMMAND Test${TEST} WORKING_DIRECTORY "${MODELICA_TEST_SOURCE_DIR}")
# set_target_properties(Test${TEST} PROPERTIES FOLDER "${MODELICA_TEST_SOURCE_DIR}")
endforeach()
endif()

0 comments on commit 12494fd

Please sign in to comment.