Skip to content

Commit 8d3e5c7

Browse files
committed
Update commonSettings.cmake
Unify boost setting for MSVC and all other compilers.
1 parent 57bcc67 commit 8d3e5c7

1 file changed

Lines changed: 36 additions & 57 deletions

File tree

cmake/commonSettings.cmake

Lines changed: 36 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,6 @@ if(MSVC)
6767
set(CMAKE_MSVC_RUNTIME_LIBRARY
6868
"MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${MSVC_LINK_DYNAMIC_RUNTIME}>:DLL>")
6969

70-
# link against static boost libraries
71-
if(NOT DEFINED Boost_USE_STATIC_LIBS)
72-
if(BUILD_SHARED_LIBS)
73-
set(Boost_USE_STATIC_LIBS 0)
74-
else()
75-
set(Boost_USE_STATIC_LIBS 1)
76-
endif()
77-
endif()
78-
79-
# Boost static runtime ON for MSVC
80-
if(NOT DEFINED Boost_USE_STATIC_RUNTIME)
81-
if(BUILD_SHARED_LIBS OR(MSVC AND MSVC_LINK_DYNAMIC_RUNTIME))
82-
set(Boost_USE_STATIC_RUNTIME 0)
83-
else()
84-
set(Boost_USE_STATIC_RUNTIME 1)
85-
endif()
86-
endif()
87-
88-
89-
90-
IF(NOT Boost_USE_STATIC_LIBS)
91-
add_definitions(-DBOOST_ALL_DYN_LINK)
92-
add_definitions(-DBOOST_TEST_DYN_LINK)
93-
endif()
9470
add_compile_options(/external:env:BOOST)
9571
add_compile_options(/external:W0)
9672
add_compile_definitions(_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING)
@@ -135,41 +111,9 @@ else()
135111
set(BUILD_SHARED_LIBS ON)
136112
endif()
137113

138-
# link against static boost libraries
139-
if(NOT DEFINED Boost_USE_STATIC_LIBS)
140-
if(BUILD_SHARED_LIBS)
141-
set(Boost_USE_STATIC_LIBS OFF)
142-
else()
143-
set(Boost_USE_STATIC_LIBS ON)
144-
endif()
145-
endif()
146-
147-
# Boost static runtime
148-
if(NOT DEFINED Boost_USE_STATIC_RUNTIME)
149-
if(BUILD_SHARED_LIBS)
150-
set(Boost_USE_STATIC_RUNTIME OFF)
151-
else()
152-
set(Boost_USE_STATIC_RUNTIME ON)
153-
endif()
154-
endif()
155-
156-
# Use Boost Release/Debug
157-
if(CMAKE_BUILD_TYPE MATCHES Release)
158-
set(Boost_USE_DEBUG_LIBS OFF)
159-
set(Boost_USE_RELEASE_LIBS ON)
160-
elseif(CMAKE_BUILD_TYPE MATCHES Debug)
161-
set(Boost_USE_DEBUG_LIBS ON)
162-
set(Boost_USE_RELEASE_LIBS OFF)
163-
endif()
164114
# Issue with Boost CMake finder introduced in version 1.70
165115
set(Boost_NO_BOOST_CMAKE ON)
166116

167-
if(NOT Boost_USE_STATIC_LIBS)
168-
# link against dynamic boost libraries
169-
add_definitions(-DBOOST_ALL_DYN_LINK)
170-
add_definitions(-DBOOST_TEST_DYN_LINK)
171-
endif()
172-
173117
# avoid a crash in valgrind that sometimes occurs if this flag is not defined
174118
add_definitions(-DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
175119

@@ -225,9 +169,44 @@ else()
225169
# if QuantLib is build separately
226170
include_directories("${CMAKE_CURRENT_LIST_DIR}/../QuantLib/build")
227171

228-
229172
endif()
230173

174+
# Boost #
175+
# link against static boost libraries
176+
if(NOT DEFINED Boost_USE_STATIC_LIBS)
177+
if(BUILD_SHARED_LIBS)
178+
set(Boost_USE_STATIC_LIBS OFF)
179+
else()
180+
set(Boost_USE_STATIC_LIBS ON)
181+
endif()
182+
endif()
183+
184+
# Boost static runtime. ON for MSVC
185+
if(NOT DEFINED Boost_USE_STATIC_RUNTIME)
186+
if(BUILD_SHARED_LIBS OR(MSVC AND MSVC_LINK_DYNAMIC_RUNTIME))
187+
set(Boost_USE_STATIC_RUNTIME OFF)
188+
else()
189+
set(Boost_USE_STATIC_RUNTIME ON)
190+
endif()
191+
endif()
192+
193+
if(NOT Boost_USE_STATIC_LIBS)
194+
# link against dynamic boost libraries
195+
add_definitions(-DBOOST_ALL_DYN_LINK)
196+
add_definitions(-DBOOST_TEST_DYN_LINK)
197+
endif()
198+
199+
# Use Boost Release/Debug
200+
if(CMAKE_BUILD_TYPE MATCHES Release)
201+
set(Boost_USE_DEBUG_LIBS OFF)
202+
set(Boost_USE_RELEASE_LIBS ON)
203+
elseif(CMAKE_BUILD_TYPE MATCHES Debug)
204+
set(Boost_USE_DEBUG_LIBS ON)
205+
set(Boost_USE_RELEASE_LIBS OFF)
206+
endif()
207+
208+
# Boost end #
209+
231210
# workaround when building with boost 1.81, see https://github.com/boostorg/phoenix/issues/111
232211
add_definitions(-DBOOST_PHOENIX_STL_TUPLE_H_)
233212

0 commit comments

Comments
 (0)