Skip to content

Commit

Permalink
[cmake] Add a separate 'memory' library.
Browse files Browse the repository at this point in the history
  - This used to be part of OpenModelicaRuntimeC library. the code provides
    memory related (garbage collection and memory_pool) functionality. Due
    to this OpenModelicaRuntimeC was being linked from other libraries
    just to get this functionality.

    the memory related functionality is now a separate lib. This lib can
    be used in places where we need the memory management related interface
    and functionality of omc.

   - Misc
     Remove unused library omcgraphstream-boot
  • Loading branch information
mahge committed Aug 17, 2021
1 parent 1f63944 commit 6aa92fa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
2 changes: 1 addition & 1 deletion OMCompiler/CMakeLists.txt
Expand Up @@ -78,7 +78,7 @@ write_compiler_detection_header(
# Set the installation lib directory as an rpath for all installed
# libs and executables.
# Maybe there is a better way to do this but it should suffice for now.
SET(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_LIBDIR})
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_LIBDIR})


# Use ccache to speedup compilation!
Expand Down
24 changes: 3 additions & 21 deletions OMCompiler/Compiler/runtime/CMakeLists.txt
Expand Up @@ -75,7 +75,7 @@ target_link_libraries(omcruntime PUBLIC omc::config)
target_link_libraries(omcruntime PUBLIC CURL::libcurl)
target_link_libraries(omcruntime PUBLIC ${Intl_LIBRARIES})
target_link_libraries(omcruntime PUBLIC Iconv::Iconv)
target_link_libraries(omcruntime PUBLIC omc::simrt::runtime)
target_link_libraries(omcruntime PUBLIC omc::simrt::memory)
target_link_libraries(omcruntime PUBLIC omc::3rd::ffi)
target_link_libraries(omcruntime PUBLIC omc::3rd::libzmq)
target_link_libraries(omcruntime PUBLIC omc::3rd::FMIL::minizip) # We use the minizip lib from 3rdParty/FMIL
Expand Down Expand Up @@ -149,7 +149,7 @@ target_sources(omcbackendruntime PRIVATE ${OMC_BACKENDRUNTIIME_SOURCES})

target_link_libraries(omcbackendruntime PUBLIC omc::config)
target_link_libraries(omcbackendruntime PUBLIC ${Intl_LIBRARIES})
target_link_libraries(omcbackendruntime PUBLIC omc::simrt::runtime)
target_link_libraries(omcbackendruntime PUBLIC omc::simrt::memory)
target_link_libraries(omcbackendruntime PUBLIC omc::3rd::fmilib::static)
target_link_libraries(omcbackendruntime PUBLIC omc::3rd::metis)

Expand All @@ -164,27 +164,9 @@ add_library(omc::compiler::graphstream ALIAS omcgraphstream)
set(OMC_GRAPH_STREAM_SOURCES GraphStreamExt_omc.cpp)
target_sources(omcgraphstream PRIVATE ${OMC_GRAPH_STREAM_SOURCES})

target_link_libraries(omcgraphstream PUBLIC omc::simrt::runtime)
target_link_libraries(omcgraphstream PUBLIC omc::simrt::memory)
target_link_libraries(omcgraphstream PUBLIC omc::3rd::netstream)

# Remove the dependency of bootstrapping on graphstream lib and remove this. It is not needed for bootstrapping.
# ######################################################################################################################
# Library: omcgraphstream-boot
add_library(omcgraphstream-boot STATIC)
add_library(omc::compiler::graphstream-boot ALIAS omcgraphstream-boot)

set(OMC_GRAPH_STREAM_SOURCES GraphStreamExt_omc.cpp)
target_sources(omcgraphstream-boot PRIVATE ${OMC_GRAPH_STREAM_SOURCES})

# Define OMC_BOOTSTRAPPING for the boot lib.
target_compile_definitions(omcgraphstream-boot PRIVATE OMC_BOOTSTRAPPING)

target_link_libraries(omcgraphstream-boot PUBLIC omc::simrt::runtime)
target_link_libraries(omcgraphstream-boot PUBLIC omc::3rd::netstream)







Expand Down
26 changes: 19 additions & 7 deletions OMCompiler/SimulationRuntime/c/cmake_3.14.cmake
@@ -1,7 +1,5 @@
cmake_minimum_required(VERSION 3.14)

project(SimulationRuntimeC)

file(GLOB OMC_SIMRT_UTIL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/util/*.c)
file(GLOB OMC_SIMRT_UTIL_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/util/*.h)

Expand All @@ -14,32 +12,46 @@ file(GLOB OMC_SIMRT_GC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/gc/*.h)
file(GLOB OMC_SIMRT_FMI_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/fmi/*.c)
file(GLOB OMC_SIMRT_FMI_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/fmi/*.h)



# ######################################################################################################################
# Library: omcmemory
## This tiny library provides the memory related functionality of OM (garbage collection and memory_pool).
## The reason it is separated is because its functionality is clearly defined and should not be part of
## a bunch of other libraries. For example there is no need to link to OpenModelicaRuntimeC just to get GC
## functionality in Compiler/runtime.
add_library(omcmemory STATIC)
add_library(omc::simrt::memory ALIAS omcmemory)

target_sources(omcmemory PRIVATE ${OMC_SIMRT_GC_SOURCES})
target_link_libraries(omcmemory PUBLIC omc::3rd::omcgc)
target_include_directories(omcmemory PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})


# ######################################################################################################################
# Library: OpenModelicaRuntimeC
add_library(OpenModelicaRuntimeC STATIC)
add_library(omc::simrt::runtime ALIAS OpenModelicaRuntimeC)

target_sources(OpenModelicaRuntimeC PRIVATE ${OMC_SIMRT_UTIL_SOURCES} ${OMC_SIMRT_META_SOURCES} ${OMC_SIMRT_GC_SOURCES})
target_link_libraries(OpenModelicaRuntimeC PUBLIC omc::3rd::omcgc)
target_sources(OpenModelicaRuntimeC PRIVATE ${OMC_SIMRT_UTIL_SOURCES} ${OMC_SIMRT_META_SOURCES})
target_link_libraries(OpenModelicaRuntimeC PUBLIC omc::simrt::memory)

if(WIN32)
target_link_libraries(OpenModelicaRuntimeC PUBLIC dbghelp)
target_link_libraries(OpenModelicaRuntimeC PUBLIC regex)
endif(WIN32)

target_include_directories(OpenModelicaRuntimeC PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

install(TARGETS OpenModelicaRuntimeC)

# ######################################################################################################################
# Library: OpenModelicaFMIRuntimeC
add_library(OpenModelicaFMIRuntimeC STATIC ${OMC_SIMRT_FMI_SOURCES})
add_library(OpenModelicaFMIRuntimeC STATIC)
add_library(omc::simrt::fmiruntime ALIAS OpenModelicaFMIRuntimeC)

target_sources(OpenModelicaFMIRuntimeC PRIVATE ${OMC_SIMRT_FMI_SOURCES})

target_link_libraries(OpenModelicaFMIRuntimeC PUBLIC omc::3rd::fmilib::static)
target_link_libraries(OpenModelicaFMIRuntimeC PUBLIC omc::simrt::runtime)

install(TARGETS OpenModelicaFMIRuntimeC)

Expand Down

0 comments on commit 6aa92fa

Please sign in to comment.