From 57371b097731c28b27921034d2bfb51a5f11b395 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 1 Oct 2026 13:07:17 +0200 Subject: [PATCH] Avoid //include in Meson-generated CMake target for prefix / As CMake's generated targets file does, reset _IMPORT_PREFIX to an empty string when it resolves to "/". Reported by @heitbaum in #5587. Signed-off-by: Niels Lohmann --- cmake/nlohmann_jsonTargets.cmake.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/nlohmann_jsonTargets.cmake.in b/cmake/nlohmann_jsonTargets.cmake.in index d8759423d..b2e57a526 100644 --- a/cmake/nlohmann_jsonTargets.cmake.in +++ b/cmake/nlohmann_jsonTargets.cmake.in @@ -12,6 +12,10 @@ if(TARGET @PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@) endif() get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/@NLOHMANN_JSON_CONFIG_TO_PREFIX@" ABSOLUTE) +# As in CMake's generated file: avoid "//include" for an installation to "/". +if(_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") +endif() add_library(@PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@ INTERFACE IMPORTED) set_target_properties(@PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@ PROPERTIES