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 6e0b0a1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 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(yyjson yyjson::yyjson 0.6.0)
find_and_link(fmt fmt::fmt-header-only 10.0.0)
find_and_link(nameof nameof::nameof 0.10.0)

# install
if(CPPYYJSON_IS_TOPLEVEL_PROJECT)
Expand Down

0 comments on commit 6e0b0a1

Please sign in to comment.