Skip to content

Commit

Permalink
Fixed more cmakelint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitcowboy committed Apr 21, 2024
1 parent 60fe551 commit 462ae2b
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 162 deletions.
12 changes: 6 additions & 6 deletions cmake/clang_tidy.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# TODO: bail out when Python_EXECUTABLE is not set

if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
if(NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
# clang-tidy and clang need to have the same version when precompiled headers are being used
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
string(REGEX MATCHALL "[0-9]+" _clang_ver_parts "${CMAKE_CXX_COMPILER_VERSION}")
LIST(GET _clang_ver_parts 0 _clang_major)
set(RUN_CLANG_TIDY_NAMES "run-clang-tidy-${_clang_major}")
Expand All @@ -14,10 +14,10 @@ else()
set(RUN_CLANG_TIDY_NAMES run-clang-tidy run-clang-tidy-18 run-clang-tidy-17 run-clang-tidy-16 run-clang-tidy-15 run-clang-tidy-14 run-clang-tidy-13 run-clang-tidy-12 run-clang-tidy-11 run-clang-tidy-10 run-clang-tidy-9 run-clang-tidy-8)
endif()

if (RUN_CLANG_TIDY_NAMES)
if(RUN_CLANG_TIDY_NAMES)
find_program(RUN_CLANG_TIDY NAMES ${RUN_CLANG_TIDY_NAMES})
message(STATUS "RUN_CLANG_TIDY=${RUN_CLANG_TIDY}")
if (RUN_CLANG_TIDY)
if(RUN_CLANG_TIDY)
include(ProcessorCount)
ProcessorCount(NPROC)
if(NPROC EQUAL 0)
Expand All @@ -27,9 +27,9 @@ if (RUN_CLANG_TIDY_NAMES)

# disable all compiler warnings since we are just interested in the tidy ones
add_custom_target(run-clang-tidy ${Python_EXECUTABLE} ${RUN_CLANG_TIDY} -p=${CMAKE_BINARY_DIR} -j ${NPROC} -quiet)
if (BUILD_GUI)
if(BUILD_GUI)
add_dependencies(run-clang-tidy gui-build-deps)
if (BUILD_TESTS)
if(BUILD_TESTS)
add_dependencies(run-clang-tidy triage-build-ui-deps)
endif()
endif()
Expand Down
14 changes: 7 additions & 7 deletions cmake/compilerCheck.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
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 ()
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
message(ERROR "Clang >= 3.5 required - detected ${CMAKE_CXX_COMPILER_VERSION} not supported")
endif ()
endif()
elseif(MSVC)
if (MSVC_VERSION VERSION_LESS 1900)
if(MSVC_VERSION VERSION_LESS 1900)
message(ERROR "Visual Studio >= 2015 (19.0) required - detected ${MSVC_VERSION} not supported")
endif ()
endif()
endif()
26 changes: 13 additions & 13 deletions cmake/compilerDefinitions.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (MSVC)
if(MSVC)
# add_compile_definitions() requires CMake 3.12

# Visual Studio only sets _DEBUG
Expand All @@ -13,10 +13,10 @@ 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_EQUAL 18 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 18)
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_EQUAL 18 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 18)
add_definitions(-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG)
else()
add_definitions(-D_LIBCPP_ENABLE_ASSERTIONS=1)
Expand All @@ -29,35 +29,35 @@ if (CPPCHK_GLIBCXX_DEBUG AND UNIX AND CMAKE_BUILD_TYPE STREQUAL "Debug")
endif()
endif()

if (HAVE_RULES)
if(HAVE_RULES)
add_definitions(-DHAVE_RULES)
endif()

if (Boost_FOUND)
if(Boost_FOUND)
add_definitions(-DHAVE_BOOST)
endif()

if (ENABLE_CHECK_INTERNAL)
if(ENABLE_CHECK_INTERNAL)
add_definitions(-DCHECK_INTERNAL)
endif()

if (DISALLOW_THREAD_EXECUTOR)
if(DISALLOW_THREAD_EXECUTOR)
add_definitions(-DDISALLOW_THREAD_EXECUTOR)
endif()

if (MSVC AND DISABLE_CRTDBG_MAP_ALLOC)
if(MSVC AND DISABLE_CRTDBG_MAP_ALLOC)
add_definitions(-DDISABLE_CRTDBG_MAP_ALLOC)
endif()

if (NO_UNIX_SIGNAL_HANDLING)
if(NO_UNIX_SIGNAL_HANDLING)
add_definitions(-DNO_UNIX_SIGNAL_HANDLING)
endif()

if (NO_UNIX_BACKTRACE_SUPPORT)
if(NO_UNIX_BACKTRACE_SUPPORT)
add_definitions(-DNO_UNIX_BACKTRACE_SUPPORT)
endif()

