mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-14 01:32:07 +08:00
Updated cmakelists.txt
This commit is contained in:
parent
65a2d8a49f
commit
dcf664ee1d
@ -167,7 +167,6 @@ set(SPDLOG_HEADERS
|
|||||||
"include/spdlog/fmt/bin_to_hex.h"
|
"include/spdlog/fmt/bin_to_hex.h"
|
||||||
"include/spdlog/fmt/fmt.h"
|
"include/spdlog/fmt/fmt.h"
|
||||||
"include/spdlog/sinks/android_sink.h"
|
"include/spdlog/sinks/android_sink.h"
|
||||||
"include/spdlog/sinks/ansicolor_sink.h"
|
|
||||||
"include/spdlog/sinks/base_sink.h"
|
"include/spdlog/sinks/base_sink.h"
|
||||||
"include/spdlog/sinks/basic_file_sink.h"
|
"include/spdlog/sinks/basic_file_sink.h"
|
||||||
"include/spdlog/sinks/callback_sink.h"
|
"include/spdlog/sinks/callback_sink.h"
|
||||||
@ -204,7 +203,6 @@ set(SPDLOG_SRCS
|
|||||||
"src/details/periodic_worker.cpp"
|
"src/details/periodic_worker.cpp"
|
||||||
"src/details/registry.cpp"
|
"src/details/registry.cpp"
|
||||||
"src/details/thread_pool.cpp"
|
"src/details/thread_pool.cpp"
|
||||||
"src/sinks/ansicolor_sink.cpp"
|
|
||||||
"src/sinks/base_sink.cpp"
|
"src/sinks/base_sink.cpp"
|
||||||
"src/sinks/basic_file_sink.cpp"
|
"src/sinks/basic_file_sink.cpp"
|
||||||
"src/sinks/rotating_file_sink.cpp"
|
"src/sinks/rotating_file_sink.cpp"
|
||||||
@ -213,18 +211,24 @@ set(SPDLOG_SRCS
|
|||||||
"src/sinks/stdout_sinks.cpp")
|
"src/sinks/stdout_sinks.cpp")
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND SPDLOG_SRCS "src/details/os_windows.cpp" "src/sinks/wincolor_sink.cpp")
|
list(APPEND SPDLOG_SRCS
|
||||||
|
"src/details/os_windows.cpp"
|
||||||
|
"src/sinks/wincolor_sink.cpp")
|
||||||
list(
|
list(
|
||||||
APPEND
|
APPEND SPDLOG_HEADERS
|
||||||
SPDLOG_HEADERS
|
"include/spdlog/sinks/wincolor_sink.h"
|
||||||
"include/spdlog/details/tcp_client_windows.h"
|
"include/spdlog/details/tcp_client_windows.h"
|
||||||
"include/spdlog/details/udp_client_windows.h"
|
"include/spdlog/details/udp_client_windows.h"
|
||||||
"include/spdlog/details/windows_include.h"
|
"include/spdlog/details/windows_include.h"
|
||||||
"include/spdlog/sinks/win_eventlog_sink.h"
|
"include/spdlog/sinks/win_eventlog_sink.h")
|
||||||
"include/spdlog/sinks/wincolor_sink.h")
|
|
||||||
else()
|
else()
|
||||||
list(APPEND SPDLOG_SRCS "src/details/os_unix.cpp")
|
list(APPEND SPDLOG_SRCS
|
||||||
list(APPEND SPDLOG_HEADERS "include/spdlog/details/tcp_client_unix.h" "include/spdlog/details/udp_client_unix.h")
|
"src/details/os_unix.cpp"
|
||||||
|
"src/sinks/ansicolor_sink.cpp")
|
||||||
|
list(APPEND SPDLOG_HEADERS
|
||||||
|
"include/spdlog/details/tcp_client_unix.h"
|
||||||
|
"include/spdlog/details/udp_client_unix.h"
|
||||||
|
"include/spdlog/sinks/ansicolor_sink.h")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
@ -233,7 +237,7 @@ endif()
|
|||||||
include(CheckSymbolExists)
|
include(CheckSymbolExists)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
check_symbol_exists(_fwrite_nolock "stdio.h" HAVE_FWRITE_UNLOCKED)
|
check_symbol_exists(_fwrite_nolock "stdio.h" HAVE_FWRITE_UNLOCKED)
|
||||||
else ()
|
else()
|
||||||
check_symbol_exists(fwrite_unlocked "stdio.h" HAVE_FWRITE_UNLOCKED)
|
check_symbol_exists(fwrite_unlocked "stdio.h" HAVE_FWRITE_UNLOCKED)
|
||||||
endif()
|
endif()
|
||||||
if(HAVE_FWRITE_UNLOCKED)
|
if(HAVE_FWRITE_UNLOCKED)
|
||||||
@ -248,7 +252,7 @@ if(BUILD_SHARED_LIBS)
|
|||||||
set(VERSION_RC ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
set(VERSION_RC ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
|
||||||
endif()
|
endif()
|
||||||
add_library(spdlog SHARED ${SPDLOG_SRCS} ${SPDLOG_HEADERS} ${VERSION_RC})
|
add_library(spdlog SHARED ${VERSION_RC})
|
||||||
target_compile_definitions(spdlog PUBLIC SPDLOG_SHARED_LIB)
|
target_compile_definitions(spdlog PUBLIC SPDLOG_SHARED_LIB)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# disable dlls related warnings on msvc
|
# disable dlls related warnings on msvc
|
||||||
@ -256,16 +260,23 @@ if(BUILD_SHARED_LIBS)
|
|||||||
/wd4275>)
|
/wd4275>)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
add_library(spdlog STATIC ${SPDLOG_SRCS} ${SPDLOG_HEADERS})
|
add_library(spdlog STATIC)
|
||||||
endif()
|
endif()
|
||||||
add_library(spdlog::spdlog ALIAS spdlog)
|
add_library(spdlog::spdlog ALIAS spdlog)
|
||||||
|
target_sources(spdlog PRIVATE ${SPDLOG_SRCS})
|
||||||
|
target_sources(
|
||||||
|
spdlog
|
||||||
|
PUBLIC FILE_SET pub_headers
|
||||||
|
TYPE HEADERS
|
||||||
|
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
|
FILES ${SPDLOG_HEADERS})
|
||||||
|
|
||||||
set(SPDLOG_INCLUDES_LEVEL "")
|
set(SPDLOG_INCLUDES_LEVEL "")
|
||||||
if(SPDLOG_SYSTEM_INCLUDES)
|
if(SPDLOG_SYSTEM_INCLUDES)
|
||||||
set(SPDLOG_INCLUDES_LEVEL "SYSTEM")
|
set(SPDLOG_INCLUDES_LEVEL "SYSTEM")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_target_properties(spdlog PROPERTIES PUBLIC_HEADER "${SPDLOG_HEADERS}")
|
# set_target_properties(spdlog PROPERTIES PUBLIC_HEADER "${SPDLOG_HEADERS}")
|
||||||
|
|
||||||
target_include_directories(spdlog ${SPDLOG_INCLUDES_LEVEL} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
|
target_include_directories(spdlog ${SPDLOG_INCLUDES_LEVEL} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
@ -296,12 +307,8 @@ endif()
|
|||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
# spdlog private defines according to the options
|
# spdlog private defines according to the options
|
||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
foreach(SPDLOG_OPTION
|
foreach(SPDLOG_OPTION SPDLOG_CLOCK_COARSE SPDLOG_PREVENT_CHILD_FD SPDLOG_NO_THREAD_ID SPDLOG_DISABLE_DEFAULT_LOGGER
|
||||||
SPDLOG_CLOCK_COARSE
|
SPDLOG_FWRITE_UNLOCKED)
|
||||||
SPDLOG_PREVENT_CHILD_FD
|
|
||||||
SPDLOG_NO_THREAD_ID
|
|
||||||
SPDLOG_DISABLE_DEFAULT_LOGGER
|
|
||||||
SPDLOG_FWRITE_UNLOCKED)
|
|
||||||
if(${SPDLOG_OPTION})
|
if(${SPDLOG_OPTION})
|
||||||
target_compile_definitions(spdlog PRIVATE ${SPDLOG_OPTION})
|
target_compile_definitions(spdlog PRIVATE ${SPDLOG_OPTION})
|
||||||
endif()
|
endif()
|
||||||
@ -343,21 +350,22 @@ if(SPDLOG_INSTALL)
|
|||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
# Include files
|
# Include files
|
||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
|
set(installed_include_dir "${CMAKE_INSTALL_INCLUDEDIR}/spdlog-2")
|
||||||
install(
|
install(
|
||||||
TARGETS spdlog
|
TARGETS spdlog
|
||||||
EXPORT spdlogTargets
|
EXPORT spdlogTargets
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} FILE_SET pub_headers
|
||||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/spdlog)
|
DESTINATION "${installed_include_dir}")
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
# Install pkg-config file
|
# Install pkg-config file
|
||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
|
if(IS_ABSOLUTE "${installed_include_dir}")
|
||||||
set(PKG_CONFIG_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
|
set(PKG_CONFIG_INCLUDEDIR "${installed_include_dir}")
|
||||||
else()
|
else()
|
||||||
set(PKG_CONFIG_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
set(PKG_CONFIG_INCLUDEDIR "\${prefix}/${installed_include_dir}")
|
||||||
endif()
|
endif()
|
||||||
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
|
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
|
||||||
set(PKG_CONFIG_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
|
set(PKG_CONFIG_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
@ -3,10 +3,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
project(spdlog_example CXX)
|
project(spdlog_example CXX)
|
||||||
|
|
||||||
if(NOT TARGET spdlog)
|
find_package(spdlog REQUIRED)
|
||||||
# Stand-alone build
|
|
||||||
find_package(spdlog REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable(example example.cpp)
|
add_executable(example example.cpp)
|
||||||
target_link_libraries(example PRIVATE spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
|
target_link_libraries(example PRIVATE spdlog $<$<BOOL:${MINGW}>:ws2_32>)
|
||||||
|
Loading…
Reference in New Issue
Block a user