diff options
author | Brad King <brad.king@kitware.com> | 2009-10-01 18:12:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-10-01 18:12:19 (GMT) |
commit | 26efeadd227977a393d2af6d36e6e1a3515aee05 (patch) | |
tree | ae31a08dde81fea72501699825e7af7231f6f5b5 | |
parent | cc11846dbf8ccd6a3dc06860afa5376937e79a4b (diff) | |
download | CMake-26efeadd227977a393d2af6d36e6e1a3515aee05.zip CMake-26efeadd227977a393d2af6d36e6e1a3515aee05.tar.gz CMake-26efeadd227977a393d2af6d36e6e1a3515aee05.tar.bz2 |
New CMake.ModulesNotice test for copyright notices
This new test checks Modules/*.cmake for the required copyright notice.
-rw-r--r-- | Tests/CMakeTests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CMakeTests/ModuleNoticesTest.cmake.in | 45 |
2 files changed, 46 insertions, 0 deletions
diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index e693996..34ac12c 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -21,6 +21,7 @@ AddCMakeTest(File "") AddCMakeTest(ConfigureFile "") AddCMakeTest(SeparateArguments "") AddCMakeTest(ImplicitLinkInfo "") +AddCMakeTest(ModuleNotices "") SET(GetPrerequisites_PreArgs "-DCTEST_CONFIGURATION_TYPE:STRING=\\\${CTEST_CONFIGURATION_TYPE}" diff --git a/Tests/CMakeTests/ModuleNoticesTest.cmake.in b/Tests/CMakeTests/ModuleNoticesTest.cmake.in new file mode 100644 index 0000000..3e4d104 --- /dev/null +++ b/Tests/CMakeTests/ModuleNoticesTest.cmake.in @@ -0,0 +1,45 @@ +# Regex to match copyright/license notices. +# We require the Kitware copyright on the first line, but the ".*" can +# match any additional copyright holder notices. +set(notice_regex " +#============================================================================= +# Copyright (20[0-9][0-9]-)?20[0-9][0-9] Kitware.* +# +# 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 distributed 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() |