From 16533b275b280e9cb51748688eef6f9f808f4291 Mon Sep 17 00:00:00 2001 From: Elias Kosunen Date: Wed, 23 May 2018 14:12:13 +0300 Subject: [PATCH] Fix test builds with C++11 --- include/fmt/format.h | 2 +- test/CMakeLists.txt | 15 +++------------ test/add-subdirectory-test/CMakeLists.txt | 2 -- test/compile-test/CMakeLists.txt | 1 - test/find-package-test/CMakeLists.txt | 2 -- 5 files changed, 4 insertions(+), 18 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 07c16694..ccafe497 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3645,7 +3645,7 @@ FMT_END_NAMESPACE #define FMT_STRING(s) [] { \ struct S : fmt::format_string { \ - static FMT_CONSTEXPR auto data() { return s; } \ + static FMT_CONSTEXPR decltype(s) data() { return s; } \ static FMT_CONSTEXPR size_t size() { return sizeof(s); } \ }; \ return S{}; \ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 785bb694..8978a083 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,7 +7,6 @@ # at http://code.google.com/p/googletest/wiki/FAQ for more details. add_library(gmock STATIC gmock-gtest-all.cc gmock/gmock.h gtest/gtest.h gtest/gtest-spi.h) -target_compile_options(gmock PUBLIC ${CPP14_FLAG}) target_compile_definitions(gmock PUBLIC GTEST_HAS_STD_WSTRING=1) target_include_directories(gmock PUBLIC .) @@ -94,12 +93,6 @@ add_fmt_test(util-test mock-allocator.h) add_fmt_test(custom-formatter-test) #add_fmt_test(ranges-test) -# Enable stricter options for one test to make sure that the header is free of -# warnings. -if (FMT_PEDANTIC AND MSVC) - target_compile_options(format-test PRIVATE /W4) -endif () - if (HAVE_OPEN) add_fmt_executable(posix-mock-test posix-mock-test.cc ../src/format.cc ${TEST_MAIN_SRC}) @@ -126,7 +119,6 @@ endif () check_cxx_compiler_flag(-fno-exceptions HAVE_FNO_EXCEPTIONS_FLAG) if (HAVE_FNO_EXCEPTIONS_FLAG) add_library(noexception-test ../src/format.cc) - target_compile_options(noexception-test PUBLIC ${CPP14_FLAG}) target_include_directories( noexception-test PRIVATE ${PROJECT_SOURCE_DIR}/include) target_compile_options(noexception-test PRIVATE -fno-exceptions) @@ -136,7 +128,6 @@ if (FMT_PEDANTIC) # Test that the library compiles without windows.h. if (CMAKE_SYSTEM_NAME STREQUAL "Windows") add_library(no-windows-h-test ../src/format.cc) - target_compile_options(no-windows-h-test PUBLIC ${CPP14_FLAG}) target_include_directories( no-windows-h-test PRIVATE ${PROJECT_SOURCE_DIR}/include) target_compile_definitions(no-windows-h-test PRIVATE FMT_USE_WINDOWS_H=0) @@ -150,7 +141,7 @@ if (FMT_PEDANTIC) --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" - "-DCPP14_FLAG=${CPP14_FLAG}" + "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" "-DSUPPORTS_USER_DEFINED_LITERALS=${SUPPORTS_USER_DEFINED_LITERALS}") # test if the targets are findable from the build directory @@ -163,7 +154,7 @@ if (FMT_PEDANTIC) --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" - "-DCPP14_FLAG=${CPP14_FLAG}" + "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" "-DFMT_DIR=${PROJECT_BINARY_DIR}" "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") @@ -177,6 +168,6 @@ if (FMT_PEDANTIC) --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" - "-DCPP14_FLAG=${CPP14_FLAG}" + "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") endif () diff --git a/test/add-subdirectory-test/CMakeLists.txt b/test/add-subdirectory-test/CMakeLists.txt index 4a4441c5..d1edd8a5 100644 --- a/test/add-subdirectory-test/CMakeLists.txt +++ b/test/add-subdirectory-test/CMakeLists.txt @@ -5,11 +5,9 @@ project(fmt-test) add_subdirectory(../.. fmt) add_executable(library-test "main.cc") -target_compile_options(library-test PUBLIC ${CPP14_FLAG}) target_link_libraries(library-test fmt::fmt) if (TARGET fmt::fmt-header-only) add_executable(header-only-test "main.cc") - target_compile_options(header-only-test PUBLIC ${CPP14_FLAG}) target_link_libraries(header-only-test fmt::fmt-header-only) endif () diff --git a/test/compile-test/CMakeLists.txt b/test/compile-test/CMakeLists.txt index dda1fb96..dbf52b07 100644 --- a/test/compile-test/CMakeLists.txt +++ b/test/compile-test/CMakeLists.txt @@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 2.8) include(CheckCXXSourceCompiles) set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../../include) -set(CMAKE_REQUIRED_FLAGS ${CPP14_FLAG}) function (generate_source result fragment) set(${result} " diff --git a/test/find-package-test/CMakeLists.txt b/test/find-package-test/CMakeLists.txt index e860879c..40c07560 100644 --- a/test/find-package-test/CMakeLists.txt +++ b/test/find-package-test/CMakeLists.txt @@ -5,11 +5,9 @@ project(fmt-test) find_package(FMT REQUIRED) add_executable(library-test main.cc) -target_compile_options(library-test PUBLIC ${CPP14_FLAG}) target_link_libraries(library-test fmt::fmt) if (TARGET fmt::fmt-header-only) add_executable(header-only-test main.cc) - target_compile_options(header-only-test PUBLIC ${CPP14_FLAG}) target_link_libraries(header-only-test fmt::fmt-header-only) endif ()