Skip to content

Commit c9012e7

Browse files
authored
Merge pull request doxygen#11536 from dpronin/dpronin/libcpp/fix
use correct definitions in debug mode with libc++ and libstdc++
2 parents a088d7c + 8a8de15 commit c9012e7

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

CMakeLists.txt

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ option(enable_coverage "Enable coverage reporting for gcc/clang [development]" O
3636
option(enable_tracing "Enable tracing option in release builds [development]" OFF)
3737
option(enable_lex_debug "Enable debugging info for lexical scanners in release builds [development]" OFF)
3838

39+
include(CheckCXXCompilerFlag)
3940

4041
set(force_qt CACHE INTERNAL "Forces doxywizard to build using the specified major version, this can be Qt5 or Qt6")
4142
set_property(CACHE force_qt PROPERTY STRINGS OFF Qt6 Qt5)
@@ -116,11 +117,28 @@ if (CMAKE_SYSTEM MATCHES "Darwin")
116117
set(EXTRA_LIBS ${CORESERVICES_LIB})
117118
endif()
118119

119-
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
120-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_LIBCPP_ENABLE_ASSERTIONS=1")
121-
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
122-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_ASSERTIONS")
123-
endif()
120+
check_cxx_source_compiles(
121+
"
122+
#include <algorithm>
123+
124+
#if !defined(__clang__) || !defined(_LIBCPP_VERSION)
125+
# error \"This is not clang with libcxx by llvm\"
126+
#endif
127+
128+
int main() {
129+
return 0;
130+
}
131+
"
132+
IS_CLANG_LIBCPP
133+
FAIL_REGEX "This is not clang with libcxx by llvm"
134+
)
135+
136+
add_compile_definitions(
137+
# LLVM's clang in combination with libc++
138+
$<$<AND:$<CONFIG:Debug>,$<BOOL:${IS_CLANG_LIBCPP}>>:_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG>
139+
# LLVM's clang or gcc in combination with libstdc++ (GNU)
140+
$<$<AND:$<CONFIG:Debug>,$<NOT:$<BOOL:${IS_CLANG_LIBCPP}>>>:_GLIBCXX_ASSERTIONS>
141+
)
124142

125143
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_OMIT_LOAD_EXTENSION=1")
126144

0 commit comments

Comments
 (0)