if (NO_WINDOWS_SEH)
if(NO_WINDOWS_SEH)
add_definitions(-DNO_WINDOWS_SEH)
endif()

Expand Down
38 changes: 19 additions & 19 deletions cmake/compileroptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@ include(CheckCXXCompilerFlag)
function(add_compile_options_safe FLAG)
string(MAKE_C_IDENTIFIER "HAS_CXX_FLAG${FLAG}" mangled_flag)
check_cxx_compiler_flag(${FLAG} ${mangled_flag})
if (${mangled_flag})
if(${mangled_flag})
add_compile_options(${FLAG})
endif()
endfunction()

function(target_compile_options_safe TARGET FLAG)
string(MAKE_C_IDENTIFIER "HAS_CXX_FLAG${FLAG}" mangled_flag)
check_cxx_compiler_flag(${FLAG} ${mangled_flag})
if (${mangled_flag})
if(${mangled_flag})
target_compile_options(${TARGET} PRIVATE ${FLAG})
endif()
endfunction()

function(target_externals_include_directories TARGET)
if (EXTERNALS_AS_SYSTEM)
if(EXTERNALS_AS_SYSTEM)
target_include_directories(${TARGET} SYSTEM ${ARGN})
else()
target_include_directories(${TARGET} ${ARGN})
endif()
endfunction()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Weverything)
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
# "Release" uses -O3 by default
add_compile_options(-O2)
endif()
if (WARNINGS_ARE_ERRORS)
if(WARNINGS_ARE_ERRORS)
add_compile_options(-Werror)
endif()
add_compile_options(-pedantic)
Expand Down Expand Up @@ -61,20 +61,20 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang
#add_compile_options(-Wsign-promo)
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# use pipes instead of temporary files - greatly reduces I/O usage
add_compile_options(-pipe)

add_compile_options(-Wno-maybe-uninitialized) # there are some false positives
add_compile_options(-Wsuggest-attribute=noreturn)
add_compile_options(-Wno-shadow) # whenever a local variable or type declaration shadows another one
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 14 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 14)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 14 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 14)
# TODO: verify this regression still exists in clang-15
if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
# work around performance regression - see https://github.com/llvm/llvm-project/issues/53555
check_cxx_compiler_flag("-mllvm -inline-deferral" _has_mllvm_inline_deferral)
if (_has_mllvm_inline_deferral)
if(_has_mllvm_inline_deferral)
add_compile_options(-mllvm -inline-deferral)
endif()
endif()
Expand All @@ -83,7 +83,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-gdwarf-4)
endif()

if (USE_LIBCXX)
if(USE_LIBCXX)
add_compile_options(-stdlib=libc++)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++")
endif()
Expand Down Expand Up @@ -133,13 +133,13 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()
endif()

if (MSVC)
if(MSVC)
# add_link_options() requires CMake 3.13

# General
add_compile_options(/W4) # Warning Level
add_compile_options(/Zi) # Debug Information Format - Program Database
if (WARNINGS_ARE_ERRORS)
if(WARNINGS_ARE_ERRORS)
add_compile_options(/WX) # Treat Warning As Errors
endif()
add_compile_options(/MP) # Multi-processor Compilation
Expand Down Expand Up @@ -213,17 +213,17 @@ if (MSVC)
endif()

# TODO: check if this can be enabled again - also done in Makefile
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
CMAKE_CXX_COMPILER_ID MATCHES "Clang")

add_compile_options(-U_GLIBCXX_DEBUG)
endif()

