Skip to content

Commit 858e32c

Browse files
committed
Update commonSettings.cmake
Link boost static for Linux also when static libs enabled.
1 parent 097f7d7 commit 858e32c

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

cmake/commonSettings.cmake

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,29 @@ else()
135135
set(BUILD_SHARED_LIBS ON)
136136
endif()
137137

138-
# link against dynamic boost libraries
139-
add_definitions(-DBOOST_ALL_DYN_LINK)
140-
add_definitions(-DBOOST_TEST_DYN_LINK)
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 0)
142+
else()
143+
set(Boost_USE_STATIC_LIBS 1)
144+
endif()
145+
endif()
146+
147+
# Boost static runtime ON for MSVC
148+
if(NOT DEFINED Boost_USE_STATIC_RUNTIME)
149+
if(BUILD_SHARED_LIBS)
150+
set(Boost_USE_STATIC_RUNTIME 0)
151+
else()
152+
set(Boost_USE_STATIC_RUNTIME 1)
153+
endif()
154+
endif()
155+
156+
if(NOT Boost_USE_STATIC_LIBS)
157+
# link against dynamic boost libraries
158+
add_definitions(-DBOOST_ALL_DYN_LINK)
159+
add_definitions(-DBOOST_TEST_DYN_LINK)
160+
endif()
141161

142162
# avoid a crash in valgrind that sometimes occurs if this flag is not defined
143163
add_definitions(-DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)

0 commit comments

Comments
 (0)