forked from Alneos/vega
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
549 lines (475 loc) · 20.9 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
# Vega - Copyright (C) 2012-2013 Alneos
#
# See the LICENSE.txt file for license information. Please report all
# bugs and problems to <[email protected]>.
# Initial version from cmake config in : http://geuz.org/gmsh
cmake_minimum_required(VERSION 2.8.2 FATAL_ERROR)
# Compatibily option with Cygwin
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
########################################################################
# Provide add_compile_options() when not available
########################################################################
if(CMAKE_VERSION VERSION_LESS "2.8.12")
function(add_compile_options)
add_definitions(${ARGN})
endfunction(add_compile_options)
endif()
# Definition of the VEGA version
set(VEGA_MAJOR_VERSION 3)
set(VEGA_MINOR_VERSION 1)
set(VEGA_PATCH_VERSION 0)
IF(NOT DEFINED VEGA_EXTRA_VERSION OR "${VEGA_EXTRA_VERSION}" STREQUAL "")
IF (NOT "$ENV{CI_COMMIT_SHA}" STREQUAL "")
message(STATUS "CI_COMMIT_SHA:" $ENV{CI_COMMIT_SHA})
string(SUBSTRING $ENV{CI_COMMIT_SHA} 0 7 VEGA_EXTRA_VERSION)
ELSE()
set(VEGA_EXTRA_VERSION "" CACHE STRING "Vega extra version string")
ENDIF()
ELSE()
message(STATUS "VEGA_EXTRA_VERSION: " ${VEGA_EXTRA_VERSION})
ENDIF()
# add this options before PROJECT keyword
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build/cmake_files)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_BUILD_TYPE DDebug CACHE STRING
"Choose the type of build, options are: None DDebug SDebug DRelease SRelease.")
#make outputs build commands and options
OPTION(CMAKE_VERBOSE_MAKEFILE "make outputs build commands" OFF)
project ( vegapp CXX C)
if(CMAKE_CROSSCOMPILING)
find_program(WINE_EXECUTABLE NAMES wine64 wine)
set(CMAKE_CROSSCOMPILING_EMULATOR ${WINE_EXECUTABLE})
endif(CMAKE_CROSSCOMPILING)
find_program(SYSTUS_EXEC NAMES systus systus.exe)
if(SYSTUS_EXEC)
set(RUN_SYSTUS ON CACHE BOOL "Run tests using Systus executable")
message(STATUS "Sytus exec: " ${SYSTUS_EXEC})
else(SYSTUS_EXEC)
set(RUN_SYSTUS OFF CACHE BOOL "Run tests using Systus executable")
endif(SYSTUS_EXEC)
mark_as_advanced(RUN_SYSTUS)
find_program(ASTER_EXEC NAMES as_run as_run.sh as_run.exe as_run.bat)
if(ASTER_EXEC)
set(RUN_ASTER ON CACHE BOOL "Run tests using Aster executable")
message(STATUS "Aster exec: " ${ASTER_EXEC})
else(ASTER_EXEC)
set(RUN_ASTER OFF CACHE BOOL "Run tests using Aster executable")
endif(ASTER_EXEC)
mark_as_advanced(RUN_ASTER)
find_program(NASTRAN_EXEC NAMES nastran)
if(NASTRAN_EXEC)
set(RUN_NASTRAN ON CACHE BOOL "Run tests using Nastran executable")
message(STATUS "Nastran exec: " ${NASTRAN_EXEC})
else(NASTRAN_EXEC)
set(RUN_NASTRAN OFF CACHE BOOL "Run tests using Nastran executable")
endif(NASTRAN_EXEC)
mark_as_advanced(RUN_NASTRAN)
# Debug and Release are reserved words for cmake see https://cmake.org/cmake/help/v3.0/variable/CMAKE_BUILD_TYPE.html
IF(CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]")
message(STATUS "Debug mode selected")
option(STATIC_LINKING "Static Linking" OFF)
option(ENABLE_DEBUG "Debug" ON)
option(ENABLE_CODECOVERAGE "Code Coverage" ON)
ENDIF(CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]")
IF(CMAKE_BUILD_TYPE MATCHES "^[Rr][Ee][Ll][Ee][Aa][Ss][Ee]")
message(STATUS "Dynamic Release mode selected")
option(STATIC_LINKING "Static Linking" OFF)
option(ENABLE_DEBUG "Debug" OFF)
option(ENABLE_CODECOVERAGE "Code Coverage" OFF)
ENDIF(CMAKE_BUILD_TYPE MATCHES "^[Rr][Ee][Ll][Ee][Aa][Ss][Ee]")
# Other legacy configurations (used by ESI)
IF(CMAKE_BUILD_TYPE MATCHES "[Dd][Dd][Ee][Bb][Uu][Gg]")
message(STATUS "Dynamic Debug mode selected")
option(STATIC_LINKING "Static Linking" OFF)
option(ENABLE_DEBUG "Debug" ON)
option(ENABLE_CODECOVERAGE "Code Coverage" ON)
add_definitions(-DVDEBUG)
ENDIF(CMAKE_BUILD_TYPE MATCHES "[Dd][Dd][Ee][Bb][Uu][Gg]")
IF(CMAKE_BUILD_TYPE MATCHES "[Ss][Dd][Ee][Bb][Uu][Gg]")
message(STATUS "Static Debug mode selected")
option(STATIC_LINKING "Static Linking" ON)
option(ENABLE_DEBUG "Debug" ON)
option(ENABLE_CODECOVERAGE "Code Coverage" ON)
add_definitions(-DVDEBUG)
ENDIF(CMAKE_BUILD_TYPE MATCHES "[Ss][Dd][Ee][Bb][Uu][Gg]")
IF(CMAKE_BUILD_TYPE MATCHES "[Dd][Rr][Ee][Ll][Ee][Aa][Ss][Ee]")
message(STATUS "Dynamic Release mode selected")
option(STATIC_LINKING "Static Linking" OFF)
option(ENABLE_DEBUG "Debug" OFF)
option(ENABLE_CODECOVERAGE "Code Coverage" OFF)
ENDIF(CMAKE_BUILD_TYPE MATCHES "[Dd][Rr][Ee][Ll][Ee][Aa][Ss][Ee]")
IF(CMAKE_BUILD_TYPE MATCHES "[Ss][Rr][Ee][Ll][Ee][Aa][Ss][Ee]")
message(STATUS "Static Release mode selected")
option(STATIC_LINKING "Static Linking" ON)
option(ENABLE_DEBUG "Debug" OFF)
option(ENABLE_CODECOVERAGE "Code Coverage" OFF)
ENDIF(CMAKE_BUILD_TYPE MATCHES "[Ss][Rr][Ee][Ll][Ee][Aa][Ss][Ee]")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmakemodules/")
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-Wshadow=local COMPILER_SUPPORTS_WSHADOWLOCAL)
if(COMPILER_SUPPORTS_WSHADOWLOCAL)
add_compile_options(-Wshadow=local)
endif()
CHECK_CXX_COMPILER_FLAG(-fext-numeric-literals COMPILER_SUPPORTS_FEXTNUMERICLITERALS)
if(COMPILER_SUPPORTS_FEXTNUMERICLITERALS)
add_compile_options(-fext-numeric-literals)
endif()
CHECK_CXX_COMPILER_FLAG(-Wduplicated-cond COMPILER_SUPPORTS_DUPLICATED_COND)
if(COMPILER_SUPPORTS_DUPLICATED_COND)
add_compile_options(-Wduplicated-cond)
endif()
CHECK_CXX_COMPILER_FLAG(-Wfloat-equal COMPILER_SUPPORTS_FLOAT_EQUAL)
if(COMPILER_SUPPORTS_FLOAT_EQUAL)
add_compile_options(-Wfloat-equal)
endif()
CHECK_CXX_COMPILER_FLAG(-Wsuggest-override COMPILER_SUPPORTS_SUGGEST_OVERRIDE)
if(COMPILER_SUPPORTS_SUGGEST_OVERRIDE)
add_compile_options(-Wsuggest-override)
endif()
CHECK_CXX_COMPILER_FLAG(-Wsuggest-final-methods COMPILER_SUPPORTS_SUGGEST_FINAL_METHODS)
if(COMPILER_SUPPORTS_SUGGEST_FINAL_METHODS)
add_compile_options(-Wsuggest-final-methods)
endif()
CHECK_CXX_COMPILER_FLAG(-Wsuggest-final-types COMPILER_SUPPORTS_SUGGEST_FINAL_TYPES)
if(COMPILER_SUPPORTS_SUGGEST_FINAL_TYPES)
add_compile_options(-Wsuggest-final-types)
endif()
CHECK_CXX_COMPILER_FLAG(-Wnon-virtual-dtor COMPILER_SUPPORTS_NON_VIRTUAL_DTOR)
if(COMPILER_SUPPORTS_NON_VIRTUAL_DTOR)
add_compile_options(-Wnon-virtual-dtor)
endif()
CHECK_CXX_COMPILER_FLAG(-Woverloaded-virtual COMPILER_SUPPORTS_OVERLOADED_VIRTUAL)
if(COMPILER_SUPPORTS_OVERLOADED_VIRTUAL)
add_compile_options(-Woverloaded-virtual)
endif()
#CHECK_CXX_COMPILER_FLAG(-fsanitize=null COMPILER_SUPPORTS_SANITIZE_NULL)
#if(COMPILER_SUPPORTS_SANITIZE_NULL)
# add_compile_options(-fsanitize=null)
#endif()
# boost variant constructor uses this see ValueOrReference
#CHECK_CXX_COMPILER_FLAG(-Wzero-as-null-pointer-constant COMPILER_SUPPORTS_ZERO_AS_NULL_POINTER_CONSTANT)
#if(COMPILER_SUPPORTS_ZERO_AS_NULL_POINTER_CONSTANT)
# add_compile_options(-Wzero-as-null-pointer-constant)
#endif()
# boost::qi seems to prefer to initialize things inside constructor, see CSVResultReader
#CHECK_CXX_COMPILER_FLAG(-Weffc++ COMPILER_SUPPORTS_EFF_CPP)
#if(COMPILER_SUPPORTS_EFF_CPP)
# add_compile_options(-Weffc++)
#endif()
if(MSVC)
# Patch for MSVC10 generator, 64 bit
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa /MP")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /INCREMENTAL:NO")
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -DBOOST_ALL_NO_LIB)
if(STATIC_LINKING)
#for now under windows don't use static runtime
#add_compile_options(/MT)
#set(CMAKE_EXE_LINKER_FLAGS "-pthread -static-libgcc -static-libstdc++ -static" CACHE INTERNAL "Linker flags")
else(STATIC_LINKING)
ADD_DEFINITIONS(-DBOOST_ALL_DYN_LINK)
#set(CMAKE_EXE_LINKER_FLAGS "-pthread -shared-libgcc -rdynamic -pipe" CACHE INTERNAL "Linker flags")
endif(STATIC_LINKING)
else(MSVC)
if(EXISTS "/etc/issue")
file(READ "/etc/issue" ETC_ISSUE)
string(REGEX MATCH "Debian|Ubuntu|Alpine" LINUX_DIST ${ETC_ISSUE})
endif()
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all")
#SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
#set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} -Wl,--strip-all")
add_compile_options(-std=c++11 -Werror -Wall -Wextra -Winit-self -Wconversion -pedantic -pedantic-errors)
IF(CMAKE_C_COMPILER_ID MATCHES "Intel")
add_compile_options(-diag-disable 1170 -fmessage-length=0) # -Wshadow
ELSEIF(CMAKE_C_COMPILER_ID MATCHES "GNU")
add_compile_options(-Woverlength-strings -fmessage-length=0 -Wmain -Wmissing-declarations -Wundef -Wredundant-decls -Wcast-align -Wswitch-default -Wlogical-op -Wuseless-cast -Wold-style-cast -Wdouble-promotion -Wunused-variable)
# try to reduce boost memory usage for Travis but causes out of time, it is better to use make -j1
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --param ggc-min-expand=1 --param ggc-min-heapsize=100000")
if(NOT CMAKE_CROSSCOMPILING)
add_compile_options(-Wsuggest-attribute=const) # LD strange results, probably because MXE is using 5.4.0
endif()
if(ENABLE_CODECOVERAGE)
find_program( GCOV_PATH gcov )
else(ENABLE_CODECOVERAGE)
if(ENABLE_DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
endif(ENABLE_DEBUG)
endif(ENABLE_CODECOVERAGE)
if(ENABLE_CODECOVERAGE AND GCOV_PATH)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 --coverage")
list(APPEND EXTERNAL_LIBRARIES gcov)
set(CTEST_COVERAGE_COMMAND "gcov")
endif(ENABLE_CODECOVERAGE AND GCOV_PATH)
ENDIF()
if(STATIC_LINKING)
if(NOT CMAKE_CROSSCOMPILING)
add_compile_options(-fPIE)
endif(NOT CMAKE_CROSSCOMPILING)
if(NOT LINUX_DIST STREQUAL "Ubuntu")
set(CMAKE_EXE_LINKER_FLAGS_EXTRA "-static") # cannot statically link on ubuntu because of glibc, so I do it only on Alpine
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread -static-libgcc -static-libstdc++ ${CMAKE_EXE_LINKER_FLAGS_EXTRA}" CACHE INTERNAL "Linker flags")
else(STATIC_LINKING)
if(NOT CMAKE_CROSSCOMPILING)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread -shared-libgcc -pipe")
endif(NOT CMAKE_CROSSCOMPILING)
endif(STATIC_LINKING)
IF(CYGWIN)
# Specific options for Cygwin
add_compile_options(-D_XOPEN_SOURCE=500)
ELSE(CYGWIN)
# Specific options for Linux compilations
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
if(NOT STATIC_LINKING)
if(NOT CMAKE_CROSSCOMPILING)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic") # LD: I think is used only by glib backtrace ?
endif(NOT CMAKE_CROSSCOMPILING)
endif(NOT STATIC_LINKING)
ENDIF(CYGWIN)
# Optional use of ccache
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)
endif(MSVC)
#set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG>)
# this variable controls the default value of the "ENABLE_XXX" options which are
# normally set to ON (useful if you want to configure a minimal version of Vega:
# e.g. "cmake -DDEFAULT=0 -DENABLE_NASTRAN=1 -DENABLE_SYSTUS=1")
set(DEFAULT ON CACHE INTERNAL "Default value for enabled-by-default options")
option(ENABLE_ASTER "Enable Aster" ${DEFAULT})
IF(DEFINED ENABLE_ASTER)
option(ENABLE_ASTER "Enable Aster" ${ENABLE_ASTER})
ENDIF(DEFINED ENABLE_ASTER)
option(ENABLE_NASTRAN "Enable Nastran" ${DEFAULT})
option(ENABLE_SYSTUS "Enable Systus" ${DEFAULT})
option(ENABLE_WRAP_PYTHON "Build Python wrappers" OFF)
set(VEGA_VERSION "${VEGA_MAJOR_VERSION}.${VEGA_MINOR_VERSION}")
set(VEGA_VERSION "${VEGA_VERSION}.${VEGA_PATCH_VERSION} ${VEGA_EXTRA_VERSION}")
set(VEGA_SHORT_LICENSE "GPL")
execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND hostname OUTPUT_VARIABLE HOSTNAME
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND whoami OUTPUT_VARIABLE PACKAGER
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT DATE)
set(DATE "unknown")
endif(NOT DATE)
set(VEGA_DATE "${DATE}")
if(NOT HOSTNAME)
set(HOSTNAME "unknown")
endif(NOT HOSTNAME)
set(VEGA_HOST "${HOSTNAME}")
if(NOT PACKAGER)
set(PACKAGER "unknown")
endif(NOT PACKAGER)
set(VEGA_PACKAGER "${PACKAGER}")
if(APPLE)
set(VEGA_OS "MacOSX")
else(APPLE)
set(VEGA_OS "${CMAKE_SYSTEM_NAME}")
endif(APPLE)
macro(set_config_option VARNAME STRING)
set(${VARNAME} TRUE)
list(APPEND CONFIG_OPTIONS ${STRING})
message(STATUS "Found " ${STRING})
endmacro(set_config_option)
# Before the add_subdirectory command(s)
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
SET (CTEST_BINARY_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
#10 hours for tests
set (CTEST_TEST_TIMEOUT 36000 CACHE STRING
"Maximum time allowed before CTest will kill the test.")
set (CTEST_OUTPUT_ON_FAILURE ON)
include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckCXXCompilerFlag)
# check if the machine is 64 bits (this is more reliable than using
# CMAKE_SIZEOF_VOID_P, which does not seem to work e.g. on some Suse
# machines)
#check_type_size("void*" SIZEOF_VOID_P) not working at the moments
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set_config_option(HAVE_64BIT_SIZE_T "Have64BitSizeT")
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(Boost_USE_STATIC_LIBS ${STATIC_LINKING})
#set(Boost_USE_MULTITHREADED ON)
IF(NOT WIN32)
#under windows don't use static runtime because medC hasn't been compiled with
#(see commented compile option /MT)
set(Boost_USE_STATIC_RUNTIME ${STATIC_LINKING})
ENDIF(NOT WIN32)
find_package(Boost 1.54.0 COMPONENTS thread date_time program_options filesystem system regex unit_test_framework REQUIRED)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
link_directories ( ${Boost_LIBRARY_DIRS} )
list(APPEND EXTERNAL_LIBRARIES ${Boost_LIBRARIES})
# Bug fix for https://stackoverflow.com/questions/35007134/c-boost-undefined-reference-to-boostfilesystemdetailcopy-file
IF("105800" STRGREATER ${Boost_VERSION})
message(STATUS "BOOST VERSION UNDER 1.58, BOOST_NO_CXX11_SCOPED_ENUMS is defined.")
add_definitions(-DBOOST_NO_CXX11_SCOPED_ENUMS)
ENDIF("105800" STRGREATER ${Boost_VERSION})
# On Cygwin, we need to explicitely look some libraries on /lib
IF(CYGWIN)
link_directories("${CYGWIN_MOUNT}/lib")
ENDIF(CYGWIN)
IF (ENABLE_CODECOVERAGE)
if (LINUX_DIST STREQUAL "Alpine")
set(Backtrace_FOUND OFF)
else()
find_package(Backtrace)
endif()
IF(Backtrace_FOUND)
list(APPEND EXTERNAL_LIBRARIES ${Backtrace_LIBRARIES})
include_directories(SYSTEM ${Backtrace_INCLUDE_DIRS})
ELSE()
set(LIBUNWIND_USE_STATIC_LIBS ${STATIC_LINKING})
find_package(Libunwind)
IF(LIBUNWIND_FOUND)
include_directories(SYSTEM ${LIBUNWIND_INCLUDE_DIR})
list(APPEND EXTERNAL_LIBRARIES ${LIBUNWIND_LIBRARIES})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-allow-multiple-definition" CACHE INTERNAL "Linker flags")
ENDIF()
ENDIF()
ENDIF()
find_package(Valgrind)
#necessary to find build_properties.h
include_directories(${CMAKE_BINARY_DIR})
if(ENABLE_ASTER)
set_config_option(HAVE_ASTER "Aster")
add_subdirectory(Aster)
endif(ENABLE_ASTER)
if(ENABLE_NASTRAN)
set_config_option(HAVE_NASTRAN "Nastran")
add_subdirectory(Nastran)
add_subdirectory(Optistruct)
endif(ENABLE_NASTRAN)
if(ENABLE_SYSTUS)
set_config_option(HAVE_SYSTUS "Systus")
add_subdirectory(Systus)
endif(ENABLE_SYSTUS)
add_subdirectory(Abstract)
add_subdirectory(ResultReaders)
add_subdirectory(Commandline)
INCLUDE(CTest)
IF(NIGHTLY_BUILD MATCHES "TRUE")
set_config_option(HAVE_LONG_TESTS "LongTests")
ENDIF(NIGHTLY_BUILD MATCHES "TRUE")
IF(BUILD_TESTING)
SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard")
MARK_AS_ADVANCED(BUILDNAME)
# Tentative fix for issue in Jenkins docker (picking dynamic library even when static is demanded and present
# See https://stackoverflow.com/questions/14077611/how-do-i-tell-cmake-to-link-in-a-static-library-in-the-source-directory
if(STATIC_LINKING)
ADD_LIBRARY(boost_unit_test_framework STATIC IMPORTED)
else(STATIC_LINKING)
ADD_LIBRARY(boost_unit_test_framework SHARED IMPORTED)
endif(STATIC_LINKING)
SET_TARGET_PROPERTIES(boost_unit_test_framework PROPERTIES IMPORTED_LOCATION ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
ENABLE_TESTING()
add_subdirectory(Test)
ENDIF()
list(SORT CONFIG_OPTIONS)
set(VEGA_CONFIG_OPTIONS "")
foreach(OPT ${CONFIG_OPTIONS})
set(VEGA_CONFIG_OPTIONS "${VEGA_CONFIG_OPTIONS} ${OPT}")
endforeach(OPT)
if(ENABLE_WRAP_PYTHON)
find_package(SWIG)
find_package(PythonLibs)
if(SWIG_FOUND AND PYTHONLIBS_FOUND)
message(STATUS "Found SWIG version " ${SWIG_VERSION})
string(SUBSTRING ${SWIG_VERSION} 0 1 SWIG_MAJOR_VERSION)
if(SWIG_MAJOR_VERSION EQUAL 1)
message("WARNING: Python bindings require SWIG >= 2: disabling Python")
else(SWIG_MAJOR_VERSION EQUAL 1)
add_subdirectory(wrappers/vegapy)
endif(SWIG_MAJOR_VERSION EQUAL 1)
endif(SWIG_FOUND AND PYTHONLIBS_FOUND)
endif(ENABLE_WRAP_PYTHON)
mark_as_advanced(VEGA_EXTRA_VERSION Boost_DIR)
##build Doxygen documentation
find_package(Doxygen)
if(DEFINED DOXYGEN_BUILD)
if(NOT DOXYGEN_BUILD)
message(STATUS "Doxygen has been disabled by the user.")
set(DOXYGEN_FOUND OFF)
endif(NOT DOXYGEN_BUILD)
endif(DEFINED DOXYGEN_BUILD)
if(DOXYGEN_FOUND)
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)
message("")
message(STATUS "Vega ${VEGA_VERSION} has been configured for ${VEGA_OS} with the " "following options:" ${VEGA_CONFIG_OPTIONS})
message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}")
message(STATUS "C compiler: " ${CMAKE_C_COMPILER})
message(STATUS "C++ compiler: " ${CMAKE_CXX_COMPILER})
message(STATUS "CMAKE_CROSSCOMPILING: ${CMAKE_CROSSCOMPILING}")
message(STATUS "CMAKE_CROSSCOMPILING_EMULATOR: ${CMAKE_CROSSCOMPILING_EMULATOR}")
message(STATUS "CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
message(STATUS "CMAKE_SYSTEM_INFO_FILE: ${CMAKE_SYSTEM_INFO_FILE}")
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "CMAKE_SYSTEM: ${CMAKE_SYSTEM}")
message(STATUS "LINUX_DIST: ${LINUX_DIST}")
get_property(INC_DIR DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
message(STATUS "Include directories: ${INC_DIR}" )
message(STATUS "External libraries: ${EXTERNAL_LIBRARIES}" )
message(STATUS "C compiler flags: " ${CMAKE_C_FLAGS})
message(STATUS "C++ compiler flags: " ${CMAKE_CXX_FLAGS})
message(STATUS "C++ linker flags: " ${CMAKE_EXE_LINKER_FLAGS})
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
message(STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX})
if(DOXYGEN_FOUND)
message(STATUS "Doxygen: " ${DOXYGEN_EXECUTABLE})
message(STATUS "Doxyfile: " ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
else(DOXYGEN_FOUND)
message(STATUS "Doxygen: not found or disabled.")
endif(DOXYGEN_FOUND)
if(VALGRIND_FOUND)
message(STATUS "Valgrind: " ${Valgrind_EXECUTABLE})
message(STATUS "Valgrind include dir: " ${Valgrind_INCLUDE_DIR})
else(VALGRIND_FOUND)
message(STATUS "Valgrind: not found or disabled.")
endif(VALGRIND_FOUND)
message(STATUS "Boost unit test library: " ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
if(${STATIC_LINKING})
message(STATUS "Static linking.")
else(${STATIC_LINKING})
message(STATUS "Dynamic linking.")
endif(${STATIC_LINKING})
#message("")
#message("Run 'ccmake ${CMAKE_CURRENT_SOURCE_DIR}' to fine-tune the configuration.")
message(STATUS "Run Sytus: " ${RUN_SYSTUS})
message(STATUS "Run Aster: " ${RUN_ASTER})
message(STATUS "Run Nastran: " ${RUN_NASTRAN})
#
# FILES TO INSTALL
SET(VEGA_EXTENSION)
IF(CYGWIN)
SET(VEGA_EXTENSION ".exe")
ENDIF(CYGWIN)
# WARNING: WIN32 IS DEPRECATED AND SHOULD NOT BE USED
IF(WIN32)
SET(VEGA_EXTENSION ".exe")
ENDIF(WIN32)
# PROGRAM
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/bin/vegapp${VEGA_EXTENSION} DESTINATION ${CMAKE_INSTALL_PREFIX})
# LICENCE FILES
INSTALL(FILES LICENSE COPYRIGHT DESTINATION ${CMAKE_INSTALL_PREFIX})
# CUSTOM FILE IF NEEDED.
IF(CMAKE_CUSTOM_INSTALL)
INCLUDE(${CMAKE_CUSTOM_INSTALL})
ENDIF(CMAKE_CUSTOM_INSTALL)
INSTALL(CODE "MESSAGE(\"VEGA installed in \" ${CMAKE_INSTALL_PREFIX})")