-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
119 lines (97 loc) · 3.01 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
cmake_minimum_required(VERSION 3.3.0)
project(Atlas VERSION 2.1.3)
include(GNUInstallDirs)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(BUILD_PYTHON "Build python module" ON)
option(BUILD_TESTS "Build test suite" ON)
option(BUILD_BENCHMARK "Build benchmark suite" ON)
option(BUILD_EXAMPLES "Build examples" ON)
option(BUILD_WITH_AD "Build with AD" OFF)
file(
GLOB
SOURCES
"src/multithreading/*.cpp"
)
file(
GLOB
INCLUDES
"include/atlas/*.hpp"
"include/atlas/curves/*.hpp"
"include/atlas/data/*.hpp"
"include/atlas/instruments/*.hpp"
"include/atlas/instruments/fixedrate/*.hpp"
"include/atlas/instruments/floatingrate/*.hpp"
"include/atlas/cashflows/*.hpp"
"include/atlas/models/*.hpp"
"include/atlas/multithreading/*.hpp"
"include/atlas/visitors/*.hpp"
"include/atlas/rates/*.hpp"
"include/atlas/others/*.hpp"
"include/atlas/parsers/*.hpp"
)
add_library(${PROJECT_NAME} STATIC ${INCLUDES} ${SOURCES})
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MD /EHsc /MP")
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif(MSVC)
target_include_directories(
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
find_package(Boost REQUIRED)
find_package(QuantLib REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC QuantLib::QuantLib Boost::boost)
#link cppad
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake
)
set(CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}" CACHE INTERNAL "")
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
# export targets to be used with find_package
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# exports target config file to be used with find_package
install(
EXPORT ${PROJECT_NAME}_Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CONFIG_INSTALL_DIR}
)
# exports config file to be used with find_package
install(
FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CONFIG_INSTALL_DIR}
)
# exports headers
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include
DESTINATION ${CMAKE_INSTALL_PREFIX})
# if(BUILD_PYTHON)
# add_subdirectory(python)
# endif()
if(BUILD_BENCHMARK)
add_subdirectory(benchmark)
endif()
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()