Skip to content

Commit 18ff442

Browse files
authored
Allow overriding the CMake target name (#4483)
1 parent aff5a31 commit 18ff442

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ endif ()
5757
##
5858
include(GNUInstallDirs)
5959

60-
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
60+
if (NOT DEFINED NLOHMANN_JSON_TARGET_NAME)
61+
# Allow overriding the target name when using FetchContent / add_subdirectory.
62+
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
63+
endif()
64+
6165
set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}" CACHE INTERNAL "")
6266
set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
6367
set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")

0 commit comments

Comments
 (0)