Enable clang tidy/warnings for tests
[alexxy/gromacs.git] / src / CMakeLists.txt
index dde7c7ae151f5db51f3017b253ec2f9a0c9f61af..d0c18815288006aaaa5feadab828970d8c2479c3 100644 (file)
@@ -50,6 +50,49 @@ configure_file(config.h.cmakein config.h)
 configure_file(gmxpre-config.h.cmakein gmxpre-config.h)
 configure_file(buildinfo.h.cmakein buildinfo.h ESCAPE_QUOTES)
 
+####
+set(IGNORED_CLANG_ALL_WARNINGS
+    "-Wno-c++98-compat -Wno-c++98-compat-pedantic" #No intention of C++98 compability
+    "-Wno-source-uses-openmp" #Don't warn for no-omp build
+    "-Wno-c++17-extensions"   #Allowed in attributes (compilers are required to ignore unknown attributes)
+    "-Wno-documentation-unknown-command" #Custom commands are used
+    "-Wno-covered-switch-default" #GCC gives maybe-uninitialized without default label and checks for illegal enum values.
+    "-Wno-switch-enum" # default statement for enum is OK
+
+    #Following ones are undecided/TODO
+    "-Wno-disabled-macro-expansion"
+    "-Wno-cast-align"
+    "-Wno-reserved-id-macro"
+    "-Wno-global-constructors"
+    "-Wno-exit-time-destructors"
+    "-Wno-unused-macros"
+    "-Wno-weak-vtables"
+    "-Wno-conditional-uninitialized"
+    "-Wno-format-nonliteral"
+    "-Wno-shadow"
+    "-Wno-cast-qual"
+    "-Wno-documentation"
+    "-Wno-used-but-marked-unused"
+    "-Wno-padded"
+    "-Wno-float-equal"
+    "-Wno-old-style-cast"
+    "-Wno-conversion"
+    "-Wno-double-promotion")
+string(REPLACE " " ";" IGNORED_CLANG_ALL_WARNINGS "${IGNORED_CLANG_ALL_WARNINGS}")
+
+if (GMX_CLANG_TIDY)
+   set(CLANG_TIDY "clang-tidy" CACHE STRING "Name of clang-tidy executable")
+   find_program(CLANG_TIDY_EXE NAMES "${CLANG_TIDY}"
+       DOC "Path to clang-tidy executable")
+   if(NOT CLANG_TIDY_EXE)
+       message(FATAL_ERROR "clang-tidy not found.")
+   endif()
+   if(CMAKE_VERSION VERSION_LESS "3.6")
+       message(FATAL_ERROR "clang-tidy support requires cmake 3.6.")
+   endif()
+endif()
+#####
+
 if (BUILD_TESTING)
     if(NOT GMX_DEVELOPER_BUILD)
         set(UNITTEST_TARGET_OPTIONS EXCLUDE_FROM_ALL)