You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a name isn't provided, try to infer it from the git repo (#202)
* Added assert_not_defined check
* Function to get package name form git uri and tests
* Autofix format
* If name is not provided, try to infer it from the git repo
* Unset result of cpm_package_name_from_git_uri if there is no match
- Also reordered tests to ensure that the result is actually unset when needed
* Removed trailing spaces in README
* Updated the main example with the new minimal syntax
* Well... autofix format again
* Update error message for missing name to reflect the possible auto-infer step
* Autofix format... yet again :)
Copy file name to clipboardExpand all lines: README.md
+8-9Lines changed: 8 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ CPMAddPackage(
43
43
44
44
The origin may be specified by a `GIT_REPOSITORY`, but other sources, such as direct URLs, are [also supported](https://cmake.org/cmake/help/v3.11/module/ExternalProject.html#external-project-definition).
45
45
If `GIT_TAG` hasn't been explicitly specified it defaults to `v(VERSION)`, a common convention for git projects.
46
-
On the other hand, if `VERSION` hasn't been explicitly specified, CPM can automatically identify the version from the git tag in some common cases.
46
+
On the other hand, if `VERSION` hasn't been explicitly specified, CPM can automatically identify the version from the git tag in some common cases.
47
47
`GIT_TAG` can also be set to a specific commit or a branch name such as `master` to always download the most recent version.
48
48
The optional argument `FIND_PACKAGE_ARGUMENTS` can be specified to a string of parameters that will be passed to `find_package` if enabled (see below).
49
49
@@ -71,7 +71,6 @@ add_executable(tests tests.cpp)
71
71
include(cmake/CPM.cmake)
72
72
73
73
CPMAddPackage(
74
-
NAME Catch2
75
74
GITHUB_REPOSITORY catchorg/Catch2
76
75
VERSION 2.5.0
77
76
)
@@ -112,7 +111,7 @@ Dependencies using CPM will automatically use the updated script of the outermos
112
111
## Limitations
113
112
114
113
-**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.
115
-
-**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).
114
+
-**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).
116
115
-**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).
117
116
118
117
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).
@@ -143,7 +142,7 @@ The most notable features are:
143
142
-[Package lock files](#package-lock) for easier transitive dependency management.
144
143
- Dependencies can be overridden [per-build](#local-package-override) using CMake CLI parameters.
145
144
146
-
ExternalProject works similarly as FetchContent, however waits with adding dependencies until build time.
145
+
ExternalProject works similarly as FetchContent, however waits with adding dependencies until build time.
147
146
This has a quite a few disadvantages, especially as it makes using custom toolchains / cross-compiling very difficult and can lead to problems with nested dependencies.
148
147
149
148
## Options
@@ -178,7 +177,7 @@ These options can also be set as environmental variables.
178
177
179
178
Library developers are often in the situation where they work on a locally checked out dependency at the same time as on a consumer project.
180
179
It is possible to override the consumer's dependency with the version by supplying the CMake option `CPM_<dependency name>_SOURCE` set to the absolute path of the local library.
181
-
For example, to use the local version of the dependency `Dep` at the path `/path/to/dep`, the consumer can be built with the following command.
180
+
For example, to use the local version of the dependency `Dep` at the path `/path/to/dep`, the consumer can be built with the following command.
182
181
183
182
```bash
184
183
cmake -Bbuild -DCPM_Dep_SOURCE=/path/to/dep
@@ -205,7 +204,7 @@ See the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/Package-lock) for mor
205
204
206
205
## Built with CPM.cmake
207
206
208
-
Some amazing projects that are built using the CPM.cmake package manager.
207
+
Some amazing projects that are built using the CPM.cmake package manager.
209
208
If you know others, feel free to add them here through a PR.
210
209
211
210
<table>
@@ -284,7 +283,7 @@ CPMAddPackage(
284
283
# 0.6.2 uses deprecated CMake syntax
285
284
VERSION 0.6.3
286
285
# 0.6.3 is not released yet, so use a recent commit
287
-
GIT_TAG 012269756149ae99745b6dafefd415843d7420bb
286
+
GIT_TAG 012269756149ae99745b6dafefd415843d7420bb
288
287
OPTIONS
289
288
"YAML_CPP_BUILD_TESTS Off"
290
289
"YAML_CPP_BUILD_CONTRIB Off"
@@ -314,7 +313,7 @@ endif()
314
313
```cmake
315
314
CPMAddPackage(
316
315
NAME nlohmann_json
317
-
VERSION 3.6.1
316
+
VERSION 3.6.1
318
317
# the git repo is incredibly large, so we download the archived include directory
0 commit comments