Use target_compile_features to specify C++ standard requirement

This commit is contained in:
Chris Thrasher
2022-11-24 23:33:42 -06:00
committed by Victor Zverovich
parent fae6f7e081
commit 69ffedfe52
9 changed files with 16 additions and 76 deletions

View File

@@ -109,7 +109,7 @@ if (FMT_MODULE)
# If module support is present the module tests require a
# test-only module to be built from {fmt}
add_library(test-module OBJECT ${CMAKE_SOURCE_DIR}/src/fmt.cc)
target_compile_features(test-module PUBLIC ${FMT_REQUIRED_FEATURES})
target_compile_features(test-module PUBLIC cxx_std_11)
target_include_directories(test-module PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
enable_module(test-module)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1...3.18)
cmake_minimum_required(VERSION 3.8...3.18)
project(fmt-test CXX)

View File

@@ -1,6 +1,6 @@
# Test if compile errors are produced where necessary.
cmake_minimum_required(VERSION 3.1...3.18)
cmake_minimum_required(VERSION 3.8...3.18)
project(compile-error-test CXX)
set(fmt_headers "
@@ -64,7 +64,7 @@ function (run_tests)
")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/CMakeLists.txt" "
cmake_minimum_required(VERSION 3.1...3.18)
cmake_minimum_required(VERSION 3.8...3.18)
project(tests CXX)
add_subdirectory(${FMT_DIR} fmt)
${cmake_targets}

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1...3.18)
cmake_minimum_required(VERSION 3.8...3.18)
project(fmt-test)

View File

@@ -22,7 +22,7 @@ function(add_fuzzer source)
if (FMT_FUZZ_LDFLAGS)
target_link_libraries(${name} PRIVATE ${FMT_FUZZ_LDFLAGS})
endif ()
target_compile_features(${name} PRIVATE cxx_generic_lambdas)
target_compile_features(${name} PRIVATE cxx_std_14)
endfunction()
foreach (source chrono-duration.cc chrono-timepoint.cc float.cc named-arg.cc one-arg.cc two-args.cc)

View File

@@ -9,6 +9,7 @@ add_library(gtest STATIC
gmock-gtest-all.cc gmock/gmock.h gtest/gtest.h gtest/gtest-spi.h)
target_compile_definitions(gtest PUBLIC GTEST_HAS_STD_WSTRING=1)
target_include_directories(gtest SYSTEM PUBLIC .)
target_compile_features(gtest PUBLIC cxx_std_11)
find_package(Threads)
if (Threads_FOUND)
@@ -17,9 +18,10 @@ else ()
target_compile_definitions(gtest PUBLIC GTEST_HAS_PTHREAD=0)
endif ()
# Workaround GTest bug https://github.com/google/googletest/issues/705.
fmt_check_cxx_compiler_flag(
-fno-delete-null-pointer-checks HAVE_FNO_DELETE_NULL_POINTER_CHECKS)
# Workaround GTest bug https://github.com/google/googletest/issues/705
if (NOT MSVC)
check_cxx_compiler_flag(-fno-delete-null-pointer-checks HAVE_FNO_DELETE_NULL_POINTER_CHECKS)
endif ()
if (HAVE_FNO_DELETE_NULL_POINTER_CHECKS)
target_compile_options(gtest PUBLIC -fno-delete-null-pointer-checks)
endif ()

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1...3.18)
cmake_minimum_required(VERSION 3.8...3.18)
project(fmt-link CXX)