diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c1da58..19d3f6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,13 @@ function(write_license_disclaimer FILE_NAME PACKAGES) file(WRITE ${FILE_NAME} "") set(PRINT_DELIMITER OFF) foreach(package ${PACKAGES}) - if(PRINT_DELIMITER) - file(APPEND ${FILE_NAME} "\n-----\n") - endif() file(GLOB licenses "${${package}_SOURCE_DIR}/LICENSE*" "${${package}_SOURCE_DIR}/license*") list(LENGTH licenses LICENSE_COUNT) if(LICENSE_COUNT GREATER_EQUAL 1) + if(PRINT_DELIMITER) + file(APPEND ${FILE_NAME} "\n-----\n") + endif() + list(GET licenses 0 license) file(READ ${license} license_TEXT) file(APPEND ${FILE_NAME} diff --git a/README.md b/README.md index a592395..25c85aa 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# CPMlicenses.cmake +# CPMLicenses.cmake A license collector for your projects using CPM.cmake. @@ -6,7 +6,7 @@ A license collector for your projects using CPM.cmake. Many open-source projects require adding a disclaimer to your binary reproducing the dependencies license. Finding and updating the disclaimer for all dependencies can be a tedious task. Luckily, if you've used [CPM.cmake](https://github.com/TheLartians/CPM.cmake) to add the dependencies this process can be automated. -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. +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 @@ -15,12 +15,12 @@ Use [CPM.cmake](https://github.com/TheLartians/CPM.cmake) to add CPMLicenses.cma ```cmake CPMAddPackage( NAME CPMLicenses.cmake - GITHUB_REPOSITORY TheLartians/CPMlicenses.cmake - VERSION 0.0.1 + GITHUB_REPOSITORY TheLartians/CPMLicenses.cmake + VERSION 0.0.2 ) ``` -After all additional dependencies have been added, create the target by calling `cpm_licenses_create_disclaimer_target( )`. Afterwards, simply build the CMake target with the specified name to create the file containing the licenses. +After all additional dependencies have been added, create the target by calling `cpm_licenses_create_disclaimer_target( )`. Afterwards, simply build the CMake target with the specified name to create the file containing the licenses. For example, with the configuration