From ad056d5d0078e889cecf8fadaf0287a168c507a0 Mon Sep 17 00:00:00 2001 From: Thomas Psota Date: Wed, 8 Mar 2023 14:49:51 +0100 Subject: [PATCH] Fix double declared nlomann_json target when used in external projects through add_subdirectory --- lib/nlohmann_json/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/nlohmann_json/CMakeLists.txt b/lib/nlohmann_json/CMakeLists.txt index cd30eaff..a12489a9 100644 --- a/lib/nlohmann_json/CMakeLists.txt +++ b/lib/nlohmann_json/CMakeLists.txt @@ -4,7 +4,11 @@ project(nlohmann_json VERSION 3.11.2) +if(NOT TARGET nlohmann_json) + add_library(${PROJECT_NAME} INTERFACE) target_include_directories(${PROJECT_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") -add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) \ No newline at end of file +add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + +endif() \ No newline at end of file