Compare commits

...

34 Commits

Author SHA1 Message Date
Lars Melchior
52ee7c9d53 Fix new release script to use correct version and hash sum (#507)
* fix new release script to use correct version and hash sum

* update logging behaviour
2023-09-18 15:01:57 +02:00
Tobias Schmidl
699c7a0038 Added download status, added comparison by hash sum (#474) 2023-09-18 14:01:34 +02:00
Vincent Hamp
daf9d766c6 Add ZIMO-Elektronik to "Built with CPM.cmake" (#490) 2023-09-18 11:45:33 +02:00
Carlo Corradini
439bfcf134 chore(license): update license year (#504) 2023-09-17 19:35:11 +00:00
Alois Klink
02ecc4608a Add SPDX tags to get_cpm.cmake to comply with MIT (#496)
Add [SPDX][1] licensing/copyright tags to the `get_cpm.cmake` script,
so that anybody that copies the `get_cpm.cmake` script into their repo
(following the instructions in the README.md)
will automatically comply with CPM's MIT license.

[1]: https://spdx.dev/
2023-08-19 12:53:28 +00:00
Johel Ernesto Guerrero Peña
4608688d85 docs: fix spelling of "through" (#489) 2023-08-19 13:29:57 +02:00
Johel Ernesto Guerrero Peña
cda03b434e ci(cmake): split additional_commands to its own file (#486) 2023-08-19 12:57:47 +02:00
Andreas K
ee556fc555 fix(lock): fix typo: CPM_CACHE_SOURCE -> CPM_SOURCE_CACHE (#485) 2023-07-12 15:43:48 +02:00
Asger Gitz-Johansen
1b59cb6b16 Add AALTITOAD to "Built with CPM.cmake" (#463) 2023-04-13 09:58:49 +00:00
Claus Klein
a02a9601da SOURCE_DIR option disable call to find_package() (#456) 2023-02-28 19:25:01 +01:00
Craig Hutchinson
af3f1ca814 Prevent check variable leaking into caller scope (#457) 2023-02-27 12:48:00 +01:00
Lars Melchior
b9b512a869 Add CMake version as workflow matrix parameter (#451)
* add CMake version as workflow matrix parameter

* change system test behaviour based on specified CMake version

* use explicit version strings

* set CMake version for both test steps

* exclude windows-2022, cmake 3.16 combination
2023-02-22 17:33:50 +01:00
Lars Melchior
e23bd4c0c3 Update Readme to match default SYSTEM behaviour (#452) 2023-02-21 20:00:20 +02:00
Lars Melchior
5f3005ab7c Move section on adding CPM higher in the Readme (#454)
Repositions the "Adding CPM" section higher in the Readme to increase incentive to try it out and make it easier to find for updating CPM in existing projects.
2023-02-21 19:59:57 +02:00
Lars Melchior
12daf366c7 Add SYSTEM option (#449)
* add system property for cpm_add_subdirectory

* add test case for system property

* lock CMake version in test workflow

* refactor to make SYSTEM an extra config option and update tests

* remove old comment change

* use consistent CMake version and extension for all workflows

* make warning more specific and try to trigger on windows

* another attempt to trigger warning on MSVC

* update readme

* simplify test case and use git tag

* add SYSTEM option to .cmake-format

* forward system arg for source overrides

* enable system implicitly for the single argument syntax

* Use SYSTEM option for FetchContent and add_subdirectory (#441)

* Use SYSTEM option for FetchContent and add_subdirectory

* Add SYSTEM option to syntax and doku

* Update CPM.cmake

* Update .cmake-format

---------

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>

---------

Co-authored-by: Claus Klein <claus.klein@arcormail.de>
2023-02-21 15:51:33 +01:00
PercentBoat4164
0938e8fde7 Improve Multi-threaded Performance. (#450)
* Optimized multi-threading.

* Remove old multi-threading implementation.

* Release files instead of removing.

* Lock before choosing to check cache or download.

* Unlock directly after verifying directory exists.
2023-02-21 15:47:15 +01:00
PercentBoat4164
09b056ae20 Add file locking to support parallel runs. (#427)
* Add file locking to support parallel runs.

* Fixed formatting.

* Prevent double locking file.

* Fix SegFault from test 2.

* Remove unnecessary debugging messages.

* Lock the package directory rather than the cache directory.
Only synchronize if CPM_SOURCE_CACHE is defined.

* Lock the version specific cache entry rather than the package specific entry.

* Remove unnecessary arguments in conditional statements.

* Change back to locking entire cache directory.

* Only check CPM_HAS_CACHE_LOCK.

* Lock on a per-package basis rather than the entire cache.

* Clean up the locked file.

* Unlock then remove to fix Windows.

* Specify use of cmake.lock as the lock file.

* - Changed CPM_HAS_CACHE_LOCK to ${CPM_ARGS_NAME}_CPM_HAS_CACHE_LOCK.
- Removed redundant variable initialization.

* Add unit test.

* Actually test if resulting git cache is clean in unit test.

* - Added comments
- Fixed formatting
- Removed unnecessary imports

* convert parallelism test to integration test

* remove comment

* - Removed now unnecessary variable.
 - Only delete file instead of unlocking it then deleting it.

* Forgot to change variable name.

* Add similar changes to the missed section.

* Fixed formatting.

* Unlock the file, but do not delete it.

* Only unlock the file if it exists.

* Changed cache.cmake test to ignore non-directory entries.

* Integration test lib make_project:
* keyword args
* 'name' arg to allow multiple projects from the same test

* - Moved checks to function.
- Fixed small grammatical errors.

* - Fix formatting

* Switch to snake case.

---------

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
Co-authored-by: Lars Melchior <lars.melchior@gmail.com>
Co-authored-by: Borislav Stanimirov <b.stanimirov@abv.bg>
2023-01-28 14:36:44 +01:00
Jan Niklas Hasse
d34d2a8730 Add JNGL to "Built with CPM.cmake" (#434)
Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
2023-01-10 15:48:29 +00:00
Lars Melchior
6fc2170d5d Update example dependency versions (#430)
* update example versions

* update doctest

* update lua

* update google benchmark

* update catch2

* update readme to match updated dependencies

Co-authored-by: Lars Melchior <lars@Larss-Laptop.local>
2023-01-10 15:31:57 +01:00
haenkel
1184a6e6e7 get_cpm: Recover from failed download (#426)
* get_cpm: Recover from failed download

If the download fails during the cmake config step
an empty `CPM_<version>.cmake` file is created.
So far the script only checks the files existence,
so there is no second try until the empty file is deleted manually.

This adds a check if the file is empty
and resumes the download on next config if it is.

* More descriptive function name
2022-11-29 17:30:22 +00:00
flagarde
c53417bd65 Small helper function for logging : (#422)
* Small helper function for logging :

This PR add an helper function only when `message(STATUS ...)` as the other are `backtracing` and adding the helper function add on stack.

It should fix #328 #342 with a few line of code.

* Formatting
2022-11-29 17:50:19 +01:00
Jan Niklas Hasse
50e9b9edb8 Instead of spdlog's bundled fmt re-use it from CPM.cmake (#364)
* Instead of spdlog's bundled fmt re-use it from CPM.cmake

* Add comment about re-using fmt for spdlog

* Update examples/spdlog/CMakeLists.txt

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>

* run cmake-format

* disable cmake-format around code block

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
2022-11-09 11:23:09 +00:00
Craig Hutchinson
03705fcce1 Added export of CPM_LAST_PACKAGE_NAME (#403) 2022-09-28 21:39:31 +02:00
Lars Melchior
f00ccd89c4 Update example in readme (#413)
* update readme example

* Update README.md
2022-09-28 22:31:15 +03:00
Lars Melchior
1f4909ca44 add CONTRIBUTING.md (#412) 2022-09-28 05:55:09 +03:00
Borislav Stanimirov
4d33686a50 Updated contributor list (#411) 2022-09-27 21:09:28 +02:00
AlessandroW
984251f46c Fix copy/paste bug in fmt example CMakeLists.txt
#410
2022-09-27 21:01:21 +03:00
Robert Maynard
63d0de7114 Don't warn about dirty source trees when a PATCH_COMMAND is provided (#401)
The patch command will always cause a dirty source tree, which
is expected and not a cause for concern.
2022-09-13 23:21:12 +02:00
Kamil Kisiel
65c760a840 Expand absolute path later in get_cpm.cmake (#397)
* Expand absolute path later in get_cpm.cmake

Supports expanding tildes in the environment.

* Apply cmake-format to get_cpm.cmake

* Use .cmake-format file
2022-09-13 20:54:57 +00:00
Robert Maynard
b5e60e72e8 cpm_find_package Use found package version when possible (#396) 2022-09-13 22:44:24 +02:00
Robert Maynard
10bf25a811 Restore policy changes in CPMAddPackage (#388)
* Restore policy changes in CPMAddPackage

Fixes #387

* Correct style issues found by CI
2022-08-11 19:12:21 +00:00
Lars Melchior
18b6cbf233 perform policy changes only in top-level CPM.cmake script (#386) 2022-08-09 12:56:46 +02:00
Olivier Le Doeuff
698741ff7c Fix a very confusing typo (#384) 2022-08-04 10:34:33 +03:00
Borislav Stanimirov
1f09de0d9b Document policies being set to NEW when including CPM.cmake (#383) 2022-08-04 08:32:05 +02:00
35 changed files with 650 additions and 241 deletions

View File

@@ -1,73 +1,5 @@
include: ["cmake/.cmake-format-additional_commands-cpm"]
format:
tab_size: 2
line_width: 100
dangle_parens: true
parse:
additional_commands:
cpmaddpackage:
pargs:
nargs: '*'
flags: []
spelling: CPMAddPackage
kwargs: &cpmaddpackagekwargs
NAME: 1
FORCE: 1
VERSION: 1
GIT_TAG: 1
DOWNLOAD_ONLY: 1
GITHUB_REPOSITORY: 1
GITLAB_REPOSITORY: 1
GIT_REPOSITORY: 1
SVN_REPOSITORY: 1
SVN_REVISION: 1
SOURCE_DIR: 1
DOWNLOAD_COMMAND: 1
FIND_PACKAGE_ARGUMENTS: 1
NO_CACHE: 1
GIT_SHALLOW: 1
URL: 1
URL_HASH: 1
URL_MD5: 1
DOWNLOAD_NAME: 1
DOWNLOAD_NO_EXTRACT: 1
HTTP_USERNAME: 1
HTTP_PASSWORD: 1
EXCLUDE_FROM_ALL: 1
SOURCE_SUBDIR: 1
OPTIONS: +
cpmfindpackage:
pargs:
nargs: '*'
flags: []
spelling: CPMFindPackage
kwargs: *cpmaddpackagekwargs
cpmdeclarepackage:
pargs:
nargs: '*'
flags: []
spelling: CPMDeclarePackage
kwargs: *cpmaddpackagekwargs
packageproject:
pargs:
nargs: '*'
flags: []
spelling: packageProject
kwargs:
NAME: 1
VERSION: 1
INCLUDE_DIR: 1
INCLUDE_DESTINATION: 1
BINARY_DIR: 1
COMPATIBILITY: 1
VERSION_HEADER: 1
DEPENDENCIES: +
cpmusepackagelock:
pargs: 1
spelling: CPMUsePackageLock
cpmregisterpackage:
pargs: 1
spelling: CPMRegisterPackage
cpmgetpackageversion:
pargs: 2
spelling: CPMGetPackageVersion

View File

@@ -12,7 +12,7 @@ jobs:
gcc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: build all
env:
CC: gcc
@@ -22,7 +22,7 @@ jobs:
clang:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: build all
env:
CC: clang

View File

@@ -10,13 +10,14 @@ jobs:
name: Publish CPM.cmake
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Set CPM version by tag
run: |
mkdir dist
sed "s/1.0.0-development-version/${GITHUB_REF/refs\/tags\/v}/g" cmake/CPM.cmake > dist/CPM.cmake
sed "s/1.0.0-development-version/${GITHUB_REF/refs\/tags\/v}/g" cmake/get_cpm.cmake > dist/get_cpm.cmake
sed -e "s/1.0.0-development-version/${GITHUB_REF/refs\/tags\/v}/g" cmake/CPM.cmake > dist/CPM.cmake
sed -e "s/1.0.0-development-version/${GITHUB_REF/refs\/tags\/v}/g" \
-e "s/CPM_HASH_SUM_PLACEHOLDER/$(sha256sum dist/CPM.cmake | cut -d' ' -f1)/" cmake/get_cpm.cmake > dist/get_cpm.cmake
- name: Upload CPM.cmake to release
uses: svenstaro/upload-release-action@v1-release

View File

@@ -11,15 +11,18 @@ on:
jobs:
style:
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.13
with:
cmake-version: '3.25.x'
- name: Install format dependencies
run: |
brew install clang-format
pip3 install cmake_format==0.6.11 pyyaml
run: pip3 install clang-format==14.0.6 cmake_format==0.6.11 pyyaml
- name: configure
run: cmake -Stest/style -Bbuild/style

View File

@@ -17,17 +17,32 @@ jobs:
# we need at least ruby 2.7 for the tests
# instead of dealing with installing a modern version of ruby on 2019, we'll just use windows-2022 here
os: [ubuntu-latest, windows-2022, macos-latest]
# we want to ensure compatibility with a recent CMake version as well as the lowest officially supported
# legacy version that we define as the default version of the second-latest Ubuntu LTS release currently available
cmake_version: ['3.16.3', '3.25.1']
exclude:
# there seems to be an issue with CMake 3.16 not finding a C++ compiler on windows-2022
- os: windows-2022
cmake_version: '3.16.3'
steps:
- name: clone
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.13
with:
cmake-version: ${{ matrix.cmake_version }}
- name: unit tests
run: |
cmake -Stest -Bbuild/test
cmake --build build/test --target test-verbose
env:
CMAKE_VERSION: ${{ matrix.cmake_version }}
- name: integration tests
run: ruby test/integration/runner.rb
env:
CPM_INTEGRATION_TEST_DIR: ./build/integration
CMAKE_VERSION: ${{ matrix.cmake_version }}

177
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,177 @@
<!-- omit in toc -->
# Contributing to CPM.cmake
First off, thanks for taking the time to contribute! ❤️
All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉
> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
> - Star the project
> - Tweet about it
> - Refer this project in your project's readme
> - Mention the project at local meetups and tell your friends/colleagues
<!-- omit in toc -->
## Table of Contents
- [I Have a Question](#i-have-a-question)
- [I Want To Contribute](#i-want-to-contribute)
- [Reporting Bugs](#reporting-bugs)
- [Suggesting Enhancements](#suggesting-enhancements)
- [Your First Code Contribution](#your-first-code-contribution)
- [Styleguides](#styleguides)
## I Have a Question
> If you want to ask a question, we assume that you have read the available [Documentation](https://github.com/cpm-cmake/CPM.cmake/blob/master/README.md).
Before you ask a question, it is best to search for existing [Issues](https://github.com/cpm-cmake/CPM.cmake/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.
If you then still feel the need to ask a question and need clarification, we recommend the following:
- Open an [Issue](https://github.com/cpm-cmake/CPM.cmake/issues/new).
- Provide as much context as you can about what you're running into.
- Provide project and platform versions (CMake, OS, etc), depending on what seems relevant.
We will then take care of the issue as soon as possible.
## I Want To Contribute
> ### Legal Notice <!-- omit in toc -->
> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license.
### Reporting Bugs
<!-- omit in toc -->
#### Before Submitting a Bug Report
A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.
- Make sure that you are using the latest version.
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://github.com/cpm-cmake/CPM.cmake/blob/master/README.md). If you are looking for support, you might want to check [this section](#i-have-a-question)).
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/cpm-cmake/CPM.cmake/issues?q=label%3Abug).
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
- Collect information about the bug:
- Stack trace / Full CMake error output
- OS, Platform and Version (Windows, Linux, macOS, x86, ARM)
- Version of CMake, compiler or other tools used, depending on what seems relevant.
- Possibly any relevant environment / command line arguments used
- Can you reliably reproduce the issue? And can you also reproduce it with older versions?
<!-- omit in toc -->
#### How Do I Submit a Good Bug Report?
We use GitHub issues to track bugs and errors. If you run into an issue with the project:
- Open an [Issue](https://github.com/cpm-cmake/CPM.cmake/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
- Explain the behavior you would expect and the actual behavior.
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
- Provide the information you collected in the previous section.
Once it's filed:
- The project team will label the issue accordingly.
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution).
### Suggesting Enhancements
This section guides you through submitting an enhancement suggestion for CPM.cmake, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.
<!-- omit in toc -->
#### Before Submitting an Enhancement
- Make sure that you are using the latest version.
- Read the [documentation](https://github.com/cpm-cmake/CPM.cmake/blob/master/README.md) carefully and find out if the functionality is already covered, maybe by an individual configuration.
- Perform a [search](https://github.com/cpm-cmake/CPM.cmake/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
<!-- omit in toc -->
#### How Do I Submit a Good Enhancement Suggestion?
Enhancement suggestions are tracked as [GitHub issues](https://github.com/cpm-cmake/CPM.cmake/issues).
- Use a **clear and descriptive title** for the issue to identify the suggestion.
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
- **Explain why this enhancement would be useful** to most CPM.cmake users. You may also want to point out the other projects that solved it better and which could serve as inspiration.
### Your First Code Contribution
Please try to keep your individual changes as minimal and focussed on the issue as possible.
If you discover that the scope of your contribution is growing larger than expected you might want to split the changes into multiple separate contributions to allow a more focussed discussion and review.
It is usually a great idea and often required to add tests for your changes.
This allows us to quickly validate that the changes are working as intended and also guarantees that they wont be broken by other future updates.
For small and targeted functional changes, e.g. supporting a new URL schema, a [unit test](#unit-tests) may be enough.
For contributions that change large-scale behaviour, such as dependency caching features, an [integration test](#integration-tests) is more suited.
Depending on the changes, a combination of both test types may also be appropriate.
#### Unit tests
Unit tests are small CMake scripts that live in the [unit test directory](./test/unit/).
They usually make use of some of the helper assertions defined in the [testing.cmake](./cmake/testing.cmake) file.
An example unit test for checking the `cpm_get_version_from_git_tag` function could look like the following.
```cmake
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
include(${CPM_PATH}/CPM.cmake)
include(${CPM_PATH}/testing.cmake)
cpm_get_version_from_git_tag("v1.2.3-a" VERSION)
assert_equal("1.2.3" ${VERSION})
```
This test can be run directly with CMake by providing the CPM source directory.
```bash
cmake -DCPM_PATH=$(pwd)/cmake -P <path to the test file>
```
We can also the [test directory's](./test/) CMakeLists to detect and run all unit tests using CMake's test runner.
```bash
cmake -Stest -Bbuild/test
cmake --build build/test --target test-verbose # or `test` for less noisy output
```
#### Integration tests
The integration tests of CPM.cmake are written in Ruby. They use a custom integration test framework which extends the [Test::Unit](https://www.rubydoc.info/github/test-unit/test-unit/Test/Unit) library.
They require Ruby 2.7.0 or later.
To run all tests from the repo root execute:
```
ruby test/integration/runner.rb
```
For a detailed guide on integration tests, see the documentation in the [integration test directory](./test/integration/).
## Styleguides
This project uses automatic code styling using [clang-format](https://clang.llvm.org/docs/ClangFormat.html) and [cmake-format](https://github.com/cheshirekow/cmake_format).
The code style is enforced by the tools using the style options defined in the [.clang-format](./.clang-format) and [.cmake-format](./.cmake-format) configuration files.
To install the necessary tools for code styling we recommend using recent version of [Python/pip](https://www.python.org).
```bash
pip3 install clang-format==14.0.6 cmake_format==0.6.11 pyyaml
```
For convenience, we have a CMake project defined in the [test/style](./test/style/) directory that can be called to automatically apply the code styling to all files currently added in git.
```bash
# initialize the project
cmake -Stest/style -Bbuild/style
# apply the code styling to this repository
cmake --build build/style --target fix-format
```
<!-- omit in toc -->
## Attribution
This guide is based on the **contributing-gen**. [Make your own](https://github.com/bttger/contributing-gen)!

View File

@@ -30,3 +30,11 @@ For detailed breakdown of individual contributions see the [Contributors page on
* [Yotam Gingold](https://github.com/yig)
* [jecassis](https://github.com/jecassis)
* [Johel Ernesto Guerrero Peña](https://github.com/JohelEGP)
* [Lars Bilke](https://github.com/bilke)
* [Lava Block](https://github.com/TheLavaBlock)
* [Anton Filimonov](https://github.com/variar)
* [David Fong](https://github.com/david-fong)
* [Thomas Mosegaard Pedersen](https://github.com/thomas-mp)
* [Evgeny Gorodetskiy](https://github.com/egorodet)
* [Kamil Kisiel](https://github.com/kisielk)
* [AlessandroW](https://github.com/AlessandroW)

118
README.md
View File

@@ -12,7 +12,7 @@ It's built as a thin wrapper around CMake's [FetchContent](https://cmake.org/cma
## Manage everything
Any downloadable project or resource can be added as a version-controlled dependency though CPM, it is not necessary to modify or package anything.
Any downloadable project or resource can be added as a version-controlled dependency through CPM, it is not necessary to modify or package anything.
Projects using modern CMake are automatically configured and their targets can be used immediately.
For everything else, the targets can be created manually after the dependency has been downloaded (see the [snippets](#snippets) below for examples).
@@ -21,6 +21,42 @@ For everything else, the targets can be created manually after the dependency ha
- [CPM: An Awesome Dependency Manager for C++ with CMake](https://medium.com/swlh/cpm-an-awesome-dependency-manager-for-c-with-cmake-3c53f4376766)
- [CMake and the Future of C++ Package Management](https://ibob.github.io/blog/2020/01/13/cmake-package-management/)
## Full CMakeLists Example
```cmake
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# create project
project(MyProject)
# add executable
add_executable(main main.cpp)
# add dependencies
include(cmake/CPM.cmake)
CPMAddPackage("gh:fmtlib/fmt#7.1.3")
CPMAddPackage("gh:nlohmann/json@3.10.5")
CPMAddPackage("gh:catchorg/Catch2@3.2.1")
# link dependencies
target_link_libraries(main fmt::fmt nlohmann_json::nlohmann_json Catch2::Catch2WithMain)
```
See the [examples directory](https://github.com/cpm-cmake/CPM.cmake/tree/master/examples) for complete examples with source code and check [below](#snippets) or in the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/More-Snippets) for example snippets.
## Adding CPM
To add CPM to your current project, simply add the [latest release](https://github.com/cpm-cmake/CPM.cmake/releases/latest) of `CPM.cmake` or `get_cpm.cmake` to your project's `cmake` directory.
The command below will perform this automatically.
```bash
mkdir -p cmake
wget -O cmake/CPM.cmake https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake
```
You can also download CPM.cmake directly from your project's `CMakeLists.txt`. See the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/Downloading-CPM.cmake-in-CMake) for more details.
## Usage
After `CPM.cmake` has been [added](#adding-cpm) to your project, the function `CPMAddPackage` can be used to fetch and configure a dependency.
@@ -44,6 +80,10 @@ On the other hand, if `VERSION` hasn't been explicitly specified, CPM can automa
If an additional optional parameter `EXCLUDE_FROM_ALL` is set to a truthy value, then any targets defined inside the dependency won't be built by default. See the [CMake docs](https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_ALL.html) for details.
If an additional optional parameter `SYSTEM` is set to a truthy value, the SYSTEM directory property of the subdirectory added will be set to true.
See the [add_subdirectory ](https://cmake.org/cmake/help/latest/command/add_subdirectory.html?highlight=add_subdirectory)
and [SYSTEM](https://cmake.org/cmake/help/latest/prop_tgt/SYSTEM.html#prop_tgt:SYSTEM) target property for details.
A single-argument compact syntax is also supported:
```cmake
@@ -55,7 +95,7 @@ CPMAddPackage("uri#tag")
CPMAddPackage("uri@version#tag")
```
In the shorthand syntax if the URI is of the form `gh:user/name`, it is interpreted as GitHub URI and converted to `https://github.com/user/name.git`. If the URI is of the form `gl:user/name`, it is interpreted as a [GitLab](https://gitlab.com/explore/) URI and converted to `https://gitlab.com/user/name.git`. If the URI is of the form `bb:user/name`, it is interpreted as a [Bitbucket](https://bitbucket.org/) URI and converted to `https://bitbucket.org/user/name.git`. Otherwise the URI used verbatim as a git URL. All packages added using the shorthand syntax will be added using the [EXCLUDE_FROM_ALL](https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_ALL.html) flag.
In the shorthand syntax if the URI is of the form `gh:user/name`, it is interpreted as GitHub URI and converted to `https://github.com/user/name.git`. If the URI is of the form `gl:user/name`, it is interpreted as a [GitLab](https://gitlab.com/explore/) URI and converted to `https://gitlab.com/user/name.git`. If the URI is of the form `bb:user/name`, it is interpreted as a [Bitbucket](https://bitbucket.org/) URI and converted to `https://bitbucket.org/user/name.git`. Otherwise the URI used verbatim as a git URL. All packages added using the shorthand syntax will be added using the [EXCLUDE_FROM_ALL](https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_ALL.html) and [SYSTEM](https://cmake.org/cmake/help/latest/prop_tgt/SYSTEM.html#prop_tgt:SYSTEM) flag.
The single-argument syntax also works for URLs:
@@ -73,47 +113,15 @@ After calling `CPMAddPackage`, the following variables are defined in the local
- `<dependency>_SOURCE_DIR` is the path to the source of the dependency.
- `<dependency>_BINARY_DIR` is the path to the build directory of the dependency.
- `<dependency>_ADDED` is set to `YES` if the dependency has not been added before, otherwise it is set to `NO`.
- `CPM_LAST_PACKAGE_NAME` is set to the determined name of the last added dependency (equivalent to `<dependency>`).
For using CPM.cmake projects with external package managers, such as conan or vcpkg, setting the variable [`CPM_USE_LOCAL_PACKAGES`](#options) will make CPM.cmake try to add a package through `find_package` first, and add it from source if it doesn't succeed.
In rare cases, this behaviour may be desirable by default. The function `CPMFindPackage` will try to find a local dependency via CMake's `find_package` and fallback to `CPMAddPackage`, if the dependency is not found.
## Full CMakeLists Example
```cmake
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# create project
project(MyProject)
# add executable
add_executable(tests tests.cpp)
# add dependencies
include(cmake/CPM.cmake)
CPMAddPackage("gh:catchorg/Catch2@2.5.0")
# link dependencies
target_link_libraries(tests Catch2)
```
See the [examples directory](https://github.com/cpm-cmake/CPM.cmake/tree/master/examples) for complete examples with source code and check [below](#snippets) or in the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/More-Snippets) for example snippets.
## Adding CPM
To add CPM to your current project, simply add the [latest release](https://github.com/cpm-cmake/CPM.cmake/releases/latest) of `CPM.cmake` or `get_cpm.cmake` to your project's `cmake` directory.
The command below will perform this automatically.
```bash
mkdir -p cmake
wget -O cmake/CPM.cmake https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake
```
You can also download CPM.cmake directly from your project's `CMakeLists.txt`. See the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/Downloading-CPM.cmake-in-CMake) for more details.
## Updating CPM
To update CPM to the newest version, update the script in the project's root directory, for example by running the command above.
To update CPM to the newest version, update the script in the project's root directory, for example by running the same command as for [adding CPM](#adding-cpm).
Dependencies using CPM will automatically use the updated script of the outermost project.
## Advantages
@@ -131,6 +139,9 @@ Dependencies using CPM will automatically use the updated script of the outermos
- **No pre-built binaries** For every new build directory, all dependencies are initially downloaded and built from scratch. To avoid extra downloads it is recommend to set the [`CPM_SOURCE_CACHE`](#CPM_SOURCE_CACHE) environmental variable. Using a caching compiler such as [ccache](https://github.com/TheLartians/Ccache.cmake) can drastically reduce build time.
- **Dependent on good CMakeLists** Many libraries do not have CMakeLists that work well for subprojects. Luckily this is slowly changing, however, until then, some manual configuration may be required (see the snippets [below](#snippets) for examples). For best practices on preparing projects for CPM, see the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/Preparing-projects-for-CPM.cmake).
- **First version used** In diamond-shaped dependency graphs (e.g. `A` depends on `C`@1.1 and `B`, which itself depends on `C`@1.2 the first added dependency will be used (in this case `C`@1.1). In this case, B requires a newer version of `C` than `A`, so CPM will emit a warning. This can be easily resolved by adding a new version of the dependency in the outermost project, or by introducing a [package lock file](#package-lock).
- **Some CMake policies set to `NEW`** Including CPM.cmake will lead to several CMake policies being set to `NEW`. Users which need the old behavior will need to manually modify their CMake code to ensure they're set to `OLD` at the appropriate places. The policies are:
- [CMP0077](https://cmake.org/cmake/help/latest/policy/CMP0077.html) and [CMP0126](https://cmake.org/cmake/help/latest/policy/CMP0126.html). They make setting package options from `CMPAddPackage` possible.
- [CMP0135](https://cmake.org/cmake/help/latest/policy/CMP0135.html) It allows for proper package rebuilds of packages which are archives, source cache is not used, and the package URL is changed to an older version.
For projects with more complex needs and where an extra setup step doesn't matter, it may be worth to check out an external C++ package manager such as [vcpkg](https://github.com/microsoft/vcpkg), [conan](https://conan.io) or [hunter](https://github.com/ruslo/hunter).
Dependencies added with `CPMFindPackage` should work with external package managers.
@@ -188,11 +199,14 @@ This can be controlled on a per package basis with the `CPM_DOWNLOAD_<dependency
### CPM_USE_LOCAL_PACKAGES
CPM can be configured to use `find_package` to search for locally installed dependencies first by setting the CMake option `CPM_USE_LOCAL_PACKAGES`.
If the option `CPM_LOCAL_PACKAGES_ONLY` is set, CPM will emit an error if the dependency is not found locally.
These options can also be set as environmental variables.
In the case that `find_package` requires additional arguments, the parameter `FIND_PACKAGE_ARGUMENTS` may be specified in the `CPMAddPackage` call. The value of this parameter will be forwarded to `find_package`.
Note that this does not apply to dependencies that have been defined with a truthy `FORCE` parameter. These will be added as defined.
### CPM_USE_NAMED_CACHE_DIRECTORIES
If set, CPM use additional directory level in cache to improve readability of packages names in IDEs like CLion. It changes cache structure, so all dependencies are downloaded again. There is no problem to mix both structures in one cache directory but then there may be 2 copies of some dependencies.
@@ -301,6 +315,32 @@ If you know others, feel free to add them here through a PR.
</a>
</td>
</tr>
<tr>
<td>
<a href="https://github.com/jhasse/jngl">
<p align="center">
<img src="https://github.com/jhasse/jngl/raw/master/doc/jngl-logo.svg" alt="JNGL" width="100pt" />
</p>
<p align="center"><b>JNGL - easy to use cross-platform 2D game library</b></p>
</a>
</td>
<td>
<a href="https://github.com/sillydan1/aaltitoad">
<p align="center">
<img src="https://github.com/sillydan1/aaltitoad/raw/v1.1.0/.github/resources/logo/toad_only.svg" alt="aaltitoad" width="100pt" />
</p>
<p align="center"><b>AALTITOAD - verifier and simulator for Tick Tock Automata</b></p>
</a>
</td>
<td>
<a href="https://github.com/ZIMO-Elektronik">
<p align="center">
<img src="https://avatars.githubusercontent.com/u/117935012?s=400&u=9a871a46dd13437f0adcae166e9efbe518ff0b99&v=4" alt="ZIMO-Elektronik" width="100pt" />
</p>
<p align="center"><b>ZIMO-Elektronik</b></p>
</a>
</td>
</tr>
</table>
## Snippets
@@ -334,7 +374,7 @@ CPMAddPackage(
NAME nlohmann_json
VERSION 3.9.1
GITHUB_REPOSITORY nlohmann/json
OPTIONS
OPTIONS
"JSON_BuildTests OFF"
)
```
@@ -346,9 +386,9 @@ CPMAddPackage(
# using `CPM_SOURCE_CACHE` is strongly recommended
CPMAddPackage(
NAME Boost
VERSION 1.77.0
VERSION 1.81.0
GITHUB_REPOSITORY "boostorg/boost"
GIT_TAG "boost-1.77.0"
GIT_TAG "boost-1.81.0"
)
```

View File

@@ -0,0 +1,69 @@
parse:
additional_commands:
cpmaddpackage:
pargs:
nargs: '*'
flags: []
spelling: CPMAddPackage
kwargs: &cpmaddpackagekwargs
NAME: 1
FORCE: 1
VERSION: 1
GIT_TAG: 1
DOWNLOAD_ONLY: 1
GITHUB_REPOSITORY: 1
GITLAB_REPOSITORY: 1
GIT_REPOSITORY: 1
SVN_REPOSITORY: 1
SVN_REVISION: 1
SOURCE_DIR: 1
DOWNLOAD_COMMAND: 1
FIND_PACKAGE_ARGUMENTS: 1
NO_CACHE: 1
GIT_SHALLOW: 1
URL: 1
URL_HASH: 1
URL_MD5: 1
DOWNLOAD_NAME: 1
DOWNLOAD_NO_EXTRACT: 1
HTTP_USERNAME: 1
HTTP_PASSWORD: 1
EXCLUDE_FROM_ALL: 1
SYSTEM: 1
SOURCE_SUBDIR: 1
OPTIONS: +
cpmfindpackage:
pargs:
nargs: '*'
flags: []
spelling: CPMFindPackage
kwargs: *cpmaddpackagekwargs
cpmdeclarepackage:
pargs:
nargs: '*'
flags: []
spelling: CPMDeclarePackage
kwargs: *cpmaddpackagekwargs
packageproject:
pargs:
nargs: '*'
flags: []
spelling: packageProject
kwargs:
NAME: 1
VERSION: 1
INCLUDE_DIR: 1
INCLUDE_DESTINATION: 1
BINARY_DIR: 1
COMPATIBILITY: 1
VERSION_HEADER: 1
DEPENDENCIES: +
cpmusepackagelock:
pargs: 1
spelling: CPMUsePackageLock
cpmregisterpackage:
pargs: 1
spelling: CPMRegisterPackage
cpmgetpackageversion:
pargs: 2
spelling: CPMGetPackageVersion

View File

@@ -5,7 +5,7 @@
# MIT License
# -----------
#[[
Copyright (c) 2019-2022 Lars Melchior and contributors
Copyright (c) 2019-2023 Lars Melchior and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -28,21 +28,18 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# the policy allows us to change options without caching
cmake_policy(SET CMP0077 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
# the policy allows us to change set(CACHE) without caching
if(POLICY CMP0126)
cmake_policy(SET CMP0126 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0126 NEW)
# Initialize logging prefix
if(NOT CPM_INDENT)
set(CPM_INDENT
"CPM:"
CACHE INTERNAL ""
)
endif()
# The policy uses the download time for timestamp, instead of the timestamp in the archive. This
# allows for proper rebuilds when a projects url changes
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
if(NOT COMMAND cpm_message)
function(cpm_message)
message(${ARGV})
endfunction()
endif()
set(CURRENT_CPM_VERSION 1.0.0-development-version)
@@ -76,7 +73,8 @@ See https://github.com/cpm-cmake/CPM.cmake for more information."
endif()
if(CURRENT_CPM_VERSION MATCHES "development-version")
message(WARNING "Your project is using an unstable development version of CPM.cmake. \
message(
WARNING "${CPM_INDENT} Your project is using an unstable development version of CPM.cmake. \
Please update to a recent release if possible. \
See https://github.com/cpm-cmake/CPM.cmake for details."
)
@@ -84,6 +82,26 @@ endif()
set_property(GLOBAL PROPERTY CPM_INITIALIZED true)
macro(cpm_set_policies)
# the policy allows us to change options without caching
cmake_policy(SET CMP0077 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
# the policy allows us to change set(CACHE) without caching
if(POLICY CMP0126)
cmake_policy(SET CMP0126 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0126 NEW)
endif()
# The policy uses the download time for timestamp, instead of the timestamp in the archive. This
# allows for proper rebuilds when a projects url changes
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
endif()
endmacro()
cpm_set_policies()
option(CPM_USE_LOCAL_PACKAGES "Always try to use `find_package` to get dependencies"
$ENV{CPM_USE_LOCAL_PACKAGES}
)
@@ -220,19 +238,14 @@ function(cpm_package_name_and_ver_from_url url outName outVer)
endif()
endfunction()
# Initialize logging prefix
if(NOT CPM_INDENT)
set(CPM_INDENT
"CPM:"
CACHE INTERNAL ""
)
endif()
function(cpm_find_package NAME VERSION)
string(REPLACE " " ";" EXTRA_ARGS "${ARGN}")
find_package(${NAME} ${VERSION} ${EXTRA_ARGS} QUIET)
if(${CPM_ARGS_NAME}_FOUND)
message(STATUS "${CPM_INDENT} using local package ${CPM_ARGS_NAME}@${VERSION}")
if(DEFINED ${CPM_ARGS_NAME}_VERSION)
set(VERSION ${${CPM_ARGS_NAME}_VERSION})
endif()
cpm_message(STATUS "${CPM_INDENT} Using local package ${CPM_ARGS_NAME}@${VERSION}")
CPMRegisterPackage(${CPM_ARGS_NAME} "${VERSION}")
set(CPM_PACKAGE_FOUND
YES
@@ -303,7 +316,7 @@ function(cpm_check_if_package_already_added CPM_ARGS_NAME CPM_ARGS_VERSION)
if("${CPM_PACKAGE_VERSION}" VERSION_LESS "${CPM_ARGS_VERSION}")
message(
WARNING
"${CPM_INDENT} requires a newer version of ${CPM_ARGS_NAME} (${CPM_ARGS_VERSION}) than currently included (${CPM_PACKAGE_VERSION})."
"${CPM_INDENT} Requires a newer version of ${CPM_ARGS_NAME} (${CPM_ARGS_VERSION}) than currently included (${CPM_PACKAGE_VERSION})."
)
endif()
cpm_get_fetch_properties(${CPM_ARGS_NAME})
@@ -360,7 +373,7 @@ function(cpm_parse_add_package_single_arg arg outArgs)
set(packageType "git")
else()
# Give up
message(FATAL_ERROR "CPM: Can't determine package type of '${arg}'")
message(FATAL_ERROR "${CPM_INDENT} Can't determine package type of '${arg}'")
endif()
endif()
@@ -380,7 +393,7 @@ function(cpm_parse_add_package_single_arg arg outArgs)
else()
# We should never get here. This is an assertion and hitting it means there's a bug in the code
# above. A packageType was set, but not handled by this if-else.
message(FATAL_ERROR "CPM: Unsupported package type '${packageType}' of '${arg}'")
message(FATAL_ERROR "${CPM_INDENT} Unsupported package type '${packageType}' of '${arg}'")
endif()
set(${outArgs}
@@ -413,7 +426,7 @@ function(cpm_check_git_working_dir_is_clean repoPath gitTag isClean)
)
if(resultGitStatus)
# not supposed to happen, assume clean anyway
message(WARNING "Calling git status on folder ${repoPath} failed")
message(WARNING "${CPM_INDENT} Calling git status on folder ${repoPath} failed")
set(${isClean}
TRUE
PARENT_SCOPE
@@ -458,7 +471,7 @@ endfunction()
function(cpm_override_fetchcontent contentName)
cmake_parse_arguments(PARSE_ARGV 1 arg "" "SOURCE_DIR;BINARY_DIR" "")
if(NOT "${arg_UNPARSED_ARGUMENTS}" STREQUAL "")
message(FATAL_ERROR "Unsupported arguments: ${arg_UNPARSED_ARGUMENTS}")
message(FATAL_ERROR "${CPM_INDENT} Unsupported arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()
string(TOLOWER ${contentName} contentNameLower)
@@ -494,13 +507,14 @@ endfunction()
# Download and add a package from source
function(CPMAddPackage)
cpm_set_policies()
list(LENGTH ARGN argnLength)
if(argnLength EQUAL 1)
cpm_parse_add_package_single_arg("${ARGN}" ARGN)
# The shorthand syntax implies EXCLUDE_FROM_ALL
set(ARGN "${ARGN};EXCLUDE_FROM_ALL;YES")
# The shorthand syntax implies EXCLUDE_FROM_ALL and SYSTEM
set(ARGN "${ARGN};EXCLUDE_FROM_ALL;YES;SYSTEM;YES;")
endif()
set(oneValueArgs
@@ -517,6 +531,7 @@ function(CPMAddPackage)
DOWNLOAD_COMMAND
FIND_PACKAGE_ARGUMENTS
NO_CACHE
SYSTEM
GIT_SHALLOW
EXCLUDE_FROM_ALL
SOURCE_SUBDIR
@@ -593,7 +608,7 @@ function(CPMAddPackage)
if(NOT DEFINED CPM_ARGS_NAME)
message(
FATAL_ERROR
"CPM: 'NAME' was not provided and couldn't be automatically inferred for package added with arguments: '${ARGN}'"
"${CPM_INDENT} 'NAME' was not provided and couldn't be automatically inferred for package added with arguments: '${ARGN}'"
)
endif()
@@ -612,6 +627,7 @@ function(CPMAddPackage)
NAME "${CPM_ARGS_NAME}"
SOURCE_DIR "${PACKAGE_SOURCE}"
EXCLUDE_FROM_ALL "${CPM_ARGS_EXCLUDE_FROM_ALL}"
SYSTEM "${CPM_ARGS_SYSTEM}"
OPTIONS "${CPM_ARGS_OPTIONS}"
SOURCE_SUBDIR "${CPM_ARGS_SOURCE_SUBDIR}"
DOWNLOAD_ONLY "${DOWNLOAD_ONLY}"
@@ -632,19 +648,21 @@ function(CPMAddPackage)
return()
endif()
if(CPM_USE_LOCAL_PACKAGES OR CPM_LOCAL_PACKAGES_ONLY)
cpm_find_package(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}" ${CPM_ARGS_FIND_PACKAGE_ARGUMENTS})
if(NOT CPM_ARGS_FORCE)
if(CPM_USE_LOCAL_PACKAGES OR CPM_LOCAL_PACKAGES_ONLY)
cpm_find_package(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}" ${CPM_ARGS_FIND_PACKAGE_ARGUMENTS})
if(CPM_PACKAGE_FOUND)
cpm_export_variables(${CPM_ARGS_NAME})
return()
endif()
if(CPM_PACKAGE_FOUND)
cpm_export_variables(${CPM_ARGS_NAME})
return()
endif()
if(CPM_LOCAL_PACKAGES_ONLY)
message(
SEND_ERROR
"CPM: ${CPM_ARGS_NAME} not found via find_package(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION})"
)
if(CPM_LOCAL_PACKAGES_ONLY)
message(
SEND_ERROR
"${CPM_INDENT} ${CPM_ARGS_NAME} not found via find_package(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION})"
)
endif()
endif()
endif()
@@ -698,25 +716,40 @@ function(CPMAddPackage)
# relative paths.
get_filename_component(download_directory ${download_directory} ABSOLUTE)
list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS SOURCE_DIR ${download_directory})
if(CPM_SOURCE_CACHE)
file(LOCK ${download_directory}/../cmake.lock)
endif()
if(EXISTS ${download_directory})
if(CPM_SOURCE_CACHE)
file(LOCK ${download_directory}/../cmake.lock RELEASE)
endif()
cpm_store_fetch_properties(
${CPM_ARGS_NAME} "${download_directory}"
"${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-build"
)
cpm_get_fetch_properties("${CPM_ARGS_NAME}")
if(DEFINED CPM_ARGS_GIT_TAG)
if(DEFINED CPM_ARGS_GIT_TAG AND NOT (PATCH_COMMAND IN_LIST CPM_ARGS_UNPARSED_ARGUMENTS))
# warn if cache has been changed since checkout
cpm_check_git_working_dir_is_clean(${download_directory} ${CPM_ARGS_GIT_TAG} IS_CLEAN)
if(NOT ${IS_CLEAN})
message(WARNING "Cache for ${CPM_ARGS_NAME} (${download_directory}) is dirty")
message(
WARNING "${CPM_INDENT} Cache for ${CPM_ARGS_NAME} (${download_directory}) is dirty"
)
endif()
endif()
cpm_add_subdirectory(
"${CPM_ARGS_NAME}" "${DOWNLOAD_ONLY}"
"${${CPM_ARGS_NAME}_SOURCE_DIR}/${CPM_ARGS_SOURCE_SUBDIR}" "${${CPM_ARGS_NAME}_BINARY_DIR}"
"${CPM_ARGS_EXCLUDE_FROM_ALL}" "${CPM_ARGS_OPTIONS}"
"${CPM_ARGS_NAME}"
"${DOWNLOAD_ONLY}"
"${${CPM_ARGS_NAME}_SOURCE_DIR}/${CPM_ARGS_SOURCE_SUBDIR}"
"${${CPM_ARGS_NAME}_BINARY_DIR}"
"${CPM_ARGS_EXCLUDE_FROM_ALL}"
"${CPM_ARGS_SYSTEM}"
"${CPM_ARGS_OPTIONS}"
)
set(PACKAGE_INFO "${PACKAGE_INFO} at ${download_directory}")
@@ -755,8 +788,8 @@ function(CPMAddPackage)
endif()
endif()
message(
STATUS "${CPM_INDENT} adding package ${CPM_ARGS_NAME}@${CPM_ARGS_VERSION} (${PACKAGE_INFO})"
cpm_message(
STATUS "${CPM_INDENT} Adding package ${CPM_ARGS_NAME}@${CPM_ARGS_VERSION} (${PACKAGE_INFO})"
)
if(NOT CPM_SKIP_FETCH)
@@ -764,11 +797,18 @@ function(CPMAddPackage)
"${CPM_ARGS_NAME}" "${CPM_ARGS_VERSION}" "${PACKAGE_INFO}" "${CPM_ARGS_UNPARSED_ARGUMENTS}"
)
cpm_fetch_package("${CPM_ARGS_NAME}" populated)
if(CPM_SOURCE_CACHE AND download_directory)
file(LOCK ${download_directory}/../cmake.lock RELEASE)
endif()
if(${populated})
cpm_add_subdirectory(
"${CPM_ARGS_NAME}" "${DOWNLOAD_ONLY}"
"${${CPM_ARGS_NAME}_SOURCE_DIR}/${CPM_ARGS_SOURCE_SUBDIR}" "${${CPM_ARGS_NAME}_BINARY_DIR}"
"${CPM_ARGS_EXCLUDE_FROM_ALL}" "${CPM_ARGS_OPTIONS}"
"${CPM_ARGS_NAME}"
"${DOWNLOAD_ONLY}"
"${${CPM_ARGS_NAME}_SOURCE_DIR}/${CPM_ARGS_SOURCE_SUBDIR}"
"${${CPM_ARGS_NAME}_BINARY_DIR}"
"${CPM_ARGS_EXCLUDE_FROM_ALL}"
"${CPM_ARGS_SYSTEM}"
"${CPM_ARGS_OPTIONS}"
)
endif()
cpm_get_fetch_properties("${CPM_ARGS_NAME}")
@@ -783,7 +823,7 @@ macro(CPMGetPackage Name)
if(DEFINED "CPM_DECLARATION_${Name}")
CPMAddPackage(NAME ${Name})
else()
message(SEND_ERROR "Cannot retrieve package ${Name}: no declaration available")
message(SEND_ERROR "${CPM_INDENT} Cannot retrieve package ${Name}: no declaration available")
endif()
endmacro()
@@ -801,6 +841,10 @@ macro(cpm_export_variables name)
"${${name}_ADDED}"
PARENT_SCOPE
)
set(CPM_LAST_PACKAGE_NAME
"${name}"
PARENT_SCOPE
)
endmacro()
# declares a package, so that any call to CPMAddPackage for the package name will use these
@@ -869,7 +913,7 @@ endfunction()
# declares a package in FetchContent_Declare
function(cpm_declare_fetch PACKAGE VERSION INFO)
if(${CPM_DRY_RUN})
message(STATUS "${CPM_INDENT} package not declared (dry run)")
cpm_message(STATUS "${CPM_INDENT} Package not declared (dry run)")
return()
endif()
@@ -915,13 +959,18 @@ function(
SOURCE_DIR
BINARY_DIR
EXCLUDE
SYSTEM
OPTIONS
)
if(NOT DOWNLOAD_ONLY AND EXISTS ${SOURCE_DIR}/CMakeLists.txt)
set(addSubdirectoryExtraArgs "")
if(EXCLUDE)
set(addSubdirectoryExtraArgs EXCLUDE_FROM_ALL)
else()
set(addSubdirectoryExtraArgs "")
list(APPEND addSubdirectoryExtraArgs EXCLUDE_FROM_ALL)
endif()
if("${SYSTEM}" AND "${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.25")
# https://cmake.org/cmake/help/latest/prop_dir/SYSTEM.html#prop_dir:SYSTEM
list(APPEND addSubdirectoryExtraArgs SYSTEM)
endif()
if(OPTIONS)
foreach(OPTION ${OPTIONS})
@@ -944,7 +993,7 @@ function(cpm_fetch_package PACKAGE populated)
PARENT_SCOPE
)
if(${CPM_DRY_RUN})
message(STATUS "${CPM_INDENT} package ${PACKAGE} not fetched (dry run)")
cpm_message(STATUS "${CPM_INDENT} Package ${PACKAGE} not fetched (dry run)")
return()
endif()
@@ -1052,6 +1101,7 @@ function(cpm_prettify_package_arguments OUT_VAR IS_IN_COMMENT)
DOWNLOAD_COMMAND
FIND_PACKAGE_ARGUMENTS
NO_CACHE
SYSTEM
GIT_SHALLOW
)
set(multiValueArgs OPTIONS)

View File

@@ -1,8 +1,11 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
set(CPM_DOWNLOAD_VERSION 1.0.0-development-version)
set(CPM_HASH_SUM "CPM_HASH_SUM_PLACEHOLDER")
if(CPM_SOURCE_CACHE)
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
@@ -10,12 +13,24 @@ else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
message(STATUS "Using CPM at ${CPM_DOWNLOAD_LOCATION}")
file(
DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
STATUS CPM_DOWNLOAD_STATUS
EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)
list(GET CPM_DOWNLOAD_STATUS 0 CPM_DOWNLOAD_STATUS_CODE)
if(NOT ${CPM_DOWNLOAD_STATUS_CODE} EQUAL 0)
# give a fatal error when download fails
list(GET CPM_DOWNLOAD_STATUS 1 CPM_DOWNLOAD_ERROR_MESSAGE)
message(FATAL_ERROR "Error occurred during download of CPM: ${CPM_DOWNLOAD_ERROR_MESSAGE}")
endif()
include(${CPM_DOWNLOAD_LOCATION})

View File

@@ -11,7 +11,7 @@ CPMAddPackage("gh:cpm-cmake/testpack-fibonacci@2.0")
CPMAddPackage(
NAME benchmark
GITHUB_REPOSITORY google/benchmark
VERSION 1.5.2
VERSION 1.7.1
OPTIONS "BENCHMARK_ENABLE_TESTING Off"
)

View File

@@ -13,9 +13,9 @@ include(../../cmake/CPM.cmake)
CPMAddPackage(
NAME Boost
VERSION 1.77.0
VERSION 1.81.0
GITHUB_REPOSITORY "boostorg/boost"
GIT_TAG "boost-1.77.0"
GIT_TAG "boost-1.81.0"
)
target_link_libraries(CPMExampleBoost PRIVATE Boost::asio)

View File

@@ -7,12 +7,12 @@ project(CPMExampleCatch2)
include(../../cmake/CPM.cmake)
CPMAddPackage("gh:cpm-cmake/testpack-fibonacci@2.0")
CPMAddPackage("gh:catchorg/Catch2@2.13.4")
CPMAddPackage("gh:catchorg/Catch2@3.2.1")
# ---- Create binary ----
add_executable(CPMExampleCatch2 main.cpp)
target_link_libraries(CPMExampleCatch2 fibonacci Catch2)
target_link_libraries(CPMExampleCatch2 fibonacci Catch2::Catch2WithMain)
target_compile_features(CPMExampleCatch2 PRIVATE cxx_std_17)
# ---- Enable testing ----

View File

@@ -1,8 +1,6 @@
#define CATCH_CONFIG_MAIN
#include <fibonacci.h>
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("fibonacci") {
REQUIRE(fibonacci(0) == 0);

View File

@@ -7,7 +7,7 @@ project(CPMExampleDoctest)
include(../../cmake/CPM.cmake)
CPMAddPackage("gh:cpm-cmake/testpack-fibonacci@2.0")
CPMAddPackage("gh:onqtam/doctest#2.4.5")
CPMAddPackage("gh:onqtam/doctest@2.4.9")
# ---- Create binary ----

View File

@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(CPMJSONExample)
project(CPMFmtExample)
# ---- Dependencies ----

View File

@@ -11,8 +11,8 @@ CPMAddPackage("gh:cpm-cmake/testpack-fibonacci@2.0")
CPMAddPackage(
NAME googletest
GITHUB_REPOSITORY google/googletest
GIT_TAG release-1.10.0
VERSION 1.10.0
GIT_TAG release-1.12.1
VERSION 1.12.1
OPTIONS "INSTALL_GTEST OFF" "gtest_force_shared_crt"
)

View File

@@ -15,29 +15,16 @@ CPMAddPackage(
if(lua_ADDED)
# lua has no CMakeLists, so we create our own target
file(GLOB lua_sources ${lua_SOURCE_DIR}/*.c)
list(REMOVE_ITEM lua_sources "${lua_SOURCE_DIR}/lua.c" "${lua_SOURCE_DIR}/luac.c")
add_library(lua STATIC ${lua_sources})
target_include_directories(lua SYSTEM PUBLIC $<BUILD_INTERFACE:${lua_SOURCE_DIR}>)
endif()
CPMAddPackage(
NAME sol2
URL https://github.com/ThePhD/sol2/archive/v3.0.2.zip
VERSION 3.0.2
DOWNLOAD_ONLY YES
)
if(sol2_ADDED)
add_library(sol2 INTERFACE IMPORTED)
target_include_directories(sol2 SYSTEM INTERFACE ${sol2_SOURCE_DIR}/include)
target_link_libraries(sol2 INTERFACE lua)
endif()
CPMAddPackage("gh:ThePhD/sol2@3.3.0")
# ---- Executable ----
add_executable(CPMSol2Example main.cpp)
target_compile_features(CPMSol2Example PRIVATE cxx_std_17)
target_link_libraries(CPMSol2Example sol2)
target_link_libraries(CPMSol2Example sol2 lua)

View File

@@ -8,6 +8,20 @@ include(../../cmake/CPM.cmake)
CPMAddPackage("gh:gabime/spdlog@1.8.2")
# spdlog uses fmt and bundles that dependency. If you want to use fmt in your project as well, you
# can let spdlog re-use fmt from CPM.cmake like this:
#
# cmake-format: off
#
# CPMAddPackage("gh:fmtlib/fmt#7.1.3")
# CPMAddPackage(
# GITHUB_REPOSITORY gabime/spdlog
# VERSION 1.8.2
# OPTIONS "SPDLOG_FMT_EXTERNAL 1"
# )
#
# cmake-format: on
# ---- Executable ----
add_executable(CPMSpdlogExample main.cpp)

View File

@@ -14,3 +14,5 @@ foreach(test ${tests})
endforeach()
add_custom_target(test-verbose COMMAND ${CMAKE_CTEST_COMMAND} -C Debug --verbose)
add_subdirectory(style)

View File

@@ -157,6 +157,11 @@ class IntegrationTest < Test::Unit::TestCase
assert_block(msg) { res.status.success? }
end
def assert_failure(res)
msg = build_message(nil, "command status was expected to be a failure, but succeeded")
assert_block(msg) { !res.status.success? }
end
def assert_same_path(a, b)
msg = build_message(nil, "<?> expected but was\n<?>", a, b)
assert_block(msg) { File.identical? a, b }
@@ -180,19 +185,20 @@ class IntegrationTest < Test::Unit::TestCase
@@test_dir
end
def make_project(template_dir = nil)
def make_project(name: nil, from_template: nil)
test_name = local_name
test_name = test_name[5..] if test_name.start_with?('test_')
base = File.join(cur_test_dir, test_name)
base += "-#{name}" if name
src_dir = base + '-src'
FileUtils.mkdir_p src_dir
if template_dir
template_dir = File.join(TestLib::TEMPLATES_DIR, template_dir)
raise "#{template_dir} is not a directory" if !File.directory?(template_dir)
FileUtils.copy_entry template_dir, src_dir
if from_template
from_template = File.join(TestLib::TEMPLATES_DIR, from_template)
raise "#{from_template} is not a directory" if !File.directory?(from_template)
FileUtils.copy_entry from_template, src_dir
end
Project.new src_dir, base + '-bin'

View File

@@ -1,4 +1,4 @@
# Integration Test Framework Refernce
# Integration Test Framework Reference
## `TestLib`
@@ -60,6 +60,7 @@ The class which must be a parent of all integration test case classes. It itself
### Utils
* `cur_test_dir` - the directory of the current test case. A subdirectory of `TestLib::TMP_DIR`
* `make_project(template_dir = nil)` - create a project from a test method. Will create a the project's source and binary directories as subdirectories of `cur_test_dir`.
* Optionally work with a template directory, in which case it will copy the contents of the template directory (one from `templates`) in the project's source directory.
* `make_project(name: nil, from_template: nil)` - create a project from a test method. Will create the project's source and binary directories as subdirectories of `cur_test_dir`.
* Optionally provide a name which will be concatenated to the project directory. This allows creating multiple projects in a test
* Optionally work with a template, in which case it will copy the contents of the template directory (one from `templates`) in the project's source directory.

View File

@@ -5,7 +5,7 @@ require_relative './lib'
class Basics < IntegrationTest
# Test cpm caches with no cpm-related env vars
def test_cpm_default
prj = make_project 'no-deps'
prj = make_project from_template: 'no-deps'
prj.create_lists_from_default_template
assert_success prj.configure
@@ -38,7 +38,7 @@ class Basics < IntegrationTest
def test_env_cpm_source_cache
ENV['CPM_SOURCE_CACHE'] = cur_test_dir
prj = make_project 'no-deps'
prj = make_project from_template: 'no-deps'
prj.create_lists_from_default_template
assert_success prj.configure

View File

@@ -9,8 +9,8 @@ class FetchContentCompatibility < IntegrationTest
end
def test_add_dependency_cpm_and_fetchcontent
prj = make_project 'using-adder'
prj = make_project from_template: 'using-adder'
prj.create_lists_from_default_template package: <<~PACK
CPMAddPackage(
NAME testpack-adder

View File

@@ -0,0 +1,21 @@
require_relative './lib'
class Parallelism < IntegrationTest
def setup
@cache_dir = File.join(cur_test_dir, 'cpmcache')
ENV['CPM_SOURCE_CACHE'] = @cache_dir
end
def test_populate_cache_in_parallel
4.times.map { |i|
prj = make_project name: i.to_s, from_template: 'using-fibadder'
prj.create_lists_from_default_template package: 'CPMAddPackage("gh:cpm-cmake/testpack-fibadder@1.0.0")'
prj
}.map { |prj|
Thread.new do
assert_success prj.configure
assert_success prj.build
end
}.map(&:join)
end
end

View File

@@ -2,8 +2,8 @@ require_relative './lib'
class RemoveSourceDir < IntegrationTest
def test_remove_source_dir
prj = make_project 'using-adder'
prj = make_project from_template: 'using-adder'
prj.create_lists_from_default_template package: <<~PACK
CPMAddPackage(
NAME testpack-adder

View File

@@ -4,7 +4,7 @@ class Simple < IntegrationTest
ADDER_PACKAGE_NAME = 'testpack-adder'
def test_update_single_package
prj = make_project 'using-adder'
prj = make_project from_template: 'using-adder'
adder_cache0 = nil
adder_ver_file = nil

View File

@@ -9,7 +9,7 @@ class SourceCache < IntegrationTest
end
def test_add_remove_dependency
prj = make_project 'using-fibadder'
prj = make_project from_template: 'using-fibadder'
###################################
# create
@@ -45,7 +45,7 @@ class SourceCache < IntegrationTest
end
def test_second_project
prj = make_project 'using-fibadder'
prj = make_project from_template: 'using-fibadder'
prj.create_lists_from_default_template package: 'CPMAddPackage("gh:cpm-cmake/testpack-fibadder@1.1.0")'
assert_success prj.configure

View File

@@ -0,0 +1,57 @@
require_relative './lib'
class SystemWarnings < IntegrationTest
def setup
# system is only supported for CMake >= 3.25
@system_supported = (!ENV['CMAKE_VERSION']) || (Gem::Version.new(ENV['CMAKE_VERSION']) >= Gem::Version.new('3.25'))
end
def test_dependency_added_using_system
for use_system in [true, false] do
prj = make_project name: use_system ? "system" : "no_system", from_template: 'using-adder'
prj.create_lists_from_default_template package: <<~PACK
# this commit has a warning in a public header
CPMAddPackage(
NAME Adder
GITHUB_REPOSITORY cpm-cmake/testpack-adder
GIT_TAG v1.0.1-warnings
SYSTEM #{use_system ? "YES" : "NO"}
)
# all packages using `adder` will error on warnings
target_compile_options(adder INTERFACE
$<$<CXX_COMPILER_ID:MSVC>:/Wall /WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Werror>
)
PACK
assert_success prj.configure
if use_system and @system_supported
assert_success prj.build
else
assert_failure prj.build
end
end
end
def test_dependency_added_implicitly_using_system
prj = make_project from_template: 'using-adder'
prj.create_lists_from_default_template package: <<~PACK
# this commit has a warning in a public header
CPMAddPackage("gh:cpm-cmake/testpack-adder@1.0.1-warnings")
# all packages using `adder` will error on warnings
target_compile_options(adder INTERFACE
$<$<CXX_COMPILER_ID:MSVC>:/Wall /WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Werror>
)
PACK
assert_success prj.configure
if @system_supported
assert_success prj.build
else
assert_failure prj.build
end
end
end

View File

@@ -26,6 +26,17 @@ function(reset_test)
update_cmake_lists()
endfunction()
function(assert_cache_directory_count directory count)
set(version_count 0)
file(GLOB potential_versions ${directory})
foreach(entry ${potential_versions})
if(IS_DIRECTORY ${entry})
math(EXPR version_count "${version_count} + 1")
endif()
endforeach()
assert_equal("${version_count}" "${count}")
endfunction()
set(FIBONACCI_VERSION 1.0)
# Read CPM_SOURCE_CACHE from arguments
@@ -40,13 +51,7 @@ execute_process(
assert_equal(${ret} "0")
assert_exists("${CPM_SOURCE_CACHE_DIR}/fibonacci")
file(GLOB FIBONACCI_VERSIONs "${CPM_SOURCE_CACHE_DIR}/fibonacci/*")
list(LENGTH FIBONACCI_VERSIONs FIBONACCI_VERSION_count)
assert_equal(${FIBONACCI_VERSION_count} "1")
file(GLOB fibonacci_versions "${CPM_SOURCE_CACHE_DIR}/fibonacci/*")
list(LENGTH fibonacci_versions fibonacci_version_count)
assert_equal(${fibonacci_version_count} "1")
assert_cache_directory_count("${CPM_SOURCE_CACHE_DIR}/fibonacci/*" 1)
# Update dependency and keep CPM_SOURCE_CACHE
@@ -54,12 +59,9 @@ set(FIBONACCI_VERSION 2.0)
update_cmake_lists()
execute_process(COMMAND ${CMAKE_COMMAND} ${TEST_BUILD_DIR} RESULT_VARIABLE ret)
assert_equal(${ret} "0")
file(GLOB FIBONACCI_VERSIONs "${CPM_SOURCE_CACHE_DIR}/fibonacci/*")
list(LENGTH FIBONACCI_VERSIONs FIBONACCI_VERSION_count)
assert_equal(${FIBONACCI_VERSION_count} "2")
assert_cache_directory_count("${CPM_SOURCE_CACHE_DIR}/fibonacci/*" 2)
# Clear cache and update

View File

@@ -6,6 +6,7 @@ include(${CPM_PATH}/testing.cmake)
set(CPM_DRY_RUN ON)
CPMAddPackage(NAME A GIT_TAG 1.2.3)
assert_equal("${CPM_LAST_PACKAGE_NAME}" "A")
CPMAddPackage(NAME A VERSION 1.2.3)
@@ -17,6 +18,8 @@ CPMAddPackage(NAME B VERSION 2.4.1)
CPMAddPackage(NAME B GIT_TAG v2.3.1)
CPMGetPackageVersion(B VERSION)
assert_equal("${CPM_LAST_PACKAGE_NAME}" "B")
assert_equal(${VERSION} "2.4.1")
CPMAddPackage(
@@ -24,6 +27,10 @@ CPMAddPackage(
GIT_TAG v3.1.2-a
VERSION 3.1.2
)
assert_equal("${CPM_LAST_PACKAGE_NAME}" "C")
CPMGetPackageVersion(C VERSION)
assert_equal(${VERSION} "3.1.2")
CPMAddPackage("gh:dry-run/D")
assert_equal("${CPM_LAST_PACKAGE_NAME}" "D")

View File

@@ -32,3 +32,4 @@ include(@CPM_PATH@/testing.cmake)
ASSERT_TRUTHY(@TEST_DEPENDENCY_NAME@_ADDED)
ASSERT_DEFINED(@TEST_DEPENDENCY_NAME@_SOURCE_DIR)
ASSERT_DEFINED(@TEST_DEPENDENCY_NAME@_BINARY_DIR)
ASSERT_EQUAL("${CPM_LAST_PACKAGE_NAME}" "@TEST_DEPENDENCY_NAME@")

View File

@@ -25,3 +25,5 @@ include(@CPM_PATH@/testing.cmake)
ASSERT_TRUTHY(Dependency_ADDED)
ASSERT_DEFINED(Dependency_SOURCE_DIR)
ASSERT_DEFINED(Dependency_BINARY_DIR)
ASSERT_EQUAL("${CPM_LAST_PACKAGE_NAME}" "Dependency")

View File

@@ -30,3 +30,4 @@ include(@CPM_PATH@/testing.cmake)
ASSERT_TRUTHY(fibonacci_ADDED)
ASSERT_DEFINED(fibonacci_SOURCE_DIR)
ASSERT_DEFINED(fibonacci_BINARY_DIR)
ASSERT_EQUAL("${CPM_LAST_PACKAGE_NAME}" "fibonacci")