yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

Add version check to Findnlohmann_json.cmake

This commit is contained in:
Markus Wick 2020-05-09 11:46:03 +02:00
parent c96a8867f0
commit 290bc20e79
1 changed files with 14 additions and 0 deletions

View File

@ -8,11 +8,25 @@ find_path(nlohmann_json_INCLUDE_DIR
PATH_SUFFIXES nlohmann PATH_SUFFIXES nlohmann
) )
if(nlohmann_json_INCLUDE_DIR)
file(STRINGS "${nlohmann_json_INCLUDE_DIR}/json.hpp" _nlohmann_json_version_lines
REGEX "#define[ \t]+NLOHMANN_JSON_VERSION_(MAJOR|MINOR|PATCH)")
string(REGEX REPLACE ".*NLOHMANN_JSON_VERSION_MAJOR +\([0-9]+\).*" "\\1" _nlohmann_json_version_major "${_nlohmann_json_version_lines}")
string(REGEX REPLACE ".*NLOHMANN_JSON_VERSION_MINOR +\([0-9]+\).*" "\\1" _nlohmann_json_version_minor "${_nlohmann_json_version_lines}")
string(REGEX REPLACE ".*NLOHMANN_JSON_VERSION_PATCH +\([0-9]+\).*" "\\1" _nlohmann_json_version_patch "${_nlohmann_json_version_lines}")
set(nlohmann_json_VERSION "${_nlohmann_json_version_major}.${_nlohmann_json_version_minor}.${_nlohmann_json_version_patch}")
unset(_nlohmann_json_version_major)
unset(_nlohmann_json_version_minor)
unset(_nlohmann_json_version_patch)
unset(_nlohmann_json_version_lines)
endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(nlohmann_json find_package_handle_standard_args(nlohmann_json
FOUND_VAR nlohmann_json_FOUND FOUND_VAR nlohmann_json_FOUND
REQUIRED_VARS REQUIRED_VARS
nlohmann_json_INCLUDE_DIR nlohmann_json_INCLUDE_DIR
nlohmann_json_VERSION
VERSION_VAR nlohmann_json_VERSION VERSION_VAR nlohmann_json_VERSION
) )