@@ -69,6 +69,30 @@ 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 ()
7296 add_compile_options (/external:env:BOOST )
7397 add_compile_options (/external:W0 )
7498 add_compile_definitions (_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING )
@@ -80,16 +104,16 @@ if(MSVC)
80104 add_compile_options (/W3 )
81105 #add_compile_options(/we4265) #no-virtual-destructor
82106 #add_compile_options(/we4388) # 'equality-operator' : signed/unsigned mismatch
83- add_compile_options (/we5038 ) # reorder
107+ add_compile_options (/we5038 ) # reorder
84108 # add_compile_options(/we4101) # unreferenced local variable (too strict)
85109 add_compile_options (/we4189 ) # 'identifier' : local variable is initialized but not referenced
86110 add_compile_options (/we4700 ) # uninitialized local variable 'name' used
87- add_compile_options (/we5233 ) # unused lambda
111+ add_compile_options (/we5233 ) # unused lambda
88112 add_compile_options (/we4508 ) # 'function' : function should return a value; 'void' return type assumed
89113 add_compile_options (/wd4834 )
90114 add_compile_options (/we26815 ) # dangling references/pointer
91115 # add_compiler_flag("/we4389" signed_compare_mscv)
92-
116+
93117 add_link_options (/LARGEADDRESSAWARE )
94118
95119 add_compile_options ("$<$<CONFIG :Release >:/GF >" )
@@ -113,8 +137,9 @@ else()
113137 set (BUILD_SHARED_LIBS ON )
114138 endif ()
115139
116- # Issue with Boost CMake finder introduced in version 1.70
117- set (Boost_NO_BOOST_CMAKE ON )
140+ # link against dynamic boost libraries
141+ add_definitions (-DBOOST_ALL_DYN_LINK )
142+ add_definitions (-DBOOST_TEST_DYN_LINK )
118143
119144 # avoid a crash in valgrind that sometimes occurs if this flag is not defined
120145 add_definitions (-DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS )
@@ -171,44 +196,9 @@ else()
171196 # if QuantLib is build separately
172197 include_directories ("${CMAKE_CURRENT_LIST_DIR} /../QuantLib/build" )
173198
174- endif ()
175199
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 ()
193200endif ()
194201
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-
212202# workaround when building with boost 1.81, see https://github.com/boostorg/phoenix/issues/111
213203add_definitions (-DBOOST_PHOENIX_STL_TUPLE_H_ )
214204
@@ -254,7 +244,7 @@ macro(get_library_name LIB_NAME OUTPUT_NAME)
254244 else ()
255245 set (CMAKE_DEBUG_POSTFIX "-gd" )
256246 endif ()
257-
247+
258248
259249 set (${OUTPUT_NAME} "${LIB_NAME}${LIB_PLATFORM}${LIB_THREAD_OPT}${LIB_RT_OPT} " )
260250 else ()
0 commit comments