-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathCMakeLists.txt
82 lines (72 loc) · 4.23 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
cmake_minimum_required(VERSION 3.8)
project(QuantLib)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
################################################################
# User configuration section: #
# modify the following definitions to suit your preferences. #
################################################################
option(QL_ERROR_FUNCTIONS "if error messages should include current function information" OFF)
option(QL_ERROR_LINES "if error messages should include file and line information" OFF)
option(QL_ENABLE_TRACING "if tracing messages should be allowed" OFF)
option(QL_NEGATIVE_RATES "if negative rates should be allowed" ON)
option(QL_EXTRA_SAFETY_CHECKS "if extra safety checks should be performed (degrade performance)" OFF)
option(QL_USE_INDEXED_COUPON "if indexed coupons instead of par coupons in floating legs should be used" OFF)
option(QL_ENABLE_SESSIONS "if singletons should return different instances for different sessions" OFF)
option(QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN "if thread-safe observer pattern should be enabled (for use in environment with an async garbage collector" OFF)
option(QL_HIGH_RESOLUTION_DATE "if date resolution down to nanoseconds should be enabled" OFF)
option(QL_ENABLE_SINGLETON_THREAD_SAFE_INIT "if singleton initialization shoudl be made thread-safe" OFF)
option(QL_USE_MKL "if Intel® MKL should be used for linear algebra routines" OFF)
option(MULTIPRECISION_NON_CENTRAL_CHI_SQUARED_QUADRATURE "if multiprecision library should be used to improve the precision of the nonr-central chi-squared Gaussian quadrature" OFF)
# compiler flags for GCC
if (CMAKE_CXX_COMPILER_ID STREQUAL GNU)
set(release_flags -O3)
set(debug_flags -g -O0 -fvar-tracking-assignments)
add_compile_options(-Wall -Wextra -pedantic -Wno-empty-body -Wno-unused-parameter -Werror -march=native -pipe -fstack-protector-strong)
# compiler flags for Clang
elseif (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(release_flags -O3)
set(debug_flags -g -O0)
add_compile_options(-Weverything -Wno-c++98-compat -Wno-documentation-unknown-command -Wno-documentation -Wno-shorten-64-to-32 -Wno-padded -Wno-float-equal -Wno-undef -Wno-missing-braces -Wno-unused-parameter -Wno-exit-time-destructors -Wno-switch-enum -Wno-sign-conversion -Wno-global-constructors -Wno-weak-vtables -Wno-unused-member-function -Wno-double-promotion -Wno-covered-switch-default -Wno-conversion -Werror -march=native -pipe -fstack-protector-strong)
endif ()
################################################################
# End of user configuration section #
################################################################
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
add_compile_options(-stdlib=libc++)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
endif ()
add_compile_options("$<$<CONFIG:Release>:${release_flags}>")
add_compile_options("$<$<CONFIG:Debug>:${debug_flags}>")
if (CMAKE_BUILD_TYPE MATCHES Release)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -s")
endif ()
if (QL_USE_MKL)
file(GLOB_RECURSE MKLPATH /opt/intel/*/mkl.h)
if (MKLPATH)
string(REPLACE "/include/mkl.h" "" MKLROOT ${MKLPATH})
include_directories(${MKLROOT}/include)
if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
add_compile_options(-Wno-reserved-id-macro -Wno-c++98-compat-pedantic)
endif ()
else ()
message(FATAL_ERROR "MKL not found, build aborted!")
endif ()
endif ()
if (MULTIPRECISION_NON_CENTRAL_CHI_SQUARED_QUADRATURE)
if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
file(GLOB_RECURSE QUADMATHINCLUDE /usr/lib/gcc/*/quadmath.h)
if (QUADMATHINCLUDE)
string(REPLACE "/quadmath.h" "" QUADMATHINCLUDE ${QUADMATHINCLUDE})
add_compile_options(-idirafter ${QUADMATHINCLUDE})
else ()
message(FATAL_ERROR "libquadmath not found, build aborted!")
endif ()
endif ()
endif ()
add_subdirectory(ql)
add_subdirectory(test-suite)
add_subdirectory(Examples)