diff --git a/CMakeLists.txt b/CMakeLists.txt index b7e16fb5..26ebbd09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,12 +47,14 @@ find_package(Threads REQUIRED) add_compile_options("$<$:${DEBUG_FLAGS}>") include(CMakeToolsHelpers OPTIONAL) -if (EXISTS ${CMAKE_SOURCE_DIR}/deps/spdlog/CMakeLists.txt) - add_subdirectory(deps/spdlog) -else() - # allow usage of installed dependency - find_package(spdlog ${SPDLOG_MIN_VERSION} REQUIRED) - add_library(${PROJECT_NAME}_spdlog INTERFACE IMPORTED) +if(NOT TARGET spdlog::spdlog) + if (EXISTS ${CMAKE_SOURCE_DIR}/deps/spdlog/CMakeLists.txt) + add_subdirectory(deps/spdlog) + else() + # allow usage of installed dependency + find_package(spdlog ${SPDLOG_MIN_VERSION} REQUIRED) + add_library(${PROJECT_NAME}_spdlog INTERFACE IMPORTED) + endif() endif() if(SPDLOG_SETUP_CPPTOML_EXTERNAL)