Skip to content

Commit

Permalink
Restructure CMake configuration files
Browse files Browse the repository at this point in the history
  • Loading branch information
beutlich committed Apr 10, 2024
1 parent 2574913 commit bac614a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/checkCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
cmake -S "$SRCDIR" -B build -DMODELICA_UTILITIES_INCLUDE_DIR="$TESTDIR" -DMODELICA_DEBUG_TIME_EVENTS=ON -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_C_FLAGS="-std=c89 -Wall -Wextra"
fi
env:
SRCDIR: ${{ github.workspace }}/Modelica/Resources/BuildProjects/CMake
SRCDIR: ${{ github.workspace }}/Modelica/Resources
TESTDIR: ${{ github.workspace }}/.CI/Test
- name: Build with ${{ matrix.compiler }}
run: |
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
shell: C:\cygwin\bin\bash.exe -eo pipefail -o igncr '{0}'
env:
CYGWIN_NOWINPATH: 1
SRCDIR: ${{ github.workspace }}/Modelica/Resources/BuildProjects/CMake
SRCDIR: ${{ github.workspace }}/Modelica/Resources
TESTDIR: ${{ github.workspace }}/.CI/Test
- name: Build with gcc
run: |
Expand Down
70 changes: 36 additions & 34 deletions Modelica/Resources/BuildProjects/CMake/src.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ elseif(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS /W3)
endif()

set(MODELICA_SOURCE_DIR "${MODELICA_RESOURCES_DIR}/C-Sources")

if(MODELICA_BUILD_ZLIB)
set(ZLIB_INCLUDE_DIR "${MODELICA_RESOURCES_DIR}/C-Sources/zlib")
set(ZLIB_INCLUDE_DIR "${MODELICA_SOURCE_DIR}/zlib")
file(TO_CMAKE_PATH ${ZLIB_INCLUDE_DIR} ZLIB_INCLUDE_DIR)
include_directories(${ZLIB_INCLUDE_DIR})
elseif(DEFINED ZLIB_INCLUDE_DIR)
Expand All @@ -63,57 +65,57 @@ else()
endif()

set(EXTC_SOURCES
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaFFT.c"
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaFFT.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaInternal.c"
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaInternal.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaRandom.c"
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaRandom.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaStrings.c"
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaStrings.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/gconstructor.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/stdint_msvc.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/stdint_wrap.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/uthash.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/win32_dirent.c"
"${MODELICA_RESOURCES_DIR}/C-Sources/win32_dirent.h"
"${MODELICA_SOURCE_DIR}/ModelicaFFT.c"
"${MODELICA_SOURCE_DIR}/ModelicaFFT.h"
"${MODELICA_SOURCE_DIR}/ModelicaInternal.c"
"${MODELICA_SOURCE_DIR}/ModelicaInternal.h"
"${MODELICA_SOURCE_DIR}/ModelicaRandom.c"
"${MODELICA_SOURCE_DIR}/ModelicaRandom.h"
"${MODELICA_SOURCE_DIR}/ModelicaStrings.c"
"${MODELICA_SOURCE_DIR}/ModelicaStrings.h"
"${MODELICA_SOURCE_DIR}/gconstructor.h"
"${MODELICA_SOURCE_DIR}/stdint_msvc.h"
"${MODELICA_SOURCE_DIR}/stdint_wrap.h"
"${MODELICA_SOURCE_DIR}/uthash.h"
"${MODELICA_SOURCE_DIR}/win32_dirent.c"
"${MODELICA_SOURCE_DIR}/win32_dirent.h"
"${MODELICA_UTILITIES_INCLUDE_DIR}/ModelicaUtilities.h"
)

set(TABLES_SOURCES
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaStandardTables.c"
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaStandardTables.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaStandardTablesUsertab.c"
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaMatIO.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/gconstructor.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/stdint_msvc.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/stdint_wrap.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/uthash.h"
"${MODELICA_SOURCE_DIR}/ModelicaStandardTables.c"
"${MODELICA_SOURCE_DIR}/ModelicaStandardTables.h"
"${MODELICA_SOURCE_DIR}/ModelicaStandardTablesUsertab.c"
"${MODELICA_SOURCE_DIR}/ModelicaMatIO.h"
"${MODELICA_SOURCE_DIR}/gconstructor.h"
"${MODELICA_SOURCE_DIR}/stdint_msvc.h"
"${MODELICA_SOURCE_DIR}/stdint_wrap.h"
"${MODELICA_SOURCE_DIR}/uthash.h"
"${MODELICA_UTILITIES_INCLUDE_DIR}/ModelicaUtilities.h"
)

