From 4c3adcf77c6500868eb556b1b88c02868195e14c Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Tue, 12 Sep 2023 20:01:56 -0400 Subject: [PATCH] Fix find_path for newer jsoncpp installations * Could NOT find JSONCPP (missing: JSON_INCLUDE_DIR) fixed https://github.com/minetest/minetest/issues/9119 * imported from https://github.com/minetest/minetest/pull/9120 The upstream JsonCpp project has renamed the json/features.h file to json/json_features.h. This patch fixes the JsonCpp installation search by looking for json/allocator.h which has not been renamed on newer versions of JsonCpp. --- cmake/Modules/FindJson.cmake | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/FindJson.cmake b/cmake/Modules/FindJson.cmake index 26339a295..9d1c8c3b1 100644 --- a/cmake/Modules/FindJson.cmake +++ b/cmake/Modules/FindJson.cmake @@ -8,17 +8,21 @@ option(ENABLE_SYSTEM_JSONCPP "Enable using a system-wide JSONCPP. May cause seg if(ENABLE_SYSTEM_JSONCPP) find_library(JSON_LIBRARY NAMES jsoncpp) - find_path(JSON_INCLUDE_DIR json/features.h PATH_SUFFIXES jsoncpp) + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5) + find_path(JSON_INCLUDE_DIR json/features.h PATH_SUFFIXES jsoncpp) + else() + find_path(JSON_INCLUDE_DIR json/allocator.h PATH_SUFFIXES jsoncpp) + endif() include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(JSONCPP DEFAULT_MSG JSON_LIBRARY JSON_INCLUDE_DIR) + find_package_handle_standard_args(Json DEFAULT_MSG JSON_LIBRARY JSON_INCLUDE_DIR) - if(JSONCPP_FOUND) + if(JSON_FOUND) message(STATUS "Using system JSONCPP library.") endif() endif() -if(NOT JSONCPP_FOUND) +if(NOT JSON_FOUND) message(STATUS "Using bundled JSONCPP library.") set(JSON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/jsoncpp) set(JSON_LIBRARY jsoncpp)