From b2d661ad2d1a62e2f775650c5006392af6320521 Mon Sep 17 00:00:00 2001 From: fuzzard Date: Sun, 12 May 2024 13:46:05 +1000 Subject: [cmake][modules] FindRapidJSON cleanup and use core_target_link_libraries --- cmake/modules/FindRapidJSON.cmake | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'cmake') diff --git a/cmake/modules/FindRapidJSON.cmake b/cmake/modules/FindRapidJSON.cmake index df34eff2b2..10a21390d1 100644 --- a/cmake/modules/FindRapidJSON.cmake +++ b/cmake/modules/FindRapidJSON.cmake @@ -5,10 +5,10 @@ # # This will define the following target: # -# RapidJSON::RapidJSON - The RapidJSON library +# ${APP_NAME_LC}::RapidJSON - The RapidJSON library # -if(NOT TARGET RapidJSON::RapidJSON) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) include(cmake/scripts/common/ModuleHelpers.cmake) macro(buildrapidjson) @@ -71,8 +71,7 @@ if(NOT TARGET RapidJSON::RapidJSON) find_path(RAPIDJSON_INCLUDE_DIRS NAMES rapidjson/rapidjson.h HINTS ${DEPENDS_PATH}/include ${PC_RapidJSON_INCLUDEDIR} - ${${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG}) endif() endif() @@ -82,11 +81,11 @@ if(NOT TARGET RapidJSON::RapidJSON) VERSION_VAR RapidJSON_VERSION) if(RAPIDJSON_FOUND) - add_library(RapidJSON::RapidJSON INTERFACE IMPORTED) - set_target_properties(RapidJSON::RapidJSON PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${RAPIDJSON_INCLUDE_DIRS}") + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} INTERFACE IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${RAPIDJSON_INCLUDE_DIRS}") if(TARGET rapidjson) - add_dependencies(RapidJSON::RapidJSON rapidjson) + add_dependencies(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} rapidjson) endif() # Add internal build target when a Multi Config Generator is used @@ -104,7 +103,9 @@ if(NOT TARGET RapidJSON::RapidJSON) endif() add_dependencies(build_internal_depends rapidjson) endif() - - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP RapidJSON::RapidJSON) + else() + if(RapidJSON_FIND_REQUIRED) + message(FATAL_ERROR "RapidJSON library not found. You may want to try -DENABLE_INTERNAL_RapidJSON=ON") + endif() endif() endif() -- cgit v1.2.3