Skip to content

Commit

Permalink
- fixed fmu export of cpp-runtime
Browse files Browse the repository at this point in the history
- cleaned up some static-linking stuff
- fixed a segfault with the newly added profiling-points
  • Loading branch information
Marcus Walther committed May 29, 2015
1 parent b407268 commit e3c2d0a
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 126 deletions.
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenFMUCpp.tpl
Expand Up @@ -780,7 +780,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
CALCHELPERMAINFILE=OMCpp<%fileNamePrefix%>CalcHelperMain.cpp
ALGLOOPSMAINFILE=OMCpp<%fileNamePrefix%>AlgLoopMain.cpp

OMCPP_LIBS= -lOMCppSystem_FMU -lOMCppDataExchange_static -lOMCppOMCFactory -lOMCppMath_static
OMCPP_LIBS= -lOMCppSystem_static -lOMCppDataExchange_static -lOMCppOMCFactory_static -lOMCppMath_static -lOMCppModelicaUtilities_static
OMCPP_SOLVER_LIBS=-Wl,-rpath,"$(OMHOME)/lib/<%getTriple()%>/omc/cpp"
MODELICA_EXTERNAL_LIBS=-lModelicaExternalC -lModelicaStandardTables -L$(LAPACK_LIBS) $(LAPACK_LIBRARIES)
BOOST_LIBRARIES = -lboost_system -lboost_filesystem -lboost_program_options
Expand Down
36 changes: 17 additions & 19 deletions SimulationRuntime/cpp/Core/SimController/CMakeLists.txt
Expand Up @@ -2,28 +2,26 @@ cmake_minimum_required (VERSION 2.8.6)

project(${SimControllerName})

IF(RUNTIME_STATIC_LINKING)
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR}/kinsol ${SUNDIALS_INCLUDE_DIR})
add_library(${SimControllerName}_static STATIC Configuration.cpp FactoryExport.cpp Initialization.cpp SimController.cpp SimManager.cpp)
install (TARGETS ${SimControllerName}_static DESTINATION ${LIBINSTALLEXT})
ELSE(RUNTIME_STATIC_LINKING)
add_library(${SimControllerName} SHARED Configuration.cpp FactoryExport.cpp Initialization.cpp SimController.cpp SimManager.cpp)
target_link_libraries( ${SimControllerName} ${OMCFactoryName} ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
add_precompiled_header(${SimControllerName} Include/Core/Modelica.h )
install (TARGETS ${SimControllerName} DESTINATION ${LIBINSTALLEXT})
ENDIF(RUNTIME_STATIC_LINKING)
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR}/kinsol ${SUNDIALS_INCLUDE_DIR})
add_library(${SimControllerName}_static STATIC Configuration.cpp FactoryExport.cpp Initialization.cpp SimController.cpp SimManager.cpp)
install (TARGETS ${SimControllerName}_static DESTINATION ${LIBINSTALLEXT})

add_library(${SimControllerName} SHARED Configuration.cpp FactoryExport.cpp Initialization.cpp SimController.cpp SimManager.cpp)
target_link_libraries( ${SimControllerName} ${OMCFactoryName}_static ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
add_precompiled_header(${SimControllerName} Include/Core/Modelica.h )
install (TARGETS ${SimControllerName} DESTINATION ${LIBINSTALLEXT})

if (UNIX)
set_target_properties(${SimControllerName} PROPERTIES COMPILE_FLAGS -fPIC)
set_target_properties(${SimControllerName}_static PROPERTIES COMPILE_FLAGS -fPIC)
endif(UNIX)

install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/SimController/ISimData.h
${CMAKE_SOURCE_DIR}/Include/Core/SimController/ISimController.h
${CMAKE_SOURCE_DIR}/Include/Core/SimController/SimController.h
${CMAKE_SOURCE_DIR}/Include/Core/SimController/SimManager.h
DESTINATION include/omc/cpp/Core/SimController)

