summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorAllen Byrne <50328838+byrnHDF@users.noreply.github.com>2023-06-13 03:05:26 (GMT)
committerGitHub <noreply@github.com>2023-06-13 03:05:26 (GMT)
commit1891387ccbb50932350216370fd83f47924ceecb (patch)
tree9fdaf884777942632457826420364ea6d564cb7e /config
parent8265bf31c9a584e4c1c9255bf57d7a875d8829bd (diff)
downloadhdf5-1891387ccbb50932350216370fd83f47924ceecb.zip
hdf5-1891387ccbb50932350216370fd83f47924ceecb.tar.gz
hdf5-1891387ccbb50932350216370fd83f47924ceecb.tar.bz2
Rework tools.cmake and add C flags (#3110)
Diffstat (limited to 'config')
-rw-r--r--config/sanitizer/tools.cmake135
1 files changed, 62 insertions, 73 deletions
diff --git a/config/sanitizer/tools.cmake b/config/sanitizer/tools.cmake
index 3a41ad4..88d3baf 100644
--- a/config/sanitizer/tools.cmake
+++ b/config/sanitizer/tools.cmake
@@ -14,101 +14,90 @@
# the License.
option(CLANG_TIDY "Turns on clang-tidy processing if it is found." OFF)
-option(IWYU "Turns on include-what-you-use processing if it is found." OFF)
-option(CPPCHECK "Turns on cppcheck processing if it is found." OFF)
+if(CLANG_TIDY)
+ find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
+ mark_as_advanced(FORCE CLANG_TIDY_EXE)
+ if(CLANG_TIDY_EXE)
+ message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
+ set(CMAKE_C_CLANG_TIDY ${CLANG_TIDY_EXE} --checks=-*,clang-analyzer-*)#${ARGN})
+ set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXE} --checks=-*,clang-analyzer-*)#${ARGN})
+ else()
+ message(STATUS "clang-tidy not found!")
+ set(CMAKE_C_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it
+ set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it
+ endif()
+else()
+ #message(STATUS "clang-tidy not enabled!")
+ set(CMAKE_C_CLANG_TIDY
+ ""
+ CACHE STRING "" FORCE) # delete it
+ set(CMAKE_CXX_CLANG_TIDY
+ ""
+ CACHE STRING "" FORCE) # delete it
+endif()
# Adds clang-tidy checks to the compilation, with the given arguments being used
# as the options set.
macro(clang_tidy)
if(CLANG_TIDY AND CLANG_TIDY_EXE)
+ set(CMAKE_C_CLANG_TIDY ${CLANG_TIDY_EXE} ${ARGN})
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXE} ${ARGN})
endif()
endmacro()
+option(IWYU "Turns on include-what-you-use processing if it is found." OFF)
+if(IWYU)
+ find_program(IWYU_EXE NAMES "include-what-you-use")
+ mark_as_advanced(FORCE IWYU_EXE)
+ if(IWYU_EXE)
+ message(STATUS "include-what-you-use found: ${IWYU_EXE}")
+ else()
+ message(SEND_ERROR "Cannot enable include-what-you-use, as executable not found!")
+ set(CMAKE_C_INCLUDE_WHAT_YOU_USE "" CACHE STRING "" FORCE) # delete it
+ set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "" CACHE STRING "" FORCE) # delete it
+ endif()
+else()
+ #message(STATUS "include-what-you-use NOT ENABLED via 'IWYU' variable!")
+ set(CMAKE_C_INCLUDE_WHAT_YOU_USE "" CACHE STRING "" FORCE) # delete it
+ set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "" CACHE STRING "" FORCE) # delete it
+endif()
+
# Adds include_what_you_use to the compilation, with the given arguments being
# used as the options set.
macro(include_what_you_use)
if(IWYU AND IWYU_EXE)
+ set(CMAKE_C_INCLUDE_WHAT_YOU_USE ${IWYU_EXE} ${ARGN})
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${IWYU_EXE} ${ARGN})
endif()
endmacro()
+option(CPPCHECK "Turns on cppcheck processing if it is found." OFF)
+if(CPPCHECK)
+ if(CPPCHECK_EXE)
+ message(STATUS "cppcheck found: ${CPPCHECK_EXE}")
+ set(CMAKE_C_CPPCHECK
+ "${CPPCHECK_EXE};--enable=warning,performance,portability,missingInclude;--template=\"[{severity}][{id}] {message} {callstack} \(On {file}:{line}\)\";--suppress=missingIncludeSystem;--quiet;--verbose;--force"
+ )
+ set(CMAKE_CXX_CPPCHECK
+ "${CPPCHECK_EXE};--enable=warning,performance,portability,missingInclude;--template=\"[{severity}][{id}] {message} {callstack} \(On {file}:{line}\)\";--suppress=missingIncludeSystem;--quiet;--verbose;--force"
+ )
+ else()
+ message(SEND_ERROR "Cannot enable cppcheck, as executable not found!")
+ set(CMAKE_C_CPPCHECK "" CACHE STRING "" FORCE) # delete it
+ set(CMAKE_CXX_CPPCHECK "" CACHE STRING "" FORCE) # delete it
+ endif()
+else()
+ # message(SEND_ERROR "cppcheck NOT ENABLED via 'CPPCHECK' variable!")
+ set(CMAKE_C_CPPCHECK "" CACHE STRING "" FORCE) # delete it
+ set(CMAKE_CXX_CPPCHECK "" CACHE STRING "" FORCE) # delete it
+endif()
+
# Adds cppcheck to the compilation, with the given arguments being used as the
# options set.
macro(cppcheck)
if(CPPCHECK AND CPPCHECK_EXE)
+ set(CMAKE_C_CPPCHECK ${CPPCHECK_EXE} ${ARGN})
set(CMAKE_CXX_CPPCHECK ${CPPCHECK_EXE} ${ARGN})
endif()
endmacro()
-find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
-mark_as_advanced(FORCE CLANG_TIDY_EXE)
-if(CLANG_TIDY_EXE)
- message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
- if(NOT CLANG_TIDY)
- message(STATUS "clang-tidy NOT ENABLED via 'CLANG_TIDY' variable!")
- set(CMAKE_CXX_CLANG_TIDY
- ""
- CACHE STRING "" FORCE) # delete it
- endif()
-elseif(CLANG_TIDY)
- message(SEND_ERROR "Cannot enable clang-tidy, as executable not found!")
- set(CMAKE_CXX_CLANG_TIDY
- ""
- CACHE STRING "" FORCE) # delete it
-else()
- message(STATUS "clang-tidy not found!")
- set(CMAKE_CXX_CLANG_TIDY
- ""
- CACHE STRING "" FORCE) # delete it
-endif()
-
-find_program(IWYU_EXE NAMES "include-what-you-use")
-mark_as_advanced(FORCE IWYU_EXE)
-if(IWYU_EXE)
- message(STATUS "include-what-you-use found: ${IWYU_EXE}")
- if(NOT IWYU)
- message(STATUS "include-what-you-use NOT ENABLED via 'IWYU' variable!")
- set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
- ""
- CACHE STRING "" FORCE) # delete it
- endif()
-elseif(IWYU)
- message(
- SEND_ERROR "Cannot enable include-what-you-use, as executable not found!")
- set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
- ""
- CACHE STRING "" FORCE) # delete it
-else()
- message(STATUS "include-what-you-use not found!")
- set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
- ""
- CACHE STRING "" FORCE) # delete it
-endif()
-
-find_program(CPPCHECK_EXE NAMES "cppcheck")
-mark_as_advanced(FORCE CPPCHECK_EXE)
-if(CPPCHECK_EXE)
- message(STATUS "cppcheck found: ${CPPCHECK_EXE}")
- if(CPPCHECK)
- set(CMAKE_CXX_CPPCHECK
- "${CPPCHECK_EXE};--enable=warning,performance,portability,missingInclude;--template=\"[{severity}][{id}] {message} {callstack} \(On {file}:{line}\)\";--suppress=missingIncludeSystem;--quiet;--verbose;--force"
- )
- endif()
- if(NOT CPPCHECK)
- message(STATUS "cppcheck NOT ENABLED via 'CPPCHECK' variable!")
- set(CMAKE_CXX_CPPCHECK
- ""
- CACHE STRING "" FORCE) # delete it
- endif()
-elseif(CPPCHECK)
- message(SEND_ERROR "Cannot enable cppcheck, as executable not found!")
- set(CMAKE_CXX_CPPCHECK
- ""
- CACHE STRING "" FORCE) # delete it
-else()
- message(STATUS "cppcheck not found!")
- set(CMAKE_CXX_CPPCHECK
- ""
- CACHE STRING "" FORCE) # delete it
-endif()