From 7475ba5039753da07b5c80ccd61983dc83c82cb0 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 21 Feb 2019 11:41:38 -0800 Subject: [PATCH] clang: explicitly enable/disable RTTI support with the compiler Add `-frtti` to the compiler with the base flags case so that RTTI is enabled by default with clang. Add its inverse analog, `cxx_no_rtti_flags` in order to test the case with RTTI off, similar to gcc. This reduces the amount of testing/support overhead needed in the non-RTTI case with clang, as the tests currently fail when these two features are off with version 1.8.1. This something I used in when investigating test failures on FreeBSD, as the tests that rely on RTTI were failing with googletest 1.8.1 on the OS platform. More investigation is being done to determine how this should be fixed on FreeBSD 11.2-RELEASE with ports, as the package doesn't currently compile the tests, and when enabled (based on my WIP diff), the tests fail in similar ways. Signed-off-by: Enji Cooper --- googletest/cmake/internal_utils.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index eab18fd0..beaefe66 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -78,10 +78,11 @@ macro(config_compiler_and_linker) # http://stackoverflow.com/questions/3232669 explains the issue. set(cxx_base_flags "${cxx_base_flags} -wd4702") elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(cxx_base_flags "-Wall -Wshadow -Werror -Wno-error=sign-conversion") + set(cxx_base_flags "-Wall -Wshadow -Werror -Wno-error=sign-conversion -frtti") set(cxx_exception_flags "-fexceptions") set(cxx_no_exception_flags "-fno-exceptions") set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls") + set(cxx_no_rtti_flags "-fno-rtti") elseif (CMAKE_COMPILER_IS_GNUCXX) set(cxx_base_flags "-Wall -Wshadow -Werror") if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0)