From 31878e8c6cd7f546d85ceabae6f9ed5806d134a3 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Tue, 1 Aug 2023 13:44:43 +0100 Subject: [PATCH] [UR] Verify that every source file includes an appropriate license comment --- CMakeLists.txt | 3 +++ cmake/helpers.cmake | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8e58472ff..66c8b35327 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,6 +170,9 @@ foreach(dir examples include source test tools) endforeach() file(GLOB_RECURSE format_src ${format_glob}) +# check for licence +VerifyLicence(${format_src}) + # Add code formatter target add_custom_target(cppformat) diff --git a/cmake/helpers.cmake b/cmake/helpers.cmake index f355592370..e647576e88 100644 --- a/cmake/helpers.cmake +++ b/cmake/helpers.cmake @@ -128,3 +128,14 @@ function(FetchContentSparse_Declare name GIT_REPOSITORY GIT_TAG GIT_DIR) WORKING_DIRECTORY ${content-build-dir}) FetchContent_Declare(${name} SOURCE_DIR ${content-build-dir}/${GIT_DIR}) endfunction() + + +# Checks that every input file includes an appropriate license notice. +function(VerifyLicence) + foreach(file ${ARGN}) + file(READ ${file} file_contents LIMIT 300) + if(NOT "${file_contents}" MATCHES "SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception") + message(FATAL_ERROR "${file} does not contain an appropriate license comment.") + endif() + endforeach() +endfunction()