@@ -8,26 +8,29 @@ if(MSVC)
88 add_definitions (-DWIN32_LEAN_MEAN )
99endif ()
1010
11- # TODO: this should probably apply to the compiler and not the platform - I think it is only "broken" with MinGW
12- # TODO: AppleClang only has libc++
13- # TODO: what about clang-cl and native Win32 clang?
14- if (CPPCHK_GLIBCXX_DEBUG AND UNIX AND CMAKE_BUILD_TYPE STREQUAL "Debug" )
15- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
16- if (USE_LIBCXX)
17- if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18)
18- add_definitions (-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG )
19- else ()
20- add_definitions (-D_LIBCPP_ENABLE_ASSERTIONS=1 )
21- endif ()
22- # TODO: also add _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS?
11+ # libstdc++-specific flags
12+ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR (NOT USE_LIBCXX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" ))
13+ if (CPPCHK_GLIBCXX_DEBUG AND CMAKE_BUILD_TYPE STREQUAL "Debug" )
14+ add_definitions (-D_GLIBCXX_DEBUG )
15+ endif ()
16+ endif ()
17+
18+ # TODO: what about clang-cl?
19+ # libc++-specific flags - AppleClang only has libc++
20+ if ((USE_LIBCXX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
21+ if (CPPCHK_GLIBCXX_DEBUG AND CMAKE_BUILD_TYPE STREQUAL "Debug" )
22+ # TODO: AppleClang versions do not align with Clang versions - add check for proper version
23+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18)
24+ add_definitions (-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG )
25+ else ()
26+ add_definitions (-D_LIBCPP_ENABLE_ASSERTIONS=1 )
2327 endif ()
28+ # TODO: also add _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS?
2429 else ()
2530 # TODO: check if this can be enabled again for Clang - also done in Makefile
2631 add_definitions (-D_GLIBCXX_DEBUG )
2732 endif ()
28- endif ()
2933
30- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND USE_LIBCXX)
3134 add_definitions (-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES )
3235endif ()
3336
0 commit comments