forked from modelica/Reference-FMUs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
131 lines (116 loc) · 2.95 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
cmake_minimum_required (VERSION 3.17)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
if (WIN32)
set(FMI_PLATFORM "${FMI_ARCHITECTURE}-windows")
elseif (APPLE)
set(FMI_PLATFORM "${FMI_ARCHITECTURE}-darwin")
else ()
set(FMI_PLATFORM "${FMI_ARCHITECTURE}-linux")
endif ()
set(FMUSIM_VERSION "" CACHE STRING "")
set(CVODE_DIR ${CMAKE_SOURCE_DIR}/build/cvode-${FMI_PLATFORM}/install/)
set(LIBXML2_DIR ${CMAKE_SOURCE_DIR}/build/libxml2-${FMI_PLATFORM}/install/)
set(ZLIB_DIR ${CMAKE_SOURCE_DIR}/build/zlib-${FMI_PLATFORM}/install/)
set(ZLIB_SRC_DIR ${CMAKE_SOURCE_DIR}/build/zlib-1.3/)
if (WIN32)
set(FMUSIM_DIST_DIR ${CMAKE_BINARY_DIR}/dist/fmusim-windows/)
elseif (APPLE)
set(FMUSIM_DIST_DIR ${CMAKE_BINARY_DIR}/dist/fmusim-darwin/)
else ()
set(FMUSIM_DIST_DIR ${CMAKE_BINARY_DIR}/dist/fmusim-linux/)
endif ()
project (FMUSim)
file(MAKE_DIRECTORY ${FMUSIM_DIST_DIR})
set(sources
../include/FMI.h
../src/FMI.c
../include/FMI1.h
../src/FMI1.c
../include/FMI2.h
../src/FMI2.c
../include/FMI3.h
../src/FMI3.c
csv.h
csv.c
FMIUtil.h
FMIUtil.c
FMISolver.h
FMIEuler.h
FMIEuler.c
FMICVode.h
FMICVode.c
FMIModelDescription.h
FMIModelDescription.c
FMIRecorder.h
FMIRecorder.c
FMIZip.h
FMIZip.c
fmi1schema.h
fmi2schema.h
fmi3schema.h
FMISimulation.h
FMISimulation.c
FMIStaticInput.h
FMIStaticInput.c
FMI1CSSimulation.h
FMI1CSSimulation.c
FMI1MESimulation.h
FMI1MESimulation.c
FMI2CSSimulation.h
FMI2CSSimulation.c
FMI2MESimulation.h
FMI2MESimulation.c
FMI3CSSimulation.h
FMI3CSSimulation.c
FMI3MESimulation.h
FMI3MESimulation.c
fmusim.c
miniunzip.c
${ZLIB_SRC_DIR}/contrib/minizip/ioapi.c
${ZLIB_SRC_DIR}/contrib/minizip/unzip.c
../src/structured_variable_name.yy.c
../include/structured_variable_name.tab.h
../src/structured_variable_name.tab.c
)
if (WIN32)
set (sources ${sources} ${ZLIB_SRC_DIR}/contrib/minizip/iowin32.c)
endif ()
add_executable(fmusim ${sources})
target_include_directories(fmusim PRIVATE
.
../include
${LIBXML2_DIR}/include/libxml2
${ZLIB_DIR}/include
${ZLIB_SRC_DIR}/contrib/minizip
${CVODE_DIR}/include
)
if (WIN32)
target_compile_definitions(fmusim PRIVATE FMUSIM_VERSION=${FMUSIM_VERSION} YY_NO_UNISTD_H LIBXML_STATIC)
else ()
target_compile_definitions(fmusim PRIVATE FMUSIM_VERSION=${FMUSIM_VERSION} LIBXML_STATIC)
endif ()
if (WIN32)
set(libraries
${LIBXML2_DIR}/lib/libxml2s.lib
${ZLIB_DIR}/lib/zlibstatic.lib
${CVODE_DIR}/lib/sundials_cvode.lib
wsock32
ws2_32
)
elseif(UNIX AND NOT APPLE)
set(libraries
${LIBXML2_DIR}/lib/libxml2.a
${ZLIB_DIR}lib/libz.a
${CVODE_DIR}/lib/libsundials_cvode.a
${CMAKE_DL_LIBS}
m
)
else ()
set(libraries
${LIBXML2_DIR}/lib/libxml2.a
${ZLIB_DIR}lib/libz.a
${CVODE_DIR}/lib/libsundials_cvode.a
)
endif ()
target_link_libraries(fmusim ${libraries})
install(TARGETS fmusim DESTINATION ${CMAKE_INSTALL_PREFIX})