wip static-lib
This commit is contained in:
		@@ -1,8 +1,5 @@
 | 
				
			|||||||
 | 
					# Copyright(c) 2019 spdlog
 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Copyright(c) 2015 Ruslan Baratov.
 | 
					 | 
				
			||||||
# Distributed under the MIT License (http://opensource.org/licenses/MIT)
 | 
					# Distributed under the MIT License (http://opensource.org/licenses/MIT)
 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
cmake_minimum_required(VERSION 3.1)
 | 
					cmake_minimum_required(VERSION 3.1)
 | 
				
			||||||
project(spdlog VERSION 1.3.1 LANGUAGES CXX)
 | 
					project(spdlog VERSION 1.3.1 LANGUAGES CXX)
 | 
				
			||||||
@@ -47,48 +44,36 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
 | 
				
			|||||||
    set(SPDLOG_MASTER_PROJECT ON)
 | 
					    set(SPDLOG_MASTER_PROJECT ON)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
option(SPDLOG_HEADER_ONLY "Header only version. Turn OFF to build as static lib" OFF)
 | 
					option(SPDLOG_STATIC_LIB "Build as static lib" OFF)
 | 
				
			||||||
option(SPDLOG_BUILD_EXAMPLES "Build examples" ${SPDLOG_MASTER_PROJECT})
 | 
					option(SPDLOG_BUILD_EXAMPLES "Build examples" ${SPDLOG_MASTER_PROJECT})
 | 
				
			||||||
option(SPDLOG_BUILD_BENCH "Build benchmarks (Requires https://github.com/google/benchmark.git to be installed)" ON)
 | 
					option(SPDLOG_BUILD_BENCH "Build benchmarks (Requires https://github.com/google/benchmark.git to be installed)" ON)
 | 
				
			||||||
option(SPDLOG_BUILD_TESTS "Build tests" ${SPDLOG_MASTER_PROJECT})
 | 
					option(SPDLOG_BUILD_TESTS "Build tests" ${SPDLOG_MASTER_PROJECT})
 | 
				
			||||||
option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF)
 | 
					option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF)
 | 
				
			||||||
