mirror of
https://github.com/fmtlib/fmt.git
synced 2026-01-01 03:12:22 +08:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c16747a80 | ||
|
|
038009b2e5 | ||
|
|
ee6b5a596e | ||
|
|
f5f9bf7f1f | ||
|
|
613f7df021 | ||
|
|
8c68e2ca04 | ||
|
|
368b66a806 | ||
|
|
1a166b0e1b | ||
|
|
38275fb27f |
@ -20,5 +20,12 @@ matrix:
|
|||||||
- os: osx
|
- os: osx
|
||||||
env: BUILD=Doc
|
env: BUILD=Doc
|
||||||
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- kubuntu-backports # cmake 2.8.12
|
||||||
|
packages:
|
||||||
|
- cmake
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- support/travis-build.py
|
- support/travis-build.py
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
message(STATUS "CMake version: ${CMAKE_VERSION}")
|
message(STATUS "CMake version: ${CMAKE_VERSION}")
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.6)
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
|
||||||
# Set the default CMAKE_BUILD_TYPE to Release.
|
# Set the default CMAKE_BUILD_TYPE to Release.
|
||||||
# This should be done before the project command since the latter can set
|
# This should be done before the project command since the latter can set
|
||||||
@ -95,14 +95,19 @@ if (BIICODE)
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_library(cppformat ${FMT_SOURCES})
|
add_library(cppformat ${FMT_SOURCES})
|
||||||
if (BUILD_SHARED_LIBS AND UNIX AND NOT APPLE)
|
if (BUILD_SHARED_LIBS)
|
||||||
# Fix rpmlint warning:
|
if (UNIX AND NOT APPLE)
|
||||||
# unused-direct-shlib-dependency /usr/lib/libformat.so.1.1.0 /lib/libm.so.6.
|
# Fix rpmlint warning:
|
||||||
target_link_libraries(cppformat -Wl,--as-needed)
|
# 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 ()
|
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
|
||||||
@ -117,7 +122,7 @@ endif ()
|
|||||||
set_target_properties(cppformat
|
set_target_properties(cppformat
|
||||||
PROPERTIES COMPILE_FLAGS "${FMT_EXTRA_COMPILE_FLAGS}")
|
PROPERTIES COMPILE_FLAGS "${FMT_EXTRA_COMPILE_FLAGS}")
|
||||||
|
|
||||||
set(CPPFORMAT_VERSION 2.0.0)
|
set(CPPFORMAT_VERSION 2.0.1)
|
||||||
if (NOT CPPFORMAT_VERSION MATCHES "^([0-9]+).([0-9]+).([0-9]+)$")
|
if (NOT CPPFORMAT_VERSION MATCHES "^([0-9]+).([0-9]+).([0-9]+)$")
|
||||||
message(FATAL_ERROR "Invalid version format ${CPPFORMAT_VERSION}.")
|
message(FATAL_ERROR "Invalid version format ${CPPFORMAT_VERSION}.")
|
||||||
endif ()
|
endif ()
|
||||||
@ -137,9 +142,10 @@ endif ()
|
|||||||
set_target_properties(cppformat PROPERTIES
|
set_target_properties(cppformat PROPERTIES
|
||||||
VERSION ${CPPFORMAT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})
|
VERSION ${CPPFORMAT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})
|
||||||
|
|
||||||
if (EXISTS .gitignore)
|
set(gitignore ${CMAKE_CURRENT_SOURCE_DIR}/.gitignore)
|
||||||
|
if (EXISTS ${gitignore})
|
||||||
# Get the list of ignored files from .gitignore.
|
# Get the list of ignored files from .gitignore.
|
||||||
file (STRINGS ".gitignore" lines)
|
file (STRINGS ${gitignore} lines)
|
||||||
LIST(REMOVE_ITEM lines /doc/html)
|
LIST(REMOVE_ITEM lines /doc/html)
|
||||||
foreach (line ${lines})
|
foreach (line ${lines})
|
||||||
string(REPLACE "." "[.]" line "${line}")
|
string(REPLACE "." "[.]" line "${line}")
|
||||||
@ -152,14 +158,46 @@ if (EXISTS .gitignore)
|
|||||||
set(CPACK_SOURCE_GENERATOR ZIP)
|
set(CPACK_SOURCE_GENERATOR ZIP)
|
||||||
set(CPACK_SOURCE_IGNORE_FILES ${ignored_files})
|
set(CPACK_SOURCE_IGNORE_FILES ${ignored_files})
|
||||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME cppformat-${CPPFORMAT_VERSION})
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME cppformat-${CPPFORMAT_VERSION})
|
||||||
|
set(CPACK_PACKAGE_NAME cppformat)
|
||||||
set(CPACK_RESOURCE_FILE_README ${FORMAT_SOURCE_DIR}/README.rst)
|
set(CPACK_RESOURCE_FILE_README ${FORMAT_SOURCE_DIR}/README.rst)
|
||||||
include(CPack)
|
include(CPack)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Install targets.
|
# Install targets.
|
||||||
if (FMT_INSTALL)
|
if (FMT_INSTALL)
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
set(config_install_dir lib/cmake/cppformat)
|
||||||
|
set(version_config ${CMAKE_CURRENT_BINARY_DIR}/cppformat-config-version.cmake)
|
||||||
|
set(project_config ${CMAKE_CURRENT_BINARY_DIR}/cppformat-config.cmake)
|
||||||
|
set(targets_export_name cppformat-targets)
|
||||||
|
|
||||||
set(FMT_LIB_DIR lib CACHE STRING
|
set(FMT_LIB_DIR lib CACHE STRING
|
||||||
"Installation directory for libraries, relative to ${CMAKE_INSTALL_PREFIX}.")
|
"Installation directory for libraries, relative to ${CMAKE_INSTALL_PREFIX}.")
|
||||||
install(TARGETS cppformat DESTINATION ${FMT_LIB_DIR})
|
|
||||||
|
# Add the include directories for both build and install tree.
|
||||||
|
target_include_directories(
|
||||||
|
cppformat PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
|
$<INSTALL_INTERFACE:include>)
|
||||||
|
|
||||||
|
# Generate the version, config and target files into the build directory.
|
||||||
|
write_basic_package_version_file(
|
||||||
|
${version_config}
|
||||||
|
VERSION ${CPPFORMAT_VERSION}
|
||||||
|
COMPATIBILITY AnyNewerVersion)
|
||||||
|
configure_package_config_file(
|
||||||
|
support/cmake/cppformat-config.cmake.in
|
||||||
|
${project_config}
|
||||||
|
INSTALL_DESTINATION ${config_install_dir})
|
||||||
|
export(TARGETS cppformat FILE ${targets_export_name}.cmake)
|
||||||
|
|
||||||
|
# Install version, config and target files.
|
||||||
|
install(
|
||||||
|
FILES ${project_config} ${version_config}
|
||||||
|
DESTINATION ${config_install_dir})
|
||||||
|
install(EXPORT ${targets_export_name} DESTINATION ${config_install_dir})
|
||||||
|
|
||||||
|
# Install the library and the include file.
|
||||||
|
install(TARGETS cppformat EXPORT ${targets_export_name} DESTINATION ${FMT_LIB_DIR})
|
||||||
install(FILES format.h DESTINATION include/cppformat)
|
install(FILES format.h DESTINATION include/cppformat)
|
||||||
endif ()
|
endif ()
|
||||||
|
|||||||
@ -1,3 +1,18 @@
|
|||||||
|
2.0.1 - 2016-03-13
|
||||||
|
------------------
|
||||||
|
|
||||||
|
* Improved CMake find and package support
|
||||||
|
(`#264 <https://github.com/cppformat/cppformat/issues/264>`_).
|
||||||
|
Thanks to `@niosHD <https://github.com/niosHD>`_.
|
||||||
|
|
||||||
|
* Fix compile error with Android NDK and mingw32
|
||||||
|
(`#241 <https://github.com/cppformat/cppformat/issues/241>`_).
|
||||||
|
Thanks to `@Gachapen (Magnus Bjerke Vik) <https://github.com/Gachapen>`_.
|
||||||
|
|
||||||
|
* Documentation fixes
|
||||||
|
(`#248 <https://github.com/cppformat/cppformat/issues/248>`_,
|
||||||
|
`#260 <https://github.com/cppformat/cppformat/issues/260>`_).
|
||||||
|
|
||||||
2.0.0 - 2015-12-01
|
2.0.0 - 2015-12-01
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|||||||
22
README.rst
22
README.rst
@ -28,9 +28,9 @@ Features
|
|||||||
* Format API with `format string syntax
|
* Format API with `format string syntax
|
||||||
<http://cppformat.github.io/latest/syntax.html>`_
|
<http://cppformat.github.io/latest/syntax.html>`_
|
||||||
similar to the one used by `str.format
|
similar to the one used by `str.format
|
||||||
<http://docs.python.org/2/library/stdtypes.html#str.format>`_ in Python.
|
<https://docs.python.org/2/library/stdtypes.html#str.format>`_ in Python.
|
||||||
* Safe `printf implementation
|
* Safe `printf implementation
|
||||||
<http://cppformat.github.io/latest/reference.html#printf-formatting-functions>`_
|
<http://cppformat.github.io/latest/api.html#printf-formatting-functions>`_
|
||||||
including the POSIX extension for positional arguments.
|
including the POSIX extension for positional arguments.
|
||||||
* Support for user-defined types.
|
* Support for user-defined types.
|
||||||
* High speed: performance of the format API is close to that of
|
* High speed: performance of the format API is close to that of
|
||||||
@ -103,10 +103,10 @@ An object of any user-defined type for which there is an overloaded
|
|||||||
// s == "The date is 2012-12-9"
|
// s == "The date is 2012-12-9"
|
||||||
|
|
||||||
You can use the `FMT_VARIADIC
|
You can use the `FMT_VARIADIC
|
||||||
<http://cppformat.github.io/latest/reference.html#utilities>`_
|
<http://cppformat.github.io/latest/api.html#utilities>`_
|
||||||
macro to create your own functions similar to `format
|
macro to create your own functions similar to `format
|
||||||
<http://cppformat.github.io/latest/reference.html#format>`_ and
|
<http://cppformat.github.io/latest/api.html#format>`_ and
|
||||||
`print <http://cppformat.github.io/latest/reference.html#print>`_
|
`print <http://cppformat.github.io/latest/api.html#print>`_
|
||||||
which take arbitrary arguments:
|
which take arbitrary arguments:
|
||||||
|
|
||||||
.. code:: c++
|
.. code:: c++
|
||||||
@ -132,10 +132,10 @@ Projects using this library
|
|||||||
* `AMPL/MP <https://github.com/ampl/mp>`_:
|
* `AMPL/MP <https://github.com/ampl/mp>`_:
|
||||||
An open-source library for mathematical programming
|
An open-source library for mathematical programming
|
||||||
|
|
||||||
* `HarpyWar/pvpgn <https://github.com/HarpyWar/pvpgn>`_:
|
* `HarpyWar/pvpgn <https://github.com/pvpgn/pvpgn-server>`_:
|
||||||
Player vs Player Gaming Network with tweaks
|
Player vs Player Gaming Network with tweaks
|
||||||
|
|
||||||
* `KBEngine <http://www.kbengine.org/>`_: An open-source MMOG server engine
|
* `KBEngine <http://kbengine.org/>`_: An open-source MMOG server engine
|
||||||
|
|
||||||
* `Lifeline <https://github.com/peter-clark/lifeline>`_: A 2D game
|
* `Lifeline <https://github.com/peter-clark/lifeline>`_: A 2D game
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ Projects using this library
|
|||||||
|
|
||||||
* `redis-cerberus <https://github.com/HunanTV/redis-cerberus>`_: A Redis cluster proxy
|
* `redis-cerberus <https://github.com/HunanTV/redis-cerberus>`_: A Redis cluster proxy
|
||||||
|
|
||||||
* `Saddy <https://code.google.com/p/saddy/>`_:
|
* `Saddy <https://github.com/mamontov-cpp/saddy-graphics-engine-2d>`_:
|
||||||
Small crossplatform 2D graphic engine
|
Small crossplatform 2D graphic engine
|
||||||
|
|
||||||
* `Salesforce Analytics Cloud <http://www.salesforce.com/analytics-cloud/overview/>`_:
|
* `Salesforce Analytics Cloud <http://www.salesforce.com/analytics-cloud/overview/>`_:
|
||||||
@ -188,7 +188,7 @@ doesn't support user-defined types. Printf also has safety issues although
|
|||||||
they are mostly solved with `__attribute__ ((format (printf, ...))
|
they are mostly solved with `__attribute__ ((format (printf, ...))
|
||||||
<http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`_ in GCC.
|
<http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`_ in GCC.
|
||||||
There is a POSIX extension that adds positional arguments required for
|
There is a POSIX extension that adds positional arguments required for
|
||||||
`i18n <http://en.wikipedia.org/wiki/Internationalization_and_localization>`_
|
`i18n <https://en.wikipedia.org/wiki/Internationalization_and_localization>`_
|
||||||
to printf but it is not a part of C99 and may not be available on some
|
to printf but it is not a part of C99 and may not be available on some
|
||||||
platforms.
|
platforms.
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ C++ Format is distributed under the BSD `license
|
|||||||
The `Format String Syntax
|
The `Format String Syntax
|
||||||
<http://cppformat.github.io/latest/syntax.html>`_
|
<http://cppformat.github.io/latest/syntax.html>`_
|
||||||
section in the documentation is based on the one from Python `string module
|
section in the documentation is based on the one from Python `string module
|
||||||
documentation <http://docs.python.org/3/library/string.html#module-string>`_
|
documentation <https://docs.python.org/3/library/string.html#module-string>`_
|
||||||
adapted for the current library. For this reason the documentation is
|
adapted for the current library. For this reason the documentation is
|
||||||
distributed under the Python Software Foundation license available in
|
distributed under the Python Software Foundation license available in
|
||||||
`doc/python-license.txt
|
`doc/python-license.txt
|
||||||
@ -409,4 +409,4 @@ formatting. Thanks `Ruslan Baratov <https://github.com/ruslo>`_ for comprehensiv
|
|||||||
and useful comments regarding performance, `Boris Kaul <https://github.com/localvoid>`_ for
|
and useful comments regarding performance, `Boris Kaul <https://github.com/localvoid>`_ for
|
||||||
`C++ counting digits benchmark <https://github.com/localvoid/cxx-benchmark-count-digits>`_.
|
`C++ counting digits benchmark <https://github.com/localvoid/cxx-benchmark-count-digits>`_.
|
||||||
Thanks to `CarterLi <https://github.com/CarterLi>`_ for contributing various
|
Thanks to `CarterLi <https://github.com/CarterLi>`_ for contributing various
|
||||||
improvements to the code.
|
improvements to the code.
|
||||||
1
doc/_templates/layout.html
vendored
1
doc/_templates/layout.html
vendored
@ -53,6 +53,7 @@
|
|||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
|
||||||
aria-expanded="false">{{ version }} <span class="caret"></span></a>
|
aria-expanded="false">{{ version }} <span class="caret"></span></a>
|
||||||
<ul class="dropdown-menu" role="menu">
|
<ul class="dropdown-menu" role="menu">
|
||||||
|
<li><a href="http://cppformat.github.io/2.0.0/">2.0.0</a></li>
|
||||||
<li><a href="http://cppformat.github.io/1.1.0/">1.1.0</a></li>
|
<li><a href="http://cppformat.github.io/1.1.0/">1.1.0</a></li>
|
||||||
<li><a href="http://cppformat.github.io/1.0.0/">1.0.0</a></li>
|
<li><a href="http://cppformat.github.io/1.0.0/">1.0.0</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
13
doc/api.rst
13
doc/api.rst
@ -8,8 +8,8 @@ All functions and classes provided by the C++ Format library reside
|
|||||||
in namespace ``fmt`` and macros have prefix ``FMT_``. For brevity the
|
in namespace ``fmt`` and macros have prefix ``FMT_``. For brevity the
|
||||||
namespace is usually omitted in examples.
|
namespace is usually omitted in examples.
|
||||||
|
|
||||||
Formatting functions
|
Format API
|
||||||
====================
|
==========
|
||||||
|
|
||||||
The following functions use :ref:`format string syntax <syntax>` similar
|
The following functions use :ref:`format string syntax <syntax>` similar
|
||||||
to the one used by Python's `str.format
|
to the one used by Python's `str.format
|
||||||
@ -36,8 +36,11 @@ arguments in the resulting string.
|
|||||||
|
|
||||||
.. doxygenfunction:: print(std::ostream&, CStringRef, ArgList)
|
.. doxygenfunction:: print(std::ostream&, CStringRef, ArgList)
|
||||||
|
|
||||||
|
.. doxygenclass:: fmt::BasicFormatter
|
||||||
|
:members:
|
||||||
|
|
||||||
Printf formatting functions
|
Printf formatting functions
|
||||||
===========================
|
---------------------------
|
||||||
|
|
||||||
The following functions use `printf format string syntax
|
The following functions use `printf format string syntax
|
||||||
<http://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html>`_ with
|
<http://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html>`_ with
|
||||||
@ -45,7 +48,9 @@ a POSIX extension for positional arguments.
|
|||||||
|
|
||||||
.. doxygenfunction:: printf(CStringRef, ArgList)
|
.. doxygenfunction:: printf(CStringRef, ArgList)
|
||||||
|
|
||||||
.. doxygenfunction:: fprintf(std::FILE*, CStringRef, ArgList)
|
.. doxygenfunction:: fprintf(std::FILE *, CStringRef, ArgList)
|
||||||
|
|
||||||
|
.. doxygenfunction:: fprintf(std::ostream&, CStringRef, ArgList)
|
||||||
|
|
||||||
.. doxygenfunction:: sprintf(CStringRef, ArgList)
|
.. doxygenfunction:: sprintf(CStringRef, ArgList)
|
||||||
|
|
||||||
|
|||||||
@ -69,10 +69,12 @@ def build_docs(version='dev'):
|
|||||||
XML_OUTPUT = doxyxml
|
XML_OUTPUT = doxyxml
|
||||||
ALIASES = "rst=\verbatim embed:rst"
|
ALIASES = "rst=\verbatim embed:rst"
|
||||||
ALIASES += "endrst=\endverbatim"
|
ALIASES += "endrst=\endverbatim"
|
||||||
|
MACRO_EXPANSION = YES
|
||||||
PREDEFINED = _WIN32=1 \
|
PREDEFINED = _WIN32=1 \
|
||||||
FMT_USE_VARIADIC_TEMPLATES=1 \
|
FMT_USE_VARIADIC_TEMPLATES=1 \
|
||||||
FMT_USE_RVALUE_REFERENCES=1 \
|
FMT_USE_RVALUE_REFERENCES=1 \
|
||||||
FMT_USE_USER_DEFINED_LITERALS=1
|
FMT_USE_USER_DEFINED_LITERALS=1 \
|
||||||
|
FMT_API=
|
||||||
EXCLUDE_SYMBOLS = fmt::internal::* StringValue write_str
|
EXCLUDE_SYMBOLS = fmt::internal::* StringValue write_str
|
||||||
'''.format(os.path.dirname(doc_dir)).encode('UTF-8'))
|
'''.format(os.path.dirname(doc_dir)).encode('UTF-8'))
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
|
|||||||
@ -59,3 +59,8 @@ div.sphinxsidebar {
|
|||||||
p.rubric {
|
p.rubric {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.github-btn {
|
||||||
|
border: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|||||||
5
posix.cc
5
posix.cc
@ -55,11 +55,14 @@
|
|||||||
|
|
||||||
# ifdef __MINGW32__
|
# ifdef __MINGW32__
|
||||||
# define _SH_DENYNO 0x40
|
# define _SH_DENYNO 0x40
|
||||||
# undef fileno
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
|
#ifdef fileno
|
||||||
|
# undef fileno
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Return type of read and write functions.
|
// Return type of read and write functions.
|
||||||
|
|||||||
4
support/cmake/cppformat-config.cmake.in
Normal file
4
support/cmake/cppformat-config.cmake.in
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake)
|
||||||
|
check_required_components(cppformat)
|
||||||
@ -2,6 +2,14 @@ set(FMT_GMOCK_DIR ../gmock)
|
|||||||
|
|
||||||
include_directories(.. ${FMT_GMOCK_DIR})
|
include_directories(.. ${FMT_GMOCK_DIR})
|
||||||
|
|
||||||
|
# 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.
|
# 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
|
||||||
# pre-compiled copy of Google Test (for example, into /usr/local)?"
|
# pre-compiled copy of Google Test (for example, into /usr/local)?"
|
||||||
@ -10,6 +18,7 @@ include_directories(.. ${FMT_GMOCK_DIR})
|
|||||||
add_library(gmock STATIC
|
add_library(gmock STATIC
|
||||||
${FMT_GMOCK_DIR}/gmock-gtest-all.cc ${FMT_GMOCK_DIR}/gmock/gmock.h
|
${FMT_GMOCK_DIR}/gmock-gtest-all.cc ${FMT_GMOCK_DIR}/gmock/gmock.h
|
||||||
${FMT_GMOCK_DIR}/gtest/gtest.h ${FMT_GMOCK_DIR}/gtest/gtest-spi.h)
|
${FMT_GMOCK_DIR}/gtest/gtest.h ${FMT_GMOCK_DIR}/gtest/gtest-spi.h)
|
||||||
|
target_include_directories(gmock INTERFACE ${FMT_GMOCK_DIR})
|
||||||
find_package(Threads)
|
find_package(Threads)
|
||||||
if (Threads_FOUND)
|
if (Threads_FOUND)
|
||||||
target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT})
|
||||||
@ -28,7 +37,7 @@ check_cxx_source_compiles("
|
|||||||
check_cxx_source_compiles("
|
check_cxx_source_compiles("
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
int main() {}" FMT_INITIALIZER_LIST)
|
int main() {}" FMT_INITIALIZER_LIST)
|
||||||
|
|
||||||
if (NOT FMT_VARIADIC_TEMPLATES OR NOT FMT_INITIALIZER_LIST)
|
if (NOT FMT_VARIADIC_TEMPLATES OR NOT FMT_INITIALIZER_LIST)
|
||||||
add_definitions(-DGTEST_LANG_CXX11=0)
|
add_definitions(-DGTEST_LANG_CXX11=0)
|
||||||
endif ()
|
endif ()
|
||||||
@ -45,7 +54,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})
|
||||||
target_link_libraries(test-main cppformat gmock)
|
target_link_cppformat(test-main gmock)
|
||||||
|
|
||||||
# Adds a test.
|
# Adds a test.
|
||||||
# Usage: add_fmt_test(name [CUSTOM_LINK] srcs...)
|
# Usage: add_fmt_test(name [CUSTOM_LINK] srcs...)
|
||||||
@ -54,7 +63,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)
|
||||||
target_link_libraries(${name} cppformat)
|
target_link_cppformat(${name})
|
||||||
endif ()
|
endif ()
|
||||||
add_test(NAME ${name} COMMAND ${name})
|
add_test(NAME ${name} COMMAND ${name})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
#include "posix.h"
|
#include "posix.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef fileno
|
||||||
# undef fileno
|
# undef fileno
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user