diff --git a/CMakeLists.txt b/CMakeLists.txt index 94f6d955..52d76549 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,13 +109,18 @@ if (REFLECTCPP_CBOR) list(APPEND REFLECT_CPP_SOURCES src/reflectcpp_cbor.cpp ) - target_include_directories(reflectcpp SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") - target_include_directories(reflectcpp SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/tinycbor") - if (MSVC) - target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/tinycbor${CMAKE_STATIC_LIBRARY_SUFFIX}") - else () - target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libtinycbor${CMAKE_STATIC_LIBRARY_SUFFIX}") - endif () + if(REFLECTCPP_USE_VCPKG) + target_include_directories(reflectcpp SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") + target_include_directories(reflectcpp SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/tinycbor") + if (MSVC) + target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/tinycbor${CMAKE_STATIC_LIBRARY_SUFFIX}") + else () + target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libtinycbor${CMAKE_STATIC_LIBRARY_SUFFIX}") + endif () + else() + find_package(tinycbor) + target_link_libraries(reflectcpp PUBLIC tinycbor::tinycbor) + endif() endif () if (REFLECTCPP_FLEXBUFFERS) @@ -131,30 +136,33 @@ if (REFLECTCPP_MSGPACK) src/reflectcpp_msgpack.cpp ) find_package(msgpack-c CONFIG REQUIRED) - if (MSVC) - target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/msgpack-c${CMAKE_STATIC_LIBRARY_SUFFIX}") - else () - target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libmsgpack-c${CMAKE_STATIC_LIBRARY_SUFFIX}") - endif () + target_link_libraries(reflectcpp PUBLIC msgpack-c) endif () if (REFLECTCPP_TOML) list(APPEND REFLECT_CPP_SOURCES src/reflectcpp_toml.cpp ) - target_include_directories(reflectcpp SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") - if (MSVC) - target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/tomlplusplus${CMAKE_STATIC_LIBRARY_SUFFIX}") - else () - target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libtomlplusplus${CMAKE_STATIC_LIBRARY_SUFFIX}") - endif () + if(REFLECTCPP_USE_VCPKG) + target_include_directories(reflectcpp SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") + if (MSVC) + target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/tomlplusplus${CMAKE_STATIC_LIBRARY_SUFFIX}") + else () + target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libtomlplusplus${CMAKE_STATIC_LIBRARY_SUFFIX}") + endif () + else() + find_package(tomlplusplus) + target_link_libraries(reflectcpp PUBLIC tomlplusplus::tomlplusplus) + endif() endif() if (REFLECTCPP_UBJSON) list(APPEND REFLECT_CPP_SOURCES src/reflectcpp_ubjson.cpp ) - target_include_directories(reflectcpp SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") + if(REFLECTCPP_USE_VCPKG) + target_include_directories(reflectcpp SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") + endif() find_package(jsoncons CONFIG REQUIRED) endif ()