File: ModuleNoticesTest.cmake.in

package info (click to toggle)
cmake 2.8.11.1-1~bpo70+1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 37,056 kB
  • sloc: cpp: 157,219; ansic: 137,155; yacc: 3,254; sh: 2,745; xml: 2,483; lex: 1,028; lisp: 215; python: 199; objc: 134; f90: 105; perl: 99; fortran: 93; makefile: 65; tcl: 55; asm: 28; php: 25; ruby: 22; java: 20
file content (46 lines) | stat: -rw-r--r-- 1,769 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
# Regex to match copyright/license notices.
# We require the Kitware copyright on the first line, but this can
# match any additional copyright holder notices.
set(notice_regex "
#=============================================================================
# Copyright (20[0-9][0-9]-)?20[0-9][0-9] [^\n]+(
# Copyright (20[0-9][0-9]-)?20[0-9][0-9] [^\n]+)*
#
# Distributed under the OSI-approved BSD License \\(the \"License\"\\);
# see accompanying file Copyright\\.txt for details\\.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\\.
# See the License for more information\\.
#=============================================================================
# \\(To distribute this file outside of CMake, substitute the full
#  License text for the above reference.\\)
")
string(REPLACE "\n" "\r?\n" notice_regex "${notice_regex}")
string(REPLACE "\r\r" "\r" notice_regex "${notice_regex}")

# Modules that do not require our notice.
set(notice_exceptions
  FindCUDA.cmake # MIT License, distributed here from upstream project
  )

# Load the list of modules to check.
set(dir "@CMake_SOURCE_DIR@/Modules")
file(GLOB all_modules RELATIVE "${dir}" "${dir}/*.cmake")
list(REMOVE_ITEM all_modules ${notice_exceptions})

# Check each module.
set(notice_missing)
foreach(module ${all_modules})
  message(STATUS "module: ${module}")
  file(READ "${dir}/${module}" module_content)
  if(NOT "${module_content}" MATCHES "${notice_regex}")
    set(notice_missing "${notice_missing}  ${module}\n")
  endif()
endforeach()

# Report the list of bad modules.
if(notice_missing)
  message(FATAL_ERROR
    "Some modules do not have a valid copyright notice:\n${notice_missing}")
endif()