Skip to content

Commit 15fb244

Browse files
m-kuhnpaleolimbot
andauthored
build(c): allow to build with system dependencies (apache#2546)
Adds two build options to disable vendored dependencies fmt and nanoarrow - `ADBC_WITH_VENDORED_FMT` - `ADBC_WITH_VENDORED_NANOARROW` The default will still use the vendored copies --------- Co-authored-by: Dewey Dunnington <dewey@dunnington.ca>
1 parent 06308e4 commit 15fb244

File tree

13 files changed

+42
-80
lines changed

13 files changed

+42
-80
lines changed

c/CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,17 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
2929

3030
include(CTest)
3131

32-
add_subdirectory(vendor/fmt EXCLUDE_FROM_ALL)
33-
set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE ON)
34-
add_subdirectory(vendor/nanoarrow)
32+
if(ADBC_WITH_VENDORED_FMT)
33+
add_subdirectory(vendor/fmt EXCLUDE_FROM_ALL)
34+
set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE ON)
35+
else()
36+
find_package(fmt REQUIRED)
37+
endif()
38+
if(ADBC_WITH_VENDORED_NANOARROW)
39+
add_subdirectory(vendor/nanoarrow)
40+
else()
41+
find_package(nanoarrow REQUIRED)
42+
endif()
3543
add_subdirectory(driver/common)
3644
add_subdirectory(driver/framework)
3745

c/cmake_modules/DefineOptions.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
133133

134134
define_option(ADBC_GGDB_DEBUG "Pass -ggdb flag to debug builds" ON)
135135

136+
define_option(ADBC_WITH_VENDORED_FMT "Use vendored copy of fmt" ON)
137+
138+
define_option(ADBC_WITH_VENDORED_NANOARROW "Use vendored copy of nanoarrow" ON)
139+
136140
#----------------------------------------------------------------------
137141
set_option_category("Test and benchmark")
138142

c/driver/bigquery/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ add_go_lib("${REPOSITORY_ROOT}/go/adbc/pkg/bigquery/"
3838
foreach(LIB_TARGET ${ADBC_LIBRARIES})
3939
target_include_directories(${LIB_TARGET} SYSTEM
4040
INTERFACE ${REPOSITORY_ROOT} ${REPOSITORY_ROOT}/c/
41-
${REPOSITORY_ROOT}/c/vendor
4241
${REPOSITORY_ROOT}/c/driver)
4342
endforeach()
4443

@@ -59,13 +58,10 @@ if(ADBC_BUILD_TESTS)
5958
EXTRA_LINK_LIBS
6059
adbc_driver_common
6160
adbc_validation
62-
nanoarrow
6361
${TEST_LINK_LIBS})
6462
target_compile_features(adbc-driver-bigquery-test PRIVATE cxx_std_17)
6563
target_include_directories(adbc-driver-bigquery-test SYSTEM
66-
PRIVATE ${REPOSITORY_ROOT}/c/
67-
${REPOSITORY_ROOT}/c/include/
68-
${REPOSITORY_ROOT}/c/vendor
64+
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
6965
${REPOSITORY_ROOT}/c/driver
7066
${REPOSITORY_ROOT}/c/driver/common)
7167
adbc_configure_target(adbc-driver-bigquery-test)

c/driver/common/CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
add_library(adbc_driver_common STATIC utils.c)
1919
adbc_configure_target(adbc_driver_common)
2020
set_target_properties(adbc_driver_common PROPERTIES POSITION_INDEPENDENT_CODE ON)
21-
target_include_directories(adbc_driver_common PRIVATE "${REPOSITORY_ROOT}/c/include"
22-
"${REPOSITORY_ROOT}/c/vendor")
21+
target_include_directories(adbc_driver_common PRIVATE "${REPOSITORY_ROOT}/c/include")
22+
target_link_libraries(adbc_driver_common PUBLIC nanoarrow::nanoarrow)
2323

2424
if(ADBC_BUILD_TESTS)
2525
add_test_case(driver_common_test
@@ -30,11 +30,9 @@ if(ADBC_BUILD_TESTS)
3030
SOURCES
3131
utils_test.cc
3232
EXTRA_LINK_LIBS
33-
adbc_driver_common
34-
nanoarrow)
33+
adbc_driver_common)
3534
target_compile_features(adbc-driver-common-test PRIVATE cxx_std_17)
3635
target_include_directories(adbc-driver-common-test
37-
PRIVATE "${REPOSITORY_ROOT}/c/include"
38-
"${REPOSITORY_ROOT}/c/vendor")
36+
PRIVATE "${REPOSITORY_ROOT}/c/include")
3937
adbc_configure_target(adbc-driver-common-test)
4038
endif()

c/driver/flightsql/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ foreach(LIB_TARGET ${ADBC_LIBRARIES})
3939
target_include_directories(${LIB_TARGET} SYSTEM
4040
INTERFACE ${REPOSITORY_ROOT}/c/
4141
${REPOSITORY_ROOT}/c/include/
42-
${REPOSITORY_ROOT}/c/vendor
4342
${REPOSITORY_ROOT}/c/driver)
4443
endforeach()
4544

@@ -61,12 +60,10 @@ if(ADBC_BUILD_TESTS)
6160
EXTRA_LINK_LIBS
6261
adbc_driver_common
6362
adbc_validation
64-
nanoarrow
6563
${TEST_LINK_LIBS})
6664
target_compile_features(adbc-driver-flightsql-test PRIVATE cxx_std_17)
6765
target_include_directories(adbc-driver-flightsql-test SYSTEM
6866
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
69-
${REPOSITORY_ROOT}/c/vendor
7067
${REPOSITORY_ROOT}/c/driver)
7168
adbc_configure_target(adbc-driver-flightsql-test)
7269
endif()

c/driver/framework/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ if(ADBC_BUILD_TESTS)
3434
SOURCES
3535
base_driver_test.cc
3636
EXTRA_LINK_LIBS
37-
adbc_driver_framework
38-
nanoarrow)
37+
adbc_driver_framework)
3938
target_compile_features(adbc-driver-framework-test PRIVATE cxx_std_17)
4039
target_include_directories(adbc-driver-framework-test
4140
PRIVATE "${REPOSITORY_ROOT}/c/"

c/driver/postgresql/CMakeLists.txt

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,18 @@ add_arrow_lib(adbc_driver_postgresql
4646
SHARED_LINK_LIBS
4747
adbc_driver_common
4848
adbc_driver_framework
49-
nanoarrow
5049
${LIBPQ_LINK_LIBRARIES}
5150
STATIC_LINK_LIBS
5251
${LIBPQ_LINK_LIBRARIES}
5352
adbc_driver_common
5453
adbc_driver_framework
55-
nanoarrow
5654
${LIBPQ_STATIC_LIBRARIES})
5755

5856
foreach(LIB_TARGET ${ADBC_LIBRARIES})
5957
target_compile_definitions(${LIB_TARGET} PRIVATE ADBC_EXPORTING)
6058
target_include_directories(${LIB_TARGET} SYSTEM
61-
PRIVATE ${REPOSITORY_ROOT}/c/
62-
${REPOSITORY_ROOT}/c/include/
63-
${LIBPQ_INCLUDE_DIRS}
64-
${REPOSITORY_ROOT}/c/vendor
65-
${REPOSITORY_ROOT}/c/driver)
59+
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
60+
${LIBPQ_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver)
6661
endforeach()
6762

6863
if(ADBC_TEST_LINKAGE STREQUAL "shared")
@@ -83,15 +78,11 @@ if(ADBC_BUILD_TESTS)
8378
EXTRA_LINK_LIBS
8479
adbc_driver_common
8580
adbc_validation
86-
nanoarrow
8781
${TEST_LINK_LIBS})
8882
target_compile_features(adbc-driver-postgresql-test PRIVATE cxx_std_17)
8983
target_include_directories(adbc-driver-postgresql-test SYSTEM
90-
PRIVATE ${REPOSITORY_ROOT}/c/
91-
${REPOSITORY_ROOT}/c/include/
92-
${LIBPQ_INCLUDE_DIRS}
93-
${REPOSITORY_ROOT}/c/vendor
94-
${REPOSITORY_ROOT}/c/driver)
84+
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
85+
${LIBPQ_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver)
9586
adbc_configure_target(adbc-driver-postgresql-test)
9687

9788
add_test_case(driver_postgresql_copy_test
@@ -105,15 +96,11 @@ if(ADBC_BUILD_TESTS)
10596
EXTRA_LINK_LIBS
10697
adbc_driver_common
10798
adbc_validation
108-
nanoarrow
10999
${TEST_LINK_LIBS})
110100
target_compile_features(adbc-driver-postgresql-copy-test PRIVATE cxx_std_17)
111101
target_include_directories(adbc-driver-postgresql-copy-test SYSTEM
112-
PRIVATE ${REPOSITORY_ROOT}/c/
113-
${REPOSITORY_ROOT}/c/include/
114-
${LIBPQ_INCLUDE_DIRS}
115-
${REPOSITORY_ROOT}/c/vendor
116-
${REPOSITORY_ROOT}/c/driver)
102+
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
103+
${LIBPQ_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver)
117104
adbc_configure_target(adbc-driver-postgresql-copy-test)
118105
endif()
119106

@@ -124,12 +111,10 @@ if(ADBC_BUILD_BENCHMARKS)
124111
EXTRA_LINK_LIBS
125112
adbc_driver_common
126113
adbc_validation
127-
nanoarrow
128114
${TEST_LINK_LIBS}
129115
benchmark::benchmark)
130116
# add_benchmark replaces _ with - when creating target
131117
target_include_directories(postgresql-benchmark
132118
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
133-
${REPOSITORY_ROOT}/c/vendor
134119
${REPOSITORY_ROOT}/c/driver)
135120
endif()

