Skip to content

Commit

Permalink
[UR] Verify that every source file includes an appropriate license co…
Browse files Browse the repository at this point in the history
…mment
  • Loading branch information
Petr Vesely committed Aug 1, 2023
1 parent 5513ee2 commit 31878e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 11 additions & 0 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 31878e8

Please sign in to comment.