FindJsonCpp: Add JsonCpp_VERSION

This also removes the JsonCpp_VERSION_STRING result variable, which
doesn't need to be deprecated and further provided by the module as this
is internal module.

Issue: #27088
This commit is contained in:
Peter Kokot
2025-08-17 08:15:13 +02:00
parent 392b4fc9aa
commit 2997d37adf
3 changed files with 11 additions and 11 deletions

View File

@@ -19,12 +19,8 @@ Result Variables
This module defines the following variables:
``JsonCpp_FOUND``
True if JsonCpp was found, false otherwise.
``JsonCpp_INCLUDE_DIRS``
Include directories needed to include JsonCpp headers.
``JsonCpp_LIBRARIES``
Libraries needed to link to JsonCpp.
``JsonCpp_VERSION_STRING``
Boolean indicating whether (the requested version of) JsonCpp was found.
``JsonCpp_VERSION``
The version of JsonCpp found.
May not be set for JsonCpp versions prior to 1.0.
``JsonCpp_VERSION_MAJOR``
@@ -33,6 +29,10 @@ This module defines the following variables:
The minor version of JsonCpp.
``JsonCpp_VERSION_PATCH``
The patch version of JsonCpp.
``JsonCpp_INCLUDE_DIRS``
Include directories needed to include JsonCpp headers.
``JsonCpp_LIBRARIES``
Libraries needed to link to JsonCpp.
Cache Variables
^^^^^^^^^^^^^^^
@@ -69,12 +69,12 @@ else()
set(_JsonCpp_H "")
endif()
if(_JsonCpp_H MATCHES "${_JsonCpp_H_REGEX}")
set(JsonCpp_VERSION_STRING "${CMAKE_MATCH_1}")
set(JsonCpp_VERSION "${CMAKE_MATCH_1}")
set(JsonCpp_VERSION_MAJOR "${CMAKE_MATCH_2}")
set(JsonCpp_VERSION_MINOR "${CMAKE_MATCH_3}")
set(JsonCpp_VERSION_PATCH "${CMAKE_MATCH_4}")
else()
set(JsonCpp_VERSION_STRING "")
set(JsonCpp_VERSION "")
set(JsonCpp_VERSION_MAJOR "")
set(JsonCpp_VERSION_MINOR "")
set(JsonCpp_VERSION_PATCH "")
@@ -86,7 +86,7 @@ unset(_JsonCpp_H)
include(${CMAKE_CURRENT_LIST_DIR}/../../Modules/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(JsonCpp
REQUIRED_VARS JsonCpp_LIBRARY JsonCpp_INCLUDE_DIR
VERSION_VAR JsonCpp_VERSION_STRING
VERSION_VAR JsonCpp_VERSION
)
#-----------------------------------------------------------------------------

View File

@@ -417,7 +417,7 @@ endif()
add_RunCMake_test(FeatureSummary)
add_RunCMake_test(FPHSA)
if(CMAKE_USE_SYSTEM_JSONCPP)
list(APPEND FileAPI_ARGS -DJsonCpp_VERSION_STRING=${JsonCpp_VERSION_STRING})
list(APPEND FileAPI_ARGS -DJsonCpp_VERSION=${JsonCpp_VERSION})
endif()
add_RunCMake_test(FileAPI -DPython_EXECUTABLE=${Python_EXECUTABLE}
-DCMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}

View File

@@ -124,7 +124,7 @@ if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo")
endif()
if(JsonCpp_VERSION_STRING AND JsonCpp_VERSION_STRING VERSION_LESS 1.7.5)
if(JsonCpp_VERSION AND JsonCpp_VERSION VERSION_LESS 1.7.5)
set(ENV{CMake_JSONCPP_PRE_1_7_5} 1)
endif()