c/driver/snowflake/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ foreach(LIB_TARGET ${ADBC_LIBRARIES})
3939
target_include_directories(${LIB_TARGET} SYSTEM
4040
INTERFACE ${REPOSITORY_ROOT}/c/
4141
${REPOSITORY_ROOT}/c/include/
42-
${REPOSITORY_ROOT}/c/vendor
4342
${REPOSITORY_ROOT}/c/driver)
4443
endforeach()
4544

@@ -64,9 +63,7 @@ if(ADBC_BUILD_TESTS)
6463
${TEST_LINK_LIBS})
6564
target_compile_features(adbc-driver-snowflake-test PRIVATE cxx_std_17)
6665
target_include_directories(adbc-driver-snowflake-test SYSTEM
67-
PRIVATE ${REPOSITORY_ROOT}/c/
68-
${REPOSITORY_ROOT}/c/include/
69-
${REPOSITORY_ROOT}/c/vendor
66+
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
7067
${REPOSITORY_ROOT}/c/driver
7168
${REPOSITORY_ROOT}/c/driver/common)
7269
adbc_configure_target(adbc-driver-snowflake-test)

c/driver/sqlite/CMakeLists.txt

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,18 @@ add_arrow_lib(adbc_driver_sqlite
5252
${SQLite3_LINK_LIBRARIES}
5353
adbc_driver_common
5454
adbc_driver_framework
55-
nanoarrow
5655
STATIC_LINK_LIBS
5756
${SQLite3_LINK_LIBRARIES}
5857
adbc_driver_common
5958
adbc_driver_framework
60-
nanoarrow
6159
${LIBPQ_STATIC_LIBRARIES})
6260

6361
foreach(LIB_TARGET ${ADBC_LIBRARIES})
6462
target_compile_definitions(${LIB_TARGET} PRIVATE ADBC_EXPORTING
6563
${ADBC_SQLITE_COMPILE_DEFINES})
6664
target_include_directories(${LIB_TARGET} SYSTEM
67-
PRIVATE ${REPOSITORY_ROOT}/c/
68-
${REPOSITORY_ROOT}/c/include/
69-
${SQLite3_INCLUDE_DIRS}
70-
${REPOSITORY_ROOT}/c/vendor
71-
${REPOSITORY_ROOT}/c/driver)
65+
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
66+
${SQLite3_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver)
7267
endforeach()
7368

7469
include(CheckTypeSize)
@@ -92,16 +87,12 @@ if(ADBC_BUILD_TESTS)
9287
EXTRA_LINK_LIBS
9388
adbc_driver_common
9489
adbc_validation
95-
nanoarrow
9690
${TEST_LINK_LIBS})
9791
target_compile_definitions(adbc-driver-sqlite-test
9892
PRIVATE ${ADBC_SQLITE_COMPILE_DEFINES})
9993
target_compile_features(adbc-driver-sqlite-test PRIVATE cxx_std_17)
10094
target_include_directories(adbc-driver-sqlite-test SYSTEM
101-
PRIVATE ${REPOSITORY_ROOT}/c/
102-
${REPOSITORY_ROOT}/c/include/
103-
${LIBPQ_INCLUDE_DIRS}
104-
${REPOSITORY_ROOT}/c/vendor
105-
${REPOSITORY_ROOT}/c/driver)
95+
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
96+
${LIBPQ_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver)
10697
adbc_configure_target(adbc-driver-sqlite-test)
10798
endif()

c/driver_manager/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ if(ADBC_BUILD_TESTS)
6060
EXTRA_LINK_LIBS
6161
adbc_driver_common
6262
adbc_validation
63-
nanoarrow
6463
${TEST_LINK_LIBS})
6564
target_compile_features(adbc-driver-manager-test PRIVATE cxx_std_17)
66-
target_include_directories(adbc-driver-manager-test SYSTEM
67-
PRIVATE ${REPOSITORY_ROOT}/c/vendor/nanoarrow/)
6865

6966
add_test_case(version_100_compatibility_test
7067
PREFIX
@@ -76,9 +73,6 @@ if(ADBC_BUILD_TESTS)
7673
adbc_version_100_compatibility_test.cc
7774
EXTRA_LINK_LIBS
7875
adbc_validation_util
79-
nanoarrow
8076
${TEST_LINK_LIBS})
8177
target_compile_features(adbc-version-100-compatibility-test PRIVATE cxx_std_17)
82-
target_include_directories(adbc-version-100-compatibility-test SYSTEM
83-
PRIVATE ${REPOSITORY_ROOT}/c/vendor/nanoarrow/)
8478
endif()

0 commit comments

Comments
 (0)