IF(RUNTIME_STATIC_LINKING)
install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/SimController/SimController.h
${CMAKE_SOURCE_DIR}/Include/Core/SimController/SimManager.h
${CMAKE_SOURCE_DIR}/Include/Core/SimController/Configuration.h
${CMAKE_SOURCE_DIR}/Include/Core/SimController/Initialization.h
DESTINATION include/omc/cpp/Core/SimController)
ENDIF(RUNTIME_STATIC_LINKING)
${CMAKE_SOURCE_DIR}/Include/Core/SimController/SimController.h
${CMAKE_SOURCE_DIR}/Include/Core/SimController/SimManager.h
${CMAKE_SOURCE_DIR}/Include/Core/SimController/Configuration.h
${CMAKE_SOURCE_DIR}/Include/Core/SimController/Initialization.h
DESTINATION include/omc/cpp/Core/SimController)
6 changes: 6 additions & 0 deletions SimulationRuntime/cpp/Core/SimController/SimController.cpp
Expand Up @@ -29,6 +29,12 @@ SimController::SimController(PATH library_path, PATH modelicasystem_path)
measureTimeFunctionsArray[0] = MeasureTimeData("initialize");
measureTimeFunctionsArray[1] = MeasureTimeData("solveInitialSystem");
}
else
{
measureTimeFunctionsArray = std::vector<MeasureTimeData>();
measuredFunctionStartValues = NULL;
measuredFunctionEndValues = NULL;
}
#endif
}

Expand Down
47 changes: 24 additions & 23 deletions SimulationRuntime/cpp/Core/SimulationSettings/CMakeLists.txt
@@ -1,29 +1,30 @@
cmake_minimum_required (VERSION 2.8.6)

project(${SimulationSettings})
# add the solver default implementation library
IF(RUNTIME_STATIC_LINKING)
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR})
add_library(${SimulationSettings}_static STATIC GlobalSettings.cpp Factory.cpp FactoryExport.cpp)
install (TARGETS ${SimulationSettings}_static DESTINATION ${LIBINSTALLEXT})
ELSE(RUNTIME_STATIC_LINKING)
add_library(${SimulationSettings} SHARED GlobalSettings.cpp Factory.cpp FactoryExport.cpp)
target_link_libraries( ${SimulationSettings} ${OMCFactoryName} ${Boost_LIBRARIES})
add_precompiled_header(${SimulationSettings} Include/Core/Modelica.h )
install (TARGETS ${SimulationSettings} DESTINATION ${LIBINSTALLEXT})
ENDIF(RUNTIME_STATIC_LINKING)

install (FILES "config/GlobalSettings.xml"
DESTINATION share/omc/runtime/cpp/config)
install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/SimulationSettings/IGlobalSettings.h
${CMAKE_SOURCE_DIR}/Include/Core/SimulationSettings/ISettingsFactory.h
${CMAKE_SOURCE_DIR}/Include/Core/SimulationSettings/ISimControllerSettings.h
DESTINATION include/omc/cpp/Core/SimulationSettings)

IF(RUNTIME_STATIC_LINKING)
install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/SimulationSettings/Factory.h
DESTINATION include/omc/cpp/Core/SimulationSettings)
ENDIF(RUNTIME_STATIC_LINKING)

include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR})
add_library(${SimulationSettings}_static STATIC GlobalSettings.cpp Factory.cpp FactoryExport.cpp)
add_precompiled_header(${SimulationSettings}_static Include/Core/Modelica.h)
install (TARGETS ${SimulationSettings}_static DESTINATION ${LIBINSTALLEXT})

add_library(${SimulationSettings} SHARED GlobalSettings.cpp Factory.cpp FactoryExport.cpp)
target_link_libraries( ${SimulationSettings} ${OMCFactoryName}_static ${Boost_LIBRARIES})
add_precompiled_header(${SimulationSettings} Include/Core/Modelica.h)
install (TARGETS ${SimulationSettings} DESTINATION ${LIBINSTALLEXT})

if (UNIX)
set_target_properties(${SimulationSettings} PROPERTIES COMPILE_FLAGS -fPIC)
set_target_properties(${SimulationSettings}_static PROPERTIES COMPILE_FLAGS -fPIC)
endif(UNIX)

