2018-07-26 07:29:12 +00:00
|
|
|
find_path(fmt_INCLUDE_DIR NAMES fmt/format.h)
|
|
|
|
|
cmake: require 4.0.0 <= libfmt-dev < 5.0.0
FMT_VERSION is now living in fmt/core.h in libfmt >= 5.0, so we cannot
parse fmt/format.h for libfmt's version anymore. also we don't need
Findfmt.cmake now. because libfmt-dev 4.0 and up is required by seastar,
also it's libfmt-dev 3.x's cmake module which fails to offer fmt::fmt
target. in other words, it's safe to drop libfmt 3.x support. but 5.0.0
is not compatible with seastar, we will have failures like:
In file included from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/aligned_buffer.hh:25:0,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/reactor.hh:26,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/alien.hh:35,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/src/core/alien.cc:23:
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:
In function 'seastar::sstring seastar::format(const char*, A&& ...)':
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:135:10:
error: 'MemoryWriter' is not a member of 'fmt'
fmt::MemoryWriter out;
^~~~~~~~~~~~
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:136:5:
error: 'out' was not declared in this scope
out.write(fmt, std::forward<A>(a)...);
^~~
so, we should build libfmt even if we have libfmt-dev 5.x
Signed-off-by: Kefu Chai <kchai@redhat.com>
2018-08-02 11:04:30 +00:00
|
|
|
if(fmt_INCLUDE_DIR)
|
2018-09-08 15:45:55 +00:00
|
|
|
set(_fmt_version_file "${fmt_INCLUDE_DIR}/fmt/core.h")
|
cmake: require 4.0.0 <= libfmt-dev < 5.0.0
FMT_VERSION is now living in fmt/core.h in libfmt >= 5.0, so we cannot
parse fmt/format.h for libfmt's version anymore. also we don't need
Findfmt.cmake now. because libfmt-dev 4.0 and up is required by seastar,
also it's libfmt-dev 3.x's cmake module which fails to offer fmt::fmt
target. in other words, it's safe to drop libfmt 3.x support. but 5.0.0
is not compatible with seastar, we will have failures like:
In file included from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/aligned_buffer.hh:25:0,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/reactor.hh:26,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/alien.hh:35,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/src/core/alien.cc:23:
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:
In function 'seastar::sstring seastar::format(const char*, A&& ...)':
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:135:10:
error: 'MemoryWriter' is not a member of 'fmt'
fmt::MemoryWriter out;
^~~~~~~~~~~~
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:136:5:
error: 'out' was not declared in this scope
out.write(fmt, std::forward<A>(a)...);
^~~
so, we should build libfmt even if we have libfmt-dev 5.x
Signed-off-by: Kefu Chai <kchai@redhat.com>
2018-08-02 11:04:30 +00:00
|
|
|
if(NOT EXISTS "${_fmt_version_file}")
|
2018-09-08 15:45:55 +00:00
|
|
|
set(_fmt_version_file "${fmt_INCLUDE_DIR}/fmt/format.h")
|
cmake: require 4.0.0 <= libfmt-dev < 5.0.0
FMT_VERSION is now living in fmt/core.h in libfmt >= 5.0, so we cannot
parse fmt/format.h for libfmt's version anymore. also we don't need
Findfmt.cmake now. because libfmt-dev 4.0 and up is required by seastar,
also it's libfmt-dev 3.x's cmake module which fails to offer fmt::fmt
target. in other words, it's safe to drop libfmt 3.x support. but 5.0.0
is not compatible with seastar, we will have failures like:
In file included from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/aligned_buffer.hh:25:0,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/reactor.hh:26,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/alien.hh:35,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/src/core/alien.cc:23:
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:
In function 'seastar::sstring seastar::format(const char*, A&& ...)':
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:135:10:
error: 'MemoryWriter' is not a member of 'fmt'
fmt::MemoryWriter out;
^~~~~~~~~~~~
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:136:5:
error: 'out' was not declared in this scope
out.write(fmt, std::forward<A>(a)...);
^~~
so, we should build libfmt even if we have libfmt-dev 5.x
Signed-off-by: Kefu Chai <kchai@redhat.com>
2018-08-02 11:04:30 +00:00
|
|
|
endif()
|
|
|
|
if(EXISTS "${_fmt_version_file}")
|
|
|
|
# parse "#define FMT_VERSION 40100" to 4.1.0
|
2018-09-08 15:45:55 +00:00
|
|
|
file(STRINGS "${_fmt_version_file}" fmt_VERSION_LINE
|
cmake: require 4.0.0 <= libfmt-dev < 5.0.0
FMT_VERSION is now living in fmt/core.h in libfmt >= 5.0, so we cannot
parse fmt/format.h for libfmt's version anymore. also we don't need
Findfmt.cmake now. because libfmt-dev 4.0 and up is required by seastar,
also it's libfmt-dev 3.x's cmake module which fails to offer fmt::fmt
target. in other words, it's safe to drop libfmt 3.x support. but 5.0.0
is not compatible with seastar, we will have failures like:
In file included from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/aligned_buffer.hh:25:0,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/reactor.hh:26,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/alien.hh:35,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/src/core/alien.cc:23:
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:
In function 'seastar::sstring seastar::format(const char*, A&& ...)':
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:135:10:
error: 'MemoryWriter' is not a member of 'fmt'
fmt::MemoryWriter out;
^~~~~~~~~~~~
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:136:5:
error: 'out' was not declared in this scope
out.write(fmt, std::forward<A>(a)...);
^~~
so, we should build libfmt even if we have libfmt-dev 5.x
Signed-off-by: Kefu Chai <kchai@redhat.com>
2018-08-02 11:04:30 +00:00
|
|
|
REGEX "^#define[ \t]+FMT_VERSION[ \t]+[0-9]+$")
|
|
|
|
string(REGEX REPLACE "^#define[ \t]+FMT_VERSION[ \t]+([0-9]+)$"
|
|
|
|
"\\1" fmt_VERSION "${fmt_VERSION_LINE}")
|
|
|
|
foreach(ver "fmt_VERSION_PATCH" "fmt_VERSION_MINOR" "fmt_VERSION_MAJOR")
|
|
|
|
math(EXPR ${ver} "${fmt_VERSION} % 100")
|
|
|
|
math(EXPR fmt_VERSION "(${fmt_VERSION} - ${${ver}}) / 100")
|
|
|
|
endforeach()
|
|
|
|
set(fmt_VERSION
|
2018-07-26 07:29:12 +00:00
|
|
|
"${fmt_VERSION_MAJOR}.${fmt_VERSION_MINOR}.${fmt_VERSION_PATCH}")
|
cmake: require 4.0.0 <= libfmt-dev < 5.0.0
FMT_VERSION is now living in fmt/core.h in libfmt >= 5.0, so we cannot
parse fmt/format.h for libfmt's version anymore. also we don't need
Findfmt.cmake now. because libfmt-dev 4.0 and up is required by seastar,
also it's libfmt-dev 3.x's cmake module which fails to offer fmt::fmt
target. in other words, it's safe to drop libfmt 3.x support. but 5.0.0
is not compatible with seastar, we will have failures like:
In file included from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/aligned_buffer.hh:25:0,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/reactor.hh:26,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/alien.hh:35,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/src/core/alien.cc:23:
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:
In function 'seastar::sstring seastar::format(const char*, A&& ...)':
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:135:10:
error: 'MemoryWriter' is not a member of 'fmt'
fmt::MemoryWriter out;
^~~~~~~~~~~~
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:136:5:
error: 'out' was not declared in this scope
out.write(fmt, std::forward<A>(a)...);
^~~
so, we should build libfmt even if we have libfmt-dev 5.x
Signed-off-by: Kefu Chai <kchai@redhat.com>
2018-08-02 11:04:30 +00:00
|
|
|
endif()
|
2018-07-26 07:29:12 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
find_library(fmt_LIBRARY NAMES fmt)
|
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(fmt
|
|
|
|
REQUIRED_VARS fmt_INCLUDE_DIR fmt_LIBRARY
|
cmake: require 4.0.0 <= libfmt-dev < 5.0.0
FMT_VERSION is now living in fmt/core.h in libfmt >= 5.0, so we cannot
parse fmt/format.h for libfmt's version anymore. also we don't need
Findfmt.cmake now. because libfmt-dev 4.0 and up is required by seastar,
also it's libfmt-dev 3.x's cmake module which fails to offer fmt::fmt
target. in other words, it's safe to drop libfmt 3.x support. but 5.0.0
is not compatible with seastar, we will have failures like:
In file included from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/aligned_buffer.hh:25:0,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/reactor.hh:26,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/alien.hh:35,
from
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/src/core/alien.cc:23:
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:
In function 'seastar::sstring seastar::format(const char*, A&& ...)':
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:135:10:
error: 'MemoryWriter' is not a member of 'fmt'
fmt::MemoryWriter out;
^~~~~~~~~~~~
/home/smithfarm/src/ceph/smithfarm/ceph/src/seastar/include/seastar/core/print.hh:136:5:
error: 'out' was not declared in this scope
out.write(fmt, std::forward<A>(a)...);
^~~
so, we should build libfmt even if we have libfmt-dev 5.x
Signed-off-by: Kefu Chai <kchai@redhat.com>
2018-08-02 11:04:30 +00:00
|
|
|
VERSION_VAR fmt_VERSION)
|
2018-07-26 07:29:12 +00:00
|
|
|
mark_as_advanced(
|
|
|
|
fmt_INCLUDE_DIR
|
|
|
|
fmt_LIBRARY
|
|
|
|
fmt_VERSION_MAJOR
|
|
|
|
fmt_VERSION_MINOR
|
|
|
|
fmt_VERSION_PATCH
|
|
|
|
fmt_VERSION_STRING)
|
|
|
|
|
|
|
|
if(fmt_FOUND AND NOT (TARGET fmt::fmt))
|
2021-07-23 09:52:12 +00:00
|
|
|
add_library(fmt-header-only INTERFACE)
|
|
|
|
set_target_properties(fmt-header-only PROPERTIES
|
2018-07-26 07:29:12 +00:00
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${fmt_INCLUDE_DIR}"
|
2021-07-23 09:52:12 +00:00
|
|
|
INTERFACE_COMPILE_DEFINITIONS FMT_HEADER_ONLY=1
|
|
|
|
INTERFACE_COMPILE_FEATURES cxx_std_11)
|
|
|
|
|
|
|
|
add_library(fmt UNKNOWN IMPORTED GLOBAL)
|
|
|
|
set_target_properties(fmt PROPERTIES
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${fmt_INCLUDE_DIR}"
|
|
|
|
INTERFACE_COMPILE_FEATURES cxx_std_11
|
2018-07-26 07:29:12 +00:00
|
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
|
|
|
|
IMPORTED_LOCATION "${fmt_LIBRARY}")
|
2021-07-23 09:52:12 +00:00
|
|
|
|
|
|
|
if(WITH_FMT_HEADER_ONLY)
|
|
|
|
# please note, this is different from how upstream defines fmt::fmt.
|
|
|
|
# in order to force 3rd party libraries to link against fmt-header-only if
|
|
|
|
# WITH_FMT_HEADER_ONLY is ON, we have to point fmt::fmt to fmt-header-only
|
|
|
|
# in this case.
|
|
|
|
add_library(fmt::fmt ALIAS fmt-header-only)
|
|
|
|
else()
|
|
|
|
add_library(fmt::fmt ALIAS fmt)
|
|
|
|
endif()
|
|
|
|
|
2018-07-26 07:29:12 +00:00
|
|
|
endif()
|