From 993b685676de7bd63c7e45d7b119acc2da9b2fc3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 12 Nov 2013 15:56:36 -0500 Subject: [PATCH 1/5] bootstrap: Parse Copyright.txt instead of duplicating notice Use 'grep' to extract the copyright notice from Copyright.txt instead of duplicating it in the bootstrap script. --- Copyright.txt | 3 ++- bootstrap | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Copyright.txt b/Copyright.txt index 83a2482c0..f78bf570f 100644 --- a/Copyright.txt +++ b/Copyright.txt @@ -1,5 +1,6 @@ CMake - Cross Platform Makefile Generator -Copyright 2000-2011 Kitware, Inc., Insight Software Consortium +Copyright 2000-2011 Kitware, Inc. +Copyright 2000-2011 Insight Software Consortium All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/bootstrap b/bootstrap index 2d44d6765..89d68d9ae 100755 --- a/bootstrap +++ b/bootstrap @@ -62,6 +62,8 @@ if [ "$cmake_version_rc" != "" ]; then cmake_version="${cmake_version}-rc${cmake_version_rc}" fi +cmake_copyright="`grep '^Copyright .* Kitware' "${cmake_source_dir}/Copyright.txt"`" + cmake_data_dir_keyword="OTHER" cmake_doc_dir_keyword="OTHER" cmake_man_dir_keyword="OTHER" @@ -402,7 +404,7 @@ Directory and file names: # Display CMake bootstrap usage cmake_version_display() { - echo "CMake ${cmake_version}, Copyright 2000-2012 Kitware, Inc." + echo "CMake ${cmake_version}, ${cmake_copyright}" } # Display CMake bootstrap error, display the log file and exit From 621ba1fd04bae0a450da91887308a5647f071892 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 12 Nov 2013 16:32:14 -0500 Subject: [PATCH 2/5] cmake-gui: Parse Copyright.txt instead of duplicating notice Set the cmake-gui MACOSX_BUNDLE_COPYRIGHT property by parsing the copyright notice line out of Copyright.txt instead of duplicating it. --- Source/QtDialog/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 88a9fc987..ee0b831ee 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -111,12 +111,15 @@ if(Qt_BIN_DIR) endif() if(APPLE) + file(STRINGS "${CMake_SOURCE_DIR}/Copyright.txt" copyright_line + LIMIT_COUNT 1 REGEX "^Copyright 2000-20[0-9][0-9] Kitware") + set_target_properties(cmake-gui PROPERTIES OUTPUT_NAME ${CMAKE_BUNDLE_NAME} MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in" MACOSX_BUNDLE_SHORT_VERSION_STRING "${CMAKE_BUNDLE_VERSION}" # TBD: MACOSX_BUNDLE_BUNDLE_VERSION "${CMAKE_BUNDLE_VERSION}" - MACOSX_BUNDLE_COPYRIGHT "Copyright 2000-2013 Kitware, Inc." + MACOSX_BUNDLE_COPYRIGHT "${copyright_line}" ) # Create a symlink in the build tree to provide a "cmake-gui" next From 3ee67d0df93a37c3026e857be48b9dfdd580062f Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 12 Nov 2013 14:51:20 -0500 Subject: [PATCH 3/5] Copyright.txt: Update year range to end in 2013 --- Copyright.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Copyright.txt b/Copyright.txt index f78bf570f..9342249a8 100644 --- a/Copyright.txt +++ b/Copyright.txt @@ -1,5 +1,5 @@ CMake - Cross Platform Makefile Generator -Copyright 2000-2011 Kitware, Inc. +Copyright 2000-2013 Kitware, Inc. Copyright 2000-2011 Insight Software Consortium All rights reserved. From 2bbf6bd7f880ee618dd1260d784ba88b042dbf89 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 12 Nov 2013 16:13:02 -0500 Subject: [PATCH 4/5] 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. --- Tests/CMakeCopyright.cmake | 22 ++++++++++++++++++++++ Tests/CMakeLists.txt | 3 +++ 2 files changed, 25 insertions(+) create mode 100644 Tests/CMakeCopyright.cmake diff --git a/Tests/CMakeCopyright.cmake b/Tests/CMakeCopyright.cmake new file mode 100644 index 000000000..a7201e97d --- /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() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index d4a55fcc5..063ad1124 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -161,6 +161,9 @@ if(BUILD_TESTING) set(CMAKE_LONG_TEST_TIMEOUT 1500) endif() + add_test(NAME CMake.Copyright + COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake) + # add a bunch of standard build-and-test style tests ADD_TEST_MACRO(CommandLineTest CommandLineTest) ADD_TEST_MACRO(FindPackageTest FindPackageTest) From 3bade75b02cd4989d0be5efc6547439eade22be9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 13 Nov 2013 09:18:57 -0500 Subject: [PATCH 5/5] Help: Parse Copyright.txt instead of using current year Configure our Sphinx conf.py with a copyright line extracted from Copyright.txt instead of using the year in which the documentation is built. This will future-proof the reported copyright year range when building documentation for old versions. --- Utilities/Sphinx/CMakeLists.txt | 9 +++++++++ Utilities/Sphinx/conf.py.in | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index 3b0b335f7..5e0ef8777 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -36,6 +36,15 @@ elseif(NOT SPHINX_EXECUTABLE) message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!") endif() +set(copyright_line_regex "^Copyright (2000-20[0-9][0-9] Kitware.*)") +file(STRINGS "${CMake_SOURCE_DIR}/Copyright.txt" copyright_line + LIMIT_COUNT 1 REGEX "${copyright_line_regex}") +if(copyright_line MATCHES "${copyright_line_regex}") + set(conf_copyright "${CMAKE_MATCH_1}") +else() + set(conf_copyright "Kitware, Inc.") +endif() + set(conf_docs "${CMake_SOURCE_DIR}/Help") set(conf_path "${CMAKE_CURRENT_SOURCE_DIR}") set(conf_version "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") diff --git a/Utilities/Sphinx/conf.py.in b/Utilities/Sphinx/conf.py.in index 52f4a315c..ef622fda3 100644 --- a/Utilities/Sphinx/conf.py.in +++ b/Utilities/Sphinx/conf.py.in @@ -13,7 +13,6 @@ import sys import os import re import glob -import time sys.path.insert(0, r'@conf_path@') @@ -21,7 +20,7 @@ source_suffix = '.rst' master_doc = 'index' project = 'CMake' -copyright = '2000-%s Kitware, Inc.' % time.strftime('%Y') +copyright = '@conf_copyright@' version = '@conf_version@' # feature version release = '@conf_release@' # full version string