From 6aa92faca83cc5e1ddb3faaecec2741dde072bb0 Mon Sep 17 00:00:00 2001 From: Mahder Gebremedhin Date: Mon, 16 Aug 2021 18:10:30 +0200 Subject: [PATCH] [cmake] Add a separate 'memory' library. - 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 --- OMCompiler/CMakeLists.txt | 2 +- OMCompiler/Compiler/runtime/CMakeLists.txt | 24 +++-------------- .../SimulationRuntime/c/cmake_3.14.cmake | 26 ++++++++++++++----- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/OMCompiler/CMakeLists.txt b/OMCompiler/CMakeLists.txt index db46dc16b0b..eeaab57e246 100644 --- a/OMCompiler/CMakeLists.txt +++ b/OMCompiler/CMakeLists.txt @@ -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! diff --git a/OMCompiler/Compiler/runtime/CMakeLists.txt b/OMCompiler/Compiler/runtime/CMakeLists.txt index 2cb92e8c697..6d10be08544 100644 --- a/OMCompiler/Compiler/runtime/CMakeLists.txt +++ b/OMCompiler/Compiler/runtime/CMakeLists.txt @@ -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 @@ -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) @@ -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) - - - - diff --git a/OMCompiler/SimulationRuntime/c/cmake_3.14.cmake b/OMCompiler/SimulationRuntime/c/cmake_3.14.cmake index dc9a88b3337..fa5bd2a60b3 100644 --- a/OMCompiler/SimulationRuntime/c/cmake_3.14.cmake +++ b/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) @@ -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)