summaryrefslogtreecommitdiff
path: root/Tests/CMakeCopyright.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-11-12 16:13:02 -0500
committerBrad King <brad.king@kitware.com>2013-11-12 16:35:26 -0500
commit2bbf6bd7f880ee618dd1260d784ba88b042dbf89 (patch)
treef23a7a824eff40333b2203e5c467d247db9b5078 /Tests/CMakeCopyright.cmake
parent3ee67d0df93a37c3026e857be48b9dfdd580062f (diff)
downloadcmake-2bbf6bd7f880ee618dd1260d784ba88b042dbf89.tar.gz
Copyright.txt: Add test to check year range
Add a CMake.Copyright test that, when the CMake version number knows the year (as it does in development versions), checks that Copyright.txt has been updated with the current version year.
Diffstat (limited to 'Tests/CMakeCopyright.cmake')
-rw-r--r--Tests/CMakeCopyright.cmake22
1 files changed, 22 insertions, 0 deletions
diff --git a/Tests/CMakeCopyright.cmake b/Tests/CMakeCopyright.cmake
new file mode 100644
index 0000000000..a7201e97d1
--- /dev/null
+++ b/Tests/CMakeCopyright.cmake
@@ -0,0 +1,22 @@
+if(CMAKE_VERSION MATCHES "\\.(20[0-9][0-9])[0-9][0-9][0-9][0-9](-|$)")
+ set(version_year "${CMAKE_MATCH_1}")
+ set(copyright_line_regex "^Copyright 2000-(20[0-9][0-9]) Kitware")
+ file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/../Copyright.txt" copyright_line
+ LIMIT_COUNT 1 REGEX "${copyright_line_regex}")
+ if(copyright_line MATCHES "${copyright_line_regex}")
+ set(copyright_year "${CMAKE_MATCH_1}")
+ if(copyright_year LESS version_year)
+ message(FATAL_ERROR "Copyright.txt contains\n"
+ " ${copyright_line}\n"
+ "but the current version year is ${version_year}.")
+ else()
+ message(STATUS "PASSED: Copyright.txt contains\n"
+ " ${copyright_line}\n"
+ "and the current version year is ${version_year}.")
+ endif()
+ else()
+ message(FATAL_ERROR "Copyright.txt has no Copyright line of expected format!")
+ endif()
+else()
+ message(STATUS "SKIPPED: CMAKE_VERSION does not know the year: ${CMAKE_VERSION}")
+endif()