Removed header only options

This commit is contained in:
gabime 2023-09-24 13:27:26 +03:00
parent fc81e0390b
commit 6d520df916
52 changed files with 11 additions and 225 deletions

View File

@ -49,11 +49,9 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \
-DCMAKE_CXX_STANDARD=${{ matrix.config.cppstd }} \
-DSPDLOG_BUILD_EXAMPLE=${{ matrix.config.examples || 'ON' }} \
-DSPDLOG_BUILD_EXAMPLE_HO=${{ matrix.config.examples || 'ON' }} \
-DSPDLOG_BUILD_WARNINGS=ON \
-DSPDLOG_BUILD_BENCH=OFF \
-DSPDLOG_BUILD_TESTS=ON \
-DSPDLOG_BUILD_TESTS_HO=OFF \
-DSPDLOG_SANITIZE_ADDRESS=${{ matrix.config.asan || 'OFF' }} \
-DSPDLOG_USE_STD_FORMAT=${{ matrix.config.std_format || 'OFF' }}
make -j2
@ -72,11 +70,9 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=20 \
-DSPDLOG_BUILD_EXAMPLE=ON \
-DSPDLOG_BUILD_EXAMPLE_HO=ON \
-DSPDLOG_BUILD_WARNINGS=ON \
-DSPDLOG_BUILD_BENCH=OFF \
-DSPDLOG_BUILD_TESTS=ON \
-DSPDLOG_BUILD_TESTS_HO=OFF \
-DSPDLOG_SANITIZE_ADDRESS=OFF
make -j
ctest -j2 --output-on-failure

View File

