Add feature testing codes in CMakeLists.txt for future use. Doesn't work though.
This commit is contained in:
parent
4fccc4399f
commit
52039e8b71
@ -80,7 +80,7 @@ if (BIICODE)
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_library(format ${FMT_SOURCES})
|
add_library(format ${FMT_SOURCES})
|
||||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
set_target_properties(format PROPERTIES COMPILE_FLAGS
|
set_target_properties(format PROPERTIES COMPILE_FLAGS
|
||||||
"-Wall -Wextra -Wshadow -pedantic")
|
"-Wall -Wextra -Wshadow -pedantic")
|
||||||
if (CPP11_FLAG)
|
if (CPP11_FLAG)
|
||||||
@ -117,6 +117,49 @@ if (NOT FMT_VARIADIC_TEMPLATES)
|
|||||||
add_definitions(-DGTEST_LANG_CXX11=0)
|
add_definitions(-DGTEST_LANG_CXX11=0)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
# g++ 4.6 supports nullptr with __cplusplus==1
|
||||||
|
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=1773
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
int main(){int*p=nullptr;}" FMT_NULLPTR)
|
||||||
|
if (FMT_NULLPTR)
|
||||||
|
add_definitions(-DFMT_USE_NULLPTR=1)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
struct C{
|
||||||
|
C()=delete;
|
||||||
|
C(const C&)=delete;
|
||||||
|
C& operator=(const C&)=delete;
|
||||||
|
};
|
||||||
|
int main(){}" FMT_DELETED_FUNCTIONS)
|
||||||
|
if (FMT_DELETED_FUNCTIONS)
|
||||||
|
add_definitions(-DFMT_USE_DELETED_FUNCTIONS=1)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
void f() noexcept {}
|
||||||
|
int main(){ f(); }" FMT_BASIC_NOEXCEPT_SUPPORT)
|
||||||
|
if (FMT_BASIC_NOEXCEPT_SUPPORT)
|
||||||
|
add_definitions(-DFMT_USE_NOEXCEPT=1)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <utility>
|
||||||
|
struct MoveOnly {
|
||||||
|
MoveOnly() {}
|
||||||
|
MoveOnly(MoveOnly&&) {}
|
||||||
|
private:
|
||||||
|
MoveOnly(const MoveOnly&);
|
||||||
|
};
|
||||||
|
int main() {
|
||||||
|
MoveOnly a;
|
||||||
|
MoveOnly b(std::move(a));
|
||||||
|
MoveOnly c(MoveOnly());
|
||||||
|
}" FMT_RVALUE_REFERENCES)
|
||||||
|
if (FMT_RVALUE_REFERENCES)
|
||||||
|
add_definitions(-DFMT_USE_RVALUE_REFERENCES=1)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# GTest doesn't detect <tuple> with clang.
|
# GTest doesn't detect <tuple> with clang.
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
target_compile_definitions(gmock PUBLIC GTEST_USE_OWN_TR1_TUPLE=1)
|
target_compile_definitions(gmock PUBLIC GTEST_USE_OWN_TR1_TUPLE=1)
|
||||||
|
|||||||
15
format.h
15
format.h
@ -115,27 +115,25 @@
|
|||||||
#if FMT_USE_NOEXCEPT || FMT_HAS_FEATURE(cxx_noexcept) || \
|
#if FMT_USE_NOEXCEPT || FMT_HAS_FEATURE(cxx_noexcept) || \
|
||||||
(FMT_GCC_VERSION >= 408 && __cplusplus >= 201103L)
|
(FMT_GCC_VERSION >= 408 && __cplusplus >= 201103L)
|
||||||
# define FMT_NOEXCEPT noexcept
|
# define FMT_NOEXCEPT noexcept
|
||||||
# define FMT_NOEXCEPT_EXPR(expr) noexcept(expr)
|
|
||||||
#else
|
#else
|
||||||
# define FMT_NOEXCEPT throw()
|
# define FMT_NOEXCEPT throw()
|
||||||
# define FMT_NOEXCEPT_EXPR(expr)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// A macro to disallow the copy constructor and operator= functions
|
// A macro to disallow the copy constructor and operator= functions
|
||||||
// This should be used in the private: declarations for a class
|
// This should be used in the private: declarations for a class
|
||||||
#if FMT_HAS_FEATURE(cxx_deleted_functions)\
|
#if FMT_USE_DELETED_FUNCTIONS || FMT_HAS_FEATURE(cxx_deleted_functions)\
|
||||||
|| (FMT_GCC_VERSION >= 404 && __cplusplus >= 201103L)\
|
|| (FMT_GCC_VERSION >= 404 && __cplusplus >= 201103L)\
|
||||||
|| (_MSC_VER >= 1800)
|
|| (_MSC_VER >= 1800)
|
||||||
#define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
#define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||||
TypeName(const TypeName&) = delete; \
|
TypeName(const TypeName&) = delete; \
|
||||||
void operator=(const TypeName&) = delete
|
TypeName& operator=(const TypeName&) = delete
|
||||||
#else
|
#else
|
||||||
#define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
#define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||||
TypeName(const TypeName&); \
|
TypeName(const TypeName&); \
|
||||||
void operator=(const TypeName&)
|
TypeName& operator=(const TypeName&)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if FMT_HAS_FEATURE(cxx_nullptr)\
|
#if FMT_USE_NULLPTR || FMT_HAS_FEATURE(cxx_nullptr)\
|
||||||
|| (FMT_GCC_VERSION >= 406 && __cplusplus >= 201103L)\
|
|| (FMT_GCC_VERSION >= 406 && __cplusplus >= 201103L)\
|
||||||
|| (_MSC_VER >= 1600)
|
|| (_MSC_VER >= 1600)
|
||||||
// Use nullptr
|
// Use nullptr
|
||||||
@ -149,12 +147,11 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
template<typename C, typename T>
|
template<typename C, typename T>
|
||||||
operator T C::*() const
|
operator T C::*() const {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void operator&() const;
|
void operator&() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ add_fmt_test(format-test)
|
|||||||
add_fmt_test(format-impl-test CUSTOM_LINK)
|
add_fmt_test(format-impl-test CUSTOM_LINK)
|
||||||
add_fmt_test(printf-test)
|
add_fmt_test(printf-test)
|
||||||
foreach (target format-test printf-test)
|
foreach (target format-test printf-test)
|
||||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS
|
set_target_properties(${target} PROPERTIES COMPILE_FLAGS
|
||||||
"-Wall -Wextra -pedantic -Wno-long-long -Wno-variadic-macros")
|
"-Wall -Wextra -pedantic -Wno-long-long -Wno-variadic-macros")
|
||||||
endif ()
|
endif ()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user