forked from bilke/cmake-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Licensing.cmake
133 lines (122 loc) · 4.31 KB
/
Licensing.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# - Building a licensing description file
#
# Original Author:
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
define_property(GLOBAL
PROPERTY
PROPRIETARY_LICENSES
BRIEF_DOCS
"Text for proprietary licenses"
FULL_DOCS
"Text for proprietary licenses")
define_property(GLOBAL
PROPERTY
SHAREALIKE_LICENSES
BRIEF_DOCS
"Text for share-alike licenses"
FULL_DOCS
"Text for share-alike licenses (e.g. GPL)")
define_property(GLOBAL
PROPERTY
PERMISSIVE_LICENSES
BRIEF_DOCS
"Text for permissive licenses"
FULL_DOCS
"Text for permissive licenses (e.g. BSD, MIT, X11)")
define_property(GLOBAL
PROPERTY
PACKAGES_LICENSED
BRIEF_DOCS
"List of all packages whose licenses are registered here"
FULL_DOCS
"List of all packages whose licenses are registered here")
define_property(GLOBAL
PROPERTY
REDISTRIBUTION_WARNINGS
BRIEF_DOCS
"Text for important redistribution warnings"
FULL_DOCS
"Text for important redistribution warnings, such as 'This is not redistributable!'")
function(add_license LICENSE_TYPE_PROPERTY package license)
get_property(def GLOBAL PROPERTY LICENSE_PACKAGE_${package} DEFINED)
if(NOT def)
define_property(GLOBAL
PROPERTY
LICENSE_PACKAGE_${package}
BRIEF_DOCS
"Flag to indicate the addition of the license for ${package}"
FULL_DOCS
"Flag to indicate the addition of the license for ${package}")
get_property(existing GLOBAL PROPERTY ${LICENSE_TYPE_PROPERTY})
set_property(GLOBAL
PROPERTY
${LICENSE_TYPE_PROPERTY}
"${existing}${license}\n\n")
if(ARGN)
define_property(GLOBAL
PROPERTY
LICENSE_EXTRAS_PACKAGE_${package}
BRIEF_DOCS
"Extras (like URL) for the license for ${package}"
FULL_DOCS
"Extras (like URL) for the license for ${package}")
set_property(GLOBAL
PROPERTY
LICENSE_EXTRAS_PACKAGE_${package}
"${ARGN}")
endif()
get_property(allpackages GLOBAL PROPERTY PACKAGES_LICENSED)
list(APPEND allpackages "${package}")
set_property(GLOBAL PROPERTY PACKAGES_LICENSED "${allpackages}")
endif()
endfunction()
function(add_proprietary_license package license)
add_license(PROPRIETARY_LICENSES "${package}" "${license}" ${ARGN})
endfunction()
function(add_sharealike_license package license)
add_license(SHAREALIKE_LICENSES "${package}" "${license}" ${ARGN})
endfunction()
function(add_permissive_license package license)
add_license(PERMISSIVE_LICENSES "${package}" "${license}" ${ARGN})
endfunction()
function(add_redistribution_warning warning)
get_property(existing GLOBAL PROPERTY REDISTRIBUTION_WARNINGS)
set_property(GLOBAL
PROPERTY
REDISTRIBUTION_WARNINGS
"${warning} ${existing}")
endfunction()
function(configure_license_file input output)
get_property(PACKAGES_LICENSED GLOBAL PROPERTY PACKAGES_LICENSED)
if(PACKAGES_LICENSED)
list(SORT PACKAGES_LICENSED)
set(PACKAGES_LICENSED_BULLETED)
foreach(package ${PACKAGES_LICENSED})
set(EXTRAS)
get_property(package_extras
GLOBAL
PROPERTY
"LICENSE_EXTRAS_PACKAGE_${package}")
if(package_extras)
set(EXTRAS " ${package_extras}")
endif()
set(PACKAGES_LICENSED_BULLETED
"${PACKAGES_LICENSED_BULLETED} * ${package}${EXTRAS}\n")
endforeach()
endif()
get_property(REDISTRIBUTION_WARNINGS
GLOBAL
PROPERTY
REDISTRIBUTION_WARNINGS)
get_property(PROPRIETARY_LICENSES GLOBAL PROPERTY PROPRIETARY_LICENSES)
get_property(SHAREALIKE_LICENSES GLOBAL PROPERTY SHAREALIKE_LICENSES)
get_property(PERMISSIVE_LICENSES GLOBAL PROPERTY PERMISSIVE_LICENSES)
configure_file("${input}" "${output}" ${ARGN})
endfunction()