@ -69,11 +69,9 @@ option(SPDLOG_BUILD_PIC "Build position independent code (-fPIC)" OFF)
# example options
option(SPDLOG_BUILD_EXAMPLE "Build example" ${SPDLOG_MASTER_PROJECT})
option(SPDLOG_BUILD_EXAMPLE_HO "Build header only example" OFF)
# testing options
option(SPDLOG_BUILD_TESTS "Build tests" OFF)
option(SPDLOG_BUILD_TESTS_HO "Build tests using the header only version" OFF)
# bench options
option(SPDLOG_BUILD_BENCH "Build benchmarks (Requires https://github.com/google/benchmark.git to be installed)" OFF)
@ -193,17 +191,6 @@ if(COMMAND target_precompile_headers AND SPDLOG_ENABLE_PCH)
target_precompile_headers(spdlog PRIVATE ${PROJECT_BINARY_DIR}/spdlog_pch.h)
endif()
# ---------------------------------------------------------------------------------------
# Header only version
# ---------------------------------------------------------------------------------------
add_library(spdlog_header_only INTERFACE)
add_library(spdlog::spdlog_header_only ALIAS spdlog_header_only)
target_include_directories(
spdlog_header_only ${SPDLOG_INCLUDES_LEVEL} 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
# ---------------------------------------------------------------------------------------
@ -212,15 +199,12 @@ if(SPDLOG_FMT_EXTERNAL OR SPDLOG_FMT_EXTERNAL_HO)
find_package(fmt CONFIG REQUIRED)
endif()
target_compile_definitions(spdlog PUBLIC SPDLOG_FMT_EXTERNAL)
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_FMT_EXTERNAL)
# use external fmt-header-nly
if(SPDLOG_FMT_EXTERNAL_HO)
target_link_libraries(spdlog PUBLIC fmt::fmt-header-only)
target_link_libraries(spdlog_header_only INTERFACE fmt::fmt-header-only)
else() # use external compile fmt
target_link_libraries(spdlog PUBLIC fmt::fmt)
target_link_libraries(spdlog_header_only INTERFACE fmt::fmt)
endif()
set(PKG_CONFIG_REQUIRES fmt) # add dependency to pkg-config
@ -231,7 +215,6 @@ endif()
# ---------------------------------------------------------------------------------------
if(ANDROID)
target_link_libraries(spdlog PUBLIC log)
target_link_libraries(spdlog_header_only INTERFACE log)
endif()
# ---------------------------------------------------------------------------------------
@ -249,7 +232,6 @@ foreach(
SPDLOG_USE_STD_FORMAT)
if(${SPDLOG_OPTION})
target_compile_definitions(spdlog PUBLIC ${SPDLOG_OPTION})
target_compile_definitions(spdlog_header_only INTERFACE ${SPDLOG_OPTION})
endif()
endforeach()
@ -307,7 +289,7 @@ if(SPDLOG_INSTALL)
# ---------------------------------------------------------------------------------------
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" PATTERN "fmt/bundled" EXCLUDE)
install(
TARGETS spdlog spdlog_header_only
TARGETS spdlog
EXPORT spdlog
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
@ -340,8 +322,6 @@ if(SPDLOG_INSTALL)
# ---------------------------------------------------------------------------------------
# Install CMake config files
# ---------------------------------------------------------------------------------------
export(TARGETS spdlog spdlog_header_only NAMESPACE spdlog::
FILE "${CMAKE_CURRENT_BINARY_DIR}/${config_targets_file}")
install(EXPORT spdlog DESTINATION ${export_dest_dir} NAMESPACE spdlog:: FILE ${config_targets_file})
include(CMakePackageConfigHelpers)

12
INSTALL
View File

@ -1,19 +1,7 @@
Header only version:
==================================================================
Just copy the files to your build tree and use a C++11 compiler.
Or use CMake:
add_executable(example_header_only example.cpp)
target_link_libraries(example_header_only spdlog::spdlog_header_only)
Compiled library version:
==================================================================
CMake:
add_executable(example example.cpp)
target_link_libraries(example spdlog::spdlog)
Or copy files src/*.cpp to your build tree and pass the -DSPDLOG_COMPILED_LIB to the compiler.
Tested on:
gcc 4.8.1 and above
clang 3.5

View File

@ -13,11 +13,3 @@ endif()
# ---------------------------------------------------------------------------------------
add_executable(example example.cpp)
target_link_libraries(example PRIVATE spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
# ---------------------------------------------------------------------------------------
# Example of using header-only library
# ---------------------------------------------------------------------------------------
if(SPDLOG_BUILD_EXAMPLE_HO)
add_executable(example_header_only example.cpp)
target_link_libraries(example_header_only PRIVATE spdlog::spdlog_header_only)
endif()

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/async_logger.h>
#endif
#include <spdlog/async_logger.h>
#include <spdlog/sinks/sink.h>
#include <spdlog/details/thread_pool.h>

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/cfg/helpers.h>
#endif
#include <spdlog/spdlog.h>
#include <spdlog/details/os.h>

View File

@ -23,7 +23,3 @@ SPDLOG_API void load_levels(const std::string &txt);
} // namespace cfg
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "helpers-inl.h"
#endif // SPDLOG_HEADER_ONLY

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/common.h>
#endif
#include <algorithm>
#include <iterator>

View File

@ -53,30 +53,6 @@
# define SPDLOG_API
#endif
//
//
//#ifdef SPDLOG_COMPILED_LIB
//# undef SPDLOG_HEADER_ONLY
//# if defined(SPDLOG_SHARED_LIB)
//# if defined(_WIN32)
//# ifdef spdlog_EXPORTS
//# define SPDLOG_API __declspec(dllexport)
//# else // !spdlog_EXPORTS
//# define SPDLOG_API __declspec(dllimport)
//# endif
//# else // !defined(_WIN32)
//# define SPDLOG_API __attribute__((visibility("default")))
//# endif
//# else // !defined(SPDLOG_SHARED_LIB)
//# define SPDLOG_API
//# endif
//# define
//#else // !defined(SPDLOG_COMPILED_LIB)
//# define SPDLOG_API
//# define SPDLOG_HEADER_ONLY
//# define inline
//#endif // #ifdef SPDLOG_COMPILED_LIB
#include <spdlog/fmt/fmt.h>
#if !defined(SPDLOG_USE_STD_FORMAT) && FMT_VERSION >= 80000 // backward compatibility with fmt versions older than 8
@ -384,7 +360,3 @@ template<typename T, typename... Args>
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "common-inl.h"
#endif

View File

@ -3,9 +3,8 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/details/file_helper.h>
#endif
#include <spdlog/details/file_helper.h>
#include <spdlog/details/os.h>
#include <spdlog/common.h>

View File

@ -56,7 +56,3 @@ private:
};
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "file_helper-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/details/log_msg.h>
#endif
#include <spdlog/details/os.h>

View File

@ -32,6 +32,3 @@ struct SPDLOG_API log_msg
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "log_msg-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/details/log_msg_buffer.h>
#endif
namespace spdlog {
namespace details {

View File

@ -28,6 +28,3 @@ public:
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "log_msg_buffer-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/details/os.h>
#endif
#include <spdlog/common.h>

View File

@ -117,6 +117,3 @@ SPDLOG_API bool fsync(FILE *fp);
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "os-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/details/periodic_worker.h>
#endif
namespace spdlog {
namespace details {

View File

@ -54,7 +54,3 @@ private:
};
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "periodic_worker-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/details/registry.h>
#endif
#include <spdlog/common.h>
#include <spdlog/details/periodic_worker.h>

View File

@ -112,7 +112,3 @@ private:
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "registry-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/details/thread_pool.h>
#endif
#include <spdlog/details/thread_pool.h>
#include <spdlog/common.h>
#include <cassert>

View File

@ -118,7 +118,3 @@ private:
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "thread_pool-inl.h"
#endif

View File

@ -10,11 +10,6 @@
#if !defined(SPDLOG_USE_STD_FORMAT)
# if !defined(SPDLOG_FMT_EXTERNAL)
# ifdef SPDLOG_HEADER_ONLY
# ifndef FMT_HEADER_ONLY
# define FMT_HEADER_ONLY
# endif
# endif
# include <spdlog/fmt/bundled/chrono.h>
# else
# include <fmt/chrono.h>

View File

@ -10,11 +10,6 @@
#if !defined(SPDLOG_USE_STD_FORMAT)
# if !defined(SPDLOG_FMT_EXTERNAL)
# ifdef SPDLOG_HEADER_ONLY
# ifndef FMT_HEADER_ONLY
# define FMT_HEADER_ONLY
# endif
# endif
# include <spdlog/fmt/bundled/compile.h>
# else
# include <fmt/compile.h>

View File

@ -10,11 +10,6 @@
#if !defined(SPDLOG_USE_STD_FORMAT)
# if !defined(SPDLOG_FMT_EXTERNAL)
# ifdef SPDLOG_HEADER_ONLY
# ifndef FMT_HEADER_ONLY
# define FMT_HEADER_ONLY
# endif
# endif
# include <spdlog/fmt/bundled/ostream.h>
# else
# include <fmt/ostream.h>

View File

@ -10,11 +10,6 @@
#if !defined(SPDLOG_USE_STD_FORMAT)
# if !defined(SPDLOG_FMT_EXTERNAL)
# ifdef SPDLOG_HEADER_ONLY
# ifndef FMT_HEADER_ONLY
# define FMT_HEADER_ONLY
# endif
# endif
# include <spdlog/fmt/bundled/ranges.h>
# else
# include <fmt/ranges.h>

View File

@ -11,11 +11,6 @@
#if !defined(SPDLOG_USE_STD_FORMAT)
# if !defined(SPDLOG_FMT_EXTERNAL)
# ifdef SPDLOG_HEADER_ONLY
# ifndef FMT_HEADER_ONLY
# define FMT_HEADER_ONLY
# endif
# endif
# include <spdlog/fmt/bundled/std.h>
# else
# include <fmt/std.h>

View File

@ -10,11 +10,6 @@
#if !defined(SPDLOG_USE_STD_FORMAT)
# if !defined(SPDLOG_FMT_EXTERNAL)
# ifdef SPDLOG_HEADER_ONLY
# ifndef FMT_HEADER_ONLY
# define FMT_HEADER_ONLY
# endif
# endif
# include <spdlog/fmt/bundled/xchar.h>
# else
# include <fmt/xchar.h>

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/logger.h>
#endif
#include <spdlog/logger.h>
#include <spdlog/sinks/sink.h>
#include <spdlog/pattern_formatter.h>

View File

@ -363,7 +363,3 @@ protected:
};
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "logger-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/pattern_formatter.h>
#endif
#include <spdlog/pattern_formatter.h>
#include <spdlog/details/fmt_helper.h>
#include <spdlog/details/log_msg.h>

View File

@ -123,6 +123,3 @@ private:
};
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "pattern_formatter-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/sinks/ansicolor_sink.h>
#endif
#include <spdlog/pattern_formatter.h>
#include <spdlog/details/os.h>

View File

@ -112,7 +112,3 @@ using ansicolor_stderr_sink_st = ansicolor_stderr_sink<details::console_nullmute
} // namespace sinks
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "ansicolor_sink-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/sinks/base_sink.h>
#endif
#include <spdlog/common.h>
#include <spdlog/pattern_formatter.h>

View File

@ -47,6 +47,3 @@ protected:
} // namespace sinks
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "base_sink-inl.h"
#endif

View File

@ -3,9 +3,8 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/sinks/basic_file_sink.h>
#endif
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/common.h>
#include <spdlog/details/os.h>

View File

@ -55,6 +55,3 @@ inline std::shared_ptr<logger> basic_logger_st(
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "basic_file_sink-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/sinks/rotating_file_sink.h>
#endif
#include <spdlog/common.h>

View File

@ -75,7 +75,3 @@ inline std::shared_ptr<logger> rotating_logger_st(const std::string &logger_name
logger_name, filename, max_file_size, max_files, rotate_on_open, event_handlers);
}
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "rotating_file_sink-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/sinks/sink.h>
#endif
#include <spdlog/common.h>

View File

@ -30,6 +30,3 @@ protected:
} // namespace sinks
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "sink-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/sinks/stdout_color_sinks.h>
#endif
#include <spdlog/logger.h>
#include <spdlog/common.h>

View File

@ -39,7 +39,3 @@ template<typename Factory = spdlog::synchronous_factory>
std::shared_ptr<logger> stderr_color_st(const std::string &logger_name, color_mode mode = color_mode::automatic);
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "stdout_color_sinks-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/sinks/stdout_sinks.h>
#endif
#include <spdlog/sinks/stdout_sinks.h>
#include <spdlog/details/console_globals.h>
#include <spdlog/pattern_formatter.h>

View File

@ -82,6 +82,3 @@ std::shared_ptr<logger> stderr_logger_st(const std::string &logger_name);
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "stdout_sinks-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/sinks/wincolor_sink.h>
#endif
#include <spdlog/sinks/wincolor_sink.h>
#include <spdlog/details/windows_include.h>
#include <wincon.h>

View File

@ -79,7 +79,3 @@ using wincolor_stderr_sink_mt = wincolor_stderr_sink<details::console_mutex>;
using wincolor_stderr_sink_st = wincolor_stderr_sink<details::console_nullmutex>;
} // namespace sinks
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
# include "wincolor_sink-inl.h"
#endif

View File

@ -3,9 +3,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
# include <spdlog/spdlog.h>
#endif
#include <spdlog/common.h>
#include <spdlog/pattern_formatter.h>

View File

@ -361,8 +361,4 @@ inline void critical(string_view_t msg)
# define SPDLOG_CRITICAL(...) (void)0
#endif
#ifdef SPDLOG_HEADER_ONLY
# include "spdlog-inl.h"
#endif
#endif // SPDLOG_H

View File

@ -84,7 +84,3 @@ if(SPDLOG_BUILD_TESTS OR SPDLOG_BUILD_ALL)
spdlog_prepare_test(spdlog-utests spdlog::spdlog)
endif()
# The header-only library version tests
if(SPDLOG_BUILD_TESTS_HO OR SPDLOG_BUILD_ALL)
spdlog_prepare_test(spdlog-utests-ho spdlog::spdlog_header_only)
endif()