mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-18 23:27:37 -05:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03705fcce1 | ||
|
|
f00ccd89c4 | ||
|
|
1f4909ca44 | ||
|
|
4d33686a50 | ||
|
|
984251f46c | ||
|
|
63d0de7114 | ||
|
|
65c760a840 | ||
|
|
b5e60e72e8 | ||
|
|
10bf25a811 | ||
|
|
18b6cbf233 | ||
|
|
698741ff7c | ||
|
|
1f09de0d9b |
6
.github/workflows/style.yml
vendored
6
.github/workflows/style.yml
vendored
@@ -11,15 +11,13 @@ on:
|
||||
jobs:
|
||||
style:
|
||||
|
||||
runs-on: macos-latest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- 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
|
||||
|
||||
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)
|
||||
|
||||
51
README.md
51
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@2.5.0")
|
||||
|
||||
# link dependencies
|
||||
target_link_libraries(main fmt::fmt nlohmann_json::nlohmann_json Catch2::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.
|
||||
|
||||
## Usage
|
||||
|
||||
After `CPM.cmake` has been [added](#adding-cpm) to your project, the function `CPMAddPackage` can be used to fetch and configure a dependency.
|
||||
@@ -73,32 +97,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 +135,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.
|
||||
@@ -334,7 +341,7 @@ CPMAddPackage(
|
||||
NAME nlohmann_json
|
||||
VERSION 3.9.1
|
||||
GITHUB_REPOSITORY nlohmann/json
|
||||
OPTIONS
|
||||
OPTIONS
|
||||
"JSON_BuildTests OFF"
|
||||
)
|
||||
```
|
||||
|
||||
@@ -28,23 +28,6 @@
|
||||
|
||||
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)
|
||||
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()
|
||||
|
||||
set(CURRENT_CPM_VERSION 1.0.0-development-version)
|
||||
|
||||
get_filename_component(CPM_CURRENT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
|
||||
@@ -84,6 +67,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}
|
||||
)
|
||||
@@ -232,6 +235,9 @@ function(cpm_find_package NAME VERSION)
|
||||
string(REPLACE " " ";" EXTRA_ARGS "${ARGN}")
|
||||
find_package(${NAME} ${VERSION} ${EXTRA_ARGS} QUIET)
|
||||
if(${CPM_ARGS_NAME}_FOUND)
|
||||
if(DEFINED ${CPM_ARGS_NAME}_VERSION)
|
||||
set(VERSION ${${CPM_ARGS_NAME}_VERSION})
|
||||
endif()
|
||||
message(STATUS "${CPM_INDENT} using local package ${CPM_ARGS_NAME}@${VERSION}")
|
||||
CPMRegisterPackage(${CPM_ARGS_NAME} "${VERSION}")
|
||||
set(CPM_PACKAGE_FOUND
|
||||
@@ -494,6 +500,7 @@ endfunction()
|
||||
|
||||
# Download and add a package from source
|
||||
function(CPMAddPackage)
|
||||
cpm_set_policies()
|
||||
|
||||
list(LENGTH ARGN argnLength)
|
||||
if(argnLength EQUAL 1)
|
||||
@@ -705,7 +712,7 @@ function(CPMAddPackage)
|
||||
)
|
||||
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})
|
||||
@@ -801,6 +808,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
|
||||
|
||||
@@ -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,6 +8,8 @@ else()
|
||||
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
endif()
|
||||
|
||||
# Expand relative path. This is important if the provided path contains a tilde (~)
|
||||
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
|
||||
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
|
||||
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
|
||||
file(DOWNLOAD
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||
|
||||
project(CPMJSONExample)
|
||||
project(CPMFmtExample)
|
||||
|
||||
# ---- Dependencies ----
|
||||
|
||||
|
||||
@@ -14,3 +14,5 @@ foreach(test ${tests})
|
||||
endforeach()
|
||||
|
||||
add_custom_target(test-verbose COMMAND ${CMAKE_CTEST_COMMAND} -C Debug --verbose)
|
||||
|
||||
add_subdirectory(style)
|
||||
|
||||
@@ -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