Skip to content

Commit

Permalink
Merge pull request #23 from 5cript/feat/dependency_find
Browse files Browse the repository at this point in the history
Updated how to find nlohmann.
  • Loading branch information
5cript authored Jul 7, 2024
2 parents 242e896 + 52cc60f commit f2f0378
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions cmake/dependencies/nlohmann_json.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
option(ROAR_FIND_NLOHMANN_JSON "Find nlohmann_json first before fetch content" ON)
option(ROAR_EXTERNAL_NLOHMANN_JSON "Use an external nlohmann_json library (provide it manually)" OFF)
set(ROAR_NLOHMANN_JSON_GIT_REPOSITORY "https://github.com/nlohmann/json.git" CACHE STRING "The URL from which to clone the nlohmann_json repository")
set(ROAR_NLOHMANN_JSON_GIT_TAG "8c391e04fe4195d8be862c97f38cfe10e2a3472e" CACHE STRING "The git tag or commit hash to checkout from the nlohmann_json repository")

if (ROAR_EXTERNAL_NLOHMANN_JSON)
function(roar_fetch_nlohmann_json)
if (ROAR_EXTERNAL_NLOHMANN_JSON)
else()
include(FetchContent)
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY ${ROAR_NLOHMANN_JSON_GIT_REPOSITORY}
GIT_TAG ${ROAR_NLOHMANN_JSON_GIT_TAG}
)

FetchContent_MakeAvailable(nlohmann_json)
endif()
endfunction()

if (ROAR_FIND_NLOHMANN_JSON)
find_package(nlohmann_json)

if (NOT nlohmann_json_FOUND)
roar_fetch_nlohmann_json()
endif()
else()
include(FetchContent)
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY ${ROAR_NLOHMANN_JSON_GIT_REPOSITORY}
GIT_TAG ${ROAR_NLOHMANN_JSON_GIT_TAG}
)

FetchContent_MakeAvailable(nlohmann_json)
roar_fetch_nlohmann_json()
endif()

0 comments on commit f2f0378

Please sign in to comment.