install (FILES "config/GlobalSettings.xml" DESTINATION share/omc/runtime/cpp/config)
install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/SimulationSettings/IGlobalSettings.h
${CMAKE_SOURCE_DIR}/Include/Core/SimulationSettings/ISettingsFactory.h
${CMAKE_SOURCE_DIR}/Include/Core/SimulationSettings/ISimControllerSettings.h
DESTINATION include/omc/cpp/Core/SimulationSettings)

install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/SimulationSettings/Factory.h
DESTINATION include/omc/cpp/Core/SimulationSettings)



Expand Down
30 changes: 14 additions & 16 deletions SimulationRuntime/cpp/Core/Solver/CMakeLists.txt
Expand Up @@ -2,32 +2,30 @@ cmake_minimum_required (VERSION 2.8.6)

project(${SolverName})

# add the solver default implementation library
IF(RUNTIME_STATIC_LINKING)
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR})
add_library(${SolverName}_static STATIC SolverDefaultImplementation.cpp SolverSettings.cpp SystemStateSelection.cpp FactoryExport.cpp SimulationMonitor.cpp )
install (TARGETS ${SolverName}_static DESTINATION ${LIBINSTALLEXT})
ELSE(RUNTIME_STATIC_LINKING)
add_library(${SolverName} SHARED SolverDefaultImplementation.cpp SolverSettings.cpp SystemStateSelection.cpp FactoryExport.cpp SimulationMonitor.cpp )
target_link_libraries (${SolverName} ${MathName} ${Boost_LIBRARIES} ${ExtensionUtilitiesName})
add_precompiled_header(${SolverName} Include/Core/Modelica.h )
install (TARGETS ${SolverName} DESTINATION ${LIBINSTALLEXT})
ENDIF(RUNTIME_STATIC_LINKING)
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR})
add_library(${SolverName}_static STATIC SolverDefaultImplementation.cpp SolverSettings.cpp SystemStateSelection.cpp FactoryExport.cpp SimulationMonitor.cpp )
add_precompiled_header(${SolverName}_static Include/Core/Modelica.h)
install (TARGETS ${SolverName}_static DESTINATION ${LIBINSTALLEXT})

add_library(${SolverName} SHARED SolverDefaultImplementation.cpp SolverSettings.cpp SystemStateSelection.cpp FactoryExport.cpp SimulationMonitor.cpp)
target_link_libraries (${SolverName} ${MathName} ${Boost_LIBRARIES} ${ExtensionUtilitiesName})
add_precompiled_header(${SolverName} Include/Core/Modelica.h)
install (TARGETS ${SolverName} DESTINATION ${LIBINSTALLEXT})

if (UNIX)
set_target_properties(${SolverName}_static PROPERTIES COMPILE_FLAGS -fPIC)
set_target_properties(${SolverName} PROPERTIES COMPILE_FLAGS -fPIC)
endif(UNIX)

install (FILES
${CMAKE_SOURCE_DIR}/Include/Core/Solver/IAlgLoopSolver.h
${CMAKE_SOURCE_DIR}/Include/Core/Solver/ILinSolverSettings.h
${CMAKE_SOURCE_DIR}/Include/Core/Solver/INonLinSolverSettings.h
${CMAKE_SOURCE_DIR}/Include/Core/Solver/ISolver.h
${CMAKE_SOURCE_DIR}/Include/Core/Solver/ISolverSettings.h
DESTINATION include/omc/cpp/Core/Solver)

IF(RUNTIME_STATIC_LINKING)
install (FILES
${CMAKE_SOURCE_DIR}/Include/Core/Solver/SolverSettings.h
${CMAKE_SOURCE_DIR}/Include/Core/Solver/SolverDefaultImplementation.h
${CMAKE_SOURCE_DIR}/Include/Core/Solver/SystemStateSelection.h
${CMAKE_SOURCE_DIR}/Include/Core/Solver/SimulationMonitor.h
DESTINATION include/omc/cpp/Core/Solver)
ENDIF(RUNTIME_STATIC_LINKING)

39 changes: 15 additions & 24 deletions SimulationRuntime/cpp/Core/System/CMakeLists.txt
Expand Up @@ -12,28 +12,21 @@ set(BASE_LIB "" CACHE INTERNAL "" )

