summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2020-02-24 15:49:11 +0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2020-02-27 18:19:31 +0200
commit242b719f0cbb24b485e439edd0da5aedee87f444 (patch)
tree53455edff4a9ed6c60fddc20d060363f68709554 /scripts
parent1db92f3c6c8cc1977a89b2060cafef754e4dd34d (diff)
downloadqtlocation-mapboxgl-242b719f0cbb24b485e439edd0da5aedee87f444.tar.gz
[build] Generate the LICENSE.md for mbgl-core
Add a script that for everything we link against mbgl-core, it will check the license and generate a file all the dependencies listed with the respective authors, project urls and license.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/license.cmake40
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/license.cmake b/scripts/license.cmake
new file mode 100644
index 0000000000..e3a7d2aaa4
--- /dev/null
+++ b/scripts/license.cmake
@@ -0,0 +1,40 @@
+# Generate the license file for the target ${param} at config time
+
+function(mbgl_generate_license param)
+ # Fake targets or non relevant.
+ set(BLACKLIST "mbgl-compiler-options")
+
+ get_target_property(LIBRARIES ${param} LINK_LIBRARIES)
+ list(INSERT LIBRARIES 0 ${param})
+
+ # cmake-format: off
+ foreach(LIBRARY IN LISTS LIBRARIES)
+ # cmake-format: on
+ if(${LIBRARY} IN_LIST BLACKLIST)
+ continue()
+ endif()
+
+ if(TARGET ${LIBRARY})
+ get_target_property(NAME ${LIBRARY} INTERFACE_MAPBOX_NAME)
+ get_target_property(URL ${LIBRARY} INTERFACE_MAPBOX_URL)
+ get_target_property(AUTHOR ${LIBRARY} INTERFACE_MAPBOX_AUTHOR)
+ get_target_property(LICENSE ${LIBRARY} INTERFACE_MAPBOX_LICENSE)
+
+ if(NOT LICENSE OR NOT EXISTS ${LICENSE})
+ message(FATAL_ERROR "License not found for target: ${LIBRARY}")
+ endif()
+
+ file(READ ${LICENSE} LICENSE_DATA)
+
+ string(APPEND LICENSE_LIST "### [${NAME}](${URL}) by ${AUTHOR}\n\n")
+ string(APPEND LICENSE_LIST "```\n${LICENSE_DATA}\n```\n\n")
+ string(APPEND LICENSE_LIST "---\n\n")
+ endif()
+ endforeach()
+
+ file(WRITE ${CMAKE_BINARY_DIR}/${param}.license ${LICENSE_LIST})
+
+ add_custom_target(${param}-license COMMAND cat ${CMAKE_BINARY_DIR}/${param}.license)
+endfunction()
+
+mbgl_generate_license(mbgl-core)