Codebase list libsbml / lintian-fixes/main CMakeLists.txt
lintian-fixes/main

Tree @lintian-fixes/main (Download .tar.gz)

CMakeLists.txt @lintian-fixes/mainraw · history · blame

   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
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
###############################################################################
#
# Description       : CMake build script for libSBML
# Original author(s): Frank Bergmann <fbergman@caltech.edu>
# Organization      : California Institute of Technology
#
# This file is part of libSBML.  Please visit http://sbml.org for more
# information about SBML, and the latest version of libSBML.
#
# Copyright (C) 2013-2017 jointly by the following organizations:
#     1. California Institute of Technology, Pasadena, CA, USA
#     2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
#     3. University of Heidelberg, Heidelberg, Germany
#
# Copyright (C) 2009-2013 jointly by the following organizations:
#     1. California Institute of Technology, Pasadena, CA, USA
#     2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
#
# Copyright (C) 2006-2008 by the California Institute of Technology,
#     Pasadena, CA, USA
#
# Copyright (C) 2002-2005 jointly by the following organizations:
#     1. California Institute of Technology, Pasadena, CA, USA
#     2. Japan Science and Technology Agency, Japan
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation.  A copy of the license agreement is provided
# in the file named "LICENSE.txt" included with this software distribution
# and also available online as http://sbml.org/software/libsbml/license.html
#
###############################################################################

cmake_minimum_required(VERSION 2.6)
project(libsbml)

if(POLICY CMP0054)
    cmake_policy(SET CMP0054 NEW)
endif()

if(POLICY CMP0058)
    cmake_policy(SET CMP0058 OLD)
endif()



set(LIBSBML_ROOT_SOURCE_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH
    "Path to the libSBML root source directory")
set(LIBSBML_ROOT_BINARY_DIR "${CMAKE_BINARY_DIR}" CACHE PATH
    "Path to the libSBML root build directory")

include (CMakeTestCCompiler)
include (CheckCSourceCompiles)
include (CheckCXXSourceCompiles)
include (CheckStructHasMember)
include (CheckLibraryExists)
include (CheckFunctionExists)
include (CheckCCompilerFlag)
include (CheckCSourceRuns)
include (CheckSymbolExists)
include (CheckTypeSize)
if (${CMAKE_VERSION} VERSION_GREATER 2.8.4)
	include(GNUInstallDirs)