# add the system default implementation library
# add a static library with the system default implementation for generating c++ fmu targets
add_library(${SystemName}_FMU STATIC AlgLoopDefaultImplementation.cpp AlgLoopSolverFactory.cpp EventHandling.cpp DiscreteEvents.cpp ContinuousEvents.cpp SystemDefaultImplementation.cpp SimVars.cpp)
set_target_properties(${SystemName}_FMU PROPERTIES COMPILE_DEFINITIONS "DRUNTIME_STATIC_LINKING")
add_library(${SystemName}_static STATIC AlgLoopDefaultImplementation.cpp AlgLoopSolverFactory.cpp EventHandling.cpp DiscreteEvents.cpp ContinuousEvents.cpp SystemDefaultImplementation.cpp SimVars.cpp)
set_target_properties(${SystemName}_static PROPERTIES COMPILE_DEFINITIONS "DRUNTIME_STATIC_LINKING")
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR}/kinsol ${SUNDIALS_INCLUDE_DIR})

if (UNIX)
set_target_properties(${SystemName}_FMU PROPERTIES COMPILE_FLAGS -fPIC)
set_target_properties(${SystemName}_static PROPERTIES COMPILE_FLAGS -fPIC)
endif(UNIX)
install (TARGETS ${SystemName}_FMU DESTINATION ${LIBINSTALLEXT})

IF(RUNTIME_STATIC_LINKING)
add_library(${SystemName}_static STATIC AlgLoopDefaultImplementation.cpp AlgLoopSolverFactory.cpp EventHandling.cpp DiscreteEvents.cpp ContinuousEvents.cpp SystemDefaultImplementation.cpp SimVars.cpp FactoryExport.cpp)
set_target_properties(${SystemName}_static PROPERTIES COMPILE_DEFINITIONS "DRUNTIME_STATIC_LINKING")
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR}/kinsol ${SUNDIALS_INCLUDE_DIR})
if (UNIX)
set_target_properties(${SystemName}_static PROPERTIES COMPILE_FLAGS -fPIC)
endif(UNIX)
install (TARGETS ${SystemName}_static DESTINATION ${LIBINSTALLEXT})
ELSE(RUNTIME_STATIC_LINKING)
add_library(${SystemName} SHARED AlgLoopDefaultImplementation.cpp AlgLoopSolverFactory.cpp EventHandling.cpp DiscreteEvents.cpp ContinuousEvents.cpp SystemDefaultImplementation.cpp SimVars.cpp FactoryExport.cpp)
target_link_libraries (${SystemName} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} ${OMCFactoryName} )
add_precompiled_header(${SystemName} Include/Core/Modelica.h )
install (TARGETS ${SystemName} DESTINATION ${LIBINSTALLEXT})
ENDIF(RUNTIME_STATIC_LINKING)
install (TARGETS ${SystemName}_static DESTINATION ${LIBINSTALLEXT})

add_library(${SystemName} SHARED AlgLoopDefaultImplementation.cpp AlgLoopSolverFactory.cpp EventHandling.cpp DiscreteEvents.cpp ContinuousEvents.cpp SystemDefaultImplementation.cpp SimVars.cpp FactoryExport.cpp)

target_link_libraries (${SystemName} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} ${OMCFactoryName}_static)
add_precompiled_header(${SystemName} Include/Core/Modelica.h)
install (TARGETS ${SystemName} DESTINATION ${LIBINSTALLEXT})

