-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
105 lines (92 loc) · 3.07 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
cmake_minimum_required(VERSION 3.9)
project(Molassembler
VERSION 3.0.0
DESCRIPTION "Graph-based molecular toolkit for possibly inorganic molecules"
LANGUAGES C CXX
)
enable_testing()
# Build molassembler shared by default
option(BUILD_SHARED_LIBS ON)
# Project-specific options
option(MOLASSEMBLER_ANALYSIS "Compile analysis binaries" OFF)
option(MOLASSEMBLER_VALIDATION "Compile validation tests" OFF)
option(MOLASSEMBLER_IPO "Try to enable interprocedural optimization" OFF)
option(MOLASSEMBLER_NO_GNU_UNIQUE "Set --no-gnu-unique GCC flag" OFF)
option(MOLASSEMBLER_SANITIZE "Add address and UB sanitizers" OFF)
# SCINE options
option(SCINE_PARALLELIZE "Enables OpenMP parallelization" ON)
option(SCINE_BUILD_TESTS "Build test executables" ON)
option(SCINE_BUILD_DOCS "Build the documentation" ON)
option(SCINE_BUILD_PYTHON_BINDINGS "Build python bindings" OFF)
# Set a default build type
set(default_build_type "Release")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(default_build_type "Debug")
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to default '${default_build_type}'")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of the build."
FORCE
)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo"
)
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake)
include(ColorMessages)
# Handle sanitization
if(MOLASSEMBLER_SANITIZE)
cmessage(STATUS "MOLASSEMBLER_SANITIZE: Adding address and UB sanitizers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address,undefined")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined")
cmessage(WARNING
"Address sanitiziation can cause ABI incompatibility issues "
"if dependencies have not been compiled the same way."
)
endif()
# Handle coverage flag
if(COVERAGE AND CMAKE_BUILD_TYPE STREQUAL "Debug")
cmessage(STATUS "COVERAGE: Adding coverage flags")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -coverage ${CMAKE_CXX_FLAGS_DEBUG}")
endif()
# Fetch dependencies
include(ImportUtilsOS)
import_utils_os()
include(CompilerSpecificSetup)
include(AddEigen)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost
COMPONENTS regex unit_test_framework program_options filesystem system
QUIET
)
include(ImportNauty)
import_nauty()
include(ImportOutcome)
import_outcome()
include(ImportJSON)
import_json()
include(ImportRingDecomposerLib)
import_rdl()
add_subdirectory(src)
if(SCINE_BUILD_DOCS)
include(DoxygenDocumentation)
include(DoxygenSettings)
set_doxygen_vars()
scine_component_documentation(UtilsOSDocumentation)
unset_doxygen_vars()
endif()
if(SCINE_BUILD_TESTS)
add_subdirectory(test)
endif()
if(MOLASSEMBLER_ANALYSIS)
add_subdirectory(analysis)
endif()
if(MOLASSEMBLER_VALIDATION)
add_subdirectory(validation)
endif()
if(SCINE_BUILD_PYTHON_BINDINGS)
add_subdirectory(python)
endif()