diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt index be69103d06..746547636c 100644 --- a/c/CMakeLists.txt +++ b/c/CMakeLists.txt @@ -29,9 +29,17 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include(CTest) -add_subdirectory(vendor/fmt EXCLUDE_FROM_ALL) -set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE ON) -add_subdirectory(vendor/nanoarrow) +if(ADBC_WITH_VENDORED_FMT) + add_subdirectory(vendor/fmt EXCLUDE_FROM_ALL) + set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE ON) +else() + find_package(fmt REQUIRED) +endif() +if(ADBC_WITH_VENDORED_NANOARROW) + add_subdirectory(vendor/nanoarrow) +else() + find_package(nanoarrow REQUIRED) +endif() add_subdirectory(driver/common) add_subdirectory(driver/framework) diff --git a/c/cmake_modules/DefineOptions.cmake b/c/cmake_modules/DefineOptions.cmake index 13e6757347..c022d523a1 100644 --- a/c/cmake_modules/DefineOptions.cmake +++ b/c/cmake_modules/DefineOptions.cmake @@ -133,6 +133,10 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") define_option(ADBC_GGDB_DEBUG "Pass -ggdb flag to debug builds" ON) + define_option(ADBC_WITH_VENDORED_FMT "Use vendored copy of fmt" ON) + + define_option(ADBC_WITH_VENDORED_NANOARROW "Use vendored copy of nanoarrow" ON) + #---------------------------------------------------------------------- set_option_category("Test and benchmark") diff --git a/c/driver/bigquery/CMakeLists.txt b/c/driver/bigquery/CMakeLists.txt index fe3937878a..990f44d87f 100644 --- a/c/driver/bigquery/CMakeLists.txt +++ b/c/driver/bigquery/CMakeLists.txt @@ -36,7 +36,6 @@ add_go_lib("${REPOSITORY_ROOT}/go/adbc/pkg/bigquery/" foreach(LIB_TARGET ${ADBC_LIBRARIES}) target_include_directories(${LIB_TARGET} SYSTEM INTERFACE ${REPOSITORY_ROOT} ${REPOSITORY_ROOT}/c/ - ${REPOSITORY_ROOT}/c/vendor ${REPOSITORY_ROOT}/c/driver) endforeach() @@ -57,13 +56,10 @@ if(ADBC_BUILD_TESTS) EXTRA_LINK_LIBS adbc_driver_common adbc_validation - nanoarrow ${TEST_LINK_LIBS}) target_compile_features(adbc-driver-bigquery-test PRIVATE cxx_std_17) target_include_directories(adbc-driver-bigquery-test SYSTEM - PRIVATE ${REPOSITORY_ROOT}/c/ - ${REPOSITORY_ROOT}/c/include/ - ${REPOSITORY_ROOT}/c/vendor + PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/ ${REPOSITORY_ROOT}/c/driver ${REPOSITORY_ROOT}/c/driver/common) adbc_configure_target(adbc-driver-bigquery-test) diff --git a/c/driver/common/CMakeLists.txt b/c/driver/common/CMakeLists.txt index 751eda3632..5855056bb4 100644 --- a/c/driver/common/CMakeLists.txt +++ b/c/driver/common/CMakeLists.txt @@ -18,8 +18,8 @@ add_library(adbc_driver_common STATIC utils.c) adbc_configure_target(adbc_driver_common) set_target_properties(adbc_driver_common PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_include_directories(adbc_driver_common PRIVATE "${REPOSITORY_ROOT}/c/include" - "${REPOSITORY_ROOT}/c/vendor") +target_include_directories(adbc_driver_common PRIVATE "${REPOSITORY_ROOT}/c/include") +target_link_libraries(adbc_driver_common PUBLIC nanoarrow::nanoarrow) if(ADBC_BUILD_TESTS) add_test_case(driver_common_test @@ -30,11 +30,9 @@ if(ADBC_BUILD_TESTS) SOURCES utils_test.cc EXTRA_LINK_LIBS - adbc_driver_common - nanoarrow) + adbc_driver_common) target_compile_features(adbc-driver-common-test PRIVATE cxx_std_17) target_include_directories(adbc-driver-common-test - PRIVATE "${REPOSITORY_ROOT}/c/include" - "${REPOSITORY_ROOT}/c/vendor") + PRIVATE "${REPOSITORY_ROOT}/c/include") adbc_configure_target(adbc-driver-common-test) endif() diff --git a/c/driver/flightsql/CMakeLists.txt b/c/driver/flightsql/CMakeLists.txt index 1101b82430..c946566f16 100644 --- a/c/driver/flightsql/CMakeLists.txt +++ b/c/driver/flightsql/CMakeLists.txt @@ -37,7 +37,6 @@ foreach(LIB_TARGET ${ADBC_LIBRARIES}) target_include_directories(${LIB_TARGET} SYSTEM INTERFACE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/ - ${REPOSITORY_ROOT}/c/vendor ${REPOSITORY_ROOT}/c/driver) endforeach() @@ -59,12 +58,10 @@ if(ADBC_BUILD_TESTS) EXTRA_LINK_LIBS adbc_driver_common adbc_validation - nanoarrow ${TEST_LINK_LIBS}) target_compile_features(adbc-driver-flightsql-test PRIVATE cxx_std_17) target_include_directories(adbc-driver-flightsql-test SYSTEM PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/ - ${REPOSITORY_ROOT}/c/vendor ${REPOSITORY_ROOT}/c/driver) adbc_configure_target(adbc-driver-flightsql-test) endif() diff --git a/c/driver/framework/CMakeLists.txt b/c/driver/framework/CMakeLists.txt index f5c642b532..fa2e03b978 100644 --- a/c/driver/framework/CMakeLists.txt +++ b/c/driver/framework/CMakeLists.txt @@ -34,8 +34,7 @@ if(ADBC_BUILD_TESTS) SOURCES base_driver_test.cc EXTRA_LINK_LIBS - adbc_driver_framework - nanoarrow) + adbc_driver_framework) target_compile_features(adbc-driver-framework-test PRIVATE cxx_std_17) target_include_directories(adbc-driver-framework-test PRIVATE "${REPOSITORY_ROOT}/c/" diff --git a/c/driver/postgresql/CMakeLists.txt b/c/driver/postgresql/CMakeLists.txt index a720696c6a..92c4c9f92d 100644 --- a/c/driver/postgresql/CMakeLists.txt +++ b/c/driver/postgresql/CMakeLists.txt @@ -46,23 +46,18 @@ add_arrow_lib(adbc_driver_postgresql SHARED_LINK_LIBS adbc_driver_common adbc_driver_framework - nanoarrow ${LIBPQ_LINK_LIBRARIES} STATIC_LINK_LIBS ${LIBPQ_LINK_LIBRARIES} adbc_driver_common adbc_driver_framework - nanoarrow ${LIBPQ_STATIC_LIBRARIES}) foreach(LIB_TARGET ${ADBC_LIBRARIES}) target_compile_definitions(${LIB_TARGET} PRIVATE ADBC_EXPORTING) target_include_directories(${LIB_TARGET} SYSTEM - PRIVATE ${REPOSITORY_ROOT}/c/ - ${REPOSITORY_ROOT}/c/include/ - ${LIBPQ_INCLUDE_DIRS} - ${REPOSITORY_ROOT}/c/vendor - ${REPOSITORY_ROOT}/c/driver) + PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/ + ${LIBPQ_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver) endforeach() if(ADBC_TEST_LINKAGE STREQUAL "shared") @@ -83,15 +78,11 @@ if(ADBC_BUILD_TESTS) EXTRA_LINK_LIBS adbc_driver_common adbc_validation - nanoarrow ${TEST_LINK_LIBS}) target_compile_features(adbc-driver-postgresql-test PRIVATE cxx_std_17) target_include_directories(adbc-driver-postgresql-test SYSTEM - PRIVATE ${REPOSITORY_ROOT}/c/ - ${REPOSITORY_ROOT}/c/include/ - ${LIBPQ_INCLUDE_DIRS} - ${REPOSITORY_ROOT}/c/vendor - ${REPOSITORY_ROOT}/c/driver) + PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/ + ${LIBPQ_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver) adbc_configure_target(adbc-driver-postgresql-test) add_test_case(driver_postgresql_copy_test @@ -105,15 +96,11 @@ if(ADBC_BUILD_TESTS) EXTRA_LINK_LIBS adbc_driver_common adbc_validation - nanoarrow ${TEST_LINK_LIBS}) target_compile_features(adbc-driver-postgresql-copy-test PRIVATE cxx_std_17) target_include_directories(adbc-driver-postgresql-copy-test SYSTEM - PRIVATE ${REPOSITORY_ROOT}/c/ - ${REPOSITORY_ROOT}/c/include/ - ${LIBPQ_INCLUDE_DIRS} - ${REPOSITORY_ROOT}/c/vendor - ${REPOSITORY_ROOT}/c/driver) + PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/ + ${LIBPQ_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver) adbc_configure_target(adbc-driver-postgresql-copy-test) endif() @@ -124,12 +111,10 @@ if(ADBC_BUILD_BENCHMARKS) EXTRA_LINK_LIBS adbc_driver_common adbc_validation - nanoarrow ${TEST_LINK_LIBS} benchmark::benchmark) # add_benchmark replaces _ with - when creating target target_include_directories(postgresql-benchmark PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/ - ${REPOSITORY_ROOT}/c/vendor ${REPOSITORY_ROOT}/c/driver) endif() diff --git a/c/driver/snowflake/CMakeLists.txt b/c/driver/snowflake/CMakeLists.txt index 1d3874b41f..4d36876856 100644 --- a/c/driver/snowflake/CMakeLists.txt +++ b/c/driver/snowflake/CMakeLists.txt @@ -37,7 +37,6 @@ foreach(LIB_TARGET ${ADBC_LIBRARIES}) target_include_directories(${LIB_TARGET} SYSTEM INTERFACE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/ - ${REPOSITORY_ROOT}/c/vendor ${REPOSITORY_ROOT}/c/driver) endforeach() @@ -62,9 +61,7 @@ if(ADBC_BUILD_TESTS) ${TEST_LINK_LIBS}) target_compile_features(adbc-driver-snowflake-test PRIVATE cxx_std_17) target_include_directories(adbc-driver-snowflake-test SYSTEM - PRIVATE ${REPOSITORY_ROOT}/c/ - ${REPOSITORY_ROOT}/c/include/ - ${REPOSITORY_ROOT}/c/vendor + PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/ ${REPOSITORY_ROOT}/c/driver ${REPOSITORY_ROOT}/c/driver/common) adbc_configure_target(adbc-driver-snowflake-test) diff --git a/c/driver/sqlite/CMakeLists.txt b/c/driver/sqlite/CMakeLists.txt index d0c45b7433..1b097546cd 100644 --- a/c/driver/sqlite/CMakeLists.txt +++ b/c/driver/sqlite/CMakeLists.txt @@ -52,23 +52,18 @@ add_arrow_lib(adbc_driver_sqlite ${SQLite3_LINK_LIBRARIES} adbc_driver_common adbc_driver_framework - nanoarrow STATIC_LINK_LIBS ${SQLite3_LINK_LIBRARIES} adbc_driver_common adbc_driver_framework - nanoarrow ${LIBPQ_STATIC_LIBRARIES}) foreach(LIB_TARGET ${ADBC_LIBRARIES}) target_compile_definitions(${LIB_TARGET} PRIVATE ADBC_EXPORTING ${ADBC_SQLITE_COMPILE_DEFINES}) target_include_directories(${LIB_TARGET} SYSTEM - PRIVATE ${REPOSITORY_ROOT}/c/ - ${REPOSITORY_ROOT}/c/include/ - ${SQLite3_INCLUDE_DIRS} - ${REPOSITORY_ROOT}/c/vendor - ${REPOSITORY_ROOT}/c/driver) + PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/ + ${SQLite3_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver) endforeach() include(CheckTypeSize) @@ -92,16 +87,12 @@ if(ADBC_BUILD_TESTS) EXTRA_LINK_LIBS adbc_driver_common adbc_validation - nanoarrow ${TEST_LINK_LIBS}) target_compile_definitions(adbc-driver-sqlite-test PRIVATE ${ADBC_SQLITE_COMPILE_DEFINES}) target_compile_features(adbc-driver-sqlite-test PRIVATE cxx_std_17) target_include_directories(adbc-driver-sqlite-test SYSTEM - PRIVATE ${REPOSITORY_ROOT}/c/ - ${REPOSITORY_ROOT}/c/include/ - ${LIBPQ_INCLUDE_DIRS} - ${REPOSITORY_ROOT}/c/vendor - ${REPOSITORY_ROOT}/c/driver) + PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/ + ${LIBPQ_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver) adbc_configure_target(adbc-driver-sqlite-test) endif() diff --git a/c/driver_manager/CMakeLists.txt b/c/driver_manager/CMakeLists.txt index 0eb17f0c8d..11582f86e3 100644 --- a/c/driver_manager/CMakeLists.txt +++ b/c/driver_manager/CMakeLists.txt @@ -60,11 +60,8 @@ if(ADBC_BUILD_TESTS) EXTRA_LINK_LIBS adbc_driver_common adbc_validation - nanoarrow ${TEST_LINK_LIBS}) target_compile_features(adbc-driver-manager-test PRIVATE cxx_std_17) - target_include_directories(adbc-driver-manager-test SYSTEM - PRIVATE ${REPOSITORY_ROOT}/c/vendor/nanoarrow/) add_test_case(version_100_compatibility_test PREFIX @@ -76,9 +73,6 @@ if(ADBC_BUILD_TESTS) adbc_version_100_compatibility_test.cc EXTRA_LINK_LIBS adbc_validation_util - nanoarrow ${TEST_LINK_LIBS}) target_compile_features(adbc-version-100-compatibility-test PRIVATE cxx_std_17) - target_include_directories(adbc-version-100-compatibility-test SYSTEM - PRIVATE ${REPOSITORY_ROOT}/c/vendor/nanoarrow/) endif() diff --git a/c/integration/duckdb/CMakeLists.txt b/c/integration/duckdb/CMakeLists.txt index 9065450b0d..2073a34fec 100644 --- a/c/integration/duckdb/CMakeLists.txt +++ b/c/integration/duckdb/CMakeLists.txt @@ -63,13 +63,11 @@ if(ADBC_BUILD_TESTS) adbc_driver_common adbc_driver_manager_static adbc_validation - duckdb - nanoarrow) + duckdb) add_dependencies(adbc-integration-duckdb-test duckdb) target_compile_features(adbc-integration-duckdb-test PRIVATE cxx_std_17) target_include_directories(adbc-integration-duckdb-test SYSTEM PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/ - ${REPOSITORY_ROOT}/c/vendor ${REPOSITORY_ROOT}/c/driver) adbc_configure_target(adbc-integration-duckdb-test) endif() diff --git a/c/validation/CMakeLists.txt b/c/validation/CMakeLists.txt index 04bc0115aa..02362259f5 100644 --- a/c/validation/CMakeLists.txt +++ b/c/validation/CMakeLists.txt @@ -20,23 +20,16 @@ adbc_configure_target(adbc_validation_util) target_compile_features(adbc_validation_util PRIVATE cxx_std_17) target_include_directories(adbc_validation_util SYSTEM PRIVATE "${REPOSITORY_ROOT}/c/include/" - "${REPOSITORY_ROOT}/c/driver/" - "${REPOSITORY_ROOT}/c/vendor/") -target_link_libraries(adbc_validation_util PUBLIC adbc_driver_common nanoarrow - GTest::gtest GTest::gmock) + "${REPOSITORY_ROOT}/c/driver/") +target_link_libraries(adbc_validation_util PUBLIC adbc_driver_common GTest::gtest + GTest::gmock) add_library(adbc_validation OBJECT adbc_validation.cc adbc_validation_connection.cc adbc_validation_database.cc adbc_validation_statement.cc) adbc_configure_target(adbc_validation) target_compile_features(adbc_validation PRIVATE cxx_std_17) -target_include_directories(adbc_validation SYSTEM - PRIVATE "${REPOSITORY_ROOT}/c/include/" - "${REPOSITORY_ROOT}/c/driver/" - "${REPOSITORY_ROOT}/c/vendor/") -target_link_libraries(adbc_validation - PUBLIC adbc_driver_common - adbc_validation_util - nanoarrow - GTest::gtest - GTest::gmock) +target_include_directories(adbc_validation SYSTEM PRIVATE "${REPOSITORY_ROOT}/c/include/" + "${REPOSITORY_ROOT}/c/driver/") +target_link_libraries(adbc_validation PUBLIC adbc_driver_common adbc_validation_util + GTest::gtest GTest::gmock) diff --git a/c/vendor/nanoarrow/CMakeLists.txt b/c/vendor/nanoarrow/CMakeLists.txt index 233f999c7f..978dc14059 100644 --- a/c/vendor/nanoarrow/CMakeLists.txt +++ b/c/vendor/nanoarrow/CMakeLists.txt @@ -21,6 +21,8 @@ add_library( nanoarrow.c ) +target_include_directories(nanoarrow PUBLIC "${CMAKE_CURRENT_LIST_DIR}/..") set_target_properties( nanoarrow PROPERTIES POSITION_INDEPENDENT_CODE ON ) +add_library(nanoarrow::nanoarrow ALIAS nanoarrow)