Skip to content

Commit b9ac2fa

Browse files
committed
use correct definitions in debug mode with libc++ and libstdc++
- llvm suggest we should use _LIBCPP_HARDENING_MODE rather than _LIBCPP_ENABLE_ASSERTIONS and they are about to remove _LIBCPP_ENABLE_ASSERTIONS from llvm's sources at all, so we need to prepare - libstdc++ uses _GLIBCXX_ASSERTIONS, libc++ by llvm uses _LIBCPP_HARDENING_MODE, so let's use them separately Signed-off-by: Denis Pronin <dannftk@yandex.ru>
1 parent 0006fa4 commit b9ac2fa

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,26 @@ if(HAS_FCF_PROTECTION)
135135
target_compile_options(btop PRIVATE -fcf-protection)
136136
endif()
137137

138+
check_cxx_source_compiles(
139+
"
140+
#include <algorithm>
141+
142+
#if !defined(__clang__) || !defined(_LIBCPP_VERSION)
143+
# error \"This is not clang with libcxx by llvm\"
144+
#endif
145+
146+
int main() {
147+
return 0;
148+
}
149+
"
150+
IS_CLANG_LIBCPP
151+
FAIL_REGEX "This is not clang with libcxx by llvm"
152+
)
153+
138154
target_compile_definitions(btop PRIVATE
139155
FMT_HEADER_ONLY
140156
_FILE_OFFSET_BITS=64
141-
$<$<CONFIG:Debug>:_GLIBCXX_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS=1>
157+
$<IF:$<AND:$<CONFIG:Debug>,$<BOOL:${IS_CLANG_LIBCPP}>>,_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG,_GLIBCXX_ASSERTIONS>
142158
# Only has an effect with optimizations enabled
143159
$<$<AND:$<NOT:$<CONFIG:Debug>>,$<BOOL:${BTOP_FORTIFY}>>:_FORTIFY_SOURCE=3>
144160
)

0 commit comments

Comments
 (0)