Skip to content

Commit

Permalink
[cmake] Improve ModelicaExternalC configuration.
Browse files Browse the repository at this point in the history
  - Look for ZLIB and add the HAVE_ZLIB  define if found.
  - Do the same for HDF5 if needed. It is disabled now.

  - Add ModelicaStandardTables library. It was overlooked before.

  - Install the libraries. They were not installed before only built.

    I am not sure if we actually need to install all of them but let it
    be for now.
  • Loading branch information
mahge committed Jul 21, 2021
1 parent 0b29726 commit 7d60c1d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ target_include_directories(metis INTERFACE metis-5.1.0/include)

# ModelicaExternalC
omc_add_subdirectory(ModelicaExternalC)
add_library(omc::3rd::modelica_external_c ALIAS ModelicaExternalC)
add_library(omc::3rd::modelica_mat_io ALIAS ModelicaMatIO)
add_library(omc::3rd::modelica_io ALIAS ModelicaIO)
add_library(omc::3rd::Modelica::ExternalC ALIAS ModelicaExternalC)
add_library(omc::3rd::Modelica::MatIO ALIAS ModelicaMatIO)
add_library(omc::3rd::Modelica::IO ALIAS ModelicaIO)
add_library(omc::3rd::Modelica::StandardTables ALIAS ModelicaStandardTables)


# Intel TBB
Expand Down
40 changes: 39 additions & 1 deletion ModelicaExternalC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,54 @@ cmake_minimum_required(VERSION 3.14)
project(OMModelicaExternalC)


# ModelicaExternalC
set(libModelicaExternalC_SOURCES C-Sources/ModelicaFFT.c
C-Sources/ModelicaInternal.c
C-Sources/ModelicaRandom.c
C-Sources/ModelicaStrings.c)
add_library(ModelicaExternalC STATIC ${libModelicaExternalC_SOURCES})

target_link_libraries(ModelicaExternalC PUBLIC m)


# ModelicaMatIO
set(libModelicaMatIO_SOURCES C-Sources/ModelicaMatIO.c C-Sources/snprintf.c)
add_library(ModelicaMatIO STATIC ${libModelicaMatIO_SOURCES})

find_package(ZLIB)
if(ZLIB_FOUND)
target_link_libraries(ModelicaMatIO PUBLIC ZLIB::ZLIB)
target_compile_definitions(ModelicaMatIO PRIVATE HAVE_ZLIB)
endif()

# find_package(HDF5)
# if(HDF5_FOUND)
# target_include_directories(ModelicaMatIO PRIVATE ${HDF5_INCLUDE_DIRS})
# target_link_libraries(ModelicaMatIO PUBLIC ${HDF5_LIBRARIES})
# target_compile_definitions(ModelicaMatIO PRIVATE HAVE_HDF5)
# endif()


# ModelicaIO
set(libModelicaIO_SOURCES C-Sources/ModelicaIO.c)
add_library(ModelicaIO STATIC ${libModelicaIO_SOURCES})
target_link_libraries(ModelicaIO INTERFACE ModelicaMatIO)

target_link_libraries(ModelicaIO PUBLIC ModelicaMatIO)



# ModelicaStandardTables
set(ModelicaStandardTables_SOURCES C-Sources/ModelicaStandardTables.c
C-Sources/ModelicaStandardTablesUsertab.c)
add_library(ModelicaStandardTables STATIC ${ModelicaStandardTables_SOURCES})

target_link_libraries(ModelicaStandardTables INTERFACE ModelicaMatIO)
target_link_libraries(ModelicaStandardTables PUBLIC m)




install(TARGETS ModelicaExternalC
ModelicaMatIO
ModelicaIO
ModelicaStandardTables)

0 comments on commit 7d60c1d

Please sign in to comment.