Skip to content

CXX-2753 Refactor CMake config files to reflect new directory structure #1037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .mci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,12 @@ functions:
export LD_LIBRARY_PATH=.:$PREFIX/lib/
export DYLD_LIBRARY_PATH=.:$PREFIX/lib/
fi
export PATH=$(pwd)/src/bsoncxx/${build_type}:$(pwd)/src/mongocxx/${build_type}:$PREFIX/bin:$(pwd)/install/bin:$PATH
PATH="$(pwd)/src/mongocxx/test/${build_type}:$PATH"
PATH="$(pwd)/src/bsoncxx/test/${build_type}:$PATH"
PATH="$(pwd)/src/mongocxx/${build_type}:$PATH"
PATH="$(pwd)/src/bsoncxx/${build_type}:$PATH"
PATH="$PREFIX/bin:$PATH"
PATH="$(pwd)/install/bin:$PATH"

export CHANGE_STREAMS_UNIFIED_TESTS_PATH="$(pwd)/../data/change-streams/unified"
export CLIENT_SIDE_ENCRYPTION_LEGACY_TESTS_PATH="$(pwd)/../data/client_side_encryption/legacy"
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ add_custom_target(docs
)

set(THIRD_PARTY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party)
set(DATA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)

option(ENABLE_TESTS "Build MongoDB C++ Driver tests." ON)

Expand Down
14 changes: 0 additions & 14 deletions src/bsoncxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,6 @@ if(BSONCXX_BUILD_STATIC)
list(APPEND bsoncxx_target_list bsoncxx_static)
endif()

if(BSONCXX_BUILD_SHARED)
if(ENABLE_TESTS)
bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" SHARED)
endif()
else()
if(ENABLE_TESTS)
bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" STATIC)
endif()
endif()

if(ENABLE_TESTS)
target_compile_definitions(bsoncxx_testing PUBLIC BSONCXX_TESTING)
endif()

# Generate and install the export header.
if(1)
function(bsoncxx_install_export_header TARGET)
Expand Down
52 changes: 42 additions & 10 deletions src/bsoncxx/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,55 @@ if(NOT BUILD_TESTING)
set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL TRUE)
endif()

# Allow `#include <third_party/catch/include/...>`
include_directories(${THIRD_PARTY_SOURCE_DIR}/..)
if(BSONCXX_BUILD_SHARED)
bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" SHARED)
else()
bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" STATIC)
endif()

file(GLOB src_bsoncxx_test_DIST_cpps RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
target_compile_definitions(bsoncxx_testing PUBLIC BSONCXX_TESTING)

# Allow `#include <third_party/catch/include/...>`
target_include_directories(bsoncxx_testing PUBLIC ${THIRD_PARTY_SOURCE_DIR}/..)

add_executable(test_bson
${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp
${src_bsoncxx_test_DIST_cpps}
array.cpp
bson_b_date.cpp
bson_builder.cpp
bson_get_values.cpp
bson_serialization.cpp
bson_types.cpp
bson_util_itoa.cpp
bson_validate.cpp
bson_value.cpp
json.cpp
oid.cpp
view_or_value.cpp
)

target_link_libraries(test_bson bsoncxx_testing ${libbson_target})
target_include_directories(test_bson PRIVATE ${libbson_include_directories})
target_compile_definitions(test_bson PRIVATE ${libbson_definitions})
# Common target properties for test executables.
add_library(bsoncxx_test_properties INTERFACE)
target_sources(bsoncxx_test_properties INTERFACE ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp)
target_link_libraries(bsoncxx_test_properties INTERFACE bsoncxx_testing ${libbson_target})
target_include_directories(bsoncxx_test_properties INTERFACE ${libbson_include_directories})
target_compile_definitions(bsoncxx_test_properties INTERFACE ${libbson_definitions})

target_link_libraries(test_bson PRIVATE bsoncxx_test_properties)

add_test(bson test_bson)
add_test(NAME bson COMMAND test_bson)

set_dist_list(src_bsoncxx_test_DIST
CMakeLists.txt
${src_bsoncxx_test_DIST_cpps}
array.cpp
bson_b_date.cpp
bson_builder.cpp
bson_get_values.cpp
bson_serialization.cpp
bson_types.cpp
bson_util_itoa.cpp
bson_validate.cpp
bson_value.cpp
json.cpp
oid.cpp
view_or_value.cpp
)
19 changes: 0 additions & 19 deletions src/mongocxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,6 @@ if(MONGOCXX_BUILD_STATIC)
list(APPEND mongocxx_target_list mongocxx_static)
endif()

if(MONGOCXX_BUILD_SHARED)
if(ENABLE_TESTS)
mongocxx_add_library(mongocxx_mocked "mongocxx-mocked" SHARED)
endif()
else()
if(ENABLE_TESTS)
mongocxx_add_library(mongocxx_mocked "mongocxx-mocked" STATIC)
endif()
endif()

if(ENABLE_TESTS)
target_link_libraries(mongocxx_mocked PUBLIC bsoncxx_testing)
target_compile_definitions(mongocxx_mocked PUBLIC MONGOCXX_TESTING)

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(mongocxx_mocked PRIVATE /bigobj)
endif()
endif()

# Generate and install the export header.
if(1)
function(mongocxx_install_export_header TARGET)
Expand Down
Loading