Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
71 changes: 45 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@
if (REFLECTCPP_BUILD_SHARED)
add_library(reflectcpp SHARED)
set_target_properties(reflectcpp PROPERTIES SOVERSION ${PROJECT_VERSION})
set(linkage_type shared)
else()
add_library(reflectcpp STATIC)
set(linkage_type static)
endif()

add_library(reflectcpp::reflectcpp ALIAS reflectcpp)
Expand Down Expand Up @@ -275,10 +277,20 @@
list(APPEND REFLECT_CPP_SOURCES
src/reflectcpp_bson.cpp
)
if (NOT TARGET mongo::bson_static AND NOT TARGET mongo::bson_shared)
find_package(bson-1.0 CONFIG REQUIRED)
endif ()
target_link_libraries(reflectcpp PUBLIC $<IF:$<TARGET_EXISTS:mongo::bson_static>,mongo::bson_static,mongo::bson_shared>)

find_package(bson 1.25.1 CONFIG REQUIRED NAMES bson bson-1.0)

# The package and target names have changed since v2
# https://github.com/mongodb/mongo-c-driver/releases/tag/2.0.0
set(bson_lib bson::${linkage_type})
if(NOT TARGET "${bson_lib}")
set(bson_lib mongo::bson_${linkage_type})
if(NOT TARGET "${bson_lib}")
message(FATAL_ERROR "Could not find a suitable libbson target")

Check failure on line 289 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / windows-msvc (benchmarks)

Could not find a suitable libbson target
endif()
endif()

target_link_libraries(reflectcpp PUBLIC "${bson_lib}")
endif ()

if (REFLECTCPP_CAPNPROTO OR REFLECTCPP_CHECK_HEADERS)
Expand Down Expand Up @@ -306,50 +318,57 @@
include_directories(PUBLIC ${jsoncons_INCLUDE_DIRS})
endif ()

set(arrow_lib Arrow::arrow_${linkage_type})
if (REFLECTCPP_CSV OR REFLECTCPP_CHECK_HEADERS)
if (NOT TARGET Arrow)
if (NOT TARGET "${arrow_lib}")
find_package(Arrow CONFIG REQUIRED)
endif()
if (REFLECTCPP_USE_VCPKG)
target_link_libraries(reflectcpp PUBLIC "$<IF:$<BOOL:${ARROW_BUILD_STATIC}>,Arrow::arrow_static,Arrow::arrow_shared>")
else()
target_link_libraries(reflectcpp PUBLIC "arrow::arrow")
endif()

target_link_libraries(reflectcpp PUBLIC "${arrow_lib}")
endif ()

if (REFLECTCPP_FLEXBUFFERS OR REFLECTCPP_CHECK_HEADERS)
list(APPEND REFLECT_CPP_SOURCES
src/reflectcpp_flexbuf.cpp
)
if (NOT TARGET flatbuffers::flatbuffers)
find_package(flatbuffers CONFIG REQUIRED)
endif ()
target_link_libraries(reflectcpp PUBLIC flatbuffers::flatbuffers)

find_package(flatbuffers CONFIG REQUIRED)

set(flatbuf_lib flatbuffers::flatbuffers)
if(REFLECTCPP_BUILD_SHARED AND TARGET flatbuffers::flatbuffers_shared)
set(flatbuf_lib flatbuffers::flatbuffers_shared)
endif()

target_link_libraries(reflectcpp PUBLIC "${flatbuf_lib}")
endif ()

if (REFLECTCPP_MSGPACK OR REFLECTCPP_CHECK_HEADERS)
list(APPEND REFLECT_CPP_SOURCES
src/reflectcpp_msgpack.cpp
)
if (NOT TARGET msgpack-c)
find_package(msgpack-c CONFIG REQUIRED NAMES msgpack msgpack-c msgpackc)

find_package(msgpack-c CONFIG REQUIRED NAMES msgpack-c msgpack msgpackc)

if(NOT REFLECTCPP_BUILD_SHARED AND TARGET msgpack-c-static)
target_link_libraries(reflectcpp PUBLIC msgpack-c-static)
else()
target_link_libraries(reflectcpp PUBLIC msgpack-c)
endif()
target_link_libraries(reflectcpp PUBLIC $<IF:$<TARGET_EXISTS:msgpack-c>,msgpack-c,$<IF:$<TARGET_EXISTS:msgpackc>,msgpackc,msgpack-c>>)
endif ()

