mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-22 18:40:05 +00:00
Simplify CMake config and do minor adjustments
for consistency with used coding conventions.
This commit is contained in:
parent
a9d2e826fe
commit
1cba0aea27
@ -94,20 +94,20 @@ if (BIICODE)
|
||||
return()
|
||||
endif ()
|
||||
|
||||
add_library(cppformat ${FMT_SOURCES})
|
||||
if (BUILD_SHARED_LIBS)
|
||||
add_library(cppformat SHARED ${FMT_SOURCES})
|
||||
if (UNIX AND NOT APPLE)
|
||||
# Fix rpmlint warning:
|
||||
# unused-direct-shlib-dependency /usr/lib/libformat.so.1.1.0 /lib/libm.so.6.
|
||||
target_link_libraries(cppformat -Wl,--as-needed)
|
||||
endif ()
|
||||
else ()
|
||||
add_library(cppformat ${FMT_SOURCES})
|
||||
endif()
|
||||
if (UNIX AND NOT APPLE)
|
||||
# Fix rpmlint warning:
|
||||
# unused-direct-shlib-dependency /usr/lib/libformat.so.1.1.0 /lib/libm.so.6.
|
||||
target_link_libraries(cppformat -Wl,--as-needed)
|
||||
endif ()
|
||||
set(FMT_EXTRA_COMPILE_FLAGS -DFMT_EXPORT)
|
||||
endif ()
|
||||
|
||||
if (FMT_PEDANTIC AND
|
||||
(CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")))
|
||||
set(FMT_EXTRA_COMPILE_FLAGS "-Wall -Wextra -Wshadow -pedantic")
|
||||
set(FMT_EXTRA_COMPILE_FLAGS
|
||||
"${FMT_EXTRA_COMPILE_FLAGS} -Wall -Wextra -Wshadow -pedantic")
|
||||
endif ()
|
||||
|
||||
# If FMT_PEDANTIC is TRUE, then test compilation with both -std=c++11
|
||||
@ -119,10 +119,6 @@ if (CPP11_FLAG AND FMT_PEDANTIC)
|
||||
set(FMT_TEST_DEFAULT_FLAGS TRUE)
|
||||
endif ()
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set(FMT_EXTRA_COMPILE_FLAGS "${FMT_EXTRA_COMPILE_FLAGS} -DFMT_EXPORT")
|
||||
endif ()
|
||||
|
||||
set_target_properties(cppformat
|
||||
PROPERTIES COMPILE_FLAGS "${FMT_EXTRA_COMPILE_FLAGS}")
|
||||
|
||||
|
20
format.h
20
format.h
@ -64,15 +64,14 @@ typedef long long intmax_t;
|
||||
# include <iterator>
|
||||
#endif
|
||||
|
||||
#if !defined(FMT_HEADER_ONLY) && (defined(_WIN32) || defined(__WIN32__) || defined(WIN32))
|
||||
#if !defined(FMT_HEADER_ONLY) && defined(_WIN32)
|
||||
# ifdef FMT_EXPORT
|
||||
# define FMT_API __declspec(dllexport)
|
||||
# elif defined(FMT_SHARED)
|
||||
# define FMT_API __declspec(dllimport)
|
||||
# else
|
||||
# define FMT_API
|
||||
# endif
|
||||
#else
|
||||
#endif
|
||||
#ifndef FMT_API
|
||||
# define FMT_API
|
||||
#endif
|
||||
|
||||
@ -903,11 +902,11 @@ class UTF16ToUTF8 {
|
||||
};
|
||||
|
||||
FMT_API void format_windows_error(fmt::Writer &out, int error_code,
|
||||
fmt::StringRef message) FMT_NOEXCEPT;
|
||||
fmt::StringRef message) FMT_NOEXCEPT;
|
||||
#endif
|
||||
|
||||
FMT_API void format_system_error(fmt::Writer &out, int error_code,
|
||||
fmt::StringRef message) FMT_NOEXCEPT;
|
||||
fmt::StringRef message) FMT_NOEXCEPT;
|
||||
|
||||
// A formatting argument value.
|
||||
struct Value {
|
||||
@ -1836,7 +1835,8 @@ class PrintfFormatter : private FormatterBase {
|
||||
|
||||
public:
|
||||
explicit PrintfFormatter(const ArgList &args) : FormatterBase(args) {}
|
||||
FMT_API void format(BasicWriter<Char> &writer, BasicCStringRef<Char> format_str);
|
||||
FMT_API void format(BasicWriter<Char> &writer,
|
||||
BasicCStringRef<Char> format_str);
|
||||
};
|
||||
} // namespace internal
|
||||
|
||||
@ -2941,7 +2941,8 @@ void format(BasicFormatter<Char> &f, const Char *&format_str, const T &value) {
|
||||
|
||||
// Reports a system error without throwing an exception.
|
||||
// Can be used to report errors from destructors.
|
||||
FMT_API void report_system_error(int error_code, StringRef message) FMT_NOEXCEPT;
|
||||
FMT_API void report_system_error(int error_code,
|
||||
StringRef message) FMT_NOEXCEPT;
|
||||
|
||||
#if FMT_USE_WINDOWS_H
|
||||
|
||||
@ -2987,7 +2988,8 @@ class WindowsError : public SystemError {
|
||||
|
||||
// Reports a Windows error without throwing an exception.
|
||||
// Can be used to report errors from destructors.
|
||||
FMT_API void report_windows_error(int error_code, StringRef message) FMT_NOEXCEPT;
|
||||
FMT_API void report_windows_error(int error_code,
|
||||
StringRef message) FMT_NOEXCEPT;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -2,9 +2,13 @@ set(FMT_GMOCK_DIR ../gmock)
|
||||
|
||||
include_directories(.. ${FMT_GMOCK_DIR})
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set(FMT_IMPORT "-DFMT_SHARED")
|
||||
endif ()
|
||||
# Links target with cppformat and any libraries passed as extra arguments.
|
||||
function (target_link_cppformat target)
|
||||
target_link_libraries(${target} cppformat ${ARGN})
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -DFMT_SHARED)
|
||||
endif ()
|
||||
endfunction ()
|
||||
|
||||
# We compile Google Test ourselves instead of using pre-compiled libraries.
|
||||
# See the Google Test FAQ "Why is it not recommended to install a
|
||||
@ -49,8 +53,7 @@ endif ()
|
||||
|
||||
set(TEST_MAIN_SRC test-main.cc gtest-extra.cc gtest-extra.h util.cc)
|
||||
add_library(test-main STATIC ${TEST_MAIN_SRC})
|
||||
set_target_properties(test-main PROPERTIES COMPILE_FLAGS "${FMT_IMPORT}")
|
||||
target_link_libraries(test-main cppformat gmock)
|
||||
target_link_cppformat(test-main gmock)
|
||||
|
||||
# Adds a test.
|
||||
# Usage: add_fmt_test(name [CUSTOM_LINK] srcs...)
|
||||
@ -59,8 +62,7 @@ function(add_fmt_test name)
|
||||
add_executable(${name} ${name}.cc ${add_fmt_test_UNPARSED_ARGUMENTS})
|
||||
target_link_libraries(${name} test-main)
|
||||
if (NOT add_fmt_test_CUSTOM_LINK)
|
||||
set_target_properties(${name} PROPERTIES COMPILE_FLAGS "${FMT_IMPORT}")
|
||||
target_link_libraries(${name} cppformat)
|
||||
target_link_cppformat(${name})
|
||||
endif ()
|
||||
add_test(NAME ${name} COMMAND ${name})
|
||||
endfunction()
|
||||
|
Loading…
Reference in New Issue
Block a user