mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-18 07:07:47 -05:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12daf366c7 | ||
|
|
0938e8fde7 | ||
|
|
09b056ae20 | ||
|
|
d34d2a8730 | ||
|
|
6fc2170d5d | ||
|
|
1184a6e6e7 | ||
|
|
c53417bd65 | ||
|
|
50e9b9edb8 | ||
|
|
03705fcce1 | ||
|
|
f00ccd89c4 | ||
|
|
1f4909ca44 | ||
|
|
4d33686a50 | ||
|
|
984251f46c | ||
|
|
63d0de7114 | ||
|
|
65c760a840 | ||
|
|
b5e60e72e8 | ||
|
|
10bf25a811 | ||
|
|
18b6cbf233 | ||
|
|
698741ff7c | ||
|
|
1f09de0d9b | ||
|
|
b224ce280d | ||
|
|
49af958fb4 | ||
|
|
90c763532a | ||
|
|
4605d32f0e | ||
|
|
ede60451a9 | ||
|
|
5961f9f9fb | ||
|
|
69e9ff3766 | ||
|
|
3fee69c894 | ||
|
|
a575ab57b7 | ||
|
|
ca421f0e0c |
@@ -34,6 +34,7 @@ parse:
|
||||
HTTP_USERNAME: 1
|
||||
HTTP_PASSWORD: 1
|
||||
EXCLUDE_FROM_ALL: 1
|
||||
SYSTEM: 1
|
||||
SOURCE_SUBDIR: 1
|
||||
OPTIONS: +
|
||||
cpmfindpackage:
|
||||
|
||||
@@ -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
|
||||
2
.github/workflows/publish.yaml
vendored
2
.github/workflows/publish.yaml
vendored
@@ -10,7 +10,7 @@ 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: |
|
||||
|
||||
@@ -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
|
||||
@@ -20,7 +20,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: clone
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup cmake
|
||||
uses: jwlawson/actions-setup-cmake@v1.13
|
||||
with:
|
||||
cmake-version: '3.25.x'
|
||||
|
||||
- name: unit tests
|
||||
run: |
|
||||
177
CONTRIBUTING.md
Normal file
177
CONTRIBUTING.md
Normal 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)!
|
||||
@@ -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)
|
||||
|
||||
115
README.md
115
README.md
@@ -21,6 +21,30 @@ 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.
|
||||
|
||||
## 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 +68,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
|
||||
@@ -73,32 +101,12 @@ 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.
|
||||
@@ -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.
|
||||
@@ -227,6 +238,22 @@ cmake --build build --target cpm-update-package-lock
|
||||
|
||||
See the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/Package-lock) for more info.
|
||||
|
||||
## Private repositories and CI
|
||||
|
||||
When using CPM.cmake with private repositories, there may be a need to provide an [access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) to be able to clone other projects. Instead of providing the token in CMake, we recommend to provide the regular URL and use [git-config](https://git-scm.com/docs/git-config) to rewrite the URLs to include the token.
|
||||
|
||||
As an example, you could include one of the following in your CI script.
|
||||
|
||||
```bash
|
||||
# Github
|
||||
git config --global url."https://${USERNAME}:${TOKEN}@github.com".insteadOf "https://github.com"
|
||||
```
|
||||
|
||||
```bash
|
||||
# GitLab
|
||||
git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com".insteadOf "https://gitlab.com"
|
||||
```
|
||||
|
||||
## Built with CPM.cmake
|
||||
|
||||
Some amazing projects that are built using the CPM.cmake package manager.
|
||||
@@ -259,6 +286,44 @@ If you know others, feel free to add them here through a PR.
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://git.io/liblava">
|
||||
<p align="center">
|
||||
<img src="https://github.com/liblava.png" alt="liblava" width="100pt" />
|
||||
</p>
|
||||
<p align="center"><b>liblava - Modern Vulkan library</b></p>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="https://github.com/variar/klogg">
|
||||
<p align="center">
|
||||
<img src="https://github.com/variar/klogg/blob/master/src/app/images/hicolor/scalable/klogg.svg" alt="klogg" width="100pt" />
|
||||
</p>
|
||||
<p align="center"><b>klogg - fast advanced log explorer</b></p>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="https://github.com/MethanePowered/MethaneKit">
|
||||
<p align="center">
|
||||
<img src="https://github.com/MethanePowered/MethaneKit/raw/master/Docs/Images/Logo/MethaneLogoSmall.png" alt="MethaneKit" width="100pt" />
|
||||
</p>
|
||||
<p align="center"><b>Methane Kit - modern 3D graphics rendering framework</b></p>
|
||||
</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/>
|
||||
<td/>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Snippets
|
||||
@@ -275,7 +340,7 @@ CPMAddPackage("gh:catchorg/Catch2@2.5.0")
|
||||
### [Range-v3](https://github.com/ericniebler/range-v3)
|
||||
|
||||
```Cmake
|
||||
CPMAddPackage("gh:ericniebler/range-v3#0.11.0")
|
||||
CPMAddPackage("gh:ericniebler/range-v3#0.12.0")
|
||||
```
|
||||
|
||||
### [Yaml-cpp](https://github.com/jbeder/yaml-cpp)
|
||||
@@ -292,7 +357,7 @@ CPMAddPackage(
|
||||
NAME nlohmann_json
|
||||
VERSION 3.9.1
|
||||
GITHUB_REPOSITORY nlohmann/json
|
||||
OPTIONS
|
||||
OPTIONS
|
||||
"JSON_BuildTests OFF"
|
||||
)
|
||||
```
|
||||
@@ -304,9 +369,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"
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
213
cmake/CPM.cmake
213
cmake/CPM.cmake
@@ -28,10 +28,25 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||
|
||||
# Initialize logging prefix
|
||||
if(NOT CPM_INDENT)
|
||||
set(CPM_INDENT
|
||||
"CPM:"
|
||||
CACHE INTERNAL ""
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT COMMAND cpm_message)
|
||||
function(cpm_message)
|
||||
message(${ARGV})
|
||||
endfunction()
|
||||
endif()
|
||||
|
||||
set(CURRENT_CPM_VERSION 1.0.0-development-version)
|
||||
|
||||
get_filename_component(CPM_CURRENT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
|
||||
if(CPM_DIRECTORY)
|
||||
if(NOT CPM_DIRECTORY STREQUAL CMAKE_CURRENT_LIST_DIR)
|
||||
if(NOT CPM_DIRECTORY STREQUAL CPM_CURRENT_DIRECTORY)
|
||||
if(CPM_VERSION VERSION_LESS CURRENT_CPM_VERSION)
|
||||
message(
|
||||
AUTHOR_WARNING
|
||||
@@ -58,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."
|
||||
)
|
||||
@@ -66,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}
|
||||
)
|
||||
@@ -93,7 +129,7 @@ set(CPM_VERSION
|
||||
CACHE INTERNAL ""
|
||||
)
|
||||
set(CPM_DIRECTORY
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
${CPM_CURRENT_DIRECTORY}
|
||||
CACHE INTERNAL ""
|
||||
)
|
||||
set(CPM_FILE
|
||||
@@ -202,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
|
||||
@@ -285,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})
|
||||
@@ -342,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()
|
||||
|
||||
@@ -362,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}
|
||||
@@ -395,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
|
||||
@@ -433,14 +464,57 @@ function(cpm_check_git_working_dir_is_clean repoPath gitTag isClean)
|
||||
|
||||
endfunction()
|
||||
|
||||
# method to overwrite internal FetchContent properties, to allow using CPM.cmake to overload
|
||||
# FetchContent calls. As these are internal cmake properties, this method should be used carefully
|
||||
# and may need modification in future CMake versions. Source:
|
||||
# https://github.com/Kitware/CMake/blob/dc3d0b5a0a7d26d43d6cfeb511e224533b5d188f/Modules/FetchContent.cmake#L1152
|
||||
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 "${CPM_INDENT} Unsupported arguments: ${arg_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
|
||||
string(TOLOWER ${contentName} contentNameLower)
|
||||
set(prefix "_FetchContent_${contentNameLower}")
|
||||
|
||||
set(propertyName "${prefix}_sourceDir")
|
||||
define_property(
|
||||
GLOBAL
|
||||
PROPERTY ${propertyName}
|
||||
BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
|
||||
FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
|
||||
)
|
||||
set_property(GLOBAL PROPERTY ${propertyName} "${arg_SOURCE_DIR}")
|
||||
|
||||
set(propertyName "${prefix}_binaryDir")
|
||||
define_property(
|
||||
GLOBAL
|
||||
PROPERTY ${propertyName}
|
||||
BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
|
||||
FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
|
||||
)
|
||||
set_property(GLOBAL PROPERTY ${propertyName} "${arg_BINARY_DIR}")
|
||||
|
||||
set(propertyName "${prefix}_populated")
|
||||
define_property(
|
||||
GLOBAL
|
||||
PROPERTY ${propertyName}
|
||||
BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
|
||||
FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
|
||||
)
|
||||
set_property(GLOBAL PROPERTY ${propertyName} TRUE)
|
||||
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
|
||||
@@ -457,6 +531,7 @@ function(CPMAddPackage)
|
||||
DOWNLOAD_COMMAND
|
||||
FIND_PACKAGE_ARGUMENTS
|
||||
NO_CACHE
|
||||
SYSTEM
|
||||
GIT_SHALLOW
|
||||
EXCLUDE_FROM_ALL
|
||||
SOURCE_SUBDIR
|
||||
@@ -533,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()
|
||||
|
||||
@@ -552,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}"
|
||||
@@ -583,7 +659,7 @@ function(CPMAddPackage)
|
||||
if(CPM_LOCAL_PACKAGES_ONLY)
|
||||
message(
|
||||
SEND_ERROR
|
||||
"CPM: ${CPM_ARGS_NAME} not found via find_package(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION})"
|
||||
"${CPM_INDENT} ${CPM_ARGS_NAME} not found via find_package(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION})"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
@@ -609,6 +685,20 @@ function(CPMAddPackage)
|
||||
list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS DOWNLOAD_COMMAND ${CPM_ARGS_DOWNLOAD_COMMAND})
|
||||
elseif(DEFINED CPM_ARGS_SOURCE_DIR)
|
||||
list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS SOURCE_DIR ${CPM_ARGS_SOURCE_DIR})
|
||||
if(NOT IS_ABSOLUTE ${CPM_ARGS_SOURCE_DIR})
|
||||
# Expand `CPM_ARGS_SOURCE_DIR` relative path. This is important because EXISTS doesn't work
|
||||
# for relative paths.
|
||||
get_filename_component(
|
||||
source_directory ${CPM_ARGS_SOURCE_DIR} REALPATH BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
else()
|
||||
set(source_directory ${CPM_ARGS_SOURCE_DIR})
|
||||
endif()
|
||||
if(NOT EXISTS ${source_directory})
|
||||
string(TOLOWER ${CPM_ARGS_NAME} lower_case_name)
|
||||
# remove timestamps so CMake will re-download the dependency
|
||||
file(REMOVE_RECURSE "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-subbuild")
|
||||
endif()
|
||||
elseif(CPM_SOURCE_CACHE AND NOT CPM_ARGS_NO_CACHE)
|
||||
string(TOLOWER ${CPM_ARGS_NAME} lower_case_name)
|
||||
set(origin_parameters ${CPM_ARGS_UNPARSED_ARGUMENTS})
|
||||
@@ -624,28 +714,50 @@ 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(CPM_SKIP_FETCH TRUE)
|
||||
set(PACKAGE_INFO "${PACKAGE_INFO} at ${download_directory}")
|
||||
|
||||
# As the source dir is already cached/populated, we override the call to FetchContent.
|
||||
set(CPM_SKIP_FETCH TRUE)
|
||||
cpm_override_fetchcontent(
|
||||
"${lower_case_name}" SOURCE_DIR "${${CPM_ARGS_NAME}_SOURCE_DIR}/${CPM_ARGS_SOURCE_SUBDIR}"
|
||||
BINARY_DIR "${${CPM_ARGS_NAME}_BINARY_DIR}"
|
||||
)
|
||||
|
||||
else()
|
||||
# Enable shallow clone when GIT_TAG is not a commit hash. Our guess may not be accurate, but
|
||||
# it should guarantee no commit hash get mis-detected.
|
||||
@@ -674,8 +786,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)
|
||||
@@ -683,11 +795,18 @@ function(CPMAddPackage)
|
||||
"${CPM_ARGS_NAME}" "${CPM_ARGS_VERSION}" "${PACKAGE_INFO}" "${CPM_ARGS_UNPARSED_ARGUMENTS}"
|
||||
)
|
||||
cpm_fetch_package("${CPM_ARGS_NAME}" populated)
|
||||
if(CPM_CACHE_SOURCE 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}")
|
||||
@@ -702,7 +821,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()
|
||||
|
||||
@@ -720,6 +839,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
|
||||
@@ -788,7 +911,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()
|
||||
|
||||
@@ -834,25 +957,20 @@ 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)
|
||||
# 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()
|
||||
|
||||
foreach(OPTION ${OPTIONS})
|
||||
cpm_parse_option("${OPTION}")
|
||||
set(${OPTION_KEY} "${OPTION_VALUE}")
|
||||
@@ -873,7 +991,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()
|
||||
|
||||
@@ -981,6 +1099,7 @@ function(cpm_prettify_package_arguments OUT_VAR IS_IN_COMMENT)
|
||||
DOWNLOAD_COMMAND
|
||||
FIND_PACKAGE_ARGUMENTS
|
||||
NO_CACHE
|
||||
SYSTEM
|
||||
GIT_SHALLOW
|
||||
)
|
||||
set(multiValueArgs OPTIONS)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
set(CPM_DOWNLOAD_VERSION 1.0.0-development-version)
|
||||
|
||||
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 +8,25 @@ else()
|
||||
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
endif()
|
||||
|
||||
if(NOT (EXISTS ${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)
|
||||
|
||||
function(download_cpm)
|
||||
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}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
|
||||
download_cpm()
|
||||
else()
|
||||
# resume download if it previously failed
|
||||
file(READ ${CPM_DOWNLOAD_LOCATION} check)
|
||||
if("${check}" STREQUAL "")
|
||||
download_cpm()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(${CPM_DOWNLOAD_LOCATION})
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 ----
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 ----
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||
|
||||
project(CPMJSONExample)
|
||||
project(CPMFmtExample)
|
||||
|
||||
# ---- Dependencies ----
|
||||
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ project(CPMRangev3Example)
|
||||
|
||||
include(../../cmake/CPM.cmake)
|
||||
|
||||
CPMAddPackage("gh:ericniebler/range-v3#0.11.0")
|
||||
CPMAddPackage("gh:ericniebler/range-v3#0.12.0")
|
||||
|
||||
# ---- Executable ----
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -14,3 +14,5 @@ foreach(test ${tests})
|
||||
endforeach()
|
||||
|
||||
add_custom_target(test-verbose COMMAND ${CMAKE_CTEST_COMMAND} -C Debug --verbose)
|
||||
|
||||
add_subdirectory(style)
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
43
test/integration/test_fetchcontent_compatibility.rb
Normal file
43
test/integration/test_fetchcontent_compatibility.rb
Normal file
@@ -0,0 +1,43 @@
|
||||
require_relative './lib'
|
||||
|
||||
# Tests FetchContent overriding with CPM
|
||||
|
||||
class FetchContentCompatibility < IntegrationTest
|
||||
def setup
|
||||
@cache_dir = File.join(cur_test_dir, 'cpmcache')
|
||||
ENV['CPM_SOURCE_CACHE'] = @cache_dir
|
||||
end
|
||||
|
||||
def test_add_dependency_cpm_and_fetchcontent
|
||||
prj = make_project from_template: 'using-adder'
|
||||
|
||||
prj.create_lists_from_default_template package: <<~PACK
|
||||
CPMAddPackage(
|
||||
NAME testpack-adder
|
||||
GITHUB_REPOSITORY cpm-cmake/testpack-adder
|
||||
VERSION 1.0.0
|
||||
OPTIONS "ADDER_BUILD_TESTS OFF"
|
||||
)
|
||||
|
||||
# should have no effect, as we added the dependency using CPM
|
||||
FetchContent_Declare(
|
||||
testpack-adder
|
||||
GIT_REPOSITORY https://github.com/cpm-cmake/testpack-adder
|
||||
GIT_TAG v1.0.0
|
||||
)
|
||||
FetchContent_MakeAvailable(testpack-adder)
|
||||
PACK
|
||||
|
||||
# configure with unpopulated cache
|
||||
assert_success prj.configure
|
||||
assert_success prj.build
|
||||
|
||||
# cache is populated
|
||||
assert_true File.exist?(File.join(@cache_dir, "testpack-adder"))
|
||||
|
||||
# configure with populated cache
|
||||
assert_success prj.configure
|
||||
assert_success prj.build
|
||||
end
|
||||
|
||||
end
|
||||
21
test/integration/test_parallelism.rb
Normal file
21
test/integration/test_parallelism.rb
Normal 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
|
||||
36
test/integration/test_remove_source_dir.rb
Normal file
36
test/integration/test_remove_source_dir.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
require_relative './lib'
|
||||
|
||||
class RemoveSourceDir < IntegrationTest
|
||||
def test_remove_source_dir
|
||||
prj = make_project from_template: 'using-adder'
|
||||
|
||||
prj.create_lists_from_default_template package: <<~PACK
|
||||
CPMAddPackage(
|
||||
NAME testpack-adder
|
||||
GITHUB_REPOSITORY cpm-cmake/testpack-adder
|
||||
VERSION 1.0.0
|
||||
OPTIONS "ADDER_BUILD_TESTS OFF"
|
||||
SOURCE_DIR testpack-adder
|
||||
)
|
||||
PACK
|
||||
|
||||
# configure and build
|
||||
assert_success prj.configure
|
||||
assert_success prj.build
|
||||
|
||||
# source_dir is populated
|
||||
assert_true File.exist?(File.join(prj.bin_dir, 'testpack-adder'))
|
||||
|
||||
# source_dir is deleted by user
|
||||
FileUtils.remove_dir(File.join(prj.bin_dir, 'testpack-adder'), true)
|
||||
assert_false File.exist?(File.join(prj.bin_dir, 'testpack-adder'))
|
||||
|
||||
# configure and build with missing source_dir to fetch new content
|
||||
assert_success prj.configure
|
||||
assert_success prj.build
|
||||
|
||||
# source_dir is populated
|
||||
assert_true File.exist?(File.join(prj.bin_dir, 'testpack-adder'))
|
||||
end
|
||||
|
||||
end
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
48
test/integration/test_system_warnings.rb
Normal file
48
test/integration/test_system_warnings.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
require_relative './lib'
|
||||
|
||||
class SystemWarnings < IntegrationTest
|
||||
|
||||
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
|
||||
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
|
||||
assert_success prj.build
|
||||
end
|
||||
|
||||
end
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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@")
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user