File: KWStyle.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 (79 lines) | stat: -rw-r--r-- 2,481 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
72
73
74
75
76
77
78
79
if(ITK_USE_KWSTYLE)
  # Define and configure configuration files
  set(kwstyle_itk_configuration_file
    ${ITK_SOURCE_DIR}/Utilities/KWStyle/ITK.kws.xml
    )
  set(kwstyle_itk_examples_files_list_file
    ${ITK_BINARY_DIR}/Utilities/KWStyle/ITKExamplesFiles.txt
    )
  configure_file( # KWStyle requires that the files list be absolute paths
    ${ITK_SOURCE_DIR}/Utilities/KWStyle/ITKExamplesFiles.txt.in
    ${kwstyle_itk_examples_files_list_file}
    )
  set(kwstyle_itk_overwrite_file
    ${ITK_SOURCE_DIR}/Utilities/KWStyle/ITKOverwrite.txt
    )

  # Define formatting for error messages for output of build target
  option(KWSTYLE_USE_VIM_FORMAT
    "Set KWStyle to generate errors with a VIM-compatible format."
    OFF
    )
  option(KWSTYLE_USE_GCC_FORMAT
    "Set KWStyle to generate errors with a GCC-compatible format."
    OFF
    )
  option(KWSTYLE_USE_MSVC_FORMAT
    "Set KWStyle to generate errors with a VisualStudio-compatible format."
    ${MSVC_IDE} # default to TRUE only with a Visual Studio IDE
    )

  mark_as_advanced(KWSTYLE_USE_VIM_FORMAT)
  mark_as_advanced(KWSTYLE_USE_GCC_FORMAT)
  mark_as_advanced(KWSTYLE_USE_MSVC_FORMAT)

  set(kwstyle_editor_format "")
  if(KWSTYLE_USE_VIM_FORMAT)
    list(APPEND kwstyle_editor_format -vim)
  endif()
  if(KWSTYLE_USE_GCC_FORMAT)
    list(APPEND kwstyle_editor_format -gcc)
  endif()
  if(KWSTYLE_USE_MSVC_FORMAT)
    list(APPEND kwstyle_editor_format -msvc)
  endif()

  list(LENGTH
    kwstyle_editor_format
    kwstyle_editor_format_length
    )
  if(kwstyle_editor_format_length GREATER 1)
    message(FATAL_ERROR "At most, only one of KWSTYLE_USE_*_FORMAT can be set to TRUE.")
  endif()

  # Add build target and CTest test
  set(kwstyle_common_arguments
    -xml ${kwstyle_itk_configuration_file}
    -v
    -o ${kwstyle_itk_overwrite_file}
    )
  add_custom_target(StyleCheckExamples
    COMMAND ${KWSTYLE_EXECUTABLE}
      ${kwstyle_common_arguments}
      -D ${kwstyle_itk_examples_files_list_file}
      ${kwstyle_editor_format}
    COMMENT "Examples Style Checker"
    WORKING_DIRECTORY ${ITK_SOURCE_DIR} # the paths in kwstyle_itk_configuration_file are relative
    )
  if(BUILD_TESTING)
    set(itk-module KWStyle)
    itk_add_test(NAME KWStyleExamplesTest
      COMMAND ${KWSTYLE_EXECUTABLE}
        ${kwstyle_common_arguments}
        -D ${kwstyle_itk_examples_files_list_file}
        -gcc
      WORKING_DIRECTORY ${ITK_SOURCE_DIR}
      )
  endif(BUILD_TESTING)

endif(ITK_USE_KWSTYLE)