set(MATIO_SOURCES
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaMatIO.c"
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaMatIO.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/read_data_impl.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/safe-math.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/snprintf.c"
"${MODELICA_RESOURCES_DIR}/C-Sources/stdint_msvc.h"
"${MODELICA_SOURCE_DIR}/ModelicaMatIO.c"
"${MODELICA_SOURCE_DIR}/ModelicaMatIO.h"
"${MODELICA_SOURCE_DIR}/read_data_impl.h"
"${MODELICA_SOURCE_DIR}/safe-math.h"
"${MODELICA_SOURCE_DIR}/snprintf.c"
"${MODELICA_SOURCE_DIR}/stdint_msvc.h"
"${ZLIB_INCLUDE_DIR}/zlib.h"
"${MODELICA_UTILITIES_INCLUDE_DIR}/ModelicaUtilities.h"
)

set(IO_SOURCES
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaIO.c"
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaIO.h"
"${MODELICA_RESOURCES_DIR}/C-Sources/ModelicaMatIO.h"
"${MODELICA_SOURCE_DIR}/ModelicaIO.c"
"${MODELICA_SOURCE_DIR}/ModelicaIO.h"
"${MODELICA_SOURCE_DIR}/ModelicaMatIO.h"
"${MODELICA_UTILITIES_INCLUDE_DIR}/ModelicaUtilities.h"
)

if(MODELICA_BUILD_ZLIB)
file(GLOB ZLIB_SOURCES
"${MODELICA_RESOURCES_DIR}/C-Sources/zlib/*.c"
"${MODELICA_RESOURCES_DIR}/C-Sources/zlib/*.h"
"${MODELICA_SOURCE_DIR}/zlib/*.c"
"${MODELICA_SOURCE_DIR}/zlib/*.h"
)
endif()

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

if(BUILD_TESTING)
set(MODELICA_TEST_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../../../.CI/Test")
get_filename_component(ABSOLUTE_MODELICA_TEST_SOURCE_DIR "${MODELICA_TEST_SOURCE_DIR}" ABSOLUTE)
if(EXISTS "${ABSOLUTE_MODELICA_TEST_SOURCE_DIR}")
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}")
set(MODELICA_TESTS
FileSystem
ModelicaStrings
Expand All @@ -15,7 +15,7 @@ if(BUILD_TESTING)
TablesNoUsertab
)
foreach(TEST ${MODELICA_TESTS})
add_executable(Test${TEST} "${ABSOLUTE_MODELICA_TEST_SOURCE_DIR}/${TEST}.c")
add_executable(Test${TEST} "${MODELICA_TEST_DIR}/${TEST}.c")
target_link_libraries(Test${TEST}
ModelicaExternalC
ModelicaStandardTables
Expand All @@ -33,12 +33,12 @@ if(BUILD_TESTING)
add_test(
NAME Test${TEST}
COMMAND Test${TEST}
WORKING_DIRECTORY "${ABSOLUTE_MODELICA_TEST_SOURCE_DIR}"
WORKING_DIRECTORY "${MODELICA_TEST_DIR}"
)
endforeach()
else()
message(WARNING
" Testsuite not found in \"${ABSOLUTE_MODELICA_TEST_SOURCE_DIR}\"."
" Testsuite not found in \"${MODELICA_TEST_DIR}\"."
" Set BUILD_TESTING to OFF to silence this warning."
)
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ endif()

project(Modelica_Standard_Library_Tables C)

include(Modelica_platform.cmake)
include(Modelica_utilities.cmake)
include(BuildProjects/CMake/Modelica_platform.cmake)
include(BuildProjects/CMake/Modelica_utilities.cmake)

set(MODELICA_RESOURCES_DIR "${PROJECT_SOURCE_DIR}/../..")
get_filename_component(ABSOLUTE_MODELICA_RESOURCES_DIR "${MODELICA_RESOURCES_DIR}" ABSOLUTE)
Expand All @@ -27,7 +27,7 @@ set(
"Library installation path (don't change)" FORCE
)

include(compiler_options.cmake)
include(options.cmake)
include(test.cmake)
include(src.cmake)
include(BuildProjects/CMake/compiler_options.cmake)
include(BuildProjects/CMake/options.cmake)
include(BuildProjects/CMake/test.cmake)
include(BuildProjects/CMake/src.cmake)

0 comments on commit bac614a

Please sign in to comment.