else ()
	set (CMAKE_INSTALL_DATADIR "share/libsbml/")
	set (CMAKE_INSTALL_LIBDIR "lib")
	set (CMAKE_INSTALL_INCLUDEDIR "include")
	set (CMAKE_INSTALL_BINDIR "bin")
	set (CMAKE_INSTALL_DATADIR "share")
	set (CMAKE_INSTALL_FULL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib")
	set (CMAKE_INSTALL_FULL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include")
endif ()

###############################################################################
#
# Parse VERSION.txt to determine the package version
#

set(LIBSBML_VERSION_MAJOR)
set(LIBSBML_VERSION_MINOR)
set(LIBSBML_VERSION_PATCH)
set(LIBSBML_VERSION_RELEASE)
set(LIBSBML_DOTTED_VERSION)

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt")

    file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt" VersionString NEWLINE_CONSUME)
    string(STRIP "${VersionString}" VersionString)
    set(LIBSBML_DOTTED_VERSION ${VersionString})
    string(REPLACE "." ";" VersionString "${VersionString}" )
    string(REPLACE "-" ";" VersionString "${VersionString}" )
    list(LENGTH VersionString versionLength)
    list(GET VersionString 0 LIBSBML_VERSION_MAJOR )
    list(GET VersionString 1 LIBSBML_VERSION_MINOR )
    list(GET VersionString 2 LIBSBML_VERSION_PATCH )

    if(${versionLength} GREATER 3)
        list(GET VersionString 3 LIBSBML_VERSION_RELEASE )
    endif()

endif()

# version number needs to be calculated correctly
MATH(EXPR LIBSBML_VERSION_NUMERIC "${LIBSBML_VERSION_MAJOR} * 10000 + ${LIBSBML_VERSION_MINOR} * 100 + ${LIBSBML_VERSION_PATCH}" )
set(PACKAGE_VERSION "${LIBSBML_VERSION_MAJOR}.${LIBSBML_VERSION_MINOR}.${LIBSBML_VERSION_PATCH}${LIBSBML_VERSION_RELEASE}")
set(PACKAGE_NAME "libSBML")

set(PACKAGE_CONFIG_DIR "${CMAKE_INSTALL_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 ${PACKAGE_VERSION})

if (WITH_DOXYGEN OR WITH_PYTHON)
  # configure the version for documentation / bindings
  configure_file(
      ${CMAKE_CURRENT_SOURCE_DIR}/docs/src/common-text/libsbml-version.html.in
      ${CMAKE_CURRENT_SOURCE_DIR}/docs/src/common-text/libsbml-version.html
  )
endif()

# 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 SBML.")
set(CPACK_PACKAGE_NAME "${PACKAGE_NAME}")
set(CPACK_PACKAGE_VENDOR "The libSBML Team")
set(CPACK_PACKAGE_CONTACT "LibSBML Team <libsbml-team@googlegroups.com>")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.txt")
set(CPACK_PACKAGE_VERSION_MAJOR "${LIBSBML_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${LIBSBML_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${LIBSBML_VERSION_PATCH}")
set(CPACK_RPM_PACKAGE_LICENSE "LGPL")
set(CPACK_RPM_PACKAGE_GROUP "Libraries/Development")
set(CPACK_DEBIAN_PACKAGE_SECTION "Libraries")

set(CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_BINARY_DIR};/.vs/;/.vscode/;/.svn/;/.libs/;/.deps/;/.bzr/;.*.o$;.*.lo$;.*.la$;${CPACK_SOURCE_IGNORE_FILES};/.DS_Store;/.svnignore;blib;libsbml-dist")

if(UNIX)
    set(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
    set(CPACK_SET_DESTDIR "ON")
endif()

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")
endif()

include(CPack)


###############################################################################
#
# Here we have the main configuration options for libsbml.
#

# Build static / shared library
# option(BUILD_SHARED_LIBS  "Build shared library. (Set to OFF to build static libraries.)" OFF)

# Whether to compile examples
option(WITH_EXAMPLES "Compile the libSBML example programs."  OFF)

# Which language bindings should be built
option(WITH_CSHARP   "Generate the C# language interface for libSBML."     OFF)
option(WITH_JAVA     "Generate the Java language interface for libSBML."   OFF)
option(WITH_PYTHON   "Generate the Python language interface for libSBML." OFF)
option(WITH_PERL     "Generate the Perl language interface for libSBML."   OFF)
option(WITH_PHP      "Generate the PHP language interface for libSBML."    OFF)
option(WITH_RUBY     "Generate the Ruby language interface for libSBML"    OFF)
option(WITH_R        "Generate the R language interface for libSBML"       OFF)
option(WITH_OCTAVE   "Generate the Octave language interface for libSBML." OFF)
option(WITH_MATLAB   "Generate the MATLAB language interface for libSBML." OFF)
option(WITH_JAVASCRIPT      "Generate the experimental Node.js language interface for libSBML." OFF)
option(WITH_STABLE_PACKAGES "Compile libSBML with all stable packages." OFF)
option(WITH_ALL_PACKAGES    "Compile libSBML with all packages." OFF)

if (WITH_ALL_PACKAGES)
  set(_EXPERIMENTAL_PACKGES "arrays;dyn;spatial;REQUIREDELEMENTS")
  foreach(package ${_EXPERIMENTAL_PACKGES})
    string(TOUPPER ${package} package_upper)
    string(CONCAT package_option "ENABLE_" ${package_upper})
    set(${package_option} ON CACHE BOOL "Enable package" FORCE)
  endforeach()
  set(WITH_STABLE_PACKAGES ON CACHE BOOL "Enable stable packages" FORCE)
endif(WITH_ALL_PACKAGES)

if (WITH_STABLE_PACKAGES)
  set(_STABLE_PACKGES "comp;distrib;fbc;groups;layout;multi;qual;render")
  foreach(package ${_STABLE_PACKGES})
    string(TOUPPER ${package} package_upper)
    string(CONCAT package_option "ENABLE_" ${package_upper})
    set(${package_option} ON CACHE BOOL "Enable package" FORCE)
  endforeach()
endif(WITH_STABLE_PACKAGES)

if (WITH_JAVASCRIPT)

  set(_PF86 "ProgramFiles(x86)")
  find_program(NODE_GYP_EXECUTABLE
        NAMES node-gyp node-gyp.cmd
        PATHS
              /usr/local/bin
              /opt/local/bin
              /usr/bin
              "$ENV{ProgramFilesProgramFiles}/nodejs/"
              "$ENV{ProgramW6432}/nodejs/"
        DOC "The file name of the node-gyp executable."
        )

  find_program(NODEJS_EXECUTABLE
        NAMES node nodeexe
        PATHS
              /usr/local/bin
              /opt/local/bin
              /usr/bin
              "$ENV{ProgramFiles}/nodejs/"
              "$ENV{ProgramW6432}/nodejs/"
        DOC "The file name of the nodejs executable."
        )
  # check that we found node-gyp
  if (NOT NODE_GYP_EXECUTABLE)
        message(FATAL_ERROR
"In oder to build the JavaScript language interface, libSBML needs the
node-gyp executable. Please set the variable named NODE_GYP_EXECUTABLE.")
  endif()

  # ensure that the swig version is high enough for javascript
  if (SWIG_VERSION AND NOT SWIG_VERSION VERSION_GREATER 3.0.1)
        message(FATAL_ERROR
"SWIG version 3.0.2 or greater is needed in order to build the JavaScript
language interface for libSBML, but only version ${SWIG_VERSION} was found.")
  endif()

endif()

# 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)
        string(REPLACE "/W3" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
        string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
    else()
        add_definitions(-Wall)
    endif()
endif()

# Add an option to instruct libSBML to not include SBMLTypes.h and other files internally.
option(LIBSBML_USE_STRICT_INCLUDES
"Compile using 'strict includes' rules: libSBML header files won't
use SBMLTypes.h, among others." OFF)
if(LIBSBML_USE_STRICT_INCLUDES)
  add_definitions(-DLIBSBML_USE_STRICT_INCLUDES)
endif(LIBSBML_USE_STRICT_INCLUDES)
mark_as_advanced(LIBSBML_USE_STRICT_INCLUDES)

set(LIBSBML_BUILD_TYPE "native")
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
  set(LIBSBML_BUILD_TYPE "32bit")
else()
  set(LIBSBML_BUILD_TYPE "64bit")
endif()
if (APPLE AND ENABLE_UNIVERSAL)
  set(LIBSBML_BUILD_TYPE "universal")
endif()

# When allocation of memory fails or the libSBML C API is unable to open
# a file, libSBML can exit the current process. By default this behavior
# is disabled.
#
option (EXIT_ON_ERROR "Call exit(-1) in case of allocation or file error." OFF)
mark_as_advanced(EXIT_ON_ERROR)

# Use the version number in the shared library.
#
option (LIBSBML_SHARED_VERSION
"Include version information into the compiled libSBML shared library." ON)
mark_as_advanced(LIBSBML_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 the libSBML unit tests. (You can then run the tests with the
command 'make test' or 'ctest'.)" OFF)
endif()

# Choose the xml parsing library to be used.
option(WITH_EXPAT    "Use the Expat XML parser library."     OFF)
option(WITH_LIBXML   "Use the libxml2 XML parser library."   ON )
option(WITH_XERCES   "Use the Xerces XML parser library."    OFF)

# Use C++ namespace.
option(WITH_CPP_NAMESPACE "Use a C++ namespace for libSBML."   OFF)

# Generate documentation.
option(WITH_DOXYGEN  "Generate documentation for libSBML 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 libsbml packages one wants.
option(WITH_SWIG     "Regenerate the programming language interface code
(for Java, Python, etc.) using SWIG."  ON )

# 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 type of build to perform. 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(LIBSBML_DEPENDENCY_DIR ${LIBSBML_ROOT_SOURCE_DIR}/dependencies/ CACHE PATH
  "Directory containing libraries that libSBML depends upon.
(Particularly important on Windows.)")
if("${LIBSBML_DEPENDENCY_DIR}" STREQUAL "")
  set(LIBSBML_DEPENDENCY_DIR ${LIBSBML_ROOT_SOURCE_DIR}/dependencies/ CACHE PATH
    "Directory containing libraries that libSBML depends upon.
(Particularly important on Windows.)" FORCE)
endif()

if (WITH_PYTHON)
    # add option to enable Python API2 (with warnings)
    option(PYTHON_USE_API2_WARNINGS   "Enable the new Python API2 with warnings."    OFF)
endif (WITH_PYTHON)

###############################################################################
#
# If WITH_SWIG is selected, we need to find swig
#
set(LIBSBML_USE_CPP_NAMESPACE OFF)
if(WITH_CPP_NAMESPACE)
    add_definitions(-DLIBSBML_USE_CPP_NAMESPACE=1)
    set(LIBSBML_USE_CPP_NAMESPACE ON)
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.4
              c:/swigwin-3.0.3
              c:/swigwin-3.0.2
              c:/swigwin-3.0.1
              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.6
              c:/swigwin-2.0.5
              c:/swigwin-2.0.4
              c:/swigwin-2.0.3
              c:/swigwin-2.0.2
              c:/swigwin-2.0.1
              c:/swigwin-2.0.0
              /usr/local/bin
              /opt/local/bin
              /usr/bin
              "C:/Program Files (x86)/Swig"
              "C:/Program Files/Swig"
        DOC "The file name of the SWIG executable."
        )
    find_package(SWIG)
    if (SWIG_FOUND AND SWIG_VERSION VERSION_LESS "2.0.4")
      message(WARNING
"You are using SWIG version ${SWIG_VERSION}.  We strongly recommend
using version 2.0.4 or greater. For libSBML JavaScript support, you
will need version 3.0.1 at minimum.")
    endif()
    set(SWIG_EXTRA_ARGS -DLIBSBML_COMPILED_IN_SRC)
    add_definitions(-DLIBSBML_COMPILED_IN_SRC)
    set(SWIG_SWIGDOCDEFINES)
endif(WITH_SWIG)


###############################################################################
#
# Locate expat if needed
#

set(LIBSBML_XML_LIBRARY)
set(LIBSBML_XML_LIBRARY_INCLUDE)
set(LIBSBML_XML_LIBRARY_LIBS)

if(WITH_EXPAT)
  if (NOT LIBEXPAT_LIBRARY)
    find_library(LIBEXPAT_LIBRARY
        NAMES libexpat.lib expat
        PATHS ${LIBSBML_DEPENDENCY_DIR}/lib
              /usr/lib /usr/local/lib
              /usr/lib/i386-linux-gnu
        DOC "The file name of the Expat library."
                )

  endif()

  if (NOT LIBEXPAT_INCLUDE_DIR)
    find_path(LIBEXPAT_INCLUDE_DIR
        NAMES expat.h
        PATHS ${LIBSBML_DEPENDENCY_DIR}/include
              /usr/include /usr/local/include
              ${CMAKE_OSX_SYSROOT}/usr/include
        DOC "The directory containing the Expat include files."
              )
  endif()

    add_definitions( -DUSE_EXPAT )
    list(APPEND SWIG_EXTRA_ARGS -DUSE_EXPAT)

    set(LIBSBML_XML_LIBRARY "expat")
    set(LIBSBML_XML_LIBRARY_INCLUDE ${LIBEXPAT_INCLUDE_DIR})
    set(LIBSBML_XML_LIBRARY_LIBS ${LIBEXPAT_LIBRARY})

    if(NOT EXISTS "${LIBEXPAT_INCLUDE_DIR}/expat.h")
        message(FATAL_ERROR
"The include directory specified for Expat appears to be invalid.
It should contain the file expat.h, but it does not.")
    else()
        if (LIBEXPAT_INCLUDE_DIR AND EXISTS "${LIBEXPAT_INCLUDE_DIR}/expat.h")
            file(STRINGS "${LIBEXPAT_INCLUDE_DIR}/expat.h" expat_version_str
                 REGEX "^#[\t ]*define[\t ]+XML_(MAJOR|MINOR|MICRO)_VERSION[\t ]+[0-9]+$")

            unset(EXPAT_VERSION_STRING)
            foreach(VPART MAJOR MINOR MICRO)
                foreach(VLINE ${expat_version_str})
                    if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$")
                        set(EXPAT_VERSION_PART "${CMAKE_MATCH_1}")
                        if(EXPAT_VERSION_STRING)
                            set(EXPAT_VERSION_STRING "${EXPAT_VERSION_STRING}.${EXPAT_VERSION_PART}")
                        else()
                            set(EXPAT_VERSION_STRING "${EXPAT_VERSION_PART}")
                        endif()
                    endif()
                endforeach()
            endforeach()

            if (EXPAT_VERSION_STRING VERSION_LESS 1.95.9)
                     message(FATAL_ERROR
"Expat version ${EXPAT_VERSION_STRING} is not compatible with libSBML.
Please use a version newer than 1.95.8 or an alternate XML parser.")
            endif()
        endif()
    endif()
endif(WITH_EXPAT)


###############################################################################
#
# Locate Libxml2 if needed
#
set(USE_LIBXML OFF)
if(WITH_LIBXML)
  if (NOT LIBXML_LIBRARY)
    find_library(LIBXML_LIBRARY
        NAMES libxml2.lib xml2
        PATHS /usr/lib /usr/local/lib
              ${LIBSBML_DEPENDENCY_DIR}/lib
        DOC "The file name of the libxml2 library."
                )
  endif()

  if (NOT LIBXML_INCLUDE_DIR)
    find_path(LIBXML_INCLUDE_DIR
        NAMES libxml/parser.h
        PATHS ${LIBSBML_DEPENDENCY_DIR}/include
              /usr/include /usr/local/include
              /usr/include/libxml2
              ${CMAKE_OSX_SYSROOT}/usr/include/libxml2
              /usr/local/include/libxml2

        DOC "The directory containing the libxml2 include files."
              )
  endif()

  add_definitions( -DUSE_LIBXML )
  list(APPEND SWIG_EXTRA_ARGS -DUSE_LIBXML)
  set(USE_LIBXML ON)

  set(LIBSBML_XML_LIBRARY "libxml2")
  set(LIBSBML_XML_LIBRARY_INCLUDE ${LIBXML_INCLUDE_DIR})
  set(LIBSBML_XML_LIBRARY_LIBS ${LIBXML_LIBRARY})

  if(NOT EXISTS "${LIBXML_INCLUDE_DIR}/libxml/parser.h")
        message(FATAL_ERROR
"The include directory specified for libxml appears to be invalid.
It should contain the file libxml/parser.h, but it does not.")
  endif()
endif(WITH_LIBXML)


###############################################################################
#
# Locate xerces
#

if(WITH_XERCES)
    add_definitions( -DUSE_XERCES )
    list(APPEND SWIG_EXTRA_ARGS -DUSE_XERCES)

    find_library(XERCES_LIBRARY
        NAMES xerces-c_3.lib xerces-c
        PATHS /usr/lib /usr/local/lib
              ${LIBSBML_DEPENDENCY_DIR}/lib
        DOC "The file name of the Xerces library."
                )

    find_path(XERCES_INCLUDE_DIR
        NAMES xercesc/parsers/XercesDOMParser.hpp
        PATHS /usr/include /usr/local/include
              ${CMAKE_OSX_SYSROOT}/usr/include/xercesc
              /usr/include/xercesc
              /usr/local/include/xercesc
              ${LIBSBML_DEPENDENCY_DIR}/include
        DOC "The directory containing the Xerces include files."
              )

    if (EXISTS "${XERCES_INCLUDE_DIR}/xercesc/util/XercesVersion.hpp")
        function(_myXercesC_GET_VERSION  version_hdr)
            file(STRINGS ${version_hdr} _contents REGEX "^[ \t]*#define XERCES_VERSION_.*")
            if(_contents)
                string(REGEX REPLACE ".*#define XERCES_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" XercesC_MAJOR "${_contents}")
                string(REGEX REPLACE ".*#define XERCES_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" XercesC_MINOR "${_contents}")
                string(REGEX REPLACE ".*#define XERCES_VERSION_REVISION[ \t]+([0-9]+).*" "\\1" XercesC_PATCH "${_contents}")

                if(NOT XercesC_MAJOR MATCHES "^[0-9]+$")
                    message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_MAJOR!")
                endif()
                if(NOT XercesC_MINOR MATCHES "^[0-9]+$")
                    message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_MINOR!")
                endif()
                if(NOT XercesC_PATCH MATCHES "^[0-9]+$")
                    message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_REVISION!")
                endif()

                set(XercesC_VERSION "${XercesC_MAJOR}.${XercesC_MINOR}.${XercesC_PATCH}" PARENT_SCOPE)
            else()
                message(FATAL_ERROR "Include file ${version_hdr} does not exist or does not contain expected version information")
            endif()
        endfunction()

        _myXercesC_GET_VERSION("${XERCES_INCLUDE_DIR}/xercesc/util/XercesVersion.hpp")
        if (XercesC_VERSION VERSION_EQUAL 2.6.0)
         message(FATAL_ERROR
"Xerces version ${XercesC_VERSION} contains known bugs
and is not compatible with libSBML. Please use a newer version of
Xerces or an alternate XML parser.")
        endif()
    endif ()

    set(LIBSBML_XML_LIBRARY "xerces-c")
    set(LIBSBML_XML_LIBRARY_INCLUDE ${XERCES_INCLUDE_DIR})
    set(LIBSBML_XML_LIBRARY_LIBS ${XERCES_LIBRARY})

    if(NOT EXISTS "${XERCES_INCLUDE_DIR}/xercesc/parsers/XercesDOMParser.hpp")
        message(FATAL_ERROR
"The include directory specified for Xerces appears to be invalid.
It should contain the file xercesc/parsers/XercesDOMParser.hpp, but
it does not.")
    endif()

endif(WITH_XERCES)

###############################################################################
#
# Locate bz2
#

set(BZIP_INITIAL_VALUE)
if (NOT LIBBZ_LIBRARY)
find_library(LIBBZ_LIBRARY
    NAMES bzip2.lib bz2 libbz2.lib
    PATHS /usr/lib /usr/local/lib
          ${CMAKE_OSX_SYSROOT}/usr/lib
          ${LIBSBML_DEPENDENCY_DIR}/lib
          NO_DEFAULT_PATH
          NO_CMAKE_ENVIRONMENT_PATH
          NO_CMAKE_PATH
          NO_SYSTEM_ENVIRONMENT_PATH
          NO_CMAKE_SYSTEM_PATH

          DOC "The file name of the bzip2 library."
)
endif()
if (NOT LIBBZ_LIBRARY)
find_library(LIBBZ_LIBRARY
    NAMES bzip2.lib bz2 libbz2.lib
    PATHS /usr/lib /usr/local/lib
          ${CMAKE_OSX_SYSROOT}/usr/lib
          ${LIBSBML_DEPENDENCY_DIR}/lib
    DOC "The file name of the bzip2 library."
)
endif()

if(EXISTS ${LIBBZ_LIBRARY})
    set(BZIP_INITIAL_VALUE ON)
else()
    set(BZIP_INITIAL_VALUE OFF)
endif()

option(WITH_BZIP2    "Enable the use of bzip2 compression."  ${BZIP_INITIAL_VALUE})
set(USE_BZ2 OFF)
if(WITH_BZIP2)

  if (NOT LIBBZ_INCLUDE_DIR)
    find_path(LIBBZ_INCLUDE_DIR
        NAMES bzlib.h bzip2/bzlib.h
        PATHS ${CMAKE_OSX_SYSROOT}/usr/include
              /usr/include /usr/local/include
              ${LIBSBML_DEPENDENCY_DIR}/include
              NO_DEFAULT_PATH
        DOC "The directory containing the bzip2 include files."
        )
  endif()

  if (NOT LIBBZ_INCLUDE_DIR)
      find_path(LIBBZ_INCLUDE_DIR
        NAMES bzlib.h bzip2/bzlib.h
        PATHS ${CMAKE_OSX_SYSROOT}/usr/include
              /usr/include /usr/local/include
              ${LIBSBML_DEPENDENCY_DIR}/include
        DOC "The directory containing the bzip2 include files."
              )
  endif()

    set(USE_BZ2 ON)
    add_definitions( -DUSE_BZ2 )
  list(APPEND SWIG_EXTRA_ARGS -DUSE_BZ2)

    # make sure that we have a valid bzip2 library
    file(TO_CMAKE_PATH "${LIBBZ_LIBRARY}" LIBBZ2_CMAKE_PATH)
    check_library_exists("${LIBBZ2_CMAKE_PATH}" "BZ2_bzCompressInit" "" LIBBZ_FOUND_SYMBOL)
    if(NOT LIBBZ_FOUND_SYMBOL)
        # this is odd, but on windows this check always fails! must be a
        # bug in the current cmake version so for now only issue this
        # warning on linux
        if(UNIX)
            message(WARNING
"The chosen bz2 library does not appear to be valid because it is
missing some required symbols. Please check that ${LIBBZ_LIBRARY}
is the bzip2 library. For details about the error, please see
${LIBSBML_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log")
        endif()
    endif()
    if(NOT EXISTS "${LIBBZ_INCLUDE_DIR}/bzlib.h")
        message(FATAL_ERROR
"The include directory specified for the bz2 library does not
appear to be valid.  It should contain the file bzlib.h, but
it does not.")
    endif()


endif(WITH_BZIP2)


###############################################################################
#
# list of additional files to link against.
#

set(EXTRA_LIBS "" CACHE STRING
"List of additional libraries to link against.  Separate multiple
names using semicolons." )
set(EXTRA_INCLUDE_DIRS "" CACHE STRING
"List of additional include directories to use during compilation.
Separate multiple directories using semicolons." )


###############################################################################
#
# Locate zlib
#

set(ZLIB_INITIAL_VALUE)
if (NOT LIBZ_LIBRARY)
find_library(LIBZ_LIBRARY
    NAMES zdll.lib z zlib.lib
    PATHS /usr/lib /usr/local/lib
          ${CMAKE_OSX_SYSROOT}/usr/lib
          ${LIBSBML_DEPENDENCY_DIR}/lib
          NO_DEFAULT_PATH
          NO_CMAKE_ENVIRONMENT_PATH
          NO_CMAKE_PATH
          NO_SYSTEM_ENVIRONMENT_PATH
          NO_CMAKE_SYSTEM_PATH
          DOC "The file name of the zip compression library."
    )
endif()
if (NOT LIBZ_LIBRARY)
find_library(LIBZ_LIBRARY
    NAMES zdll.lib z zlib.lib
    PATHS /usr/lib /usr/local/lib
          ${CMAKE_OSX_SYSROOT}/usr/lib
          ${LIBSBML_DEPENDENCY_DIR}/lib
    DOC "The file name of the zip compression library."
    )
endif()

if(EXISTS ${LIBZ_LIBRARY})
    set(ZLIB_INITIAL_VALUE ON)
else()
    set(ZLIB_INITIAL_VALUE OFF)
endif()
option(WITH_ZLIB     "Enable the use of zip compression."    ${ZLIB_INITIAL_VALUE} )

set(USE_ZLIB OFF)
if(WITH_ZLIB)

  if (NOT LIBZ_INCLUDE_DIR)
    find_path(LIBZ_INCLUDE_DIR
        NAMES zlib.h zlib/zlib.h
        PATHS ${CMAKE_OSX_SYSROOT}/usr/include
              /usr/include /usr/local/include
              ${LIBSBML_DEPENDENCY_DIR}/include
              NO_DEFAULT_PATH
        DOC "The directory containing the zlib include files."
              )
  endif()
    if (NOT LIBZ_INCLUDE_DIR)
        find_path(LIBZ_INCLUDE_DIR
        NAMES zlib.h zlib/zlib.h
        PATHS ${CMAKE_OSX_SYSROOT}/usr/include
              /usr/include /usr/local/include
              ${LIBSBML_DEPENDENCY_DIR}/include
        DOC "The directory containing the zlib include files."
              )
    endif()
    set(USE_ZLIB ON)
    add_definitions( -DUSE_ZLIB )
  list(APPEND SWIG_EXTRA_ARGS -DUSE_ZLIB)

    # make sure that we have a valid zip library
    file(TO_CMAKE_PATH "${LIBZ_LIBRARY}" LIBZ_CMAKE_PATH)
    check_library_exists("${LIBZ_CMAKE_PATH}" "gzopen" "" LIBZ_FOUND_SYMBOL)
    if(NOT LIBZ_FOUND_SYMBOL)
        # this is odd, but on windows this check always fails! must be a
        # bug in the current cmake version so for now only issue this
        # warning on linux
        if(UNIX)
            message(WARNING
"The chosen zlib library does not appear to be valid because it is
missing certain required symbols. Please check that ${LIBZ_LIBRARY} is
the correct zlib library. For details about the error, please see
${LIBSBML_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log")
        endif()
    endif()

    if(NOT EXISTS "${LIBZ_INCLUDE_DIR}/zlib.h")
        message(FATAL_ERROR
"The include directory specified for zlib does not appear to be
valid. It should contain the file zlib.h, but it does not.")
    endif()

endif(WITH_ZLIB)


###############################################################################
#
# Find the C# compiler to use and set name for resulting library
#

if(WITH_CSHARP)
    FILE(TO_CMAKE_PATH "$ENV{WINDIR}" windir)
    find_program(CSHARP_COMPILER
        NAMES gmcs csc mcs
        PATHS
            ${windir}/Microsoft.NET/Framework/v2.0.50727/
            ${windir}/Microsoft.NET/Framework/v3.0/
            /usr/bin
            /usr/local/bin
        DOC "The file name of the C# compiler for the libsbmlcs assembly."
        )
    find_program(CSHARP_EXAMPLE_COMPILER
        NAMES gmcs csc mcs
        PATHS
            ${windir}/Microsoft.NET/Framework/v4.0.30319/
            ${windir}/Microsoft.NET/Framework/v3.5/
            ${windir}/Microsoft.NET/Framework/v3.0/
            ${windir}/Microsoft.NET/Framework/v2.0.50727/
            /usr/bin
            /usr/local/bin
        DOC "The file name of the C# compiler to be used for the examples."
        )
    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)


###############################################################################
#
# Enable support for testing ... can be invoked by running ctest
# or make test
#

if(WITH_CHECK)

    # we do use tests, that require 2.8.4
    cmake_minimum_required(VERSION 2.8.4)

    # set test timeout to 3000 as the normal time limit is not sufficient
    # for the comp tests
    SET(DART_TESTING_TIMEOUT "3000" CACHE STRING "" FORCE)

    enable_testing()

    find_library(LIBCHECK_LIBRARY
        NAMES check libcheck
        PATHS /usr/lib /usr/local/lib ${LIBSBML_DEPENDENCY_DIR}/lib
        DOC "The file name of the libcheck library."
    )

    find_path(LIBCHECK_INCLUDE_DIR
        NAMES check.h
        PATHS /usr/include /usr/local/include  ${LIBSBML_DEPENDENCY_DIR}/include
        DOC "The directory containing the libcheck include files."
              )

    if(NOT EXISTS "${LIBCHECK_INCLUDE_DIR}/check.h")
        message(FATAL_ERROR
"The include directory specified for the 'check' library appears to be
invalid. It should contain the file check.h, but it does not.")
    endif()

    if(${CMAKE_GENERATOR} MATCHES "Visual Studio 6" OR ${CMAKE_GENERATOR} MATCHES "Visual Studio 7")
        message(WARNING "Libcheck is not compatible with Visual Studio 2003 (or earlier versions).")
    endif()

  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)

      # check that check compiles/links - needs cmake 3+

      if(${CMAKE_VERSION} VERSION_GREATER 3.0.0)
        set(CHECK_CHECK_CODE
        "
        #include <check.h>
        
        START_TEST (sanity_check)
        {
            fail_unless(5 == 5, \"this should succeed\");
            fail_unless(6 == 5, \"this should fail\");
        }
        END_TEST
        
        int 
        main(void)
        {
            Suite *s1 = suite_create(\"Core\");
            TCase *tc1_1 = tcase_create(\"Core\");
            SRunner *sr = srunner_create(s1);
            int nf;
        
            suite_add_tcase(s1, tc1_1);
            tcase_add_test(tc1_1, sanity_check);
        
            srunner_run_all(sr, CK_ENV);
            nf = srunner_ntests_failed(sr);
            srunner_free(sr);
            ;
            return nf == 0 ? 0 : 1;
        }
        " 
        )

        set(CMAKE_REQUIRED_LIBRARIES_CACHE ${CMAKE_REQUIRED_LIBRARIES})
        unset(CHECK_CHECK_TEST CACHE)
        unset(CHECK_CHECK_TEST2 CACHE)

        set(CHECK_CHECK_TEST)
        set(CMAKE_REQUIRED_LIBRARIES "-lcheck -lm ${EXTRA_LIBS}")
        CHECK_C_SOURCE_COMPILES("${CHECK_CHECK_CODE}" CHECK_CHECK_TEST)

        if (NOT CHECK_CHECK_TEST)
            set(CHECK_CHECK_TEST2)
            set(CMAKE_REQUIRED_LIBRARIES "-lcheck -lm -pthread -lrt -lsubunit ${EXTRA_LIBS}")
            CHECK_C_SOURCE_COMPILES("${CHECK_CHECK_CODE}" CHECK_CHECK_TEST2)
            
            if (CHECK_CHECK_TEST2)
                set(CHECK_TMP_LIBS "-pthread -lrt -lsubunit ${EXTRA_LIBS}")
                string(STRIP "${CHECK_TMP_LIBS}" CHECK_TMP_LIBS)
                set(EXTRA_LIBS "${CHECK_TMP_LIBS}" CACHE STRING
                "List of additional libraries to link against.  Separate multiple
                names using semicolons." FORCE)                
                unset(CHECK_TMP_LIBS)
                message(STATUS "Check requires the following EXTRA_LIBS : ${EXTRA_LIBS}")
            else ()
                message(WARNING
"Check cannot compile tests, please specify the correct EXTRA_LIBS for your operating system.")            
            endif (CHECK_CHECK_TEST2)
            unset(CHECK_CHECK_TEST2 CACHE)

        endif (NOT CHECK_CHECK_TEST)

        unset(CHECK_CHECK_TEST CACHE)
        set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_FLAGS_CACHE})

      endif(${CMAKE_VERSION} VERSION_GREATER 3.0.0)

  endif(UNIX)

    include(CTest)

endif(WITH_CHECK)


###############################################################################
#
# 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}.
#

set( MISC_PREFIX )
if(UNIX OR CYGWIN)
    set(PATH_SEP "/")
    set(FILE_SEP ":")
    set( MISC_PREFIX "${CMAKE_INSTALL_DATADIR}/libsbml/" )
    set(LIBSBML_LIBRARY sbml)
else()
    set( MISC_PREFIX ".\\" )
    set(PATH_SEP "\\")
    set(FILE_SEP ";")
    if(MINGW)
        set(LIBSBML_LIBRARY sbml)
    else()
        set(LIBSBML_LIBRARY libsbml)
    endif()
endif()

# On some Linux  (64bit) systems (64bit) the libraries should be installed into lib64 rather
# than lib. It will default to 'lib' but can be overwritten.

set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Full path to the library output directory")
mark_as_advanced(CMAKE_INSTALL_LIBDIR)

###############################################################################
#
# Set up remaining variables, add option for universal binaries
#

set(USING_INTEL)
if (WIN32 AND CMAKE_C_COMPILER AND ${CMAKE_C_COMPILER} MATCHES ".*icl.*$")
  message(STATUS "Detected Intel Compiler")
  set(USING_INTEL TRUE)
endif ()


set(BUILD_DEFINITIONS)
if(UNIX)
    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. (Not available on
other operating systems.)" OFF)

        set(CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING
           "A semicolon-separated list of architectures for which libSBML should be built.")
        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_GREATER "10.7" OR
                   OSX_SDK_VERSION  VERSION_EQUAL "10.8" OR
                   OSX_SDK_VERSION  VERSION_GREATER "10.8")

                   # OSX Lion no longer supports ppc architecture
                   set(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING
                      "A semicolon-separated list of architectures for which libSBML should be built." FORCE)

                elseif(OSX_SDK_VERSION AND OSX_SDK_VERSION  VERSION_LESS "10.7" )

                   set(CMAKE_OSX_ARCHITECTURES "i386;ppc;x86_64" CACHE STRING
                       "A semicolon-separated list of architectures for which libSBML should be built." FORCE)

                else()

                   set(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING
                       "A semicolon-separated list of architectures for which libSBML should be built." 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)

    if(WITH_CHECK)
        if(CMAKE_VERSION VERSION_GREATER "3.0.0")
            # https://cmake.org/cmake/help/v3.0/module/CheckCXXSourceCompiles.html
            # CMAKE_REQUIRED_FLAGS = string of compile command line flags
            # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
            # CMAKE_REQUIRED_INCLUDES = list of include directories
            # CMAKE_REQUIRED_LIBRARIES = list of libraries to link
            
            # <code>       - source code to try to compile, must define 'main'
            # <var>        - variable to store whether the source code compiled
            # <fail-regex> - fail if test output matches this regex

            # set(CMAKE_REQUIRED_LIBRARIES "${EXTRA_LIBS}")
            # CHECK_CXX_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>])

            # set(CMAKE_REQUIRED_LIBRARIES "-lrt -lpthread -lsubunit")
            # CHECK_CXX_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>])

            # set(CMAKE_REQUIRED_LIBRARIES "-lrt -lpthread")
            # CHECK_CXX_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>])
        endif(CMAKE_VERSION VERSION_GREATER "3.0.0")
        # plan A now extinct
        #add_subdirectory(dev/utilities/linux-check-libs)
        #target_link_libraries(${LIBSBML_LIBRARY} ${LIBSBML_LIBS} ${EXTRA_LIBS})
    endif(WITH_CHECK)

    
    # not needing these defines, and they do cause warnings
    # add_definitions( -DPACKAGE_VERSION=\"${PACKAGE_VERSION}\"  -DPACKAGE_NAME=\"${PROJECT_NAME}\")
    # set(BUILD_DEFINITIONS "${BUILD_DEFINITIONS} -DPACKAGE_VERSION=\"${PACKAGE_VERSION}\"  -DPACKAGE_NAME=\"${PROJECT_NAME}\"")

else(UNIX)
    # not needing these defines, and they do cause warnings
    # add_definitions(-DPACKAGE_VERSION=\"${PACKAGE_VERSION}\"  -DPACKAGE_NAME=\"${PROJECT_NAME}\")
    add_definitions(-DWIN32 -DLIBSBML_EXPORTS -DLIBLAX_EXPORTS)
    set(BUILD_DEFINITIONS "${BUILD_DEFINITIONS} -DWIN32 -DLIBSBML_EXPORTS -DLIBLAX_EXPORTS")
    if(MSVC OR USING_INTEL)
        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)
        endif(WITH_STATIC_RUNTIME)

        # on VS enable multiprocessor build
        SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")

        # Provide an easy way to use Visual Leak Detector (https://vld.codeplex.com)
    option(LIBSBML_USE_VLD "When running debug builds with MSVC use Visual Leak Detector." OFF)
    mark_as_advanced(LIBSBML_USE_VLD)
    if (LIBSBML_USE_VLD)
          find_path(VLD_INCLUDE_DIR
            NAMES vld.h
            PATHS ${LIBSBML_DEPENDENCY_DIR}/include
            "$ENV{PROGRAMFILES}/Visual Leak Detector/include"
            "$ENV{ProgramW6432}/Visual Leak Detector/include"
            DOC "Directory containing VLD files."
          )
          if (NOT VLD_INCLUDE_DIR)
            message(WARNING "VLD is not found on your system, please ensure you installed it correctly.")
      else()
        include_directories(${VLD_INCLUDE_DIR})
      endif()

      add_definitions( -DLIBSBML_USE_VLD)

    endif (LIBSBML_USE_VLD)

    # 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)
        # add /bigobj to allow debug builds to work with swig and packages
        ADD_DEFINITIONS(/bigobj)
        SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj")
        SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /bigobj")
    endif()

        file(GLOB WIN32_BINARIES ${LIBSBML_DEPENDENCY_DIR}/bin/*.dll)
        INSTALL(FILES ${WIN32_BINARIES} DESTINATION bin)
        file(GLOB WIN32_DEPENDENCIES ${LIBSBML_DEPENDENCY_DIR}/lib/*.lib)
        install(FILES ${WIN32_DEPENDENCIES} DESTINATION lib)
        if(WITH_LIBXML)
      if (EXTRA_LIBS STREQUAL "")
        # populate EXTRA_LIBS variable
              find_library(LIBICONV_LIBRARY
                NAMES libiconv.lib iconv.lib iconv
                PATHS /usr/lib /usr/local/lib
                      ${CMAKE_OSX_SYSROOT}/usr/lib
                      ${LIBSBML_DEPENDENCY_DIR}/lib
                DOC "The file name of the libiconv library."
              )

        set(ADDITIONAL_LIBS)
        if (EXISTS ${LIBICONV_LIBRARY})
        set(ADDITIONAL_LIBS "${ADDITIONAL_LIBS}${LIBICONV_LIBRARY};")
        endif()
        if (EXISTS ${LIBZ_LIBRARY})
        set(ADDITIONAL_LIBS "${ADDITIONAL_LIBS}${LIBZ_LIBRARY};")
        endif()
        set(EXTRA_LIBS "WS2_32.lib;${ADDITIONAL_LIBS}" CACHE STRING "List of additional libraries to link against." FORCE)
      endif()
    endif()
    elseif(CYGWIN)
        add_definitions(-DCYGWIN)
        set(BUILD_DEFINITIONS "${BUILD_DEFINITIONS} -DCYGWIN")
    elseif(MINGW)
        if(WITH_LIBXML)
            # this is necessary to build with libxml2 on mingw
            add_definitions(-DLIBXML_STATIC)
        endif(WITH_LIBXML)
    endif(MSVC OR USING_INTEL)

endif(UNIX)


###############################################################################
#
# Disable in-source build
#

if("${LIBSBML_ROOT_SOURCE_DIR}" STREQUAL "${LIBSBML_ROOT_BINARY_DIR}" )
    message(FATAL_ERROR "In-source builds of libSBML are disabled.
Please create a separate build directory.")
endif()


###############################################################################
#
# Add check that only one XML library was selection
#

set(LIBRARY_COUNT 0)
if(WITH_EXPAT)
    math(EXPR LIBRARY_COUNT "${LIBRARY_COUNT} + 1")
endif()
if(WITH_LIBXML)
    math(EXPR LIBRARY_COUNT "${LIBRARY_COUNT} + 1")
endif()
if(WITH_XERCES)
    math(EXPR LIBRARY_COUNT "${LIBRARY_COUNT} + 1")
endif()

if(LIBRARY_COUNT GREATER 1)
    message(FATAL_ERROR
"Only one XML library should be chosen. Please select only one of the
following options: WITH_LIBXML, WITH_EXPAT or WITH_XERCES.")
endif()


###############################################################################
#
# Add check that at least one XML library was selection
#

if(LIBRARY_COUNT EQUAL 0)
    message(FATAL_ERROR
"A XML library must be selected. Please select one of the following
options: WITH_LIBXML, WITH_EXPAT or WITH_XERCES.")
endif()

###############################################################################
#
# Include options for all libSBML packages
#
set(LIBSBML_PACKAGE_INCLUDES)
set(LIBSBML_PACKAGE_SUMMARY)
file(GLOB PACKAGE_OPTIONS "*package.cmake")
foreach(package ${PACKAGE_OPTIONS})
    include(${package})
endforeach()

if (LIBSBML_PACKAGE_INCLUDES)
  list(REMOVE_DUPLICATES LIBSBML_PACKAGE_INCLUDES)
endif()

###############################################################################
#
# Build the actual libSBML library
#

add_subdirectory(src)


###############################################################################
#
# Build examples if specified
#

if(WITH_EXAMPLES)

    # code that builds the examples
    add_subdirectory(examples)

endif(WITH_EXAMPLES)


if(WITH_DOXYGEN)
    add_subdirectory(docs)
endif()


###############################################################################
#
# Install documentation
#

set(DOCUMENTATION_FILES
        COPYING.txt
        FUNDING.txt
        LICENSE.txt
        NEWS.txt
        README.md
        VERSION.txt
)

install(FILES ${DOCUMENTATION_FILES} DESTINATION ${MISC_PREFIX})

###############################################################################
#
# Write libsbml.pc
#

set (PRIVATE_LIBS "-lstdc++ -lm")
if (WITH_ZLIB)
set (PRIVATE_LIBS "${LIBZ_LIBRARY} ${PRIVATE_LIBS}")
endif()
if (WITH_BZIP2)
set (PRIVATE_LIBS "${LIBBZ_LIBRARY} ${PRIVATE_LIBS}")
endif()
if (WITH_LIBXML)
set (PRIVATE_LIBS "${LIBXML_LIBRARY} ${PRIVATE_LIBS}")
endif()
if (WITH_EXPAT)
set (PRIVATE_LIBS "${LIBEXPAT_LIBRARY} ${PRIVATE_LIBS}")
endif()
if (WITH_XERCES)
set (PRIVATE_LIBS "${XERCES_LIBRARY} ${PRIVATE_LIBS}")
endif()

file(WRITE  "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "Name: ${PACKAGE_NAME}\n")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "Description: A library for reading/writing/manipulating SBML\n")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "URL: http://sbml.org/Software/libSBML\n")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "Version: ${PACKAGE_VERSION}\n")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "\n")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "prefix=${CMAKE_INSTALL_PREFIX}\n")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "libdir=${CMAKE_INSTALL_FULL_LIBDIR}\n")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "includedir=${CMAKE_INSTALL_FULL_INCLUDEDIR}\n")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "\n")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "Libs: -L\${libdir} -lsbml\n")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "Libs.private:        ${PRIVATE_LIBS}\n")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "Cflags: -I\${includedir}\n")
if (WITH_XERCES)
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "Conflicts: xerces-c = 2.6.0\n")
endif()

if (WITH_LIBXML)
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc" "Requires.private: libxml-2.0 >= 2.6.22\n")
endif()

if (UNIX)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libsbml.pc"
        DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()

###############################################################################
#
# Print Summary
#
if (NOT HOSTNAME)
 site_name(HOSTNAME)
endif()

message(STATUS "
----------------------------------------------------------------------
libSBML version ${PACKAGE_VERSION}
----------------------------------------------------------------------

   More information and the latest version are available online at
   http://sbml.org/Software/libSBML

   Please report problems using the issue tracker at
   http://sbml.org/Software/libsbml/issue-tracker

   To contact the developers directly, email libsbml-team@googlegroups.com

   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}

   XML parser library configuration:
     XML library                     = ${LIBSBML_XML_LIBRARY}
     CPPFLAGS for XML                = -I${LIBSBML_XML_LIBRARY_INCLUDE}
     LIBS for XML                    = ${LIBSBML_XML_LIBRARY_LIBS}

   Other libSBML configuration settings:
     Installation $prefix            = ${CMAKE_INSTALL_PREFIX}")

if(UNIX)
    if(APPLE)
        message(STATUS "     Value of $DYLD_LIBRARY_PATH     = $ENV{DYLD_LIBRARY_PATH}")
    else()
        message(STATUS "     Value of $LD_LIBRARY_PATH       = $ENV{LD_LIBRARY_PATH}")
    endif()
endif()

if(WITH_SWIG)
    message(STATUS "     Using SWIG                      = ${SWIG_EXECUTABLE} (Version ${SWIG_VERSION})")

    if (SWIG_FOUND AND SWIG_VERSION VERSION_LESS "2.0.4")
      message(WARNING "   You are using SWIG version ${SWIG_VERSION}. We strongly recommend at least version 2.0.4.")
    endif()

endif()


if(WITH_CSHARP)
    message(STATUS "     Using C#                        = ${CSHARP_COMPILER}")
endif()

if(WITH_JAVA)
    message(STATUS "     Using Java                      = ${Java_JAVA_EXECUTABLE}")
endif()

if(WITH_JAVASCRIPT)
    message(STATUS "     Using Node.js                   = ${NODE_GYP_EXECUTABLE}")
endif()

if(WITH_PYTHON)
    message(STATUS "     Using Python                    = ${PYTHON_EXECUTABLE}")
endif()

if(WITH_PERL)
    message(STATUS "     Using Perl                      = ${PERL_EXECUTABLE}")
endif()

if(WITH_RUBY)
    message(STATUS "     Using Ruby                      = ${RUBY_EXECUTABLE}")
endif()

if(WITH_OCTAVE)
    message(STATUS "     Using Octave                    = ${MKOCTFILE_EXECUTABLE}")
endif()

if(WITH_MATLAB)
    message(STATUS "     Using Matlab                    = ${MATLAB_ROOT_PATH}")
endif()

if(WITH_R)
    message(STATUS "     Using R                         = ${R_INTERPRETER}")
endif()

if(WITH_PHP)
    message(STATUS "     Using PHP                       = yes")
endif()

if(WITH_CHECK)
    message(STATUS "     Using libcheck                  = ${LIBCHECK_LIBRARY}")
endif()

if(WITH_CPP_NAMESPACE)
    message(STATUS "     Using C++ namespace ('libsbml') = yes")
else()
    message(STATUS "     Using C++ namespace ('libsbml') = no")
endif()

if(APPLE)
    if(CMAKE_OSX_ARCHITECTURES STREQUAL "")
        message(STATUS "     Building 'universal' binaries   = no (using native arch)")
    else()
        list(REMOVE_DUPLICATES CMAKE_OSX_ARCHITECTURES)
        list(REMOVE_ITEM CMAKE_OSX_ARCHITECTURES "")
        list(SORT CMAKE_OSX_ARCHITECTURES)
        list(LENGTH CMAKE_OSX_ARCHITECTURES NUM_ARCHS)
        if(NUMARCHS EQUAL 1)
            message(STATUS "     Building 'universal' binaries   = no (using ${CMAKE_OSX_ARCHITECTURES})")
        else()
            message(STATUS "     Building 'universal' binaries   = yes (using ${CMAKE_OSX_ARCHITECTURES})")
        endif()
    endif()
endif()

message(STATUS "")
if(WITH_EXAMPLES)
  message(STATUS "     Build examples                  = yes")
else()
  message(STATUS "     Build examples                  = no")
endif()

message(STATUS "")

if(PYTHON_USE_API2_WARNINGS)
  message(STATUS "")
  message(STATUS "     Using Python API2 warnings      = yes")
endif(PYTHON_USE_API2_WARNINGS)

if (LIBSBML_PACKAGE_SUMMARY)
  message(STATUS "")
  message(STATUS "   Support for SBML Level 3 Packages: ")
  foreach(summary ${LIBSBML_PACKAGE_SUMMARY})
    message(STATUS "     ${summary}")
  endforeach()
endif(LIBSBML_PACKAGE_SUMMARY)

message(STATUS "
")
message(STATUS "Other potentially important settings:")
if(WITH_ZLIB)
    message(STATUS "  Compression support is enabled for .zip and .gz files")
else()
    message(STATUS "
Warning: reading/writing compressed SBML in .zip or .gz format in
this copy of libSBML is not supported or has been disabled.
If this was not your intention, please check the WITH_ZLIB
option.")
endif()

if(WITH_BZIP2)
    message(STATUS "  Compression support is enabled for .bz2 files")
else()
    message(STATUS "
Warning: reading/writing compressed SBML in .bz2 format in
this copy of libSBML is not supported or has been disabled.
If this was not your intention, please check the WITH_BZIP2
option.")
endif()

message(STATUS "
----------------------------------------------------------------------")


## Add uninstall target
## as available from http://www.cmake.org/Wiki/RecipeAddUninstallTarget
CONFIGURE_FILE(
  "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/dev/utilities/sboTree/updateSBO.cmake")
# add update_sbo target
ADD_CUSTOM_TARGET(update_sbo
  "${CMAKE_COMMAND}"
      -DSRC_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
      -DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}"
      -P "${CMAKE_CURRENT_SOURCE_DIR}/dev/utilities/sboTree/updateSBO.cmake")
endif()
## To compile a test program simply comment out the lines below ...
#
#OPTION(WITH_TEST_PROGRAM " COMPILE SMALL TEST PROGRAM " ON)
#
#if(WITH_TEST_PROGRAM)
#
#include_directories(${CMAKE_CURRENT_SOURCE_DIR})
#
#add_executable(libsbml_test test.cpp)
#target_link_libraries(libsbml_test ${LIBSBML_LIBRARY}-static)
#
#endif()
#