From 55e7844ca079c31d798aeb77339df404fcc1626a Mon Sep 17 00:00:00 2001 From: David Zemon Date: Fri, 17 May 2019 23:15:08 -0500 Subject: [PATCH] Remove the namespaced Namespaces are good for avoiding collisions, but since the non-namespaced targets still exist, it does no good to add the namespaced targets on top. --- CMakeLists.txt | 2 -- example/CMakeLists.txt | 11 ++++++++--- tests/CMakeLists.txt | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 042ac7a7..c939248b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,6 @@ message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) # Build library add_library(spdlog src/spdlog.cpp) -add_library(spdlog::spdlog ALIAS spdlog) target_compile_definitions(spdlog PUBLIC SPDLOG_COMPILED_LIB ) target_include_directories(spdlog PUBLIC "$") set_target_properties(spdlog PROPERTIES OUTPUT_NAME "spdlog") @@ -67,7 +66,6 @@ set_target_properties(spdlog PROPERTIES DEBUG_POSTFIX "-debug") # Headr only add_library(spdlog_header_only INTERFACE) target_include_directories(spdlog_header_only INTERFACE "$") -add_library(spdlog::header_only ALIAS spdlog_header_only) if(SPDLOG_FMT_EXTERNAL AND NOT TARGET fmt::fmt) find_package(fmt REQUIRED CONFIG) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 98bdca6e..9dc977e7 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -24,9 +24,14 @@ cmake_minimum_required(VERSION 3.1) project(SpdlogExamples CXX) -if(NOT TARGET spdlog::spdlog) - # Stand-alone build - find_package(spdlog CONFIG REQUIRED) +if(TARGET spdlog) + # If we're running this example as part of the primary spdlog applciation + # then add an alias. This allows us to use the same "spdlog::spdlog" + # below that a user would use (with the namespace) + add_library(spdlog::spdlog ALIAS spdlog) +else() + # Stand-alone build + find_package(spdlog REQUIRED) endif() find_package(Threads REQUIRED) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 48f80e0e..8679174d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -21,7 +21,7 @@ set(SPDLOG_UTESTS_SOURCES add_executable(${PROJECT_NAME} ${SPDLOG_UTESTS_SOURCES}) target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) -target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog) +target_link_libraries(${PROJECT_NAME} PRIVATE spdlog) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")