From 131878ce9e18e3fcc5fdd690c93ee9d36f0a18d3 Mon Sep 17 00:00:00 2001 From: Olivier Ldff Date: Sat, 11 Apr 2020 16:44:37 +0200 Subject: [PATCH] use target_compile_features to use c++11 if cmake > 3.8 If target_compile_features is available and cxx_std_11. This fix compilation with clang and gcc when c++11 isn't specified by user. --- googletest/cmake/internal_utils.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index 2f70f0b0..b3e8b819 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -188,6 +188,10 @@ function(cxx_library_with_type name type cxx_flags) endif() target_link_libraries(${name} PUBLIC ${threads_spec}) endif() + + if (NOT "${CMAKE_VERSION}" VERSION_LESS "3.8") + target_compile_features(${name} PUBLIC cxx_std_11) + endif() endfunction() ########################################################################