Skip to content

Commit 033e61a

Browse files
authored
feat: integrate cargo into cmake build (#2690)
1 parent 416d488 commit 033e61a

File tree

5 files changed

+25
-16
lines changed

5 files changed

+25
-16
lines changed

duckdb-vortex/CMakeLists.txt

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.22)
22

33
# Set extension name here
44
set(TARGET_NAME vortex_duckdb)
5+
set(EXTENSION_NAME ${TARGET_NAME}_extension)
6+
set(EXTENSION_SOURCES src/vortex_duckdb_extension.cpp)
7+
set(LOADABLE_EXTENSION_NAME ${TARGET_NAME}_loadable_extension)
58

6-
# DuckDB's extension distribution supports vcpkg. As such, dependencies can be added in ./vcpkg.json and then
7-
# used in cmake with find_package. Feel free to remove or replace with other dependencies.
8-
# Note that it should also be removed from vcpkg.json to prevent needlessly installing it..
9+
# DuckDB's extension distribution supports vcpkg. As such, dependencies can be
10+
# added in ./vcpkg.json and then used in cmake with find_package. Feel free to
11+
# remove or replace with other dependencies. Note that it should also be removed
12+
# from vcpkg.json to prevent needlessly installing it..
913
find_package(OpenSSL REQUIRED)
1014

11-
set(EXTENSION_NAME ${TARGET_NAME}_extension)
12-
set(LOADABLE_EXTENSION_NAME ${TARGET_NAME}_loadable_extension)
15+
include(FetchContent)
16+
FetchContent_Declare(
17+
Corrosion
18+
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
19+
GIT_TAG v0.5.1
20+
)
21+
FetchContent_MakeAvailable(Corrosion)
1322

14-
project(${TARGET_NAME})
15-
include_directories(src/include)
23+
# Import targets defined in a package or workspace manifest `Cargo.toml` file
24+
corrosion_import_crate(MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../vortex-duckdb/Cargo.toml)
1625

17-
set(EXTENSION_SOURCES src/vortex_duckdb_extension.cpp)
26+
project(${TARGET_NAME}_project)
27+
include_directories(src/include)
1828

1929
build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES})
2030
build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES})
2131

22-
# Link OpenSSL in both the static library as the loadable extension
23-
target_link_libraries(${EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)
24-
target_link_libraries(${LOADABLE_EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)
32+
target_link_libraries(${EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto vortex_duckdb-static)
33+
target_link_libraries(${LOADABLE_EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto vortex_duckdb-shared)
2534

2635
install(
2736
TARGETS ${EXTENSION_NAME}
2837
EXPORT "${DUCKDB_EXPORT_SET}"
2938
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
30-
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}")
39+
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}")

duckdb-vortex/duckdb

duckdb-vortex/src/vortex_duckdb_extension.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static void LoadInternal(DatabaseInstance &instance) {
4747
void VortexDuckdbExtension::Load(DuckDB &db) {
4848
LoadInternal(*db.instance);
4949
}
50+
5051
std::string VortexDuckdbExtension::Name() {
5152
return "vortex_duckdb";
5253
}

vortex-duckdb/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ readme = { workspace = true }
1717
name = "vortex_duckdb"
1818
path = "src/lib.rs"
1919
bench = false
20+
crate-type = ["staticlib", "cdylib"]
2021

2122
[dependencies]
2223
itertools = { workspace = true }
@@ -27,7 +28,5 @@ vortex-error = { workspace = true }
2728
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
2829
duckdb = { workspace = true }
2930

30-
[dev-dependencies]
31-
3231
[lints]
3332
workspace = true

vortex-duckdb/cbindgen.toml

Whitespace-only changes.

0 commit comments

Comments
 (0)