Skip to content

Commit f4a8e10

Browse files
committed
CXX-957 Honor BUILD_SHARED_LIBS to a sufficient degree
1 parent c9596fb commit f4a8e10

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ set(CMAKE_CXX_EXTENSIONS OFF)
6161
include(GenerateExportHeader)
6262
include(InstallRequiredSystemLibraries)
6363

64+
# Allow the user to decie whether to install the shared libaries. Note that we always build them,
65+
# since otherwise it makes the CMake logic very complex, but setting BUILD_SHARED_LIBS=Off will at
66+
# least disable installing them.
67+
option(BUILD_SHARED_LIBS "Install shared libraries" ON)
68+
6469
# If the user did not customize the install prefix,
6570
# set it to live under build so we don't inadverently pollute /usr/local
6671
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

src/bsoncxx/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,14 @@ install(FILES
170170
COMPONENT dev
171171
)
172172

173-
install(TARGETS
174-
bsoncxx
175-
RUNTIME DESTINATION bin COMPONENT runtime
176-
LIBRARY DESTINATION lib COMPONENT runtime
177-
ARCHIVE DESTINATION lib COMPONENT dev
178-
)
173+
if (BUILD_SHARED_LIBS)
174+
install(TARGETS
175+
bsoncxx
176+
RUNTIME DESTINATION bin COMPONENT runtime
177+
LIBRARY DESTINATION lib COMPONENT runtime
178+
ARCHIVE DESTINATION lib COMPONENT dev
179+
)
180+
endif()
179181

180182
install(TARGETS
181183
bsoncxx_static

src/mongocxx/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,14 @@ install(FILES
178178
COMPONENT dev
179179
)
180180

181-
install(TARGETS
182-
mongocxx
183-
RUNTIME DESTINATION bin COMPONENT runtime
184-
LIBRARY DESTINATION lib COMPONENT runtime
185-
ARCHIVE DESTINATION lib COMPONENT dev
186-
)
181+
if (BUILD_SHARED_LIBS)
182+
install(TARGETS
183+
mongocxx
184+
RUNTIME DESTINATION bin COMPONENT runtime
185+
LIBRARY DESTINATION lib COMPONENT runtime
186+
ARCHIVE DESTINATION lib COMPONENT dev
187+
)
188+
endif()
187189

188190
install(TARGETS
189191
mongocxx_static

0 commit comments

Comments
 (0)