File: ITKModuleKWStyleTest.cmake

package info (click to toggle)
insighttoolkit5 5.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 704,404 kB
  • sloc: cpp: 783,697; ansic: 628,724; xml: 44,704; fortran: 34,250; python: 22,874; sh: 4,078; pascal: 2,636; lisp: 2,158; makefile: 461; yacc: 328; asm: 205; perl: 203; lex: 146; tcl: 132; javascript: 98; csh: 81
file content (80 lines) | stat: -rw-r--r-- 2,940 bytes parent folder | download | duplicates (2)
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
72
73
74
75
76
77
78
79
80
# 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()
    if(NOT DISABLE_MODULE_TESTS)
      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()
  endif()
endmacro()