set(parquet_lib Parquet::parquet_${linkage_type})
if (REFLECTCPP_PARQUET OR REFLECTCPP_CHECK_HEADERS)
if (NOT TARGET Arrow)
if (NOT TARGET "${arrow_lib}")
find_package(Arrow CONFIG REQUIRED)
endif()
if (REFLECTCPP_USE_VCPKG)
if (NOT TARGET Parquet)
find_package(Parquet CONFIG REQUIRED)
endif()
target_link_libraries(reflectcpp PUBLIC "$<IF:$<BOOL:${ARROW_BUILD_STATIC}>,Arrow::arrow_static,Arrow::arrow_shared>")
target_link_libraries(reflectcpp PUBLIC "$<IF:$<BOOL:${ARROW_BUILD_STATIC}>,Parquet::parquet_static,Parquet::parquet_shared>")
else()
target_link_libraries(reflectcpp PUBLIC "arrow::arrow")

if (NOT TARGET "${parquet_lib}")
find_package(Parquet CONFIG REQUIRED
NAMES Parquet Arrow # Conan merges the Parquet package into Arrow
)
endif()

target_link_libraries(reflectcpp PUBLIC "${arrow_lib}" "${parquet_lib}")

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (PARQUET-C++20-gcc-11)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (benchmarks-C++20-gcc-13)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (PARQUET-C++23-llvm-18)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (benchmarks-C++20-gcc-14)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (headers-C++23-llvm-18)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (benchmarks-C++20-gcc-11)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (PARQUET-C++20-gcc-14)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (PARQUET-C++23-gcc-14)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (benchmarks-C++20-llvm-17)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (benchmarks-C++23-llvm-18)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (PARQUET-C++20-gcc-13)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (benchmarks-C++20-llvm-16)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (benchmarks-C++20-llvm-18)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (PARQUET-C++20-llvm-16)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (benchmarks-C++20-gcc-12)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (headers-C++20-gcc-11)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (PARQUET-C++20-llvm-18)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (headers-C++20-llvm-18)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (benchmarks-C++23-gcc-14)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (headers-C++20-gcc-13)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (PARQUET-C++20-llvm-17)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (headers-C++20-gcc-12)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (headers-C++20-gcc-14)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (headers-C++20-llvm-16)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / (headers-C++20-llvm-17)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / windows-msvc-shared (PARQUET)

Target "reflectcpp" links to:

Check failure on line 371 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / windows-msvc (PARQUET)

Target "reflectcpp" links to:
endif ()

if (REFLECTCPP_TOML OR REFLECTCPP_CHECK_HEADERS)
Expand Down
1 change: 1 addition & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def requirements(self):
self.requires("jsoncons/0.176.0", transitive_headers=True)
if self.options.with_csv or self.options.with_parquet:
self.requires("arrow/21.0.0", transitive_headers=True)
self.default_options["arrow/*:with_csv"] = self.options.with_csv
if self.options.with_flatbuffers:
self.requires("flatbuffers/24.3.25", transitive_headers=True)
if self.options.with_msgpack:
Expand Down
6 changes: 3 additions & 3 deletions reflectcpp-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if ((REFLECTCPP_JSON OR REFLECTCPP_AVRO OR REFLECTCPP_CBOR OR REFLECTCPP_UBJSON)
endif()

if (REFLECTCPP_BSON)
find_dependency(bson-1.0)
find_dependency(bson 1.25.1 NAMES bson bson-1.0)
endif ()

if (REFLECTCPP_CAPNPROTO)
Expand All @@ -49,12 +49,12 @@ if (REFLECTCPP_FLEXBUFFERS)
endif ()

if (REFLECTCPP_MSGPACK)
find_dependency(msgpack-c)
find_dependency(msgpack-c NAMES msgpack-c msgpack msgpackc)
endif()

if (REFLECTCPP_PARQUET)
find_dependency(Arrow)
find_dependency(Parquet)
find_dependency(Parquet NAMES Parquet Arrow)
endif()

if (REFLECTCPP_TOML)
Expand Down
Loading