@@ -69,30 +69,6 @@ if(MSVC)
6969 set (CMAKE_MSVC_RUNTIME_LIBRARY
7070 "MultiThreaded$<$<CONFIG :Debug >:Debug >$<$<BOOL :${MSVC_LINK_DYNAMIC_RUNTIME} >:DLL >" )
7171
72- # link against static boost libraries
73- if (NOT DEFINED Boost_USE_STATIC_LIBS)
74- if (BUILD_SHARED_LIBS )
75- set (Boost_USE_STATIC_LIBS 0)
76- else ()
77- set (Boost_USE_STATIC_LIBS 1)
78- endif ()
79- endif ()
80-
81- # Boost static runtime ON for MSVC
82- if (NOT DEFINED Boost_USE_STATIC_RUNTIME)
83- if (BUILD_SHARED_LIBS OR (MSVC AND MSVC_LINK_DYNAMIC_RUNTIME))
84- set (Boost_USE_STATIC_RUNTIME 0)
85- else ()
86- set (Boost_USE_STATIC_RUNTIME 1)
87- endif ()
88- endif ()
89-
90-
91-
92- IF (NOT Boost_USE_STATIC_LIBS)
93- add_definitions (-DBOOST_ALL_DYN_LINK )
94- add_definitions (-DBOOST_TEST_DYN_LINK )
95- endif ()
9672 add_compile_options (/external:env:BOOST )
9773 add_compile_options (/external:W0 )
9874 add_compile_definitions (_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING )
@@ -137,9 +113,8 @@ else()
137113 set (BUILD_SHARED_LIBS ON )
138114 endif ()
139115
140- # link against dynamic boost libraries
141- add_definitions (-DBOOST_ALL_DYN_LINK )
142- add_definitions (-DBOOST_TEST_DYN_LINK )
116+ # Issue with Boost CMake finder introduced in version 1.70
117+ set (Boost_NO_BOOST_CMAKE ON )
143118
144119 # avoid a crash in valgrind that sometimes occurs if this flag is not defined
145120 add_definitions (-DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS )
@@ -196,9 +171,44 @@ else()
196171 # if QuantLib is build separately
197172 include_directories ("${CMAKE_CURRENT_LIST_DIR} /../QuantLib/build" )
198173
199-
200174endif ()
201175
176+ # Boost #
177+ # link against static boost libraries
178+ if (NOT DEFINED Boost_USE_STATIC_LIBS)
179+ if (BUILD_SHARED_LIBS )
180+ set (Boost_USE_STATIC_LIBS OFF )
181+ else ()
182+ set (Boost_USE_STATIC_LIBS ON )
183+ endif ()
184+ endif ()
185+
186+ # Boost static runtime. ON for MSVC
187+ if (NOT DEFINED Boost_USE_STATIC_RUNTIME)
188+ if (BUILD_SHARED_LIBS OR (MSVC AND MSVC_LINK_DYNAMIC_RUNTIME))
189+ set (Boost_USE_STATIC_RUNTIME OFF )
190+ else ()
191+ set (Boost_USE_STATIC_RUNTIME ON )
192+ endif ()
193+ endif ()
194+
195+ if (NOT Boost_USE_STATIC_LIBS)
196+ # link against dynamic boost libraries
197+ add_definitions (-DBOOST_ALL_DYN_LINK )
198+ add_definitions (-DBOOST_TEST_DYN_LINK )
199+ endif ()
200+
201+ # Use Boost Release/Debug
202+ if (CMAKE_BUILD_TYPE MATCHES Release)
203+ set (Boost_USE_DEBUG_LIBS OFF )
204+ set (Boost_USE_RELEASE_LIBS ON )
205+ elseif (CMAKE_BUILD_TYPE MATCHES Debug)
206+ set (Boost_USE_DEBUG_LIBS ON )
207+ set (Boost_USE_RELEASE_LIBS OFF )
208+ endif ()
209+
210+ # Boost end #
211+
202212# workaround when building with boost 1.81, see https://github.com/boostorg/phoenix/issues/111
203213add_definitions (-DBOOST_PHOENIX_STL_TUPLE_H_ )
204214
0 commit comments