mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-26 20:20:04 +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()
|
return()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
add_library(cppformat ${FMT_SOURCES})
|
||||||
if (BUILD_SHARED_LIBS)
|
if (BUILD_SHARED_LIBS)
|
||||||
add_library(cppformat SHARED ${FMT_SOURCES})
|
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
# Fix rpmlint warning:
|
# Fix rpmlint warning:
|
||||||
# unused-direct-shlib-dependency /usr/lib/libformat.so.1.1.0 /lib/libm.so.6.
|
# unused-direct-shlib-dependency /usr/lib/libformat.so.1.1.0 /lib/libm.so.6.
|
||||||
target_link_libraries(cppformat -Wl,--as-needed)
|
target_link_libraries(cppformat -Wl,--as-needed)
|
||||||
endif ()
|
endif ()
|
||||||
else ()
|
set(FMT_EXTRA_COMPILE_FLAGS -DFMT_EXPORT)
|
||||||
add_library(cppformat ${FMT_SOURCES})
|
endif ()
|
||||||
endif()
|
|
||||||
|
|
||||||
if (FMT_PEDANTIC AND
|
if (FMT_PEDANTIC AND
|
||||||
(CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")))
|
(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 ()
|
endif ()
|
||||||
|
|
||||||
# If FMT_PEDANTIC is TRUE, then test compilation with both -std=c++11
|
# 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)
|
set(FMT_TEST_DEFAULT_FLAGS TRUE)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS)
|
|
||||||
set(FMT_EXTRA_COMPILE_FLAGS "${FMT_EXTRA_COMPILE_FLAGS} -DFMT_EXPORT")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set_target_properties(cppformat
|
set_target_properties(cppformat
|
||||||
PROPERTIES COMPILE_FLAGS "${FMT_EXTRA_COMPILE_FLAGS}")
|
PROPERTIES COMPILE_FLAGS "${FMT_EXTRA_COMPILE_FLAGS}")
|
||||||
|
|
||||||
|
16
format.h
16
format.h
@ -64,15 +64,14 @@ typedef long long intmax_t;
|
|||||||
# include <iterator>
|
# include <iterator>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(FMT_HEADER_ONLY) && (defined(_WIN32) || defined(__WIN32__) || defined(WIN32))
|
#if !defined(FMT_HEADER_ONLY) && defined(_WIN32)
|
||||||
# ifdef FMT_EXPORT
|
# ifdef FMT_EXPORT
|
||||||
# define FMT_API __declspec(dllexport)
|
# define FMT_API __declspec(dllexport)
|
||||||
# elif defined(FMT_SHARED)
|
# elif defined(FMT_SHARED)
|
||||||
# define FMT_API __declspec(dllimport)
|
# define FMT_API __declspec(dllimport)
|
||||||
# else
|
|
||||||
# define FMT_API
|
|
||||||
# endif
|
# endif
|
||||||
#else
|
#endif
|
||||||
|
#ifndef FMT_API
|
||||||
# define FMT_API
|
# define FMT_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1836,7 +1835,8 @@ class PrintfFormatter : private FormatterBase {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PrintfFormatter(const ArgList &args) : FormatterBase(args) {}
|
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
|
} // 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.
|
// Reports a system error without throwing an exception.
|
||||||
// Can be used to report errors from destructors.
|
// 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
|
#if FMT_USE_WINDOWS_H
|
||||||
|
|
||||||
@ -2987,7 +2988,8 @@ class WindowsError : public SystemError {
|
|||||||
|
|
||||||
// Reports a Windows error without throwing an exception.
|
// Reports a Windows error without throwing an exception.
|
||||||
// Can be used to report errors from destructors.
|
// 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
|
#endif
|
||||||
|
|
||||||
|
@ -2,9 +2,13 @@ set(FMT_GMOCK_DIR ../gmock)
|
|||||||
|
|
||||||
include_directories(.. ${FMT_GMOCK_DIR})
|
include_directories(.. ${FMT_GMOCK_DIR})
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS)
|
# Links target with cppformat and any libraries passed as extra arguments.
|
||||||
set(FMT_IMPORT "-DFMT_SHARED")
|
function (target_link_cppformat target)
|
||||||
endif ()
|
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.
|
# We compile Google Test ourselves instead of using pre-compiled libraries.
|
||||||
# See the Google Test FAQ "Why is it not recommended to install a
|
# 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)
|
set(TEST_MAIN_SRC test-main.cc gtest-extra.cc gtest-extra.h util.cc)
|
||||||
add_library(test-main STATIC ${TEST_MAIN_SRC})
|
add_library(test-main STATIC ${TEST_MAIN_SRC})
|
||||||
set_target_properties(test-main PROPERTIES COMPILE_FLAGS "${FMT_IMPORT}")
|
target_link_cppformat(test-main gmock)
|
||||||
target_link_libraries(test-main cppformat gmock)
|
|
||||||
|
|
||||||
# Adds a test.
|
# Adds a test.
|
||||||
# Usage: add_fmt_test(name [CUSTOM_LINK] srcs...)
|
# 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})
|
add_executable(${name} ${name}.cc ${add_fmt_test_UNPARSED_ARGUMENTS})
|
||||||
target_link_libraries(${name} test-main)
|
target_link_libraries(${name} test-main)
|
||||||
if (NOT add_fmt_test_CUSTOM_LINK)
|
if (NOT add_fmt_test_CUSTOM_LINK)
|
||||||
set_target_properties(${name} PROPERTIES COMPILE_FLAGS "${FMT_IMPORT}")
|
target_link_cppformat(${name})
|
||||||
target_link_libraries(${name} cppformat)
|
|
||||||
endif ()
|
endif ()
|
||||||
add_test(NAME ${name} COMMAND ${name})
|
add_test(NAME ${name} COMMAND ${name})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
Loading…
Reference in New Issue
Block a user