-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
112 lines (100 loc) · 5.13 KB
/
Copy pathCMakeLists.txt
File metadata and controls
112 lines (100 loc) · 5.13 KB
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
cmake_minimum_required(VERSION 3.15)
# Required for CMAKE_MSVC_RUNTIME_LIBRARY (CMP0091)
cmake_policy(SET CMP0091 NEW)
project(QuantLibAddin CXX)
include(gensrc/cmake/commonSettings.cmake)
# Build the HTML documentation? Off by default; enable with -DBUILD_DOCS=ON.
# Defined here (before the subprojects) so each subproject can gate its own
# add_subdirectory(Docs) on it, and so the aggregate `docs` target below can be
# gated on it too. Each subproject also declares this option independently so
# that it still works when configured standalone.
option(BUILD_DOCS "Add targets to build the HTML documentation with Doxygen" OFF)
# -----------------------------------------------------------------------
# gensrc — optional code-generation step (the "Full" build).
# Defines the RUN_GENSRC option and the ohgensrc / qlgensrc targets.
# The dependency wiring onto the library targets (ohlib, QuantLibObjects)
# is done further below, once those targets have been created.
# -----------------------------------------------------------------------
add_subdirectory(gensrc)
# -----------------------------------------------------------------------
# QuantLib (adds target ql_library, aliased as QuantLib::QuantLib)
# -----------------------------------------------------------------------
set(QL_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(QL_BUILD_TEST_SUITE OFF CACHE BOOL "" FORCE)
# QL_TAGGED_LAYOUT is ON by default when MSVC is used, which sets
# CMAKE_RELEASE_POSTFIX / CMAKE_DEBUG_POSTFIX globally. Those global
# postfixes would affect every cmake target in the build, not just
# ql_library. We therefore turn the flag OFF here so that only
# ql_library gets its postfix set (we do that explicitly below).
set(QL_TAGGED_LAYOUT OFF CACHE BOOL "" FORCE)
add_subdirectory(QuantLib)
# Apply tagged layout postfixes to ql_library only, mirroring what
# QL_TAGGED_LAYOUT would have done, so the library filename matches
# the filenames expected by the hand-maintained VS build.
if(MSVC)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_ql_arch_tag "-x64")
else()
set(_ql_arch_tag "")
endif()
if(MSVC_LINK_DYNAMIC_RUNTIME)
set(_ql_debug_postfix "${_ql_arch_tag}-mt-gd")
set(_ql_release_postfix "${_ql_arch_tag}-mt")
else()
set(_ql_debug_postfix "${_ql_arch_tag}-mt-sgd")
set(_ql_release_postfix "${_ql_arch_tag}-mt-s")
endif()
set_target_properties(ql_library PROPERTIES
DEBUG_POSTFIX "${_ql_debug_postfix}"
RELEASE_POSTFIX "${_ql_release_postfix}"
RELWITHDEBINFO_POSTFIX "${_ql_release_postfix}"
MINSIZEREL_POSTFIX "${_ql_release_postfix}"
)
endif()
# -----------------------------------------------------------------------
# ObjectHandler static libs (ohlib + ohxllib) and xlsdk
# -----------------------------------------------------------------------
add_subdirectory(ObjectHandler)
# -----------------------------------------------------------------------
# QuantLibObjects static lib (QuantLibAddin qlo wrapper)
# -----------------------------------------------------------------------
add_subdirectory(QuantLibAddin)
# -----------------------------------------------------------------------
# QuantLibXL — the Excel XLL (Windows only). The subdirectory is always
# added so that its Docs (which build on any platform) are available; the
# XLL library target itself is guarded by if(WIN32) inside the subproject.
# -----------------------------------------------------------------------
add_subdirectory(QuantLibXL)
# -----------------------------------------------------------------------
# When the "Full" build is enabled, make the addin libraries depend on the
# gensrc targets so the autogenerated sources are refreshed before compiling.
# -----------------------------------------------------------------------
if(RUN_GENSRC)
add_dependencies(ohlib ohgensrc)
add_dependencies(QuantLibObjects qlgensrc)
endif()
# -----------------------------------------------------------------------
# Documentation — each subproject adds its own Docs subdirectory (gated on
# BUILD_DOCS) from inside its own CMakeLists.txt, so that — like the rest of the
# repository — a project's docs are part of that standalone project and can be
# built on their own, e.g.:
# cmake -S ObjectHandler/Docs -B <build> && cmake --build <build> --target docs
#
# Building the docs needs only Python 3, Doxygen and (optionally) Graphviz dot —
# not a C++ compiler or Boost — so the documentation can be built even on a
# machine that cannot compile the libraries.
#
# Here, in the integrated build, we only add an aggregate `docs` target that
# depends on every project's per-project doc target. The per-project targets
# (gensrc-docs, ObjectHandler-docs, QuantLibAddin-docs, QuantLibXL-docs) are
# defined by each subproject's Docs/CMakeLists.txt.
# -----------------------------------------------------------------------
if(BUILD_DOCS)
add_custom_target(docs
COMMENT "Building all HTML documentation (gensrc, ObjectHandler, QuantLibAddin, QuantLibXL)")
add_dependencies(docs
gensrc-docs
ObjectHandler-docs
QuantLibAddin-docs
QuantLibXL-docs)
endif()