File: ITKModuleKWStyleTest.cmake

package info (click to toggle)
insighttoolkit4 4.13.3withdata-dfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 489,260 kB
  • sloc: cpp: 557,342; ansic: 146,850; fortran: 34,788; python: 16,572; sh: 2,187; lisp: 2,070; tcl: 993; java: 362; perl: 200; makefile: 129; csh: 81; pascal: 69; xml: 19; ruby: 10
file content (71 lines) | stat: -rw-r--r-- 2,948 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Provides itk_module_kwstyle_test macro for the internal modular api
#
# This macro adds an additional test to each module to perform KWStyle
#check on the code. Each module can provide the following file in the
#module root to override the default:
#  ITKKWStyleOverwrite.txt
#       - a KWSyle file to over write the default rules
#  ITKKWStyleFiles.txt.in
#       - a KWSyle file to be configured specifying files
#       - Lines should be of the form:
#           @ITK_MODULE_BINARY_DIR@/include/itk*.h
#         where ITK_MODULE in the name of the project specified by the
#         module.
#
# Globally the ITK.kws.xml file is used to configure the expected
#style.
option(ITK_USE_KWSTYLE "Enable the use of KWStyle for checking coding style." ${BUILD_TESTING})
mark_as_advanced(ITK_USE_KWSTYLE)
find_package(KWStyle 1.0.1 QUIET)

if(NOT KWSTYLE_FOUND AND BUILD_TESTING AND ITK_USE_KWSTYLE AND NOT CMAKE_CROSSCOMPILING)
  include(${ITK_CMAKE_DIR}/../Utilities/KWStyle/BuildKWStyle.cmake)
elseif(NOT KWSTYLE_FOUND)
  set(ITK_USE_KWSTYLE OFF)
endif()

macro(itk_module_kwstyle_test _name)

  set(_kwstyle_itk_configuration_file "${ITK_CMAKE_DIR}/../Utilities/KWStyle/ITK.kws.xml"  )

  if(EXISTS "${${itk-module}_SOURCE_DIR}/ITKKWStyleOverwrite.txt")
    set(_kwstyle_itk_overwrite_file "${${itk-module}_SOURCE_DIR}/ITKKWStyleOverwrite.txt" )
  else()
    set(_kwstyle_itk_overwrite_file "${ITK_CMAKE_DIR}/../Utilities/KWStyle/ITKOverwrite.txt" )
  endif()

  if(EXISTS "${${itk-module}_SOURCE_DIR}/ITKKWStyleFiles.txt.in")
    set(_kwstyle_itk_module_files_list_file "${${itk-module}_BINARY_DIR}/ITKKWStyleFiles.txt")
    # KWStyle requires that the files list be absolute paths
    configure_file(
      ${${itk-module}_SOURCE_DIR}/ITKKWStyleFiles.txt.in
      ${_kwstyle_itk_module_files_list_file}
      )
  else()
    set(_kwstyle_itk_module_files_list_file  "${${itk-module}_BINARY_DIR}/ITKKWStyleFiles.txt")
    set(_kwstyle_file_list "${${itk-module}_SOURCE_DIR}/include/itk*.h"
                            "${${itk-module}_SOURCE_DIR}/include/itk*.hxx"
                            "${${itk-module}_SOURCE_DIR}/src/*.cxx"
                            "${${itk-module}_SOURCE_DIR}/src/*.h"
                            "${${itk-module}_SOURCE_DIR}/src/*.hxx"
                            "${${itk-module}_SOURCE_DIR}/test/*.cxx")
    file(WRITE ${_kwstyle_itk_module_files_list_file} "")
    foreach(item ${_kwstyle_file_list})
      file(APPEND ${_kwstyle_itk_module_files_list_file} "${item}\n")
    endforeach()
  endif()

  if (NOT KWSTYLE_EXECUTABLE)
    message(WARNING "KWSTYLE_EXECUTABLE is not set!")
  else()
    itk_add_test(NAME ${itk-module}KWStyleTest
      COMMAND ${KWSTYLE_EXECUTABLE}
        -xml ${_kwstyle_itk_configuration_file}
        -v
        -o ${_kwstyle_itk_overwrite_file}
        -D ${_kwstyle_itk_module_files_list_file}
        -gcc
      WORKING_DIRECTORY ${ITK_CMAKE_DIR}/..
      )
  endif()
endmacro()