From 6e0b0a15b5b3adf1c1a3e2960e5152ac29396cfa Mon Sep 17 00:00:00 2001 From: Yoshiki Matsuda Date: Sun, 17 Mar 2024 12:04:39 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Accept=20version=20in=20`find=5F?= =?UTF-8?q?and=5Flink`=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index acf298d..e46ad04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)