Skip to content

Commit

Permalink
[cmake] Remove the Optimization library.
Browse files Browse the repository at this point in the history
  - this is also to reduce the amount of DLLs. It is actually better to
    just disable ipopt and dynamic optimization with a flag.

    It is enabled with the option WITH_IPOPT to match the makefile build
    system.

    NOTE: Disabling the option in CMake DOES NOT actually result in a
    functional compilation right now. The reason is that the flag WITH_IPOPT
    is actually hard coded in to omc_config* headers.

    I will fix that later.
  • Loading branch information
mahge committed Nov 11, 2021
1 parent 3515fef commit e02f3bc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
1 change: 1 addition & 0 deletions OMCompiler/CMakeLists.txt
Expand Up @@ -20,6 +20,7 @@ string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# options
omc_option(WITH_IPOPT "Should we enable dynamic optimization support with Ipopt." ON)
omc_option(OMC_USE_CORBA "Should use corba." OFF)

omc_option(OMC_USE_LPSOLVE "Should we use lpsolve." OFF)
Expand Down
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/runtime/CMakeLists.txt
Expand Up @@ -277,7 +277,7 @@ else()

string(REPLACE ";" " " LAPACK_LIBRARIES_SPACE "${LAPACK_LIBRARIES}")
set(RT_LDFLAGS_GENERATED_CODE " -lOpenModelicaRuntimeC -llapack -lblas -lm -lpthread -rdynamic")
set(RT_LDFLAGS_GENERATED_CODE_SIM " -lSimulationRuntimeC -lOpenModelicaRuntimeC -lOptimizationRuntime -lOpenModelicaRuntimeC -lzlib -llapack -lblas -lm -ldl -lpthread -lgfortran -lstdc++ -rdynamic -Wl,--no-undefined")
set(RT_LDFLAGS_GENERATED_CODE_SIM " -lSimulationRuntimeC -lOpenModelicaRuntimeC -lzlib -llapack -lblas -lm -ldl -lpthread -lgfortran -lstdc++ -rdynamic -Wl,--no-undefined")
set(RT_LDFLAGS_GENERATED_CODE_SOURCE_FMU " -llapack -lblas -lm -lpthread -rdynamic -Wl,--no-undefined")
set(RT_LDFLAGS_GENERATED_CODE_SOURCE_FMU_STATIC "-Wl,-Bstatic -lSimulationRuntimeFMI -Wl,-Bdynamic -llapack -lblas -lm -ldl -lpthread -lgfortran -lstdc++ -rdynamic -Wl,--no-undefined")

Expand Down
24 changes: 5 additions & 19 deletions OMCompiler/SimulationRuntime/c/cmake_3.14.cmake
Expand Up @@ -84,6 +84,11 @@ if(WIN32)
target_link_options(SimulationRuntimeC PRIVATE -Wl,--export-all-symbols)
endif(WIN32)

if(WITH_IPOPT)
target_sources(SimulationRuntimeC PRIVATE ${OMC_SIMRT_OPTIMIZATION_SOURCES})
target_compile_definitions(SimulationRuntimeC PRIVATE -DWITH_IPOPT)
target_link_libraries(SimulationRuntimeC PUBLIC omc::3rd::ipopt)
endif()

# Fix me. Make an interface (header only library) out of 3rdParty/dgesv
target_include_directories(SimulationRuntimeC PRIVATE ${OMCompiler_SOURCE_DIR}/3rdParty/dgesv/include/)
Expand All @@ -93,25 +98,6 @@ target_include_directories(SimulationRuntimeC PRIVATE ${OMCompiler_SOURCE_DIR}/3
install(TARGETS SimulationRuntimeC)


# ######################################################################################################################
# Library: OptimizationRuntime
## This is now separated from SimulationRuntimeC. Just for clarity. It can be put back in there if needed.
## However having it as a separate lib will allow us to remove it based on an option. This means we can
## also remove the need for ipopt and mumps if this is disabled.
add_library(OptimizationRuntime SHARED)
add_library(omc::simrt::optimize ALIAS OptimizationRuntime)

target_sources(OptimizationRuntime PRIVATE ${OMC_SIMRT_OPTIMIZATION_SOURCES})

target_link_libraries(OptimizationRuntime PUBLIC omc::config)
target_link_libraries(OptimizationRuntime PUBLIC omc::simrt::runtime)
target_link_libraries(OptimizationRuntime PUBLIC omc::simrt::simruntime)
target_link_libraries(OptimizationRuntime PUBLIC omc::3rd::ipopt)


install(TARGETS OptimizationRuntime)


# ######################################################################################################################
# include the configuration for (source code) FMI runtime and generate RuntimeSources.mo
# This is separated into another file just for clarity. Once it is cleaned up and organized
Expand Down

0 comments on commit e02f3bc

Please sign in to comment.