Coder Social home page Coder Social logo

cpm-cmake / cpmlicenses.cmake Goto Github PK

View Code? Open in Web Editor NEW
31.0 3.0 2.0 27 KB

๐Ÿ“œ Give credit automatically! A license disclaimer generator for your CPM.cmake dependencies.

License: MIT License

CMake 100.00%
opensource open-source licenses licences devops cmake dependency detection automatic automation

cpmlicenses.cmake's Introduction

Check Check

CPMLicenses.cmake

A license collector for your projects using CPM.cmake.

About

Many open-source projects require adding a disclaimer to your binary reproducing the dependencies license. Unfortunately, finding and maintaining the disclaimers for all dependencies can be a tedious task. Luckily, if you're using CPM.cmake to add the dependencies, this process can be automated using this package.

CPMlicenses.cmake will automatically scan all source directories of your CPM.cmake dependencies and find any file that begins with LICENCE or LICENSE, appending the contents to an output file that you can use as a license disclaimer. If no license has been found for a package, a warning will be emitted.

Usage

Use CPM.cmake to add CPMLicenses.cmake to your project.

CPMAddPackage(
  NAME CPMLicenses.cmake 
  GITHUB_REPOSITORY cpm-cmake/CPMLicenses.cmake
  VERSION 0.0.5
)

After all additional dependencies have been added, create the target by calling cpm_licenses_create_disclaimer_target(<target name> <output file> <packages>). Afterwards, simply build the CMake target with the specified name to create the file containing the licenses.

For example, with the configuration

cpm_licenses_create_disclaimer_target(
  write-licenses "${CMAKE_CURRENT_BINARY_DIR}/third_party.txt" "${CPM_PACKAGES}"
)

building the target write licenses (e.g. calling cmake --build build --target write-licenses) will create the file third_party.txt in your build directory, containing all license disclaimers of dependencies added by CPM.cmake.

Example output

The generated disclaimer contains the name of the dependency as well as the included license text. Below is an example of the disclaimer generated for Catch2.

The following software may be included in this product: Catch2. This software contains the following license and notice below:

Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

cpmlicenses.cmake's People

Contributors

bilke avatar developerpaul123 avatar thelartians avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cpmlicenses.cmake's Issues

Allow the target to be run automatically

It would be nice to add an option to add the ALL keyword on the target options to allow it to be run automatically and maybe add an install path relative '${CMAKE_INSTALL_DOCDIR}'.

Something like this pseudo-code?

function(cpm_licenses_create_disclaimer_target TARGET_NAME FILE_NAME PACKAGES)
  cmake_parse_arguments(ARGS "ALL" "PATH" "" ${ARGN})
  set(PACKAGE_SOURCES "")
  foreach(package ${PACKAGES})
    cpm_get_fetch_properties(${package})
    list(APPEND PACKAGE_SOURCES "-D${package}_SOURCE_DIR=\"${${package}_SOURCE_DIR}\"")
  endforeach()

  if(ARGS_ALL)
  add_custom_target(
    ${TARGET_NAME} ALL
    COMMAND
      ${CMAKE_COMMAND} -DPRINT_license_FILE_NAME=${FILE_NAME}
      "-DPRINT_license_PACKAGES=\"${PACKAGES}\"" ${PACKAGE_SOURCES} -P ${CPMlicenses_SCRIPT_PATH}
  )
else()
  add_custom_target(
    ${TARGET_NAME} ALL
    COMMAND
      ${CMAKE_COMMAND} -DPRINT_license_FILE_NAME=${FILE_NAME}
      "-DPRINT_license_PACKAGES=\"${PACKAGES}\"" ${PACKAGE_SOURCES} -P ${CPMlicenses_SCRIPT_PATH}
  )
endif()
INSTALL(FILES ${FILE_NAME} DESTINATION "${CMAKE_INSTALL_DOCDIR}/${ARGS_PATH}")
endfunction()

[BUG] CPMLicenses Fails with Folders Named `LICENSE`

I realize that this generally isn't the case in most projects, but I accidentally made it happen with a project I'm working on where I created a folder called LICENSE instead of a file and didn't realize it. When I tried to run the write-licenses build target it failed due to not being about to "read" the directory.

Idea: Support license type checks e.g. Error on non-commercial usage etc.

It could be great to extend the functionality to allow to automatically detect and warn if a license is not permitted in the scope of the current project, be it commercial or otherwise.

There could be some sort of workflow :

  1. User populates a list of allowed+disallow license types
  2. On build warn when a type not listed is found
    • User may append the allowed or disallow list
    • User may add explicit exception for a project (May have other agreement)

Prerequisite feature would be #5 to detect the types of licenses used

Idea: Generate a summary of used licenses

It would be great if along with finding the licenses there were a short summary which could be easier to review.
This would require finding a way to 'detect' what type of license the project uses. Very much similar to GitHub does, maybe this can be a good source for regex or similar!

Appears GitHub use this: https://github.com/licensee/licensee

Extension

As an extension to this feature could generate a diagram for use in documentation. using DOT and Graphviz maybe etc.
image
https://i1.wp.com/www.embeddeduse.com/wp-content/uploads/2016/04/qt-licenses-up-to-5.6.png?ssl=1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.