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.
This commit is contained in:
timomrs 2022-01-08 06:33:35 +02:00 committed by GitHub
parent 68b2a46a29
commit 88f4f090a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -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}"