-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate third party libraries; resolves #79 #119
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ option(REFLECTCPP_YAML "Enable YAML support" OFF) | |
option(REFLECTCPP_BUILD_BENCHMARKS "Build benchmarks" OFF) | ||
option(REFLECTCPP_BUILD_TESTS "Build tests" OFF) | ||
|
||
option(REFLECTCPP_USE_BUNDLED_DEPENDENCIES "Use the bundled dependencies" ON) | ||
|
||
set(REFLECTCPP_USE_VCPKG_DEFAULT OFF) | ||
if (REFLECTCPP_BUILD_TESTS OR REFLECTCPP_BUILD_BENCHMARKS OR REFLECTCPP_BSON OR REFLECTCPP_CBOR OR REFLECTCPP_FLEXBUFFERS OR REFLECTCPP_MSGPACK OR REFLECTCPP_XML OR REFLECTCPP_TOML OR REFLECTCPP_YAML) | ||
# enable vcpkg per default if require features other than JSON | ||
|
@@ -29,15 +31,32 @@ project(reflectcpp) | |
|
||
set(CMAKE_CXX_STANDARD 20) | ||
|
||
if (REFLECTCPP_BUILD_SHARED) | ||
add_library(reflectcpp SHARED src/yyjson.c) | ||
else () | ||
add_library(reflectcpp STATIC src/yyjson.c) | ||
endif () | ||
if(REFLECTCPP_USE_BUNDLED_DEPENDENCIES) | ||
if (REFLECTCPP_BUILD_SHARED) | ||
add_library(reflectcpp SHARED src/yyjson.c) | ||
else() | ||
add_library(reflectcpp STATIC src/yyjson.c) | ||
endif() | ||
else() | ||
if (REFLECTCPP_BUILD_SHARED) | ||
add_library(reflectcpp SHARED) | ||
else() | ||
add_library(reflectcpp STATIC) | ||
endif() | ||
endif() | ||
|
||
set_target_properties(reflectcpp PROPERTIES LINKER_LANGUAGE CXX) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead, probably could use the But setting it just to // yyjson.cpp
extern C {
#include "yyjson.c"
} Quick test shows, that at least clangd is happy with it, and uses the right compiler and flags. |
||
target_compile_features(reflectcpp PUBLIC cxx_std_20) | ||
|
||
target_include_directories(reflectcpp PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> ) | ||
if(REFLECTCPP_USE_BUNDLED_DEPENDENCIES) | ||
target_include_directories(reflectcpp PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/rfl/thirdparty>) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the |
||
else() | ||
target_include_directories(reflectcpp PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> ) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DREFLECTCPP_NO_BUNDLED_DEPENDENCIES") | ||
find_package(ctre CONFIG REQUIRED) | ||
find_package(yyjson CONFIG REQUIRED) | ||
target_link_libraries(reflectcpp INTERFACE yyjson::yyjson) | ||
endif() | ||
|
||
if (REFLECTCPP_BSON OR REFLECTCPP_BUILD_BENCHMARKS) | ||
find_package(bson-1.0 CONFIG REQUIRED) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably instead of
SHARED
orSTATIC
,INTERFACE
would be the choice for Header-Only-Libhttps://cmake.org/cmake/help/latest/command/add_library.html#interface-libraries