forked from gimli-org/gimli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
615 lines (516 loc) · 23.3 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
# main cmake configuration file
cmake_minimum_required(VERSION 2.8.8)
if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
message( FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt." )
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
include(GIMLImacros)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
add_custom_target(pygimli)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Sets the configuration to build (Release, Debug, etc...)")
endif()
project(libgimli)
# Check if conda package is created
if(DEFINED ENV{CONDA_BUILD})
message(STATUS "Conda package is being created.")
set(CONDA_BUILD TRUE)
set(Boost_INCLUDE_DIR "${CMAKE_PREFIX_PATH}/include")
else()
set(CONDA_BUILD FALSE)
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -pipe -ansi -Wall -Wno-long-long -Wno-unused-result")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-unused-variable")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-unused-value")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-unused-local-typedefs")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-strict-aliasing")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-int-in-bool-context")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-class-memaccess")
add_definitions(-std=c++11)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -p -O2 -std=c++11 -g -ansi -pedantic -fno-omit-frame-pointer -Wall")
if (WIN32 OR CONDA_BUILD)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-deprecated-declarations -Wno-class-memaccess")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-class-memaccess") # new since gcc.8 maybe need to be checked
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-parentheses") # from boost since gcc.8 maybe need to be checked
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-attributes") # from gcc-8.2 + boost
endif()
if (NOT WIN32 AND ASAN)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
endif()
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-Os")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-overloaded-virtual")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Qunused-arguments")
if (APPLE)
# If it's libc++ and you're on <= 10.8, you need to compile with clang++ -stdlib=libc++. If it's libstdc++ and you're on 10.9 or later, you need to compile with clang++ -stdlib=libstdc++.
# add_compile_options(-stdlib=libstdc++)
# add_compile_options(-stdlib=libc++)
endif()
else() # if gcc
endif()
elseif(MSVC)
# MSVC complain a lot of possible unsecure std function
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
find_package(Git)
if (GIT_FOUND)
message(STATUS, ${GIT_FOUND})
execute_process(
COMMAND
${GIT_EXECUTABLE} describe --tags
WORKING_DIRECTORY
${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE
GIMLI_GITVERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
message(STATUS, "setting version from git description: ${GIMLI_GITVERSION}")
set(LIBGIMLI_VERSION ${GIMLI_GITVERSION})
else()
set(LIBGIMLI_VERSION "untaged")
endif()
set(PACKAGE_NAME \"${PROJECT_NAME}\" )
set(PACKAGE_VERSION \"${LIBGIMLI_VERSION}\" )
set(PACKAGE_BUGREPORT \"[email protected]\")
################################################################################
# Check for libs and other packages we might use.
################################################################################
if(NOT THIRDPARTY_DIR)
if (NOT ADDRESSMODEL)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message(STATUS "Target is 64 bits")
set (ADDRESSMODEL "64")
else()
message(STATUS "Target is 32 bits")
set (ADDRESSMODEL "32")
endif()
endif()
set(TARGETNAME "-${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}-${ADDRESSMODEL}")
set(ENV{TARGETNAME} ${TARGETNAME})
set(THIRDPARTY_DIR ${PROJECT_SOURCE_DIR}/../thirdParty/)
get_filename_component(EXTERNAL_DIR "${THIRDPARTY_DIR}/dist${TARGETNAME}" ABSOLUTE)
get_filename_component(EXTERNAL_BUILD_DIR "${THIRDPARTY_DIR}/build${TARGETNAME}" ABSOLUTE)
message(STATUS "ThirdParty set to: ${THIRDPARTY_DIR}")
message(STATUS "External set to: ${EXTERNAL_DIR}")
endif()
if(NOT EXTERNAL_DIR)
set(EXTERNAL_DIR ${PROJECT_SOURCE_DIR}/external/)
message(STATUS "External set to: ${EXTERNAL_DIR}")
endif()
include(CheckIncludeFileCXX)
find_package(Threads REQUIRED)
if (PYVERSION)
find_package(PythonInterp ${PYVERSION} REQUIRED)
else()
find_package(PythonInterp)
endif()
# if (PYVERSION)
# set(Python_ADDITIONAL_VERSIONS ${PYVERSION})
# endif()
# find_package(PythonInterp) # find version belongs to the active python command
#
# if(WIN32)
# find_package(PythonLibs)
# endif(WIN32)
function(find_boost_from_distname_file)
set (BOOST_DIST_NAME_FILE "${EXTERNAL_DIR}/.boost-py${PYTHON_VERSION_MAJOR}.dist")
if (EXISTS ${BOOST_DIST_NAME_FILE})
message(STATUS "reading ${BOOST_DIST_NAME_FILE}")
FILE(READ "${EXTERNAL_DIR}/.boost-py${PYTHON_VERSION_MAJOR}.dist" BOOST_DIST_NAME)
STRING(REGEX REPLACE "\n" "" BOOST_DIST_NAME "${BOOST_DIST_NAME}")
get_filename_component(BOOST_ROOT "${EXTERNAL_DIR}/${BOOST_DIST_NAME}" ABSOLUTE)
else()
message(STATUS "there is no ${BOOST_DIST_NAME_FILE}")
endif()
if (EXISTS ${BOOST_ROOT})
message(STATUS "BOOST_ROOT from ${EXTERNAL_DIR}/.boost-py${PYTHON_VERSION_MAJOR}.dist: ${BOOST_ROOT}")
set(BOOST_ROOT ${BOOST_ROOT} CACHE FILEPATH "Boost root distribution")
set(Boost_INCLUDE_DIR ${BOOST_ROOT}/include)
get_filename_component(Boost_INCLUDE_DIR "${Boost_INCLUDE_DIR}" ABSOLUTE)
message(STATUS "Boost_INCLUDE_DIR, ${Boost_INCLUDE_DIR}")
else()
message(STATUS "BOOST_ROOT does not exist: ${BOOST_ROOT}")
endif()
endfunction(find_boost_from_distname_file)
if (NOT USE_BOOST_THREAD)
if (NOT WIN32)
set (USE_BOOST_THREAD FALSE)
else()
set (USE_BOOST_THREAD FALSE)
endif()
endif()
if (YES)
message(STATUS "Trying to guess boost installation:")
if (NOT Boost_INCLUDE_DIR)
message(STATUS "no BOOST_INCLUDE_DIR")
if (BOOST_ROOT)
message(STATUS "Found boost root: ${BOOST_ROOT}")
get_filename_component(BOOST_ROOT "${BOOST_ROOT}" ABSOLUTE)
set(Boost_INCLUDE_DIR ${BOOST_ROOT}/include)
message(STATUS "set BOOST_INCLUDE_DIR: ${BOOST_INCLUDE_DIR}")
else()
if (NOT WIN32)
find_package(Boost 1.46.0 COMPONENTS system thread)
endif()
# we should think about cmake superbuild with ExternalProject_Add as the replacement for find_or_build_package (next generation)
if (NOT Boost_INCLUDE_DIR)
find_boost_from_distname_file()
endif()
find_or_build_package_check(Boost boost Boost_INCLUDE_DIR False)
find_boost_from_distname_file()
#exit()
endif(BOOST_ROOT)
message(STATUS "BOOST_ROOT, ${BOOST_ROOT}")
endif(NOT Boost_INCLUDE_DIR)
message(STATUS "BOOST_ROOT, ${BOOST_ROOT}")
message(STATUS "Boost_INCLUDE_DIR, ${Boost_INCLUDE_DIR}")
if (USE_BOOST_THREAD)
find_package(Boost 1.46.0 COMPONENTS system thread REQUIRED)
link_directories(${BOOST_LIBRARYDIR})
endif()
mark_as_advanced(Boost_INCLUDE_DIR BOOST_ROOT)
endif()
if (NOT USE_BOOST_THREAD)
set(Boost_THREAD_FOUND OFF)
set(BOOST_BIND_FOUND OFF)
set(USE_IPC OFF)
else()
set(Boost_THREAD_FOUND ON)
set(BOOST_BIND_FOUND ON)
endif()
# Find packages that CHOLMOD depends on
set(CMAKE_LIBRARY_PATH ${EXTERNAL_DIR}/lib $ENV{EXTERNAL_DIR}/lib ${CMAKE_LIBRARY_PATH})
if (J) # dummy to avoid error msg
endif()
set (UMFPACK_FOUND FALSE)
find_or_build_package(Triangle triangle LOCAL)
find_or_build_package(BLAS lapack)
find_or_build_package(LAPACK lapack)
find_or_build_package(CHOLMOD suitesparse)
find_package(UMFPACK)
if (";${BLAS_LIBRARIES};" MATCHES "openblas")
message(STATUS "openblas is used: ${BLAS_LIBRARIES}")
FIND_PATH(OpenBLAS_INCLUDE_DIR
NAMES cblas.h
PATHS /usr/include/openblas
NO_DEFAULT_PATH
)
if (NOT OpenBLAS_INCLUDE_DIR)
FIND_PATH(OpenBLAS_INCLUDE_DIR
NAMES cblas.h
)
endif()
message(STATUS "openblas cblas.h: ${OpenBLAS_INCLUDE_DIR}")
if (OpenBLAS_INCLUDE_DIR)
set(OPENBLAS_CBLAS_FOUND TRUE)
else()
set(OPENBLAS_CBLAS_FOUND FALSE)
endif()
set(OPENBLAS_FOUND TRUE)
else()
set(OPENBLAS_FOUND FALSE)
endif()
if (NOT AVOID_CPPUNIT)
find_package(CppUnit)
if (CPPUNIT_FOUND)
option (LIBGIMLI_BUILD_TESTS "Build unittests" ON)
endif (CPPUNIT_FOUND)
endif()
if (NOT AVOID_READPROC)
if(WIN32)
set(READPROC_FOUND FALSE)
else(WIN32)
find_package(readproc)
endif(WIN32)
else()
set(READPROC_FOUND FALSE)
endif()
################################################################################
# Check for python stuff
################################################################################
if (WIN32)
#if (NOT PYTHON_LIBRARY)
# get_filename_component(PYTHONPATH "${PYTHON_EXECUTABLE}" PATH )
# if (${ADDRESSMODEL} EQUAL 32 OR ${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR} GREATER 34) # works at least for WinPython3.5
# set (PYTHON_LIBRARY ${PYTHONPATH}/libs/libpython${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.a)
# else()
# set (PYTHON_LIBRARY ${PYTHONPATH}/libs/libpython${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.dll.a)
# endif()
# endif()
else()
set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
set(PythonLibs_FIND_VERSION ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
endif()
find_package(PythonLibs)
find_python_module(numpy)
################################################################################
# Manuall check for boost python
################################################################################
function(find_boost_python_manual bp_version)
message(STATUS " ... searching for libboost_python${bp_version}")
find_package(Boost 1.46 COMPONENTS "python${bp_version}")
if (${Boost_PYTHON${bp_version}_FOUND})
set(Boost_PYTHON_FOUND
${Boost_PYTHON${bp_version}_FOUND} PARENT_SCOPE)
set(Boost_PYTHON_LIBRARY
${Boost_PYTHON${bp_version}_LIBRARY_RELEASE} PARENT_SCOPE)
message(STATUS " ... found: ${Boost_PYTHON_LIBRARY}")
else()
message(STATUS " ... not found.")
endif()
endfunction()
if (Boost_PYTHON_LIBRARY)
#set (Boost_PYTHON_LIBRARY ${Boost_PYTHON_LIBRARY})
else()
message(STATUS "boost-python not found by cmake find ... trying to determine boost-python now again ...")
if (WIN32)
set(bp_version "${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}-mt")
find_package(Boost 1.46.0 COMPONENTS "python${bp_version}")
if (NOT Boost_PYTHON_FOUND)
set(BOOST_FOUND TRUE)
set(Boost_PYTHON_FOUND TRUE})
set(Boost_PYTHON_LIBRARY
${BOOST_ROOT}/lib/libboost_python${bp_version}.dll)
endif()
endif()
# the name for py3 boost-python library lacks probably py3 suffix, which is different for different OS
set (Boost_PYTHON_FOUND False)
set (Boost_PYTHON_LIBRARY "None")
message(STATUS "***** ${Boost_PYTHON_FOUND}, ${Boost_PYTHON_LIBRARY}")
if (NOT Boost_PYTHON_FOUND)
#/usr/lib/x86_64-linux-gnu/libboost_python-py34.so (debian)
set(bp_version "-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
find_boost_python_manual(${bp_version})
endif()
if (NOT Boost_PYTHON_FOUND)
# /usr/lib/libboost_python3.so.1.64.0 (arch style)
set(bp_version "${PYTHON_VERSION_MAJOR}")
find_boost_python_manual(${bp_version})
endif()
if (NOT Boost_PYTHON_FOUND)
# /usr/lib/libboost_python-3.4.so (gentoo <boost-1.70)
set(bp_version "-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
find_boost_python_manual(${bp_version})
endif()
if (NOT Boost_PYTHON_FOUND)
# /usr/lib/libboost_python37.so # gentoo >=boost-1.70)
set(bp_version "${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
find_boost_python_manual(${bp_version})
endif()
if (Boost_PYTHON_FOUND)
message(STATUS "found: ${Boost_PYTHON_FOUND}: ${Boost_PYTHON_LIBRARY}")
else()
message(STATUS "Sorry but no boost-python found. Please search for "
"any libboost_python* on your system and "
"provide it to the authors so we can try to fix "
"this here.")
endif()
endif()
if (NOT CASTER)
set(CASTER "castxml")
if (CMAKE_COMPILER_IS_GNUCC)
string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${CMAKE_CXX_COMPILER_VERSION})
list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)
list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR)
if (${GCC_MAJOR} EQUAL 5)
message(STATUS "Found gcc version above 5: choosing castxml")
set(CASTER "castxml")
endif()
endif()
endif()
if (CASTER STREQUAL "gccxml")
find_or_build_package(gccxml gccxml LOCAL)
set(CASTER_EXECUTABLE ${GCCXML_EXECUTABLE})
else()
if (NOT CASTER_EXECUTABLE)
find_program(CASTXML castxml)
if (NOT CASTXML OR CASTXML_LOCAL OR CASTXML_LOCALSRC)
find_program(CLANG_EXECUTABLE
NAMES clang++-3.9 clang++-3.8 clang++-3.7 clang++-3.6 clang
)
if(CLANG_EXECUTABLE)
message(STATUS "clang++ found : ${CLANG_EXECUTABLE}")
else()
message(FATAL_ERROR "Can't found program: clang")
endif()
find_or_build_package(castxml castxmlbin LOCAL)
set(CASTER_EXECUTABLE ${CASTXML_EXECUTABLE})
if (NOT CASTXML_EXECUTABLE OR CASTXML_LOCALSRC)
find_or_build_package(castxml castxml LOCAL)
set(CASTER_EXECUTABLE ${CASTXML_EXECUTABLE})
endif()
else()
set(CASTER_EXECUTABLE ${CASTXML})
endif()
endif()
endif()
find_or_build_package(pygccxml pygccxml LOCAL)
find_or_build_package(pyplusplus pygccxml LOCAL)
if (CASTER_EXECUTABLE)
set (CASTER_FOUND TRUE)
endif()
if (PYTHON_EXECUTABLE)
set (PYTHON_FOUND TRUE)
endif()
if (Boost_PYTHON_LIBRARY)
set (Boost_PYTHON_FOUND TRUE)
endif()
find_package(Doxygen)
find_package(Sphinx 1.5)
if (SPHINX_FOUND)
add_subdirectory(doc EXCLUDE_FROM_ALL)
file(GLOB_RECURSE DOCFILES RELATIVE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}" "*.rst")
file(GLOB_RECURSE PNGFILES RELATIVE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}" "*.png")
list(APPEND DOCFILES ${PNGFILES})
file(GLOB_RECURSE BIBFILES RELATIVE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}" "*.bib")
list(APPEND DOCFILES ${BIBFILES})
file(GLOB_RECURSE PYFILES RELATIVE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}" "doc/paper/*.py")
list(APPEND DOCFILES ${PYFILES})
set(RSTFILES ${DOCFILES} CACHE INTERNAL "RST source file that we need to copy")
#foreach(file ${DOCFILES})
#message(${file})
#endforeach()
endif()
message(STATUS "**********************************************************************")
message(STATUS "************************* Dependencies found *************************")
message(STATUS "**********************************************************************")
if (CONDA_BUILD)
message(STATUS "CONDA_BUILD: ${CONDA_BUILD}")
endif()
message(STATUS "THREADS :${Threads_FOUND} ${CMAKE_THREAD_LIBS_INIT}")
message(STATUS "USE_BOOST_THREAD :${USE_BOOST_THREAD} ${Boost_THREAD_LIBRARIES}")
message(STATUS "CHOLMOD_LIBRARIES :${CHOLMOD_LIBRARIES}")
message(STATUS "UMFPACK_LIBRARIES :${UMFPACK_LIBRARIES}")
message(STATUS "TRIANGLE_FOUND :${TRIANGLE_FOUND} Triangle_LIBRARIES: ${Triangle_LIBRARIES}")
message(STATUS "PYTHON_FOUND :${PYTHON_FOUND} PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}" )
message(STATUS "PYTHONLIBS_FOUND :${PYTHONLIBS_FOUND} PYTHON_LIBRARY: ${PYTHON_LIBRARY}" )
message(STATUS "PYTHON_INCLUDE_DIR : ${PYTHON_INCLUDE_DIR} ${PYTHON_INCLUDE}" )
message(STATUS "Boost_INCLUDE_DIR : ${Boost_INCLUDE_DIR}")
message(STATUS "Boost_PYTHON_FOUND :${Boost_PYTHON_FOUND} Boost_PYTHON_LIBRARY: ${Boost_PYTHON_LIBRARY}" )
message(STATUS "numpy_FOUND :${numpy_FOUND} PY_NUMPY: ${PY_NUMPY}" )
message(STATUS "CASTER_FOUND :${CASTER_FOUND} Caster: ${CASTER_EXECUTABLE}")
message(STATUS "PYGCCXML_FOUND :${PYGCCXML_FOUND} PYGCCXML: ${PYGCCXML_PATH}" )
message(STATUS "PYPLUSPLUS_FOUND :${PYPLUSPLUS_FOUND} PYPLUSPLUS_PATH: ${PYPLUSPLUS_PATH}" )
message(STATUS "")
message(STATUS "**********************************************************************")
message(STATUS "*************** Optional Dependencies found **************************")
message(STATUS "**********************************************************************")
message(STATUS "CPPUNIT :${CPPUNIT_FOUND} ${CPPUNIT_LIBRARIES}")
message(STATUS "Doxygen :${DOXYGEN_FOUND} ")
message(STATUS "Sphinx :${SPHINX_FOUND} ")
message(STATUS "**********************************************************************")
if (PYTHON_EXECUTABLE
AND TRIANGLE_FOUND
AND PYTHON_FOUND
AND PYTHONLIBS_FOUND
AND Boost_PYTHON_FOUND
AND numpy_FOUND
AND CASTER_FOUND
AND PYGCCXML_FOUND
AND PYPLUSPLUS_FOUND
)
set (PYGIMLI 1)
message(STATUS "")
message (STATUS "pygimli can be build. run: make pygimli")
message(STATUS "**********************************************************************")
message(STATUS "")
message(STATUS "")
else()
message (FATAL_ERROR "pygimli cannot be build due to some missing packages.
Check above for python, castxml, pygccxml, pyplusplus, boost_python, numpy")
endif ()
configure_file("${PROJECT_SOURCE_DIR}/config.cmake.h.in" "${PROJECT_BINARY_DIR}/config.cmake.h" )
add_definitions(-DHAVE_CONFIG_CMAKE_H)
add_custom_target(removedoc
COMMAND
${CMAKE_MAKE_PROGRAM} clean -f ${CMAKE_CURRENT_BINARY_DIR}/doc/
)
add_custom_target(checkall
DEPENDS
doc
#linkcheck
)
#add_dependencies(doc removedoc)
# Add if pytest found?
add_dependencies(checkall pgtest)
if (CPPUNIT_FOUND)
add_dependencies(checkall gtest)
endif (CPPUNIT_FOUND)
################################################################################
# Define the configurable options
################################################################################
include(CMakeDependentOption)
cmake_dependent_option( GIMLI_BUILD_SHARED_LIBS_WITH_STATIC_DEPENDENCIES
"For WIN32 and APPLE where the dependency pack is used, prefer the static dependency libs over the shared/dynamic ones. NOTE: On Windows you also need to be mindful of which C/C++ runtime setting has been used to compile the various
components - they must all match or you will get crashes, heap corruption and/or
other issues." FALSE "WIN32 OR APPLE" FALSE)
# cmake_dependent_option(GIMLI_BUILD_PYTHON_MODULES "Specifies whether to build the Python extension module(s)" "PYTHONINTERP_FOUND;PYTHONLIBS_FOUND;Boost_PYTHON_FOUND")
################################################################################
#
################################################################################
set (LIBRARY_INSTALL_DIR lib)
set (INCLUDE_INSTALL_DIR include/gimli/)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
if (WIN32)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
else()
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
endif()
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# set up install sub-directories
if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND EXISTS "${CMAKE_INSTALL_PREFIX}/lib64")
set( GIMLI_LIB_INSTALL_DIR lib64 )
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4 AND EXISTS "${CMAKE_INSTALL_PREFIX}/lib32")
set( GIMLI_LIB_INSTALL_DIR lib32 )
else()
set( GIMLI_LIB_INSTALL_DIR lib )
endif()
set( GIMLI_VER_INSTALL_SUBDIR "/${CMAKE_PROJECT_NAME}-${GIMLI_VERSION_MAJOR}" )
set( GIMLI_DATA_INSTALL_DIR "share${GIMLI_VER_INSTALL_SUBDIR}" )
set( GIMLI_DOC_INSTALL_DIR "share/doc${GIMLI_VER_INSTALL_SUBDIR}" )
set( GIMLI_PKGCONFIG_INSTALL_DIR "${GIMLI_LIB_INSTALL_DIR}/pkgconfig" )
set( GIMLI_MODULE_INSTALL_DIR "${GIMLI_LIB_INSTALL_DIR}/${CMAKE_PROJECT_NAME}-${GIMLI_VERSION_MAJOR}.${GIMLI_VERSION_MINOR}" )
set( GIMLI_SAMPLE_INSTALL_DIR "${GIMLI_MODULE_INSTALL_DIR}" ) # TODO: put into /samples subdir!
set( GIMLI_INCLUDE_INSTALL_DIR "include${GIMLI_VER_INSTALL_SUBDIR}" )
#set( GIMLI_PYTHON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/python/pygimli)
################################################################################
# Add main header locations (for everything we build)
################################################################################
include_directories( ${libgimli_SOURCE_DIR}/src)
include_directories("${PROJECT_BINARY_DIR}")
################################################################################
# descend into subdirs
################################################################################
if (LIBGIMLI_BUILD_TESTS)
enable_testing()
endif(LIBGIMLI_BUILD_TESTS)
add_subdirectory(src)
add_subdirectory(tests EXCLUDE_FROM_ALL)
add_subdirectory(apps EXCLUDE_FROM_ALL)
if (PYGIMLI)
# set( PYGIMLI_SOURCE_DIR ${CMAKE_SOURCE_DIR}/python/pygimli )
# set( PYGIMLI_BUILD_DIR ${CMAKE_BINARY_DIR}/package/pygimli )
#
# file(GLOB_RECURSE PYFILES RELATIVE "${PYGIMLI_SOURCE_DIR}" "python/pygimli/*.py")
# set(PYGIMLI_FILES ${PYFILES} CACHE INTERNAL "pygimli source files that we need to copy")
add_subdirectory(python EXCLUDE_FROM_ALL)
endif (PYGIMLI)
#CR what is this good for?
# export(TARGETS gimli
# FILE "${PROJECT_BINARY_DIR}/Gimli.cmake")