Disable exceptions and RTTI in CMake configuration.
PiperOrigin-RevId: 252842234
This commit is contained in:
parent
4cb80b7ddc
commit
69061b464a
@ -49,9 +49,31 @@ check_cxx_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC)
|
|||||||
check_cxx_symbol_exists(F_FULLFSYNC "fcntl.h" HAVE_FULLFSYNC)
|
check_cxx_symbol_exists(F_FULLFSYNC "fcntl.h" HAVE_FULLFSYNC)
|
||||||
check_cxx_symbol_exists(O_CLOEXEC "fcntl.h" HAVE_O_CLOEXEC)
|
check_cxx_symbol_exists(O_CLOEXEC "fcntl.h" HAVE_O_CLOEXEC)
|
||||||
|
|
||||||
include(CheckCXXSourceCompiles)
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
# Disable C++ exceptions.
|
||||||
|
string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHs-c-")
|
||||||
|
add_definitions(-D_HAS_EXCEPTIONS=0)
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes")
|
# Disable RTTI.
|
||||||
|
string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
|
||||||
|
else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
# Enable strict prototype warnings for C code in clang and gcc.
|
||||||
|
if(NOT CMAKE_C_FLAGS MATCHES "-Wstrict-prototypes")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes")
|
||||||
|
endif(NOT CMAKE_C_FLAGS MATCHES "-Wstrict-prototypes")
|
||||||
|
|
||||||
|
# Disable C++ exceptions.
|
||||||
|
string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
||||||
|
|
||||||
|
# Disable RTTI.
|
||||||
|
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
||||||
|
endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
|
||||||
|
include(CheckCXXSourceCompiles)
|
||||||
|
|
||||||
# Test whether -Wthread-safety is available. See
|
# Test whether -Wthread-safety is available. See
|
||||||
# https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
|
# https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
|
||||||
|
Loading…
x
Reference in New Issue
Block a user