Skip to content

Commit 36fdd69

Browse files
author
Petr Vesely
committed
[UR] Verify that every source file includes an appropriate license comment
1 parent 4834f8b commit 36fdd69

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ foreach(dir examples include source test tools)
170170
endforeach()
171171
file(GLOB_RECURSE format_src ${format_glob})
172172

173+
# check for licence
174+
VerifyLicence(${format_src})
175+
173176
# Add code formatter target
174177
add_custom_target(cppformat)
175178

cmake/helpers.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,14 @@ function(FetchContentSparse_Declare name GIT_REPOSITORY GIT_TAG GIT_DIR)
146146
WORKING_DIRECTORY ${content-build-dir})
147147
FetchContent_Declare(${name} SOURCE_DIR ${content-build-dir}/${GIT_DIR})
148148
endfunction()
149+
150+
151+
# Checks that every input file includes an appropriate license notice.
152+
function(VerifyLicence)
153+
foreach(file ${ARGN})
154+
file(READ ${file} file_contents LIMIT 300)
155+
if(NOT "${file_contents}" MATCHES "SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception")
156+
message(FATAL_ERROR "${file} does not contain an appropriate license comment.")
157+
endif()
158+
endforeach()
159+
endfunction()

0 commit comments

Comments
 (0)