Clean up CMake a bit more

This commit is contained in:
David Zemon 2019-05-17 23:33:44 -05:00
parent 24e4f0aa87
commit dd2f293f33
2 changed files with 7 additions and 12 deletions

View File

@ -54,8 +54,6 @@ option(SPDLOG_BUILD_TESTS "Build tests" ON)
option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF)
option(SPDLOG_INSTALL "Generate the install target." ${SPDLOG_MASTER_PROJECT})
set(HEADER_BASE "${CMAKE_CURRENT_SOURCE_DIR}/include/spdlog")
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
find_package(Threads REQUIRED)
@ -63,9 +61,10 @@ find_package(Threads REQUIRED)
# Build library
add_library(spdlog src/spdlog.cpp)
target_compile_definitions(spdlog PUBLIC SPDLOG_COMPILED_LIB )
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 DEBUG_POSTFIX "-debug")
target_include_directories(spdlog PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
target_link_libraries(spdlog PUBLIC Threads::Threads)
# Header only

View File

@ -1,7 +1,3 @@
project(spdlog-utests CXX)
find_package(Threads REQUIRED)
set(SPDLOG_UTESTS_SOURCES
test_errors.cpp
test_file_helper.cpp
@ -19,10 +15,10 @@ set(SPDLOG_UTESTS_SOURCES
test_sink.h
test_fmt_helper.cpp)
add_executable(${PROJECT_NAME} ${SPDLOG_UTESTS_SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE spdlog)
add_executable(spdlog-utests ${SPDLOG_UTESTS_SOURCES})
target_link_libraries(spdlog-utests spdlog)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
enable_testing()
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})
add_test(NAME spdlog-utests COMMAND spdlog-utests)