Skip to content

Commit

Permalink
nlohmann
Browse files Browse the repository at this point in the history
  • Loading branch information
frs69wq committed Sep 16, 2024
1 parent 437ab6f commit d059588
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
45 changes: 45 additions & 0 deletions conf/cmake/Findnlohmann_json.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
include(FindPackageHandleStandardArgs)

# Look for the header file.
find_path(NLOHMANN_JSON_INCLUDE_DIR
NAMES
nlohmann/json.hpp
HINTS
"${NLOHMANN_JSON_LOCATION}/include"
"$ENV{NLOHMANN_JSON_LOCATION}/include"
PATHS
"$ENV{PROGRAMFILES}/nlohmann/include"
"$ENV{PROGRAMFILES}/nlohmann/json/include"
"$ENV{PROGRAMFILES}/nlohmann_json/include"
/usr/include/
/usr/local/include/
/opt/local/include/
/sw/include/
DOC
"The directory where headers files of nlohmann_json resides")
mark_as_advanced(NLOHMANN_JSON_INCLUDE_DIR)

if (NLOHMANN_JSON_INCLUDE_DIR)
# Tease the NLOHMANN_JSON_VERSION numbers from the lib headers
include(utils/ParseVersion)

parse_version(${NLOHMANN_JSON_INCLUDE_DIR} nlohmann/json.hpp NLOHMANN_JSON_VERSION_MAJOR)
parse_version(${NLOHMANN_JSON_INCLUDE_DIR} nlohmann/json.hpp NLOHMANN_JSON_VERSION_MINOR)
parse_version(${NLOHMANN_JSON_INCLUDE_DIR} nlohmann/json.hpp NLOHMANN_JSON_VERSION_PATCH)

set(NLOHMANN_JSON_VERSION "${NLOHMANN_JSON_VERSION_MAJOR}.${NLOHMANN_JSON_VERSION_MINOR}.${NLOHMANN_JSON_VERSION_PATCH}")
endif (NLOHMANN_JSON_INCLUDE_DIR)

find_package_handle_standard_args(nlohmann_json
REQUIRED_VARS NLOHMANN_JSON_INCLUDE_DIR
VERSION_VAR NLOHMANN_JSON_VERSION)

if (nlohmann_json_FOUND)
set(NLOHMANN_JSON_INCLUDE_DIRS ${NLOHMANN_JSON_INCLUDE_DIR})

if (NOT TARGET nlohmann::json)
add_library(nlohmann::json UNKNOWN IMPORTED)
set_target_properties(nlohmann::json PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${NLOHMANN_JSON_INCLUDE_DIRS}")
endif ()
endif ()
15 changes: 0 additions & 15 deletions conf/cmake/nlohmann_jsonConfig.cmake

This file was deleted.

0 comments on commit d059588

Please sign in to comment.