-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
105 lines (90 loc) · 4.07 KB
/
Copy pathCMakeLists.txt
File metadata and controls
105 lines (90 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
cmake_minimum_required(VERSION 3.5)
# Set extension name here
set(TARGET_NAME mongo)
# MongoDB C++ driver requires C++17 for std::optional and std::string_view.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# DuckDB's extension distribution supports vcpkg. As such, dependencies can be added in ./vcpkg.json and then
# used in cmake with find_package. Feel free to remove or replace with other dependencies.
# Note that it should also be removed from vcpkg.json to prevent needlessly installing it..
find_package(bsoncxx CONFIG REQUIRED)
find_package(mongocxx CONFIG REQUIRED)
set(EXTENSION_NAME ${TARGET_NAME}_extension)
set(LOADABLE_EXTENSION_NAME ${TARGET_NAME}_loadable_extension)
project(${TARGET_NAME})
include_directories(src/include)
set(EXTENSION_SOURCES
src/mongo_extension.cpp
src/mongo_optimizer.cpp
src/mongo_table_function.cpp
src/mongo_schema_inference.cpp
src/schema/mongo_schema_inference_helpers.cpp
src/mongo_filter_pushdown.cpp
src/mongo_expr_pushdown.cpp
src/mongo_storage_extension.cpp
src/mongo_catalog.cpp
src/mongo_schema_entry.cpp
src/mongo_instance.cpp
src/mongo_transaction.cpp
src/mongo_transaction_manager.cpp
src/mongo_clear_cache.cpp
src/mongo_secrets.cpp
)
build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES})
build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES})
# Link MongoDB C++ driver in both the static library as the loadable extension
# Use static libraries if available, otherwise use shared
target_link_libraries(${EXTENSION_NAME}
$<IF:$<TARGET_EXISTS:mongo::mongocxx_static>,mongo::mongocxx_static,mongo::mongocxx_shared>
$<IF:$<TARGET_EXISTS:mongo::bsoncxx_static>,mongo::bsoncxx_static,mongo::bsoncxx_shared>
)
target_link_libraries(${LOADABLE_EXTENSION_NAME}
$<IF:$<TARGET_EXISTS:mongo::mongocxx_static>,mongo::mongocxx_static,mongo::mongocxx_shared>
$<IF:$<TARGET_EXISTS:mongo::bsoncxx_static>,mongo::bsoncxx_static,mongo::bsoncxx_shared>
)
install(
TARGETS ${EXTENSION_NAME}
EXPORT "${DUCKDB_EXPORT_SET}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}")
# Integration test is only built when developing the extension standalone.
# When embedded via duckdb_extension_load, CMAKE_PROJECT_NAME is the host
# project name, so we skip this target to avoid missing test-framework headers.
if(CMAKE_PROJECT_NAME STREQUAL "${TARGET_NAME}")
add_executable(test_atlas_integration
test/integration/test_atlas_integration.cpp
${EXTENSION_SOURCES}
)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEBUG_OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build/debug")
file(MAKE_DIRECTORY "${DEBUG_OUTPUT_DIR}")
set_target_properties(test_atlas_integration PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${DEBUG_OUTPUT_DIR}"
)
message(STATUS "test_atlas_integration (DEBUG) will be built in: ${DEBUG_OUTPUT_DIR}")
else()
set_target_properties(test_atlas_integration PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/extension/mongo"
)
message(STATUS "test_atlas_integration (RELEASE) will be built in: ${CMAKE_BINARY_DIR}/extension/mongo")
endif()
target_link_libraries(test_atlas_integration
duckdb_static
$<IF:$<TARGET_EXISTS:duckdb_generated_extension_loader>,duckdb_generated_extension_loader,dummy_static_extension_loader>
$<$<TARGET_EXISTS:core_functions_extension>:core_functions_extension>
$<$<TARGET_EXISTS:parquet_extension>:parquet_extension>
$<$<TARGET_EXISTS:tpch_extension>:tpch_extension>
$<$<TARGET_EXISTS:jemalloc_extension>:jemalloc_extension>
$<IF:$<TARGET_EXISTS:mongo::mongocxx_static>,mongo::mongocxx_static,mongo::mongocxx_shared>
$<IF:$<TARGET_EXISTS:mongo::bsoncxx_static>,mongo::bsoncxx_static,mongo::bsoncxx_shared>
)
target_include_directories(test_atlas_integration PRIVATE
src/include
duckdb/src/include
duckdb
duckdb/third_party/catch
duckdb/test/include
)
target_compile_options(test_atlas_integration PRIVATE -g -O0)
add_test(NAME test_atlas_integration COMMAND test_atlas_integration "[mongo][atlas][integration]")
endif()