Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cmake/compilerCheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
message(ERROR "GCC >= 5.1 required - detected ${CMAKE_CXX_COMPILER_VERSION} not supported")
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
message(ERROR "Clang >= 3.5 required - detected ${CMAKE_CXX_COMPILER_VERSION} not supported")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
message(ERROR "AppleClang >= 6.0 required - detected ${CMAKE_CXX_COMPILER_VERSION} not supported")
endif()
elseif(MSVC)
if(MSVC_VERSION VERSION_LESS 1900)
message(ERROR "Visual Studio >= 2015 (19.0) required - detected ${MSVC_VERSION} not supported")
endif()
else()
message(WARNING "Unknown compiler ${CMAKE_CXX_COMPILER_ID}")
endif()
32 changes: 18 additions & 14 deletions cmake/compilerDefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@ if(MSVC)
add_definitions(-DWIN32_LEAN_MEAN)
endif()

# TODO: this should probably apply to the compiler and not the platform - I think it is only "broken" with MinGW
# TODO: AppleClang only has libc++
# TODO: what about clang-cl and native Win32 clang?
if(CPPCHK_GLIBCXX_DEBUG AND UNIX AND CMAKE_BUILD_TYPE STREQUAL "Debug")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(USE_LIBCXX)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18)
add_definitions(-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG)
else()
add_definitions(-D_LIBCPP_ENABLE_ASSERTIONS=1)
endif()
# TODO: also add _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS?
# libstdc++-specific flags
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR (NOT USE_LIBCXX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
if(CPPCHK_GLIBCXX_DEBUG AND CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-D_GLIBCXX_DEBUG)
endif()
endif()

# TODO: what about clang-cl?
# libc++-specific flags - AppleClang only has libc++
if ((USE_LIBCXX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
if(CPPCHK_GLIBCXX_DEBUG AND CMAKE_BUILD_TYPE STREQUAL "Debug")
# TODO: determine proper version for AppleClang - current value is based on the oldest version avaialble in CI
if((CMAKE_CXX_COMPILER_ID STREQUALS "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17))
add_definitions(-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG)
else()
add_definitions(-D_LIBCPP_ENABLE_ASSERTIONS=1)
endif()
# TODO: also add _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS?
else()
# TODO: check if this can be enabled again for Clang - also done in Makefile
add_definitions(-D_GLIBCXX_DEBUG)
endif()
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND USE_LIBCXX)
add_definitions(-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
endif()

Expand Down
4 changes: 4 additions & 0 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ if (NOT USE_BOOST AND USE_BOOST_INT128)
endif()
option(USE_LIBCXX "Use libc++ instead of libstdc++" OFF)

if(USE_LIBCXX AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(FATAL_ERROR "libc++ can only be used with a Clang-based compiler")
endif()

option(NO_UNIX_SIGNAL_HANDLING "Disable usage of Unix Signal Handling" OFF)
option(NO_UNIX_BACKTRACE_SUPPORT "Disable usage of Unix Backtrace support" OFF)
option(NO_WINDOWS_SEH "Disable usage of Windows SEH" OFF)
Expand Down
2 changes: 2 additions & 0 deletions lib/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
# define UNUSED
#endif

// TODO: AppleClang versions do not align with Clang versions - add check for proper version
// warn_unused
#if __has_cpp_attribute (gnu::warn_unused) || \
(defined(__clang__) && (__clang_major__ >= 15))
Expand All @@ -115,6 +116,7 @@
# define DEPRECATED
#endif

// TODO: AppleClang versions do not align with Clang versions - add check for proper version
// returns_nonnull
#if __has_cpp_attribute (gnu::returns_nonnull)
# define RET_NONNULL [[gnu::returns_nonnull]]
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ You can stop the script whenever you like with Ctrl C.

## Compiling

Cppcheck requires a C++ compiler with (partial) C++11 support. Minimum required versions are GCC 5.1 / Clang 3.5 / Visual Studio 2015.
Cppcheck requires a C++ compiler with (partial) C++11 support. Minimum required versions are GCC 5.1 / Clang 3.5 / AppleClang 6.0 / Visual Studio 2015.

To build the GUI application, you need to use the CMake build system.

Expand Down
Loading