option(SPDLOG_INSTALL "Generate the install target." ${SPDLOG_MASTER_PROJECT})
 | 
					option(SPDLOG_INSTALL "Generate the install target." ${SPDLOG_MASTER_PROJECT})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(HEADER_BASE "${CMAKE_CURRENT_SOURCE_DIR}/include")
 | 
					set(HEADER_BASE "${CMAKE_CURRENT_SOURCE_DIR}/include/spdlog")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(SPDLOG_HEADER_ONLY)
 | 
					if(SPDLOG_STATIC_LIB)
 | 
				
			||||||
	add_definitions(-DSPDLOG_HEADER_ONLY)
 | 
					    add_definitions(-DSPDLOG_STATIC_LIB)
 | 
				
			||||||
    add_library(spdlog INTERFACE)
 | 
					    file(GLOB SRC_FILES ${HEADER_BASE}/impl/*.cpp)
 | 
				
			||||||
    add_library(spdlog::spdlog ALIAS spdlog)
 | 
					 | 
				
			||||||
    target_include_directories(
 | 
					 | 
				
			||||||
            spdlog
 | 
					 | 
				
			||||||
            INTERFACE
 | 
					 | 
				
			||||||
            "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
else()
 | 
					 | 
				
			||||||
	remove_definitions(-DSPDLOG_HEADER_ONLY)
 | 
					 | 
				
			||||||
    file(GLOB SRC_FILES ${HEADER_BASE}/spdlog/impl/*.cpp)
 | 
					 | 
				
			||||||
    add_library(spdlog STATIC ${SRC_FILES})
 | 
					    add_library(spdlog STATIC ${SRC_FILES})
 | 
				
			||||||
    add_library(spdlog::spdlog ALIAS spdlog)
 | 
					    target_include_directories(spdlog PUBLIC  "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>")
 | 
				
			||||||
    target_include_directories(
 | 
					else()
 | 
				
			||||||
            spdlog
 | 
					    add_library(spdlog INTERFACE)
 | 
				
			||||||
            PUBLIC
 | 
					    target_include_directories(spdlog INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>")
 | 
				
			||||||
            "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					add_library(spdlog::spdlog ALIAS spdlog)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
if(SPDLOG_FMT_EXTERNAL)
 | 
					if(SPDLOG_FMT_EXTERNAL)
 | 
				
			||||||
    target_compile_definitions(spdlog INTERFACE SPDLOG_FMT_EXTERNAL)
 | 
					    target_compile_definitions(spdlog INTERFACE SPDLOG_FMT_EXTERNAL)
 | 
				
			||||||
    target_link_libraries(spdlog INTERFACE fmt::fmt)
 | 
					    target_link_libraries(spdlog INTERFACE fmt::fmt)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
if(SPDLOG_BUILD_EXAMPLES)
 | 
					if(SPDLOG_BUILD_EXAMPLES)
 | 
				
			||||||
    add_subdirectory(example)
 | 
					    add_subdirectory(example)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
@@ -105,9 +90,9 @@ endif()
 | 
				
			|||||||
#---------------------------------------------------------------------------------------
 | 
					#---------------------------------------------------------------------------------------
 | 
				
			||||||
# install
 | 
					# install
 | 
				
			||||||
#---------------------------------------------------------------------------------------
 | 
					#---------------------------------------------------------------------------------------
 | 
				
			||||||
install(DIRECTORY ${HEADER_BASE}/spdlog DESTINATION include)
 | 
					install(DIRECTORY ${HEADER_BASE} DESTINATION include)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(NOT SPDLOG_HEADER_ONLY)
 | 
					if(SPDLOG_STATIC_LIB)
 | 
				
			||||||
    install(TARGETS spdlog ARCHIVE DESTINATION lib)
 | 
					    install(TARGETS spdlog ARCHIVE DESTINATION lib)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -65,6 +65,6 @@ private:
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
} // namespace spdlog
 | 
					} // namespace spdlog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef SPDLOG_HEADER_ONLY
 | 
					#ifndef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/impl/async_logger.cpp"
 | 
					#include "spdlog/impl/async_logger.cpp"
 | 
				
			||||||
#endif // SPDLOG_HEADER_ONLY
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,10 +23,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "spdlog/fmt/fmt.h"
 | 
					#include "spdlog/fmt/fmt.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef SPDLOG_HEADER_ONLY
 | 
					
 | 
				
			||||||
#define SPDLOG_INLINE inline
 | 
					#ifdef SPDLOG_STATIC_LIB
 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
#define SPDLOG_INLINE
 | 
					#define SPDLOG_INLINE
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#define SPDLOG_INLINE inline
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// visual studio upto 2013 does not support noexcept nor constexpr
 | 
					// visual studio upto 2013 does not support noexcept nor constexpr
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,6 +57,6 @@ private:
 | 
				
			|||||||
} // namespace details
 | 
					} // namespace details
 | 
				
			||||||
} // namespace spdlog
 | 
					} // namespace spdlog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef SPDLOG_HEADER_ONLY
 | 
					#ifndef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/impl/file_helper.cpp"
 | 
					#include "spdlog/impl/file_helper.cpp"
 | 
				
			||||||
#endif // ! SPDLOG_HEADER_ONLY
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,6 +33,6 @@ struct log_msg
 | 
				
			|||||||
} // namespace details
 | 
					} // namespace details
 | 
				
			||||||
} // namespace spdlog
 | 
					} // namespace spdlog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef SPDLOG_HEADER_ONLY
 | 
					#ifndef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/impl/log_msg.cpp"
 | 
					#include "spdlog/impl/log_msg.cpp"
 | 
				
			||||||
#endif //  SPDLOG_HEADER_ONLY
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -88,6 +88,6 @@ void wbuf_to_utf8buf(const fmt::wmemory_buffer &wbuf, fmt::memory_buffer &target
 | 
				
			|||||||
} // namespace details
 | 
					} // namespace details
 | 
				
			||||||
} // namespace spdlog
 | 
					} // namespace spdlog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef SPDLOG_HEADER_ONLY
 | 
					#ifndef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/impl/os.cpp"
 | 
					#include "spdlog/impl/os.cpp"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -97,6 +97,6 @@ private:
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
} // namespace spdlog
 | 
					} // namespace spdlog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef SPDLOG_HEADER_ONLY
 | 
					#ifndef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/impl/pattern_formatter.cpp"
 | 
					#include "spdlog/impl/pattern_formatter.cpp"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -101,6 +101,6 @@ private:
 | 
				
			|||||||
} // namespace details
 | 
					} // namespace details
 | 
				
			||||||
} // namespace spdlog
 | 
					} // namespace spdlog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef SPDLOG_HEADER_ONLY
 | 
					#ifndef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/impl/registry.cpp"
 | 
					#include "spdlog/impl/registry.cpp"
 | 
				
			||||||
#endif // SPDLOG_HEADER_ONLY
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,6 +11,8 @@
 | 
				
			|||||||
#include <vector>
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace spdlog {
 | 
					namespace spdlog {
 | 
				
			||||||
 | 
					class async_logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace details {
 | 
					namespace details {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using async_logger_ptr = std::shared_ptr<spdlog::async_logger>;
 | 
					using async_logger_ptr = std::shared_ptr<spdlog::async_logger>;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
#ifndef SPDLOG_HEADER_ONLY
 | 
					#ifdef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/async_logger.h"
 | 
					#include "spdlog/async_logger.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@
 | 
				
			|||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
 | 
					// Distributed under the MIT License (http://opensource.org/licenses/MIT)
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef SPDLOG_HEADER_ONLY
 | 
					#ifdef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/details/file_helper.h"
 | 
					#include "spdlog/details/file_helper.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
#include "spdlog/details/os.h"
 | 
					#include "spdlog/details/os.h"
 | 
				
			||||||
#include "spdlog/sinks/sink.h"
 | 
					#include "spdlog/sinks/sink.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef SPDLOG_HEADER_ONLY
 | 
					#ifdef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/details/log_msg.h"
 | 
					#include "spdlog/details/log_msg.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
#ifndef SPDLOG_HEADER_ONLY
 | 
					#ifdef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/logger.h"
 | 
					#include "spdlog/logger.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
// Copyright(c) 2015 Gabi Melman.
 | 
					// Copyright(c) 2015 Gabi Melman.
 | 
				
			||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
 | 
					// Distributed under the MIT License (http://opensource.org/licenses/MIT)
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
#ifndef SPDLOG_HEADER_ONLY
 | 
					#ifdef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/details/os.h"
 | 
					#include "spdlog/details/os.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,9 +3,9 @@
 | 
				
			|||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
 | 
					// Distributed under the MIT License (http://opensource.org/licenses/MIT)
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef SPDLOG_HEADER_ONLY
 | 
					#ifdef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/details/pattern_formatter.h"
 | 
					#include "spdlog/details/pattern_formatter.h"
 | 
				
			||||||
#endif // !SPDLOG_HEADER_ONLY
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "spdlog/details/fmt_helper.h"
 | 
					#include "spdlog/details/fmt_helper.h"
 | 
				
			||||||
#include "spdlog/details/log_msg.h"
 | 
					#include "spdlog/details/log_msg.h"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
// Copyright(c) 2015 Gabi Melman.
 | 
					// Copyright(c) 2015 Gabi Melman.
 | 
				
			||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
 | 
					// Distributed under the MIT License (http://opensource.org/licenses/MIT)
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
#ifndef SPDLOG_HEADER_ONLY
 | 
					#ifdef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/details/registry.h"
 | 
					#include "spdlog/details/registry.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
#include "spdlog/common.h"
 | 
					#include "spdlog/common.h"
 | 
				
			||||||
#include "spdlog/details/pattern_formatter.h"
 | 
					#include "spdlog/details/pattern_formatter.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef SPDLOG_HEADER_ONLY
 | 
					#ifdef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/sinks/sink.h"
 | 
					#include "spdlog/sinks/sink.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -340,6 +340,6 @@ protected:
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
} // namespace spdlog
 | 
					} // namespace spdlog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef SPDLOG_HEADER_ONLY
 | 
					#ifndef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/impl/logger.cpp"
 | 
					#include "spdlog/impl/logger.cpp"
 | 
				
			||||||
#endif // SPDLOG_HEADER_ONLY
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,6 +41,6 @@ protected:
 | 
				
			|||||||
} // namespace sinks
 | 
					} // namespace sinks
 | 
				
			||||||
} // namespace spdlog
 | 
					} // namespace spdlog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef SPDLOG_HEADER_ONLY
 | 
					#ifndef SPDLOG_STATIC_LIB
 | 
				
			||||||
#include "spdlog/impl/sink.cpp"
 | 
					#include "spdlog/impl/sink.cpp"
 | 
				
			||||||
#endif // SPDLOG_HEADER_ONLY
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user