@@ -36,6 +36,7 @@ option(enable_coverage "Enable coverage reporting for gcc/clang [development]" O
3636option (enable_tracing "Enable tracing option in release builds [development]" OFF )
3737option (enable_lex_debug "Enable debugging info for lexical scanners in release builds [development]" OFF )
3838
39+ include (CheckCXXCompilerFlag)
3940
4041set (force_qt CACHE INTERNAL "Forces doxywizard to build using the specified major version, this can be Qt5 or Qt6" )
4142set_property (CACHE force_qt PROPERTY STRINGS OFF Qt6 Qt5)
@@ -116,11 +117,28 @@ if (CMAKE_SYSTEM MATCHES "Darwin")
116117 set (EXTRA_LIBS ${CORESERVICES_LIB} )
117118endif ()
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
125143set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_OMIT_LOAD_EXTENSION=1" )
126144
0 commit comments