do not fetch nlohmann_json if it already added in main project (#287)

This commit is contained in:
andrejlevkovitch 2023-09-22 16:12:57 +02:00 committed by GitHub
parent 79535fe0b6
commit 0be4d4c4b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,16 +80,17 @@ endif ()
]==============================================================================================] ]==============================================================================================]
set(fetch_packages "") set(fetch_packages "")
# Fetch/Find nlohmann_json if (NOT TARGET nlohmann_json)
# TODO: Remove when bumping cmake >= 3.24 # Fetch/Find nlohmann_json
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) # TODO: Remove when bumping cmake >= 3.24
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
FetchContent_Declare(nlohmann_json FetchContent_Declare(nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json GIT_REPOSITORY https://github.com/nlohmann/json
GIT_TAG ${JSON_FETCH_VERSION} GIT_TAG ${JSON_FETCH_VERSION}
FIND_PACKAGE_ARGS FIND_PACKAGE_ARGS
) )
list(APPEND fetch_packages nlohmann_json) list(APPEND fetch_packages nlohmann_json)
else () else ()
# Try to get system installed version # Try to get system installed version
find_package(nlohmann_json QUIET) find_package(nlohmann_json QUIET)
if (NOT nlohmann_json_FOUND) if (NOT nlohmann_json_FOUND)
@ -100,6 +101,7 @@ else ()
) )
list(APPEND fetch_packages nlohmann_json) list(APPEND fetch_packages nlohmann_json)
endif () endif ()
endif ()
endif () endif ()
# Handle configure flags # Handle configure flags