mirror of
https://github.com/GerbilSoft/rom-properties.git
synced 2025-06-18 03:25:38 -04:00
[cmake] gcc.cmake: Add some more clang libc++ hardening options.
These options are now only applied if compiling with clang. While it's possible to use libc++ with gcc, it requires a lot of manual changes, and basicaly no one does it. (libstdc++ with clang is commonly done on desktop Linux systems, though.) Don't -D_LIBCPP_ENABLE_ASSERTIONS on clang-17 or later. It's deprecated, and may result in a compile error. (...though on Android/Termux with clang-20.1.3, it didn't...)
This commit is contained in:
parent
bd5b649bf3
commit
191cbab172
@ -303,10 +303,24 @@ SET(RP_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${CFLAGS_VECTORIZE}")
|
||||
SET(RP_C_FLAGS_RELWITHDEBINFO "-O2 -ggdb -DNDEBUG ${CFLAGS_VECTORIZE}")
|
||||
SET(RP_CXX_FLAGS_RELWITHDEBINFO "-O2 -ggdb -DNDEBUG ${CFLAGS_VECTORIZE}")
|
||||
|
||||
# Enable C++ assertions. (libstdc++ / libc++)
|
||||
# Also enable C++ debug mode. (libstdc++ only)
|
||||
# TODO: Only enable GLIBCXX for libstdc++, and LIBCPP for libc++.
|
||||
SET(RP_CXX_FLAGS_DEBUG "${RP_CXX_FLAGS_DEBUG} -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_LIBCPP_ENABLE_ASSERTIONS -D_LIBCPP_ENABLE_HARDENED_MODE")
|
||||
# Enable C++ assertions and other hardening options. (libstdc++ / libc++)
|
||||
# TODO: Check for the actual C++ runtime being used instead of
|
||||
# assuming libc++ is only used with Clang.
|
||||
SET(RP_CXX_FLAGS_DEBUG "${RP_CXX_FLAGS_DEBUG} -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC")
|
||||
|
||||
# libc++ (clang only)
|
||||
IF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
SET(RP_CXX_FLAGS_DEBUG "${RP_CXX_FLAGS_DEBUG} -D_LIBCPP_ASSERT=1 -D_LIBCPP_DEBUG=1 -D_LIBCPP_ENABLE_HARDENED_MODE=1")
|
||||
|
||||
IF(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 16.50)
|
||||
# clang-17: Use _LIBCPP_HARDENING_MODE.
|
||||
SET(RP_CXX_FLAGS_DEBUG "${RP_CXX_FLAGS_DEBUG} -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG")
|
||||
ELSE(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 16.50)
|
||||
# clang-16 or earlier: Use _LIBCPP_ENABLE_ASSERTIONS.
|
||||
# NOTE: _LIBCPP_ENABLE_ASSERTIONS causes an error if using clang-17 or later.
|
||||
SET(RP_CXX_FLAGS_DEBUG "${RP_CXX_FLAGS_DEBUG} -D_LIBCPP_ENABLE_ASSERTIONS=1")
|
||||
ENDIF(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 16.50)
|
||||
ENDIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
|
||||
# Unset temporary variables.
|
||||
UNSET(CFLAG_OPTIMIZE_DEBUG)
|
||||
|
Loading…
Reference in New Issue
Block a user