From 88f4f090a80ea6129f83c3ce855537a97cd6057a Mon Sep 17 00:00:00 2001 From: timomrs <92291334+timomrs@users.noreply.github.com> Date: Sat, 8 Jan 2022 06:33:35 +0200 Subject: [PATCH] Allow using json_cpp in other sublibraries (#1145) If another sublibrary also imports jsoncpp, `FindJsonCpp.cmake` fails with error message `add_library cannot create imported target Jsoncpp_lib because another target with the same name already exists.`. Adding the `if (NOT TARGET Jsoncpp_lib)`-guard fixes this. It might be useful to check if there's a similar problem with other sublibraries included by Drogon. --- cmake_modules/FindJsoncpp.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake_modules/FindJsoncpp.cmake b/cmake_modules/FindJsoncpp.cmake index 6c10eb28..d220e70c 100755 --- a/cmake_modules/FindJsoncpp.cmake +++ b/cmake_modules/FindJsoncpp.cmake @@ -58,7 +58,9 @@ if(Jsoncpp_FOUND) ) endif(jsoncpp_ver LESS 1.7) endif() - add_library(Jsoncpp_lib INTERFACE IMPORTED) + if (NOT TARGET Jsoncpp_lib) + add_library(Jsoncpp_lib INTERFACE IMPORTED) + endif() set_target_properties(Jsoncpp_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${JSONCPP_INCLUDE_DIRS}"