if (MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:8000000")
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:8000000")
endif()

if (CYGWIN)
if(CYGWIN)
# TODO: this is a linker flag - not a compiler flag
add_compile_options(-Wl,--stack,8388608)
endif()
Expand Down
10 changes: 5 additions & 5 deletions cmake/cxx11.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
macro(use_cxx11)
# some GitHub Action Windows runners randomly fail with a complaint that Qt6 requires a C++17 compiler
if (MSVC AND USE_QT6)
if(MSVC AND USE_QT6)
# CMAKE_CXX_STANDARD 17 was added in CMake 3.8
set (CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to use")
else ()
set (CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to use")
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to use")
else()
set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to use")
endif()
endmacro(use_cxx11)
endmacro()
4 changes: 2 additions & 2 deletions cmake/dynamic_analyzer_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ endif()
if(ANALYZE_UNDEFINED)
# TODO: enable signed-integer-overflow
add_compile_options(-fsanitize=undefined -fno-sanitize=signed-integer-overflow)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-fsanitize=nullability)
endif()
add_compile_options(-fno-sanitize-recover=all)
add_compile_options(-fno-omit-frame-pointer)

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fno-sanitize=signed-integer-overflow")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=nullability")
endif()
endif()
Expand Down
34 changes: 17 additions & 17 deletions cmake/findDependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
if (BUILD_GUI)
if(BUILD_GUI)
list(APPEND qt_components Core Gui Widgets PrintSupport LinguistTools Help Network)
if (WITH_QCHART)
if(WITH_QCHART)
list(APPEND qt_components Charts)
endif()
if (BUILD_TESTS)
if(BUILD_TESTS)
list(APPEND qt_components Test)
endif()
if (USE_QT6)
if(USE_QT6)
find_package(Qt6 COMPONENTS ${qt_components} REQUIRED)
set(QT_VERSION "${Qt6Core_VERSION_STRING}")
if (NOT QT_VERSION)
if(NOT QT_VERSION)
# TODO: how to get the actual version?
message(WARNING "'Qt6Core_VERSION_STRING' is not set - using 6.0.0 as fallback")
set(QT_VERSION "6.0.0")
endif()
if (MSVC)
if(MSVC)
# disable Visual Studio C++ memory leak detection since it causes compiler errors with Qt 6
# D:\a\cppcheck\Qt\6.2.4\msvc2019_64\include\QtCore/qhash.h(179,15): warning C4003: not enough arguments for function-like macro invocation 'free' [D:\a\cppcheck\cppcheck\build\gui\cppcheck-gui.vcxproj]
# D:\a\cppcheck\Qt\6.2.4\msvc2019_64\include\QtCore/qhash.h(179,15): error C2059: syntax error: ',' [D:\a\cppcheck\cppcheck\build\gui\cppcheck-gui.vcxproj]
Expand All @@ -30,48 +30,48 @@ if (BUILD_GUI)
endif()
endif()

if (HAVE_RULES)
if(HAVE_RULES)
find_path(PCRE_INCLUDE pcre.h)
find_library(PCRE_LIBRARY NAMES pcre pcred)
if (NOT PCRE_LIBRARY OR NOT PCRE_INCLUDE)
if(NOT PCRE_LIBRARY OR NOT PCRE_INCLUDE)
message(FATAL_ERROR "pcre dependency for RULES has not been found")
endif()
endif()

set(CMAKE_INCLUDE_CURRENT_DIR ON)

if (CMAKE_VERSION VERSION_EQUAL "3.12" OR CMAKE_VERSION VERSION_GREATER "3.12")
if(CMAKE_VERSION VERSION_EQUAL "3.12" OR CMAKE_VERSION VERSION_GREATER "3.12")
find_package(Python COMPONENTS Interpreter)
if (NOT Python_Interpreter_FOUND)
if(NOT Python_Interpreter_FOUND)
message(WARNING "No python interpreter found - disabling matchcompiler.")
set(USE_MATCHCOMPILER_OPT "Off")
endif()
else()
find_package(PythonInterp 3 QUIET)
if (NOT PYTHONINTERP_FOUND)
if(NOT PYTHONINTERP_FOUND)
set(PYTHONINTERP_FOUND "")
find_package(PythonInterp 2.7 QUIET)
if (NOT PYTHONINTERP_FOUND AND NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
if(NOT PYTHONINTERP_FOUND AND NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
message(WARNING "No python interpreter found - disabling matchcompiler.")
set(USE_MATCHCOMPILER_OPT "Off")
endif()
endif()
if (PYTHONINTERP_FOUND)
if(PYTHONINTERP_FOUND)
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
set(Python_VERSION ${PYTHON_VERSION_STRING})
set(Python_Interpreter_FOUND ${PYTHONINTERP_FOUND})
endif()
endif()

if (NOT USE_BUNDLED_TINYXML2)
if(NOT USE_BUNDLED_TINYXML2)
find_package(tinyxml2 QUIET)
if (TARGET tinyxml2::tinyxml2)
if(TARGET tinyxml2::tinyxml2)
set(tinyxml2_LIBRARIES "tinyxml2::tinyxml2")
set(tinyxml2_INCLUDE_DIRS $<TARGET_PROPERTY:tinyxml2::tinyxml2,INTERFACE_INCLUDE_DIRECTORIES>)
else()
find_library(tinyxml2_LIBRARIES tinyxml2)
find_path(tinyxml2_INCLUDE_DIRS tinyxml2.h)
if (NOT tinyxml2_LIBRARIES AND NOT tinyxml2_INCLUDE_DIRS)
if(NOT tinyxml2_LIBRARIES AND NOT tinyxml2_INCLUDE_DIRS)
message(FATAL_ERROR "tinyxml2 has not been found")
else()
set(tinyxml2_FOUND 1)
Expand All @@ -81,7 +81,7 @@ endif()

find_package(Threads REQUIRED)

if (USE_BOOST)
if(USE_BOOST)
# we are using the header-only "container" component
find_package(Boost QUIET)
endif()
Expand Down
Loading

0 comments on commit 462ae2b

Please sign in to comment.