CMakeCopyright.cmake 959 B

12345678910111213141516171819202122
  1. if(CMAKE_VERSION MATCHES "\\.(20[0-9][0-9])[0-9][0-9][0-9][0-9](-|$)")
  2. set(version_year "${CMAKE_MATCH_1}")
  3. set(copyright_line_regex "^Copyright 2000-(20[0-9][0-9]) Kitware")
  4. file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/../Copyright.txt" copyright_line
  5. LIMIT_COUNT 1 REGEX "${copyright_line_regex}")
  6. if(copyright_line MATCHES "${copyright_line_regex}")
  7. set(copyright_year "${CMAKE_MATCH_1}")
  8. if(copyright_year LESS version_year)
  9. message(FATAL_ERROR "Copyright.txt contains\n"
  10. " ${copyright_line}\n"
  11. "but the current version year is ${version_year}.")
  12. else()
  13. message(STATUS "PASSED: Copyright.txt contains\n"
  14. " ${copyright_line}\n"
  15. "and the current version year is ${version_year}.")
  16. endif()
  17. else()
  18. message(FATAL_ERROR "Copyright.txt has no Copyright line of expected format!")
  19. endif()
  20. else()
  21. message(STATUS "SKIPPED: CMAKE_VERSION does not know the year: ${CMAKE_VERSION}")
  22. endif()