|
|
|
@ -1,5 +1,4 @@
|
|
|
|
|
# Copyright(c) 2019 spdlog authors
|
|
|
|
|
# Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
|
|
|
# Copyright(c) 2019 spdlog authors Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
|
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 3.2)
|
|
|
|
|
|
|
|
|
@ -9,7 +8,7 @@ else()
|
|
|
|
|
cmake_policy(VERSION 3.11)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
ENABLE_LANGUAGE(C)
|
|
|
|
|
enable_language(C)
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
# Start spdlog project
|
|
|
|
@ -31,7 +30,6 @@ if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
# Compiler config
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
@ -46,7 +44,6 @@ if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
|
|
|
|
|
set(CMAKE_CXX_EXTENSIONS ON)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
# Set SPDLOG_MASTER_PROJECT to ON if we are building spdlog
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
@ -100,13 +97,17 @@ if(WIN32)
|
|
|
|
|
option(SPDLOG_WCHAR_FILENAMES "Support wchar filenames" OFF)
|
|
|
|
|
endif()
|
|
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
|
|
|
|
option(SPDLOG_CLOCK_COARSE "Use the much faster (but much less accurate) CLOCK_REALTIME_COARSE instead of the regular clock," OFF)
|
|
|
|
|
option(SPDLOG_CLOCK_COARSE
|
|
|
|
|
"Use the much faster (but much less accurate) CLOCK_REALTIME_COARSE instead of the regular clock," OFF)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
option(SPDLOG_PREVENT_CHILD_FD "Prevent from child processes to inherit log file descriptors" OFF)
|
|
|
|
|
option(SPDLOG_NO_THREAD_ID "prevent spdlog from querying the thread id on each log call if thread id is not needed" OFF)
|
|
|
|
|
option(SPDLOG_NO_TLS "prevent spdlog from using thread local storage" OFF)
|
|
|
|
|
option(SPDLOG_NO_ATOMIC_LEVELS "prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently" OFF)
|
|
|
|
|
option(
|
|
|
|
|
SPDLOG_NO_ATOMIC_LEVELS
|
|
|
|
|
"prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently"
|
|
|
|
|
OFF)
|
|
|
|
|
|
|
|
|
|
# clang-tidy
|
|
|
|
|
if(${CMAKE_VERSION} VERSION_GREATER "3.5")
|
|
|
|
@ -124,13 +125,7 @@ message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
# Static/Shared library (shared not supported in windows yet)
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
set(SPDLOG_SRCS
|
|
|
|
|
src/spdlog.cpp
|
|
|
|
|
src/stdout_sinks.cpp
|
|
|
|
|
src/color_sinks.cpp
|
|
|
|
|
src/file_sinks.cpp
|
|
|
|
|
src/async.cpp
|
|
|
|
|
src/cfg.cpp)
|
|
|
|
|
set(SPDLOG_SRCS src/spdlog.cpp src/stdout_sinks.cpp src/color_sinks.cpp src/file_sinks.cpp src/async.cpp src/cfg.cpp)
|
|
|
|
|
|
|
|
|
|
if(NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
|
|
|
|
|
list(APPEND SPDLOG_SRCS src/fmt.cpp)
|
|
|
|
@ -157,8 +152,7 @@ endif()
|
|
|
|
|
add_library(spdlog::spdlog ALIAS spdlog)
|
|
|
|
|
|
|
|
|
|
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>"
|
|
|
|
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
|
|
|
|
target_link_libraries(spdlog PUBLIC Threads::Threads)
|
|
|
|
|
spdlog_enable_warnings(spdlog)
|
|
|
|
@ -177,12 +171,10 @@ endif()
|
|
|
|
|
add_library(spdlog_header_only INTERFACE)
|
|
|
|
|
add_library(spdlog::spdlog_header_only ALIAS spdlog_header_only)
|
|
|
|
|
|
|
|
|
|
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>"
|
|
|
|
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
|
|
|
|
target_link_libraries(spdlog_header_only INTERFACE Threads::Threads)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
# Use fmt package if using external fmt
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
@ -253,7 +245,6 @@ if(SPDLOG_NO_ATOMIC_LEVELS)
|
|
|
|
|
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_NO_ATOMIC_LEVELS)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
# Build binaries
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
@ -294,7 +285,9 @@ if (SPDLOG_INSTALL)
|
|
|
|
|
# Include files
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" PATTERN "fmt/bundled" EXCLUDE)
|
|
|
|
|
install(TARGETS spdlog spdlog_header_only EXPORT spdlog
|
|
|
|
|
install(
|
|
|
|
|
TARGETS spdlog spdlog_header_only
|
|
|
|
|
EXPORT spdlog
|
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
|
|
@ -316,22 +309,16 @@ if (SPDLOG_INSTALL)
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
# Install CMake config files
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
install(EXPORT spdlog
|
|
|
|
|
DESTINATION ${export_dest_dir}
|
|
|
|
|
NAMESPACE spdlog::
|
|
|
|
|
FILE ${config_targets_file})
|
|
|
|
|
install(EXPORT spdlog DESTINATION ${export_dest_dir} NAMESPACE spdlog:: FILE ${config_targets_file})
|
|
|
|
|
|
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
configure_file("${project_config_in}" "${project_config_out}" @ONLY)
|
|
|
|
|
|
|
|
|
|
write_basic_package_version_file("${version_config_file}" COMPATIBILITY SameMajorVersion)
|
|
|
|
|
install(FILES
|
|
|
|
|
"${project_config_out}"
|
|
|
|
|
"${version_config_file}" DESTINATION "${export_dest_dir}")
|
|
|
|
|
install(FILES "${project_config_out}" "${version_config_file}" DESTINATION "${export_dest_dir}")
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
# Support creation of installable packages
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
include(cmake/spdlogCPack.cmake)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|