@@ -60,49 +60,15 @@ option(QL_INSTALL_TEST_SUITE "Install test suite" ON)
6060option (QL_TAGGED_LAYOUT "Library names use layout tags" ${MSVC} )
6161option (QL_USE_CLANG_TIDY "Use clang-tidy when building" OFF )
6262option (QL_USE_INDEXED_COUPON "Use indexed coupons instead of par coupons" OFF )
63+ option (QL_USE_STD_ANY "Use std::any instead of boost::any" OFF )
6364option (QL_USE_STD_CLASSES "Enable all QL_USE_STD_ options" OFF )
64- option (QL_USE_STD_SHARED_PTR "Use standard smart pointers instead of Boost ones" OFF )
6565option (QL_USE_STD_FUNCTION "Use std::function and std::bind instead of Boost ones" OFF )
66+ option (QL_USE_STD_OPTIONAL "Use std::optional instead of boost::optional" OFF )
67+ option (QL_USE_STD_SHARED_PTR "Use standard smart pointers instead of Boost ones" OFF )
6668option (QL_USE_STD_TUPLE "Use std::tuple instead of boost::tuple" OFF )
6769set (QL_EXTERNAL_SUBDIRECTORIES "" CACHE STRING "Optional list of external source directories to be added to the build (semicolon-separated)" )
6870set (QL_EXTRA_LINK_LIBRARIES "" CACHE STRING "Optional extra link libraries to add to QuantLib" )
6971
70- # Convenience option to activate all STD options
71- if (QL_USE_STD_CLASSES)
72- set (QL_USE_STD_SHARED_PTR ON )
73- set (QL_USE_STD_FUNCTION ON )
74- set (QL_USE_STD_TUPLE ON )
75- endif ()
76-
77- if (QL_USE_CLANG_TIDY)
78- if (NOT DEFINED QL_CLANG_TIDY)
79- set (QL_CLANG_TIDY clang-tidy)
80- endif ()
81- if (NOT DEFINED QL_CLANG_TIDY_OPTIONS)
82- set (QL_CLANG_TIDY_OPTIONS)
83- endif ()
84- if (QL_CLANG_TIDY_OPTIONS)
85- set (CMAKE_CXX_CLANG_TIDY "${QL_CLANG_TIDY} ;${QL_CLANG_TIDY_OPTIONS} " )
86- else ()
87- set (CMAKE_CXX_CLANG_TIDY "${QL_CLANG_TIDY} " )
88- endif ()
89- endif ()
90-
91- # Project shared libs ON for UNIX
92- if (NOT DEFINED BUILD_SHARED_LIBS )
93- set (BUILD_SHARED_LIBS ${UNIX} )
94- endif ()
95-
96- # Boost static libs ON for MSVC
97- if (NOT DEFINED Boost_USE_STATIC_LIBS)
98- set (Boost_USE_STATIC_LIBS ${MSVC} )
99- endif ()
100-
101- # Boost static runtime ON for MSVC
102- if (NOT DEFINED Boost_USE_STATIC_RUNTIME)
103- set (Boost_USE_STATIC_RUNTIME ${MSVC} )
104- endif ()
105-
10672# Require C++14 or higher
10773if (NOT DEFINED CMAKE_CXX_STANDARD )
10874 set (CMAKE_CXX_STANDARD 14)
@@ -117,6 +83,26 @@ if (NOT DEFINED CMAKE_CXX_EXTENSIONS)
11783 set (CMAKE_CXX_EXTENSIONS FALSE )
11884endif ()
11985
86+ # Convenience option to activate all STD options
87+ if (QL_USE_STD_CLASSES)
88+ if (CMAKE_CXX_STANDARD GREATER_EQUAL 17)
89+ set (QL_USE_STD_ANY ON )
90+ set (QL_USE_STD_OPTIONAL ON )
91+ endif ()
92+ set (QL_USE_STD_FUNCTION ON )
93+ set (QL_USE_STD_SHARED_PTR ON )
94+ set (QL_USE_STD_TUPLE ON )
95+ endif ()
96+
97+ if (CMAKE_CXX_STANDARD LESS 17)
98+ if (QL_USE_STD_ANY)
99+ message (FATAL_ERROR "QL_USE_STD_ANY requires at least C++17" )
100+ endif ()
101+ if (QL_USE_STD_OPTIONAL)
102+ message (FATAL_ERROR "QL_USE_STD_OPTIONAL requires at least C++17" )
103+ endif ()
104+ endif ()
105+
120106# Set the default warning level we use to pass the GitHub workflows
121107if (QL_ENABLE_DEFAULT_WARNING_LEVEL)
122108 if (MSVC )
@@ -145,6 +131,35 @@ if (QL_COMPILE_WARNING_AS_ERROR)
145131 endif ()
146132endif ()
147133
134+ if (QL_USE_CLANG_TIDY)
135+ if (NOT DEFINED QL_CLANG_TIDY)
136+ set (QL_CLANG_TIDY clang-tidy)
137+ endif ()
138+ if (NOT DEFINED QL_CLANG_TIDY_OPTIONS)
139+ set (QL_CLANG_TIDY_OPTIONS)
140+ endif ()
141+ if (QL_CLANG_TIDY_OPTIONS)
142+ set (CMAKE_CXX_CLANG_TIDY "${QL_CLANG_TIDY} ;${QL_CLANG_TIDY_OPTIONS} " )
143+ else ()
144+ set (CMAKE_CXX_CLANG_TIDY "${QL_CLANG_TIDY} " )
145+ endif ()
146+ endif ()
147+
148+ # Project shared libs ON for UNIX
149+ if (NOT DEFINED BUILD_SHARED_LIBS )
150+ set (BUILD_SHARED_LIBS ${UNIX} )
151+ endif ()
152+
153+ # Boost static libs ON for MSVC
154+ if (NOT DEFINED Boost_USE_STATIC_LIBS)
155+ set (Boost_USE_STATIC_LIBS ${MSVC} )
156+ endif ()
157+
158+ # Boost static runtime ON for MSVC
159+ if (NOT DEFINED Boost_USE_STATIC_RUNTIME)
160+ set (Boost_USE_STATIC_RUNTIME ${MSVC} )
161+ endif ()
162+
148163if (NOT DEFINED QL_BOOST_VERSION)
149164 # Boost 1.75.0 or greater required for compiling with C++20
150165 if (CMAKE_CXX_STANDARD GREATER_EQUAL 20)
0 commit comments