forked from sbmlteam/libCombine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
652 lines (518 loc) · 22.5 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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
###############################################################################
#
# Description : CMake build script for libCombine
# Original author(s): Frank Bergmann <[email protected]>
# Organization : California Institute of Technology
#
###############################################################################
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
cmake_minimum_required(VERSION 2.6...3.19)
###############################################################################
#
# Parse VERSION.txt to determine the package version
#
set(LIBCOMBINE_VERSION_MAJOR)
set(LIBCOMBINE_VERSION_MINOR)
set(LIBCOMBINE_VERSION_PATCH)
set(LIBCOMBINE_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)
set(COMBINE_DOTTED_VERSION ${VersionString})
string(REPLACE "." ";" VersionString "${VersionString}" )
string(REPLACE "-" ";" VersionString "${VersionString}" )
list(LENGTH VersionString versionLength)
list(GET VersionString 0 LIBCOMBINE_VERSION_MAJOR )
list(GET VersionString 1 LIBCOMBINE_VERSION_MINOR )
list(GET VersionString 2 LIBCOMBINE_VERSION_PATCH )
if(${versionLength} GREATER 3)
list(GET VersionString 3 LIBCOMBINE_VERSION_RELEASE )
endif()
endif()
MATH(EXPR LIBCOMBINE_VERSION_NUMERIC "${LIBCOMBINE_VERSION_MAJOR} * 10000 + ${LIBCOMBINE_VERSION_MINOR} * 100 + ${LIBCOMBINE_VERSION_PATCH}" )
set(LIBCOMBINE_VERSION "${LIBCOMBINE_VERSION_MAJOR}.${LIBCOMBINE_VERSION_MINOR}.${LIBCOMBINE_VERSION_PATCH}${LIBCOMBINE_VERSION_RELEASE}")
set(PACKAGE_NAME "libCombine")
project(libCombine VERSION "${LIBCOMBINE_VERSION_MAJOR}.${LIBCOMBINE_VERSION_MINOR}.${LIBCOMBINE_VERSION_PATCH}"
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include (CMakeTestCXXCompiler)
include (CheckCSourceCompiles)
include (CheckCXXSourceCompiles)
include (CheckStructHasMember)
include (CheckLibraryExists)
include (CheckFunctionExists)
include (CheckCCompilerFlag)
include (CheckCSourceRuns)
include (CheckSymbolExists)
include (CheckTypeSize)
include(GNUInstallDirs)
set(PACKAGE_CONFIG_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/cmake CACHE PATH
"Path into which the cmake config files should be installed")
# PACKAGE_VERSION gets overridden by using other packages, so setting
# the PROJECT_VERSION, which will be used when exporting targets in
# src/CMakeLists.txt
set(PROJECT_VERSION ${LIBCOMBINE_VERSION})
# add make dist and make check target as they are already familiar for
# everyone using the gnumake build
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
add_custom_target(check COMMAND ${CMAKE_MAKE_PROGRAM} test)
###############################################################################
#
# The next lines configure the parameters for packaging the binaries.
# They can be invoked with "make package" or "nmake package" or by using
# cpack -G zip|deb|rpm|dmg|nsis
#
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An API library for reading/writing/manipulating OMEX.")
set(CPACK_PACKAGE_NAME "${PACKAGE_NAME}")
set(CPACK_PACKAGE_VENDOR "The SBML Team")
set(CPACK_PACKAGE_CONTACT "LibSBML Team <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
set(CPACK_PACKAGE_VERSION_MAJOR "${LIBCOMBINE_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${LIBCOMBINE_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${LIBCOMBINE_VERSION_PATCH}")
set(CPACK_RPM_PACKAGE_LICENSE "BSD")
set(CPACK_RPM_PACKAGE_GROUP "Libraries/Development")
set(CPACK_DEBIAN_PACKAGE_SECTION "Libraries")
set(CPACK_SOURCE_TGZ "ON")
set(CPACK_SOURCE_ZIP "ON")
set(CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_BINARY_DIR};/.svn/;/.libs/;/.deps/;/.bzr/;/.*.o$/;/.*.lo$/;/.*.la$/;/.git/;${CPACK_SOURCE_IGNORE_FILES};/.DS_Store;/.svnignore;blib;libsbml-dist;/*.txt.user/;/.vs/;/.vscode/")
set(ADDITIONAL_LIB_DIRS)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")
set(CPACK_RPM_PACKAGE_ARCHITECTURE "i386")
else()
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
set(ADDITIONAL_LIB_DIRS "/usr/lib64" "/usr/lib/x86_64-linux-gnu/")
endif()
include(CPack)
###############################################################################
#
# list of additional files to link against.
#
set(EXTRA_LIBS "" CACHE STRING "List of additional libraries to link against." )
set(EXTRA_INCLUDE "" CACHE STRING "List of additional include directories to add." )
set(EXTRA_DEFS "" CACHE STRING "List of additional flag to add." )
SET(ACTUAL_EXTRA_LIBS)
if (EXTRA_LIBS AND NOT UNIX)
foreach(current ${EXTRA_LIBS})
file(TO_CMAKE_PATH "${current}" CUR_PATH)
SET(ACTUAL_EXTRA_LIBS ${ACTUAL_EXTRA_LIBS} ${CUR_PATH})
endforeach()
set(EXTRA_LIBS ${ACTUAL_EXTRA_LIBS})
endif()
###############################################################################
#
# Here we have the main configuration options for libcombine.
#
# Build static / shared library
option(LIBCOMBINE_SKIP_SHARED_LIBRARY "If set the shared library will not be built." OFF)
# Whether to compile examples
option(WITH_EXAMPLES "Compile the libCombine example programs." OFF)
# Which language bindings should be built
option(WITH_CSHARP "Generate C# language bindings." OFF)
option(WITH_JAVA "Generate Java language bindings." OFF)
option(WITH_PYTHON "Generate Python language bindings." OFF)
option(WITH_PERL "Generate Perl language bindings." OFF)
option(WITH_RUBY "Generate Ruby language bindings" OFF)
option(WITH_R "Generate R language bindings" OFF)
option(WITH_OCTAVE "Generate Octave language bindings." OFF)
option(WITH_MATLAB "Generate MATLAB language bindings." OFF)
# Add an option to compile with all warnings shown
option(WITH_WALL "Compile with -Wall, so that the compiler will display all warnings." OFF)
mark_as_advanced(WITH_WALL)
if(WITH_WALL)
if(MSVC OR USING_INTEL)
add_definitions(/W4)
else()
add_definitions(-Wall)
endif()
endif()
set(LIBCOMBINE_BUILD_TYPE "native")
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(LIBCOMBINE_BUILD_TYPE "32bit")
else()
set(LIBCOMBINE_BUILD_TYPE "64bit")
endif()
if (APPLE AND ENABLE_UNIVERSAL)
set(LIBCOMBINE_BUILD_TYPE "universal")
endif()
# Use the version number in the shared library.
#
option (LIBCOMBINE_SHARED_VERSION "Build the libcombine shared library with version information" ON)
mark_as_advanced(LIBCOMBINE_SHARED_VERSION)
# Enable the generation of unit tests. If enabled, all test runners
# will be created and can be run with "make test" or ctest.
# This won't work in Visual Studio 2003, so we disable this option there.
#
if(NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio 6" AND NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio 7")
option(WITH_CHECK "Compile unit tests. Run with 'make test' or 'ctest'." OFF)
endif()
# Use C++ namespace.
option(WITH_CPP_NAMESPACE "Use a C++ namespace for libCombine." OFF)
# Generate documentation.
option(WITH_DOXYGEN "Generate documentation for libCombine using Doxygen." OFF )
# marks as advanced, so as to hide documentation generation
mark_as_advanced(WITH_DOXYGEN)
# Re-generate the swig bindings? This really should be on by default
# otherwise one might have the wrong wrapper code without support for
# the libcombine packages one wants.
option(WITH_SWIG "Regenerate SWIG-based language bindings." ON )
set( MISC_PREFIX )
if(UNIX OR CYGWIN)
set(PATH_SEP "/")
set(FILE_SEP ":")
set( MISC_PREFIX "share/libcombine/" )
set(COMBINE_LIBRARY Combine)
else()
set( MISC_PREFIX "" )
set(PATH_SEP "\\")
set(FILE_SEP ";")
if(MINGW)
set(COMBINE_LIBRARY Combine)
else()
set(COMBINE_LIBRARY libCombine)
endif()
endif()
# Set build type default.
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build to perform. The options are: None (CMAKE_CXX_FLAGS
or CMAKE_C_FLAGS are used), Debug, Release, RelWithDebInfo, MinSizeRel.")
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the build type. The options are: None (CMAKE_CXX_FLAGS or
CMAKE_C_FLAGS are used), Debug, Release, RelWithDebInfo, MinSizeRel." FORCE)
endif()
# Set the default dependency directory.
set(LIBCOMBINE_DEPENDENCY_DIR ${CMAKE_SOURCE_DIR}/dependencies/ CACHE PATH
"Directory containing libraries that libCombine depends upon. (Particularly important on Windows.)")
if("${LIBCOMBINE_DEPENDENCY_DIR}" STREQUAL "")
set(LIBCOMBINE_DEPENDENCY_DIR ${CMAKE_SOURCE_DIR}/dependencies/ CACHE PATH
"Directory containing libraries that libCombine depends upon. (Particularly important on Windows.)" FORCE)
endif()
set(LIBCOMBINE_ROOT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(LIBCOMBINE_ROOT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
###############################################################################
#
# If WITH_SWIG is selected, we need to find swig
#
set (LIBCOMBINE_USE_CPP_NAMESPACE 0)
if(WITH_CPP_NAMESPACE)
add_definitions(-DLIBCOMBINE_USE_CPP_NAMESPACE)
set (LIBCOMBINE_USE_CPP_NAMESPACE 1)
endif()
if (SWIG_EXECUTABLE AND NOT EXISTS "${SWIG_EXECUTABLE}")
unset(SWIG_EXECUTABLE CACHE )
unset(SWIG_DIR CACHE )
unset(SWIG_VERSION CACHE )
endif()
if(WITH_SWIG)
find_program(SWIG_EXECUTABLE
NAMES swig
PATHS
c:/swigwin-3.0.10
c:/swigwin-3.0.9
c:/swigwin-3.0.8
c:/swigwin-3.0.7
c:/swigwin-3.0.6
c:/swigwin-3.0.5
c:/swigwin-3.0.2
c:/swigwin-3.0.0
c:/swigwin-2.0.12
c:/swigwin-2.0.11
c:/swigwin-2.0.10
c:/swigwin-2.0.9
c:/swigwin-2.0.8
c:/swigwin-2.0.7
c:/swigwin-2.0.4
c:/swigwin-2.0.2
c:/swigwin-2.0.1
c:/swigwin-2.0.0
/usr/local/bin
/opt/local/bin
/usr/bin
DOC "The file name of the swig executable."
)
set(SWIG_EXTRA_ARGS)
endif(WITH_SWIG)
# Update cmake path variables
if (LIBCOMBINE_DEPENDENCY_DIR AND EXISTS ${LIBCOMBINE_DEPENDENCY_DIR})
set(CMAKE_PREFIX_PATH "${LIBCOMBINE_DEPENDENCY_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake;${CMAKE_PREFIX_PATH}")
endif()
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
# install find module so that libCombine can be found easily
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/FindLIBCOMBINE.cmake"
DESTINATION share/cmake/Modules)
###############################################################################
#
# Locate libsbml
#
find_package(LIBSBML REQUIRED)
# detect zipper library if sources are not included
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/submodules/zipper)
find_package(ZIPPER REQUIRED)
endif()
find_package(ZLIB REQUIRED)
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 libcombine library as x86
set(CSHARP_EXTRA_ARGS -platform:x86 )
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
# mark libcombine library as x64
set(CSHARP_EXTRA_ARGS -platform:x64 )
endif()
endif()
endif(WITH_CSHARP)
# allow the user to define additional compilation symbols
if (EXTRA_DEFS)
foreach(var ${EXTRA_DEFS})
add_definitions(-D${var})
endforeach()
endif()
set(USE_ZLIB ON)
add_definitions( -DUSE_ZLIB )
if (ZLIB_LIBRARY_NAME)
set(LIBCOMBINE_LIBS ${LIBCOMBINE_LIBS} ${ZLIB_LIBRARY_NAME})
elseif (ZLIB_LIBRARY)
set(LIBCOMBINE_LIBS ${LIBCOMBINE_LIBS} ${ZLIB_LIBRARY})
endif()
if (LIBSBML_LIBRARY_NAME)
set(LIBCOMBINE_LIBS ${LIBCOMBINE_LIBS} ${LIBSBML_LIBRARY_NAME})
elseif (LIBSBML_LIBRARY)
set(LIBCOMBINE_LIBS ${LIBCOMBINE_LIBS} ${LIBSBML_LIBRARY})
endif()
if (ZIPPER_LIBRARY_NAME)
set(LIBCOMBINE_LIBS ${LIBCOMBINE_LIBS} ${ZIPPER_LIBRARY_NAME})
elseif (ZIPPER_LIBRARY)
set(LIBCOMBINE_LIBS ${LIBCOMBINE_LIBS} ${ZIPPER_LIBRARY})
endif()
if (XML_LIBRARY_NAME)
set(LIBCOMBINE_LIBS ${LIBCOMBINE_LIBS} ${XML_LIBRARY_NAME})
elseif (XML_LIBRARY)
set(LIBCOMBINE_LIBS ${LIBCOMBINE_LIBS} ${XML_LIBRARY})
endif()
set(USING_INTEL FALSE)
if (WIN32 AND CMAKE_C_COMPILER AND CMAKE_C_COMPILER MATCHES ".*icl.*$")
message(STATUS "Detected Intel Compiler")
set(USING_INTEL TRUE)
endif ()
if(MSVC OR USING_INTEL)
add_definitions(-DWIN32 -DLIBCOMBINE_EXPORTS -DLIBLAX_EXPORTS)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
set(BUILD_DEFINITIONS "${BUILD_DEFINITIONS} -D_CRT_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)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif(WITH_STATIC_RUNTIME)
# CMake no longer creates PDB files for static libraries after 2.8.11
# so we store debug information in the object files instead
if (${CMAKE_VERSION} VERSION_GREATER "2.8.11")
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 "/Zi")
STRING(REPLACE "/Zi" "/Z7" "${flag_var}" "${${flag_var}}")
endif(${flag_var} MATCHES "/Zi")
endforeach(flag_var)
endif()
else()
if(APPLE)
# on osx starting with xcode 4.3 the system root is in
# the app bundle, however cmake (up to 2.8.8) does not seem
# to update the path, so lets try it here
if (CMAKE_OSX_SYSROOT AND NOT EXISTS ${CMAKE_OSX_SYSROOT})
if (EXISTS "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/${CMAKE_OSX_SYSROOT}")
set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/${CMAKE_OSX_SYSROOT}" CACHE STRING "The SDK root to be used" FORCE)
endif()
endif()
add_definitions(-DMACOSX)
set(BUILD_DEFINITIONS "${BUILD_DEFINITIONS} -DMACOSX")
# Since we are encountering errors with the use of libc++ on OSX
# this option allows to override which stdlib to use
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
option(CLANG_USE_STDLIB "Use libstdc++ rather than libc++" OFF)
if (CLANG_USE_STDLIB)
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++" )
endif()
endif()
# On OSX it is common to build universal binaries to support multiple
# processor architectures. The default behavior is not to build
# multiple architectures, as most users might not need that.
option(ENABLE_UNIVERSAL "Create universal binaries on Mac OS X." OFF)
set(CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING
"A semicolon-separated list of build architectures to be used.")
if(ENABLE_UNIVERSAL)
# if universal binaries are requested and none defined so far
# overwrite them with all three common architectures. If the user
# specified their own list of architectures do not touch!
if(CMAKE_OSX_ARCHITECTURES STREQUAL "")
STRING(REGEX REPLACE "^.*MacOSX([0-9]*\\.[0-9]*)\\.sdk$" "\\1"
OSX_SDK_VERSION "${CMAKE_OSX_SYSROOT}")
if(OSX_SDK_VERSION VERSION_EQUAL "10.7" OR OSX_SDK_VERSION VERSION_EQUAL "10.8")
# OSX Lion no longer supports ppc architecture
set(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING
"A semicolon-separated list of build architectures to be used." FORCE)
else()
set(CMAKE_OSX_ARCHITECTURES "i386;ppc;x86_64" CACHE STRING
"A semicolon-separated list of build architectures to be used." FORCE)
endif()
endif()
endif(ENABLE_UNIVERSAL)
else(APPLE)
add_definitions(-DLINUX)
if(NOT CYGWIN)
# on cygwin all code is position independent so -fPIC is not needed
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -fPIC")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -fPIC")
endif()
set(BUILD_DEFINITIONS "${BUILD_DEFINITIONS} -DLINUX")
endif(APPLE)
endif()
# need an extra definition of __APPLE__ to prevent ioapi.c to
# change the name for the fopen/ftell/fseek commands
# unfortunately that won't work for qt
if (CYGWIN AND NOT WITH_QT_FILESYSTEM)
add_definitions(-D__APPLE__)
endif()
# allow definition of extra include dirs
if (EXTRA_INCLUDE_DIRS)
include_directories(${EXTRA_INCLUDE_DIRS})
endif()
include_directories(${LIBSBML_INCLUDE_DIR})
include_directories(${XML_INCLUDE_DIR})
include_directories(${ZLIB_INCLUDE_DIR})
include_directories(${ZIPPER_INCLUDE_DIR})
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/src/)
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/src/)
file(GLOB COMBINE_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/combine/*.h
)
install(FILES ${COMBINE_HEADERS} DESTINATION include/combine)
file(GLOB COMBINE_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/combine/*.cpp
)
source_group(combine FILES ${COMBINE_SOURCES} ${COMBINE_HEADERS})
# if we have the zipper sources, include them directly
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/submodules/zipper)
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/submodules/zipper/zipper)
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/submodules/zipper)
file(GLOB ZIPPER_SOURCES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/submodules/zipper/zipper/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/submodules/zipper/zipper/*.h
${CMAKE_CURRENT_SOURCE_DIR}/submodules/zipper/zipper/tps/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/submodules/zipper/zipper/tps/*.h
)
set(COMBINE_SOURCES ${COMBINE_SOURCES} ${ZIPPER_SOURCES})
source_group(zipper FILES ${ZIPPER_SOURCES})
endif()
# include minizip sources if we have them and libSBML has been compiled
# without compression
set (LIBSBML_HAS_MINIZIP)
if (LIBSBML_LIBRARY)
SET(CMAKE_REQUIRED_LIBRARIES ${LIBSBML_LIBRARY} ${LIBZ_LIBRARY} ${EXTRA_LIBS})
CHECK_FUNCTION_EXISTS(zipOpen3 LIBSBML_HAS_MINIZIP)
endif()
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/submodules/zipper/minizip AND NOT LIBSBML_HAS_MINIZIP)
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/submodules/zipper/minizip)
file(GLOB MINIZIP_SOURCES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/submodules/zipper/minizip/*.c
)
if (UNIX AND NOT CYGWIN)
list(REMOVE_ITEM MINIZIP_SOURCES
../submodules/zipper/minizip/iowin32.c
)
endif()
set(COMBINE_SOURCES ${COMBINE_SOURCES} ${MINIZIP_SOURCES})
source_group(minizip FILES ${MINIZIP_SOURCES})
elseif(LIBSBML_HAS_MINIZIP AND EXISTS ${LIBSBML_INCLUDE_DIR})
include_directories(${LIBSBML_INCLUDE_DIR}/sbml/compress)
endif()
set(LIBCOMBINE_SOURCES ${COMBINE_SOURCES} ${COMBINE_HEADERS})
set(LIBCOMBINE_LIBRARY ${COMBINE_LIBRARY})
add_subdirectory(src)
if (WITH_EXAMPLES)
add_subdirectory(examples)
endif(WITH_EXAMPLES)
option(BUILD_TEST "Build the test program." ON)
if (BUILD_TEST)
enable_testing()
if (UNIX)
# setup valgrind
set(CMAKE_MEMORYCHECK_COMMAND valgrind)
set(CMAKE_MEMORYCHECK_COMMAND_OPTIONS
"--error-exitcode=1 --trace-children=yes --leak-check=full --show-reachable=yes --leak-resolution=high --track-origins=yes --error-limit=no ")
set(MEMCHECK_COMMAND
"${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS}")
separate_arguments(MEMCHECK_COMMAND)
endif()
include(CTest)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/test)
file(GLOB TEST_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/test/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/test/*.h
${CMAKE_CURRENT_SOURCE_DIR}/src/test/*.hpp
)
add_executable(${COMBINE_LIBRARY}-test ${TEST_SOURCES})
target_link_libraries(${COMBINE_LIBRARY}-test ${LIBCOMBINE_LIBRARY}-static ${LIBCOMBINE_LIBS} ${EXTRA_LIBS})
add_test(test_${COMBINE_LIBRARY}_run ${CMAKE_CURRENT_BINARY_DIR}/${COMBINE_LIBRARY}-test )
set_tests_properties(test_${COMBINE_LIBRARY}_run PROPERTIES ENVIRONMENT
"srcdir=${CMAKE_CURRENT_SOURCE_DIR}/src/test")
endif()
if (NOT HOSTNAME)
site_name(HOSTNAME)
endif()
message(STATUS "
----------------------------------------------------------------------
libCombine version ${LIBCOMBINE_VERSION}
----------------------------------------------------------------------
Configured on host '${HOSTNAME}'
host type = ${CMAKE_SYSTEM_NAME}
host operating system = ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}
host CPU architecture = ${CMAKE_SYSTEM_PROCESSOR}
General build flags:
CC = ${CMAKE_C_COMPILER}
CXX = ${CMAKE_CXX_COMPILER}
CPPFLAGS = ${BUILD_DEFINITIONS}
CFLAGS = ${CMAKE_C_FLAGS}
CXXFLAGS = ${CMAKE_CXX_FLAGS}
LDFLAGS = ${CMAKE_EXE_LINKER_FLAGS}
SBML library configuration:
SBML library = ${LIBSBML_LIBRARY}
SBML include dir = ${LIBSBML_INCLUDE_DIR}
libSBML compression support = ${LIBSBML_HAS_MINIZIP}
XML library configuration:
XML library = ${XML_LIBRARY}
XML include dir = ${XML_INCLUDE_DIR}
Zlib library configuration:
Zlib library = ${ZLIB_LIBRARY}
Zlib include dir = ${ZLIB_INCLUDE_DIR}
Zipper library configuration:
Zipper library = ${ZIPPER_LIBRARY}
Zipper include dir = ${ZIPPER_INCLUDE_DIR}
Other configuration settings:
Installation $prefix = ${CMAKE_INSTALL_PREFIX}
")