Create clang-tidy cmake option
authorejjordan <e.jjordan12@gmail.com>
Tue, 12 Nov 2019 22:46:59 +0000 (23:46 +0100)
committerPaul Bauer <paul.bauer.q@gmail.com>
Wed, 13 Nov 2019 13:00:24 +0000 (14:00 +0100)
This option checks that clang-tidy will work and allows clang-tidy
to be set using the libcurses gui.

Change-Id: I6660a1d72dafa4328974bd3fc557fff8ec7d6b7e

src/CMakeLists.txt

index 427fce5f081512d8d9a7963ce06fb0bf283386ad..951976335eb9c2eb7894ee554e91430d04558592 100644 (file)
@@ -103,15 +103,29 @@ set(IGNORED_CLANG_ALL_WARNINGS
     "-Wno-double-promotion")
 string(REPLACE " " ";" IGNORED_CLANG_ALL_WARNINGS "${IGNORED_CLANG_ALL_WARNINGS}")
 
+option(GMX_CLANG_TIDY "Use clang-tidy" OFF)
 if (GMX_CLANG_TIDY)
+   if("${GMX_OPENMP}")
+       message(FATAL_ERROR "clang-tidy cannot be combined with openmp.")
+   endif()
+   if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
+   elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithAssert")
+   elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
+   elseif("${CMAKE_BUILD_TYPE}" STREQUAL "ASAN")
+   else()
+       message(FATAL_ERROR "Can only use clang-tidy with build type containing asserts: Debug, RelWithAssert, RelWithDebInfo, ASAN.")
+   endif()
+   set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+   mark_as_advanced(CMAKE_EXPORT_COMPILE_COMMANDS)
    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()
+   mark_as_advanced(CLANG_TIDY)
+   mark_as_advanced(CLANG_TIDY_EXE)
 endif()
-#####
 
 add_subdirectory(external)