#IF (NOT ((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") OR MSVC))
#install (TARGETS ${BasiLibName} DESTINATION ${LIBINSTALLEXT})
Expand All @@ -47,22 +40,20 @@ install (FILES
${CMAKE_SOURCE_DIR}/Include/Core/System/ContinuousEvents.h
${CMAKE_SOURCE_DIR}/Include/Core/System/SimVars.h
${CMAKE_SOURCE_DIR}/Include/Core/System/FactoryExport.h
DESTINATION include/omc/cpp/Core/System)
install (FILES
${CMAKE_SOURCE_DIR}/Include/Core/System/IAlgLoop.h
${CMAKE_SOURCE_DIR}/Include/Core/System/IAlgLoopSolverFactory.h
${CMAKE_SOURCE_DIR}/Include/Core/System/AlgLoopSolverFactory.h
${CMAKE_SOURCE_DIR}/Include/Core/System/IContinuous.h
${CMAKE_SOURCE_DIR}/Include/Core/System/IMixedSystem.h
${CMAKE_SOURCE_DIR}/Include/Core/System/IEvent.h
${CMAKE_SOURCE_DIR}/Include/Core/System/ITime.h
${CMAKE_SOURCE_DIR}/Include/Core/System/ITime.h
${CMAKE_SOURCE_DIR}/Include/Core/System/ISystemProperties.h
${CMAKE_SOURCE_DIR}/Include/Core/System/ISystemInitialization.h
${CMAKE_SOURCE_DIR}/Include/Core/System/IStepEvent.h
${CMAKE_SOURCE_DIR}/Include/Core/System/IWriteOutput.h
${CMAKE_SOURCE_DIR}/Include/Core/System/IStateSelection.h
${CMAKE_SOURCE_DIR}/Include/Core/System/IWriteOutput.h
${CMAKE_SOURCE_DIR}/Include/Core/System/IStateSelection.h
${CMAKE_SOURCE_DIR}/Include/Core/System/ISimVars.h
DESTINATION include/omc/cpp/Core/System)
DESTINATION include/omc/cpp/Core/System)



Expand Down
17 changes: 9 additions & 8 deletions SimulationRuntime/cpp/Core/Utils/Modelica/CMakeLists.txt
Expand Up @@ -3,17 +3,18 @@ cmake_minimum_required (VERSION 2.8.6)
project(${ModelicaUtilitiesName})
# add the solver default implementation library

IF(RUNTIME_STATIC_LINKING)
add_library(${ModelicaUtilitiesName} STATIC ModelicaUtilities.cpp ModelicaSimulationError.cpp)
ELSE(RUNTIME_STATIC_LINKING)
add_library(${ModelicaUtilitiesName} SHARED ModelicaUtilities.cpp ModelicaSimulationError.cpp)
add_precompiled_header(${ModelicaUtilitiesName} Include/Core/Modelica.h )
ENDIF(RUNTIME_STATIC_LINKING)
add_library(${ModelicaUtilitiesName}_static STATIC ModelicaUtilities.cpp ModelicaSimulationError.cpp)
set_target_properties(${ModelicaUtilitiesName}_static PROPERTIES COMPILE_DEFINITIONS "DRUNTIME_STATIC_LINKING")
add_library(${ModelicaUtilitiesName} SHARED ModelicaUtilities.cpp ModelicaSimulationError.cpp)
add_precompiled_header(${ModelicaUtilitiesName} Include/Core/Modelica.h )

if (UNIX)
set_target_properties(${ModelicaUtilitiesName} PROPERTIES COMPILE_FLAGS -fPIC)
set_target_properties(${ModelicaUtilitiesName}_static PROPERTIES COMPILE_FLAGS -fPIC)
set_target_properties(${ModelicaUtilitiesName} PROPERTIES COMPILE_FLAGS -fPIC)
endif(UNIX)

target_link_libraries (${ModelicaUtilitiesName} ${Boost_LIBRARIES})
install (TARGETS ${ModelicaUtilitiesName}_static DESTINATION ${LIBINSTALLEXT})
install (TARGETS ${ModelicaUtilitiesName} DESTINATION ${LIBINSTALLEXT})

install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/Utils/Modelica/ModelicaUtilities.h ${CMAKE_SOURCE_DIR}/Include/Core/Utils/Modelica/FactoryExport.h ${CMAKE_SOURCE_DIR}/Include/Core/Utils/Modelica/ModelicaSimulationError.h DESTINATION include/omc/cpp/Core/Utils/Modelica)
install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/Utils/Modelica/ModelicaUtilities.h ${CMAKE_SOURCE_DIR}/Include/Core/Utils/Modelica/FactoryExport.h ${CMAKE_SOURCE_DIR}/Include/Core/Utils/Modelica/ModelicaSimulationError.h DESTINATION include/omc/cpp/Core/Utils/Modelica)

0 comments on commit e3c2d0a

Please sign in to comment.