Skip to content

Commit 0689ed4

Browse files
committed
only print delimiter when necessary
1 parent 94c221d commit 0689ed4

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ function(write_license_disclaimer FILE_NAME PACKAGES)
22
file(WRITE ${FILE_NAME} "")
33
set(PRINT_DELIMITER OFF)
44
foreach(package ${PACKAGES})
5-
if(PRINT_DELIMITER)
6-
file(APPEND ${FILE_NAME} "\n-----\n")
7-
endif()
85
file(GLOB licenses "${${package}_SOURCE_DIR}/LICENSE*" "${${package}_SOURCE_DIR}/license*")
96
list(LENGTH licenses LICENSE_COUNT)
107
if(LICENSE_COUNT GREATER_EQUAL 1)
8+
if(PRINT_DELIMITER)
9+
file(APPEND ${FILE_NAME} "\n-----\n")
10+
endif()
11+
1112
list(GET licenses 0 license)
1213
file(READ ${license} license_TEXT)
1314
file(APPEND ${FILE_NAME}

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# CPMlicenses.cmake
1+
# CPMLicenses.cmake
22

33
A license collector for your projects using CPM.cmake.
44

55
## About
66

77
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.
88

9-
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.
9+
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.
1010

1111
## Usage
1212

@@ -15,12 +15,12 @@ Use [CPM.cmake](https://github.com/TheLartians/CPM.cmake) to add CPMLicenses.cma
1515
```cmake
1616
CPMAddPackage(
1717
NAME CPMLicenses.cmake
18-
GITHUB_REPOSITORY TheLartians/CPMlicenses.cmake
19-
VERSION 0.0.1
18+
GITHUB_REPOSITORY TheLartians/CPMLicenses.cmake
19+
VERSION 0.0.2
2020
)
2121
```
2222

23-
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.
23+
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.
2424

2525
For example, with the configuration
2626

0 commit comments

Comments
 (0)