-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
243 lines (196 loc) · 9.13 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# CMakeLists.txt file for MasterSim library and applications
# Author: Andreas Nicolai (andreas.nicolai -at- gmx.net)
# Require a fairly recent cmake version
cmake_minimum_required( VERSION 2.8...3.10 )
# The project name
project( MasterSimBundle )
# enable @rpath on MacOS
cmake_policy(SET CMP0042 NEW)
if (${CMAKE_VERSION} VERSION_GREATER "3.11")
# use new OpenGL libs when having both new and legacy OpenGL libs on Linux
cmake_policy(SET CMP0072 NEW)
endif()
# enable this to test deb-deployment
# use in conjunction with `cmake -DCMAKE_INSTALL_PREFIX=/some/local/path`
# add_definitions( -DIBK_BUILDING_DEBIAN_PACKAGE )
# -------------------------------------------------------------
# MACRO definitions
# -------------------------------------------------------------
# Macros to hide/show cached variables.
# These two macros can be used to "hide" or "show" in the
# list of cached variables various variables and/or options
# that depend on other options.
# Note that once a variable is modified, it will preserve its
# value (hidding it merely makes it internal)
MACRO(HIDE_VARIABLE var)
IF(DEFINED ${var})
SET(${var} "${${var}}" CACHE INTERNAL "")
ENDIF(DEFINED ${var})
ENDMACRO(HIDE_VARIABLE)
MACRO(SHOW_VARIABLE var type doc default)
IF(DEFINED ${var})
SET(${var} "${${var}}" CACHE "${type}" "${doc}" FORCE)
ELSE(DEFINED ${var})
SET(${var} "${default}" CACHE "${type}" "${doc}")
ENDIF(DEFINED ${var})
ENDMACRO(SHOW_VARIABLE)
# -------------------------------------------------------------
# Initial commands
# -------------------------------------------------------------
# Uncomment this to enable detailed make output
#set( CMAKE_VERBOSE_MAKEFILE ON )
# Hide some more cache variables to keep things tidy
MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY)
MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
# Set default build type
if (NOT CMAKE_BUILD_TYPE)
set( CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif (NOT CMAKE_BUILD_TYPE)
# on Unix we want really detailed warnings
if (UNIX)
ADD_DEFINITIONS( -Wall -fPIC )
endif (UNIX)
# add VC compiler-specific flags (NONMINMAX define and disable "unsafe" warnings)
if (MSVC)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D\"NOMINMAX\" /wd4996 /GS-" )
endif (MSVC)
# -------------------------------------------------------------
# Required packages
# -------------------------------------------------------------
# automatically add CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR to the include directories in every processed CMakeLists.txt
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if (DISABLE_QT)
message("*** Building without Qt5 ***")
else (DISABLE_QT)
message("*** Building with Qt5 ***")
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5Svg REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
# when building with gcc/icc add compile flag
if (NOT MSVC)
if (APPLE)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++" )
else (APPLE)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -std=gnu++11" )
endif (APPLE)
endif (NOT MSVC)
endif (DISABLE_QT)
if( APPLE )
find_library(IOKIT NAMES IOKit REQUIRED)
find_library(SYSTEM_CONFIGURATION SystemConfiguration REQUIRED)
find_library(COREFOUNDATION NAMES CoreFoundation REQUIRED)
find_library(SECURITY_FRAMEWORK Security REQUIRED)
set(APPLE_FRAMEWORKS
${IOKIT}
${SECURITY_FRAMEWORK}
${COREFOUNDATION}
${SYSTEM_CONFIGURATION}
)
endif( APPLE )
# -------------------------------------------------------------
# Subdirectories and subprojects
# -------------------------------------------------------------
# add subdirectories for all builds
if (NOT UNIX)
add_subdirectory( externals/zlib/src libz)
endif (NOT UNIX)
add_subdirectory( externals/minizip/projects/cmake_local minizip)
add_subdirectory( externals/IBK/projects/cmake_local IBK )
add_subdirectory( externals/IBKMK/projects/cmake_local IBKMK )
add_subdirectory( externals/TiCPP/projects/cmake_local TiCPP )
add_subdirectory( MasterSim )
if (NOT DISABLE_QT)
message("*** Building Qt-based libs ***")
add_subdirectory( externals/BlockMod/projects/cmake BlockMod )
endif (NOT DISABLE_QT)
# -------------------------------------------------------------
# Executables/applications
# -------------------------------------------------------------
add_subdirectory( MasterSimulator )
if (NOT DISABLE_QT)
add_subdirectory( MasterSimulatorUI )
endif (NOT DISABLE_QT)
# -------------------------------------------------------------
# Test FMUs Libraries
# -------------------------------------------------------------
add_subdirectory( TestFMUs/Math003Part1 )
add_subdirectory( TestFMUs/Math003Part2 )
add_subdirectory( TestFMUs/Math003Part3 )
add_subdirectory( TestFMUs/LotkaVolterraPrey )
add_subdirectory( TestFMUs/LotkaVolterraPredator )
add_subdirectory( TestFMUs/FourRealInputVars )
# Support for 'make install' on Unix/Linux (not on MacOS!)
if (UNIX AND NOT APPLE)
# -------------------------------------------------------------
# Generate FMUs to be shipped with examples
# -------------------------------------------------------------
# define a command that re-generates the FMUs from the already compiled libraries
# it depends on the compiled shared libraries
add_custom_command(
DEPENDS Math003Part1 Math003Part2 Math003Part3 LotkaVolterraPrey LotkaVolterraPredator FourRealInputVars
OUTPUT ${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Part1.fmu
${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Part2.fmu
${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Part3.fmu
${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Predator.fmu
${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Prey.fmu
${PROJECT_SOURCE_DIR}/TestFMUs/fmus/FourRealInputVars.fmu
COMMAND ${PROJECT_SOURCE_DIR}/TestFMUs/generate_FMUs.sh ${CMAKE_CURRENT_BINARY_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/TestFMUs
COMMENT "Generating example FMUs"
)
# define a target that is always build - it checks the existence and time-stamp
# of the example fmu files and if they are missing/out of date it
# executes the command above to generate/update the FMUs
add_custom_target(ExampleFMUs ALL
DEPENDS ${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Part1.fmu
${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Part2.fmu
${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Part3.fmu
${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Predator.fmu
${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Prey.fmu
${PROJECT_SOURCE_DIR}/TestFMUs/fmus/FourRealInputVars.fmu
)
# -------------------------------------------------------------
# Install example FMUs
# -------------------------------------------------------------
# installation targets for Unix systems
include(GNUInstallDirs)
# Math_003_control_loop
set(EXAMPLE_DESTINATION_DIR ${CMAKE_INSTALL_DATAROOTDIR}/mastersim/examples/Math_003_control_loop)
install(FILES ${PROJECT_SOURCE_DIR}/data/examples/linux64/Math_003_control_loop/Math003_GaussSeidel_2iters_adaptive_Richardson.msim
DESTINATION ${EXAMPLE_DESTINATION_DIR})
install(FILES ${PROJECT_SOURCE_DIR}/data/examples/linux64/Math_003_control_loop/Math003_GaussSeidel_2iters_adaptive_Richardson.bm
DESTINATION ${EXAMPLE_DESTINATION_DIR})
install(FILES ${PROJECT_SOURCE_DIR}/data/examples/linux64/Math_003_control_loop/Math003_GaussSeidel_2iters_adaptive_Richardson.msim.png
DESTINATION ${EXAMPLE_DESTINATION_DIR})
install(FILES ${PROJECT_SOURCE_DIR}/data/examples/linux64/Math_003_control_loop/Math003_GaussSeidel_2iters_adaptive_Richardson.p2
DESTINATION ${EXAMPLE_DESTINATION_DIR})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/data/examples/linux64/Math_003_control_loop/description
DESTINATION ${EXAMPLE_DESTINATION_DIR})
# we install newly generated FMUs
install(FILES ${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Part1.fmu
DESTINATION ${EXAMPLE_DESTINATION_DIR}/fmus/IBK)
install(FILES ${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Part2.fmu
DESTINATION ${EXAMPLE_DESTINATION_DIR}/fmus/IBK)
install(FILES ${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Part3.fmu
DESTINATION ${EXAMPLE_DESTINATION_DIR}/fmus/IBK)
# Lotka_Volterra_System
set(EXAMPLE_DESTINATION_DIR ${CMAKE_INSTALL_DATAROOTDIR}/mastersim/examples/Lotka_Volterra_System)
install(FILES ${PROJECT_SOURCE_DIR}/data/examples/linux64/Lotka_Volterra_System/LV_Richardson_noiter.msim
DESTINATION ${EXAMPLE_DESTINATION_DIR})
install(FILES ${PROJECT_SOURCE_DIR}/data/examples/linux64/Lotka_Volterra_System/LV_Richardson_noiter.bm
DESTINATION ${EXAMPLE_DESTINATION_DIR})
install(FILES ${PROJECT_SOURCE_DIR}/data/examples/linux64/Lotka_Volterra_System/LV_Richardson_noiter.msim.png
DESTINATION ${EXAMPLE_DESTINATION_DIR})
install(FILES ${PROJECT_SOURCE_DIR}/data/examples/linux64/Lotka_Volterra_System/LV_Richardson_noiter.p2
DESTINATION ${EXAMPLE_DESTINATION_DIR})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/data/examples/linux64/Lotka_Volterra_System/description
DESTINATION ${EXAMPLE_DESTINATION_DIR})
# we install newly generated FMUs
install(FILES ${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Prey.fmu
DESTINATION ${EXAMPLE_DESTINATION_DIR}/fmus/IBK)
install(FILES ${PROJECT_SOURCE_DIR}/TestFMUs/fmus/Predator.fmu
DESTINATION ${EXAMPLE_DESTINATION_DIR}/fmus/IBK)
endif (UNIX AND NOT APPLE)