Skip to content

Commit

Permalink
CXXCBC-639: Allow to build both static and shared libraries
Browse files Browse the repository at this point in the history
To avoid issues with generation of cmake helper scripts the following
changes has been made:

* interface libraries that are used to carry compiler options and flags
  are declared as IMPORTED to avoid unnecessary INTERFACE_LINK
  dependencies for the static library

* jsonsl, asio and couchbase_backtrace libraries are not linked as a
  targets, but rather as a object files directly. This is also done to
  avoid announcing them as a transitive dependencies. All these
  libraries are hidden and never exposed.

* for other third-party dependencies do not disable install tasks, which
  generate export files

This patch also removes some unused cmake files (of crypto, sasl and
operations/management directories).

Fixes #701
  • Loading branch information
avsej committed Jan 14, 2025
1 parent 3510b3a commit f462a77
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 130 deletions.
16 changes: 9 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ include(cmake/PreventInSourceBuilds.cmake)
include(cmake/StandardProjectSettings.cmake)

# 'library' to set the c++ standard / compile-time options requested
add_library(project_options INTERFACE)
add_library(project_options INTERFACE IMPORTED)
target_compile_features(project_options INTERFACE cxx_std_17)
if(MSVC)
target_compile_options(project_options INTERFACE /bigobj)
endif()

# 'library' to use the warnings specified in CompilerWarnings.cmake
add_library(project_warnings INTERFACE)
add_library(project_warnings INTERFACE IMPORTED)

include(cmake/BuildTracing.cmake)

Expand Down Expand Up @@ -506,7 +506,9 @@ foreach(TARGET ${couchbase_cxx_client_LIBRARIES})

target_include_directories(
${TARGET} SYSTEM PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party/cxx_function>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party/expected/include>)
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party/expected/include>
$<BUILD_INTERFACE:$<TARGET_PROPERTY:jsonsl,INTERFACE_INCLUDE_DIRECTORIES>>
$<BUILD_INTERFACE:$<TARGET_PROPERTY:asio,INTERFACE_INCLUDE_DIRECTORIES>>)

target_include_directories(${TARGET} PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

Expand All @@ -517,13 +519,13 @@ foreach(TARGET ${couchbase_cxx_client_LIBRARIES})
project_warnings
spdlog::spdlog
Microsoft.GSL::GSL
asio
llhttp::llhttp
taocpp::json
snappy
jsonsl
couchbase_backtrace
hdr_histogram_static)
hdr_histogram_static
$<TARGET_OBJECTS:asio>
$<TARGET_OBJECTS:couchbase_backtrace>
$<TARGET_OBJECTS:jsonsl>)

if(WIN32)
target_link_libraries(${TARGET} PRIVATE iphlpapi)
Expand Down
6 changes: 0 additions & 6 deletions cmake/ThirdPartyDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@ if(NOT TARGET spdlog::spdlog)
"gabime/spdlog"
EXCLUDE_FROM_ALL ON
OPTIONS
"SPDLOG_INSTALL OFF"
"BUILD_SHARED_LIBS OFF"
"CMAKE_C_VISIBILITY_PRESET hidden"
"CMAKE_CXX_VISIBILITY_PRESET hidden"
"CMAKE_POSITION_INDEPENDENT_CODE ON"
"NO_CMAKE_SYSTEM_PATH ON"
"NO_CMAKE_INSTALL_PREFIX ON"
"NO_CMAKE_SYSTEM_PACKAGE_REGISTRY ON"
"SPDLOG_BUILD_SHARED OFF"
"SPDLOG_FMT_EXTERNAL OFF")
endif()
Expand All @@ -51,7 +47,6 @@ if(NOT TARGET Microsoft.GSL::GSL)
"microsoft/gsl"
EXCLUDE_FROM_ALL ON
OPTIONS
"GSL_INSTALL OFF"
"CMAKE_C_VISIBILITY_PRESET hidden"
"CMAKE_CXX_VISIBILITY_PRESET hidden"
"CMAKE_POSITION_INDEPENDENT_CODE ON")
Expand Down Expand Up @@ -111,7 +106,6 @@ if(NOT TARGET snappy)
"google/snappy"
EXCLUDE_FROM_ALL ON
OPTIONS
"SNAPPY_INSTALL OFF"
"CMAKE_C_VISIBILITY_PRESET hidden"
"CMAKE_CXX_VISIBILITY_PRESET hidden"
"CMAKE_POSITION_INDEPENDENT_CODE ON"
Expand Down
21 changes: 0 additions & 21 deletions core/crypto/CMakeLists.txt

This file was deleted.

80 changes: 0 additions & 80 deletions core/operations/management/CMakeLists.txt

This file was deleted.

16 changes: 0 additions & 16 deletions core/sasl/CMakeLists.txt

This file was deleted.

0 comments on commit f462a77

Please sign in to comment.