Skip to content

Commit

Permalink
Fixed dependencies in the CMakeLists.txt so they work with packages f…
Browse files Browse the repository at this point in the history
…rom sources other than vcpkg (#273)
  • Loading branch information
liuzicheng1987 authored Nov 23, 2024
1 parent e34440c commit 385241f
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 ()

Expand Down

0 comments on commit 385241f

Please sign in to comment.