From 0da0d2e739a0f9034f0d30d51d0fef4042773d33 Mon Sep 17 00:00:00 2001 From: Borislav Stanimirov Date: Mon, 4 Nov 2024 13:23:21 +0200 Subject: [PATCH] Allow overriding the CMake target name --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a49dc47e..c7bbc7da4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,11 @@ endif () ## include(GNUInstallDirs) -set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME}) +if (NOT DEFINED NLOHMANN_JSON_TARGET_NAME) + # Allow overriding the target name when using FetchContent / add_subdirectory. + set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME}) +endif() + set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}" CACHE INTERNAL "") set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}") set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")