Skip to content

Commit

Permalink
🔧 Accept version in find_and_link function
Browse files Browse the repository at this point in the history
  • Loading branch information
yosh-matsuda committed Mar 17, 2024
1 parent c55ef99 commit 2f679f2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,18 @@ endif()

# dependencies
function(find_and_link package_name qualified_name)
if(NOT TARGET ${package_name})
find_package(${package_name} CONFIG REQUIRED)
cmake_parse_arguments(FIND_AND_LINK "" "VERSION" "" ${ARGN})
if(NOT TARGET ${package_name} OR CPPYYJSON_IS_TOPLEVEL_PROJECT)
find_package(${package_name} ${FIND_AND_LINK_VERSION} CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} INTERFACE ${qualified_name})
else()
target_link_libraries(${PROJECT_NAME} INTERFACE ${package_name})
endif()
endfunction()

find_and_link(yyjson yyjson::yyjson)
find_and_link(fmt fmt::fmt-header-only)
find_and_link(nameof nameof::nameof)
find_and_link(fmt fmt::fmt-header-only VERSION 10.0.0)
find_and_link(nameof nameof::nameof VERSION 0.10.0)

# install
if(CPPYYJSON_IS_TOPLEVEL_PROJECT)
Expand Down

0 comments on commit 2f679f2

Please sign in to comment.