-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
256 lines (198 loc) · 7.33 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
243
244
245
246
247
248
249
250
251
252
253
254
####################################################################
#
# CMake Build Script for SBML Spatial, a UI for the
# spatial simulator from Akira
#
# Frank T. Bergmann
#
cmake_minimum_required(VERSION 2.6)
project(spatial)
cmake_policy(SET CMP0020 NEW)
set(SPATIAL_VERSION_MAJOR)
set(SPATIAL_VERSION_MINOR)
set(SPATIAL_VERSION_PATCH)
set(SPATIAL_VERSION_RELEASE)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt")
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt" VersionString NEWLINE_CONSUME)
string(STRIP "${VersionString}" VersionString)
string(REPLACE "." ";" VersionString "${VersionString}" )
string(REPLACE "-" ";" VersionString "${VersionString}" )
list(LENGTH VersionString versionLength)
list(GET VersionString 0 SPATIAL_VERSION_MAJOR )
list(GET VersionString 1 SPATIAL_VERSION_MINOR )
list(GET VersionString 2 SPATIAL_VERSION_PATCH )
if(${versionLength} GREATER 3)
list(GET VersionString 3 SPATIAL_VERSION_RELEASE )
endif()
endif()
set(CPACK_PACKAGE_VERSION_MAJOR "${SPATIAL_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${SPATIAL_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${SPATIAL_VERSION_PATCH}")
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/license.txt")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/readme.md")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_SOURCE_IGNORE_FILES
"aa;aa.zip;screenshots;.DS_STORE;testmodels/.DS_Store;/build/;/.bzr/;~$;${CPACK_SOURCE_IGNORE_FILES}")
set(CPACK_NSIS_CREATE_ICONS "CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\SBML Spatial.lnk' '\$INSTDIR\\\\bin\\\\SpatialUI.exe'")
include(CPack)
option(WITH_TEST_OPENMP "Test whether compiler supports OpenMP" OFF)
if (WITH_TEST_OPENMP)
find_package(OpenMP)
endif()
find_package(ZLIB)
find_library(LIBSBML_LIBRARY
NAMES sbml-static.lib sbml-static sbml
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
${CMAKE_SOURCE_DIR}
${SPATIAL_DEPENDENCY_DIR}/lib
DOC "The file name of the libsbml library."
)
find_path(LIBSBML_INCLUDE_DIR
NAMES sbml/SBase.h
PATHS /usr/include /usr/local/include
${CMAKE_SOURCE_DIR}/include
${SPATIAL_DEPENDENCY_DIR}/include
DOC "The libsbml include directory."
)
option(LIBSBML_STATIC "Linking against the static libSBML." ON)
if (LIBSBML_STATIC)
add_definitions(-DLIBSBML_STATIC -DLIBLAX_STATIC)
set(BUILD_DEFINITIONS "${BUILD_DEFINITIONS} -DLIBSBML_STATIC -DLIBLAX_STATIC")
endif()
###############################################################################
#
# Need some variables set up, such as the name for the libSBML
# library and the Path and file separator characters. The
# MISC_PREFIX variable will cause libsbml bindings, examples and
# documentation to be installed in PREFIX/${MISC_PREFIX}.
#
if(UNIX OR CYGWIN)
set(PATH_SEP "/")
set(FILE_SEP ":")
else()
set(PATH_SEP "\\")
set(FILE_SEP ";")
endif()
set(EXTRA_LIBS "" CACHE STRING "List of additional libraries to link against." )
set(EXTRA_FLAGS "" CACHE STRING "List of extra flags." )
set(EXTRA_INCLUDE "" CACHE STRING "List of include diretories." )
if (EXTRA_FLAGS)
foreach(${flag} ${EXTRA_FLAGS})
add_definitions(-D${flag})
endforeach()
endif()
###############################################################################
#
# SBW Integration
#
option(ENABLE_SBW "Enable SBW Integration." ON)
SET(USE_SBW_INTEGRATION 0)
if (ENABLE_SBW)
SET(USE_SBW_INTEGRATION 1)
add_definitions(-DUSE_SBW_INTEGRATION)
if (APPLE)
add_definitions(-DDARWIN)
endif()
if (UNIX)
add_definitions(-DLINUX)
endif()
find_library(SBW_LIBRARY
NAMES SBW-static.lib SBW-static SBW
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
${CMAKE_SOURCE_DIR}
${SPATIAL_DEPENDENCY_DIR}/lib
DOC "The file name of the SBW library."
)
find_path(SBW_INCLUDE_DIR
NAMES SBW/SBW.h
PATHS /usr/include /usr/local/include
${CMAKE_SOURCE_DIR}/include
${SPATIAL_DEPENDENCY_DIR}/include
DOC "The SBW include directory."
)
endif()
option(WITH_CSHARP "Generate C# language bindings." OFF)
option(WITH_JAVA "Generate Java language bindings." OFF)
###############################################################################
#
# Find the C# compiler to use and set name for resulting library
#
if(WITH_CSHARP)
find_program(CSHARP_COMPILER
NAMES gmcs csc
PATHS C:/Windows/Microsoft.NET/Framework/v2.0.50727/ /usr/bin /usr/local/bin
DOC "The file name of the C# compiler."
)
if(UNIX)
else()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
# mark libsbml library as x86
set(CSHARP_EXTRA_ARGS -platform:x86 )
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
# mark libsbml library as x64
set(CSHARP_EXTRA_ARGS -platform:x64 )
endif()
endif()
endif(WITH_CSHARP)
if(WIN32 AND NOT CYGWIN)
add_definitions(-DLIBSBML_EXPORTS -DWIN32)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
set(BUILD_DEFINITIONS "${BUILD_DEFINITIONS} -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS")
option(WITH_STATIC_RUNTIME "Compile using the static MSVC Runtime." OFF)
if(WITH_STATIC_RUNTIME)
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
endforeach(flag_var)
add_definitions( -D_MT)
endif(WITH_STATIC_RUNTIME)
endif()
endif()
if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
set(EXTRA_LIBS ${EXTRA_LIBS} ${ZLIB_LIBRARIES})
endif(ZLIB_FOUND)
option(ENABLE_OPENMP "Enable OpenMP if available" ON)
if(OPENMP_FOUND AND ENABLE_OPENMP)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
add_subdirectory(SpatialSBML)
option(BUILD_CL "Build Command line executable" ON)
if (BUILD_CL)
add_subdirectory(SpatialCL)
endif()
option(BUILD_UI "Build Graphical User Interface (Qt based)" OFF)
if (BUILD_UI)
add_subdirectory(SpatialUI)
endif()
file(GLOB EXAMPLE_FILES examples/*.xml )
install(FILES ${EXAMPLE_FILES} DESTINATION examples)
message(STATUS
"
Project Spatial SBML ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
==========================
Install Prefix : ${CMAKE_INSTALL_PREFIX}
SBML INCLUDE : ${LIBSBML_INCLUDE_DIR}
SBML Library : ${LIBSBML_LIBRARY}
C FLAGS : ${CMAKE_C_FLAGS}
CXX FLAGS : ${CMAKE_CXX_FLAGS}
Extra Libs : ${EXTRA_LIBS}
"
)
if(WITH_CSHARP)
message(STATUS " Using C# = ${CSHARP_COMPILER}")
endif()
if(WITH_JAVA)
message(STATUS " Using Java = ${Java_JAVA_EXECUTABLE}")
endif()
add_subdirectory(bindings)