1 | # Copyright (C) 2014 Modelon AB |
---|
2 | |
---|
3 | # This program is free software: you can redistribute it and/or modify |
---|
4 | # it under the terms of the GNU General Public License version 3 as published |
---|
5 | # by the Free Software Foundation, or optionally, under the terms of the |
---|
6 | # Common Public License version 1.0 as published by IBM. |
---|
7 | |
---|
8 | # This program is distributed in the hope that it will be useful, |
---|
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | # GNU General Public License, or the Common Public License, for more details. |
---|
12 | |
---|
13 | # You should have received copies of the GNU General Public License |
---|
14 | # and the Common Public License along with this program. If not, |
---|
15 | # see <http://www.gnu.org/licenses/> or |
---|
16 | # <http://www.ibm.com/developerworks/library/os-cpl.html/> respectively. |
---|
17 | |
---|
18 | # NOTE: CMake 2.8.6 is required since this is the version used in development. |
---|
19 | # The script is KNOWN NOT TO WORK WITH 2.8.3 and below (ExternalProject |
---|
20 | # interface changes). CMake 2.8.4 and 2.8.5 are not tested. |
---|
21 | cmake_minimum_required (VERSION 2.8.6 FATAL_ERROR) |
---|
22 | |
---|
23 | project (SimulationRuntime) |
---|
24 | |
---|
25 | #Inputs through flags |
---|
26 | add_definitions(-DTOP_SRC) |
---|
27 | add_definitions(-DSUNDIALS_HOME) |
---|
28 | add_definitions(-DMINPACK_HOME) |
---|
29 | if(NOT TOP_SRC) |
---|
30 | set(TOP_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../) |
---|
31 | message(STATUS "TOP_SRC was not defined, using ${TOP_SRC}") |
---|
32 | endif() |
---|
33 | |
---|
34 | if(NOT MINPACK_HOME) |
---|
35 | set(MINPACK_HOME ${TOP_SRC}/ThirdParty/Minpack/cminpack-1.3.2/) |
---|
36 | message(STATUS "MINPACK_HOME was not defined, using ${MINPACK_HOME}") |
---|
37 | endif() |
---|
38 | include_directories(${MINPACK_HOME}) |
---|
39 | |
---|
40 | # Get the JModelica install directory |
---|
41 | if(CMAKE_INSTALL_DIR) |
---|
42 | set(JMODELICA_INSTALL_DIR ${CMAKE_INSTALL_DIR}) |
---|
43 | else() |
---|
44 | set(JMODELICA_INSTALL_DIR ${TOP_SRC}/../install) |
---|
45 | message(STATUS "Install dir not defined, using ${JMODELICA_INSTALL_DIR}") |
---|
46 | endif() |
---|
47 | message(STATUS JMODELICA_INSTALL_DIR=${JMODELICA_INSTALL_DIR}) |
---|
48 | |
---|
49 | #Make the directory for header files to be installed in. |
---|
50 | set(RTLIB_INCLUDE_DIR ${JMODELICA_INSTALL_DIR}/include/RuntimeLibrary) |
---|
51 | install(CODE "file(MAKE_DIRECTORY $ENV{DESTDIR}${RTLIB_INCLUDE_DIR})") |
---|
52 | |
---|
53 | #Make the directory for lib files to be installed in. |
---|
54 | # Add spaces around CMAKE_C_FLAGS so that we can check for " -m64 " with spaces around it |
---|
55 | if(" ${CMAKE_C_FLAGS} " MATCHES " -m64 ") |
---|
56 | set(RTLIB_LIB_DIR ${JMODELICA_INSTALL_DIR}/lib/RuntimeLibrary64) |
---|
57 | set(RTLIB_BIN_DIR ${JMODELICA_INSTALL_DIR}/bin64) |
---|
58 | else() |
---|
59 | set(RTLIB_LIB_DIR ${JMODELICA_INSTALL_DIR}/lib/RuntimeLibrary) |
---|
60 | set(RTLIB_BIN_DIR ${JMODELICA_INSTALL_DIR}/bin) |
---|
61 | endif() |
---|
62 | install(CODE "file(MAKE_DIRECTORY $ENV{DESTDIR}${RTLIB_LIB_DIR})") |
---|
63 | |
---|
64 | if(NOT(WIN32 OR CYGWIN OR APPLE)) |
---|
65 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_SHARED_LIBRARY_C_FLAGS}") |
---|
66 | SET(WITH_PIC ON) |
---|
67 | elseif(MSVC) |
---|
68 | add_definitions(/D _CRT_SECURE_NO_WARNINGS) |
---|
69 | endif() |
---|
70 | |
---|
71 | #Including Sundials. |
---|
72 | message(STATUS SUNDIALS_HOME=${SUNDIALS_HOME}) |
---|
73 | include_directories(${SUNDIALS_HOME}/include) |
---|
74 | |
---|
75 | set(RuntimeLibrary_BUILD ${SimulationRuntime_BINARY_DIR}) |
---|
76 | |
---|
77 | #Add jmi |
---|
78 | add_subdirectory(src/jmi) |
---|
79 | |
---|
80 | #Add fmi2 |
---|
81 | include_directories(src/jmi) |
---|
82 | add_subdirectory(src/fmi2) |
---|
83 | |
---|
84 | #Add fmi1_me |
---|
85 | add_subdirectory(src/fmi1_me) |
---|
86 | |
---|
87 | #Add fmi1_cs |
---|
88 | include_directories(src/fmi1_me) |
---|
89 | add_subdirectory(src/fmi1_cs) |
---|
90 | |
---|
91 | #Add modules |
---|
92 | include_directories(src/jmi/module_include) |
---|
93 | add_subdirectory(src/modules) |
---|
94 | |
---|
95 | #Add evaluator |
---|
96 | include_directories(src/evaluator) |
---|
97 | add_subdirectory(src/evaluator) |
---|
98 | |
---|
99 | if(EXTRA_RUNTIME_MODULES) |
---|
100 | set(index 1) |
---|
101 | foreach(module ${EXTRA_RUNTIME_MODULES}) |
---|
102 | add_subdirectory(${module} "extra${index}") |
---|
103 | math(EXPR index "${index}+1") |
---|
104 | endforeach() |
---|
105 | endif() |
---|
106 | |
---|