Skip to content
Snippets Groups Projects
Commit b5fc3409 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

FindJsonCpp: add version detection

parent 8798774b
No related branches found
No related tags found
No related merge requests found
......@@ -19,8 +19,21 @@ find_library(JsonCpp_LIBRARY
set(JsonCpp_INCLUDE_DIRS ${JsonCpp_INCLUDE_DIR})
set(JsonCpp_LIBRARIES "${JsonCpp_LIBRARY}")
set(_JsonCpp_version_args)
if (EXISTS "${JsonCpp_INCLUDE_DIR}/json/version.h")
file(STRINGS "${JsonCpp_INCLUDE_DIR}/json/version.h" _JsonCpp_version_contents REGEX "#\\s+define\\s+JSONCPP_VERSION_[A-Z]+")
foreach (_JsonCpp_version_part MAJOR MINOR PATCH)
string(REGEX REPLACE ".*#\\s*define ARMA_VERSION_${_JsonCpp_version_part}\\s+([0-9]+).*" "\\1" JsonCpp_VERSION_${_JsonCpp_version_part} "${_JsonCpp_version_contents}")
endforeach ()
set(JsonCpp_VERSION_STRING "${JsonCpp_VERSION_MAJOR}.${JsonCpp_VERSION_MINOR}.${JsonCpp_VERSION_PATCH}")
set(_JsonCpp_version_args VERSION_VAR JsonCpp_VERSION_STRING)
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(JsonCpp DEFAULT_MSG
JsonCpp_LIBRARIES JsonCpp_INCLUDE_DIRS)
JsonCpp_LIBRARIES JsonCpp_INCLUDE_DIRS
${_JsonCpp_version_args})
mark_as_advanced(JsonCpp_INCLUDE_DIR JsonCpp_LIBRARY)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment