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.
This commit is contained in:
David Zemon 2019-05-17 23:15:08 -05:00
parent 8dd85285e7
commit 55e7844ca0
3 changed files with 9 additions and 6 deletions

View File

@ -58,7 +58,6 @@ message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
# Build library # Build library
add_library(spdlog src/spdlog.cpp) add_library(spdlog src/spdlog.cpp)
add_library(spdlog::spdlog ALIAS spdlog)
target_compile_definitions(spdlog PUBLIC SPDLOG_COMPILED_LIB ) target_compile_definitions(spdlog PUBLIC SPDLOG_COMPILED_LIB )
target_include_directories(spdlog PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>") target_include_directories(spdlog PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>")
set_target_properties(spdlog PROPERTIES OUTPUT_NAME "spdlog") set_target_properties(spdlog PROPERTIES OUTPUT_NAME "spdlog")
@ -67,7 +66,6 @@ set_target_properties(spdlog PROPERTIES DEBUG_POSTFIX "-debug")
# Headr only # Headr only
add_library(spdlog_header_only INTERFACE) add_library(spdlog_header_only INTERFACE)
target_include_directories(spdlog_header_only INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>") target_include_directories(spdlog_header_only INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>")
add_library(spdlog::header_only ALIAS spdlog_header_only)
if(SPDLOG_FMT_EXTERNAL AND NOT TARGET fmt::fmt) if(SPDLOG_FMT_EXTERNAL AND NOT TARGET fmt::fmt)
find_package(fmt REQUIRED CONFIG) find_package(fmt REQUIRED CONFIG)

View File

@ -24,9 +24,14 @@
cmake_minimum_required(VERSION 3.1) cmake_minimum_required(VERSION 3.1)
project(SpdlogExamples CXX) project(SpdlogExamples CXX)
if(NOT TARGET spdlog::spdlog) 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 # Stand-alone build
find_package(spdlog CONFIG REQUIRED) find_package(spdlog REQUIRED)
endif() endif()
find_package(Threads REQUIRED) find_package(Threads REQUIRED)

View File

@ -21,7 +21,7 @@ set(SPDLOG_UTESTS_SOURCES
add_executable(${PROJECT_NAME} ${SPDLOG_UTESTS_SOURCES}) add_executable(${PROJECT_NAME} ${SPDLOG_UTESTS_SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) 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") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")