325 Commits

Author SHA1 Message Date
Alecto Irene Perez
d9364ce284 Implement #624: Use shorter hashes with CPM_SOURCE_CACHE (#631)
* Add ASSERT_CONTENTS_EQUAL test macro in testing.cmake

Checks if the contents of a file matches the given input

* Use shorter hashes with CPM_SOURCE_CACHE (#624)

Uses shorter hashes with CPM_SOURCE_CACHE. Falls back to a longer hash
if necessary (ie, if there's a collision with an existing hash).

See: https://github.com/cpm-cmake/CPM.cmake/issues/624

* Update integration tests to support shorter hashes

* trigger ci

* run cmake-format

* if already available, use the legacy cache hash

* create temporary file in current binary dir

* add test case for legacy hash

---------

Co-authored-by: Lars Melchior <lars.melchior@gmail.com>
Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
v0.42.0
2025-05-18 19:02:47 +02:00
Simon Gene Gottlieb
d7614381ab feature: allow URI to use shorthand syntax with additional options (#617)
* feature: add URI to use shorthand syntax with additional options

This allows to combine the shorthand syntax with URI and additional arguments:
```
CPMAddPackage(URI "gh:nlohmann/json@3.9.1" OPTIONS "JSON_BUildTests OFF")
```

This is much shorter than the longer syntax way of writing:
```
CPMAddPackage(
  NAME nlohmann_json
  VERSION 3.9.1
  GITHUB_REPOSITORY nlohmann/json
  OPTIONS
    "JSON_BuildTests OFF"
)
```

* fix: use shorthand syntax in examples

* test: add test for shorthand syntax with options

* doc: extend README mentioning shorthand syntax with options

* feat: URI keyword also sets EXCLUDE_FROM AND SYSTEM

* doc: more explicit about the behavior of URI

* doc: adjust README accordingly to PR-Review

* test: fix inline documentation of test_simple

* move URI comment

* added new test for shorthand syntax

* reset simple test

* add that URI must be the first argument

---------

Co-authored-by: Lars Melchior <lars.melchior@gmail.com>
v0.41.0
2025-05-03 19:12:08 +02:00
Avus-c
97023e8b97 fix: do not generate module files with DOWNLOAD_ONLY (#654)
Co-authored-by: Avus <48911667+Avus@users.noreply.github.com>
v0.40.8
2025-03-12 19:10:52 +01:00
flagarde
0f231080d9 Fetch content (#593)
* Add git_archival mechanism

* fetch_content

* Delete .pre-commit-config.yaml

* Update CPM.cmake

* cmake-format
v0.40.7
2025-03-04 17:06:21 +01:00
Patrick Stewart
33efd5f5d2 Fix version filename for find_package redirects (#630)
Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
v0.40.6
2025-03-02 22:08:20 +01:00
Lars Melchior
4b3a60fb32 Investigate sol2 CI build issue (#648)
* trigger CI to see if sol2 example is reliably failing

* attempt patch from github comment

* fix patch

* add info to comment on patch

* run fix-format

* simplify patchfile
2025-03-02 21:59:58 +01:00
Rokas Kupstys
cd28d445ae Fix finding patch executable when cross-compiling on windows. (#627)
`WIN32` checks whether current build context is windows. This is not correct in case of cross-compiling, because we are interested in finding host's tools, not SDK's tools.
v0.40.5
2024-12-29 18:15:04 +01:00
Daniel Lemire
2a9e203320 doc: warn users that PATCHES may not work properly when CPM_SOURCE_CACHE is unset. (#580) 2024-12-22 23:25:51 +01:00
Scott B
22381df399 Update boost to 1.86 (#592)
* Update to v1.85.0

* Boost example to 1.86
2024-12-22 22:39:17 +01:00
Avus-c
c3807eb774 circumvent bug in cmake <3.30.3 (#605)
Co-authored-by: Avus <48911667+Avus@users.noreply.github.com>
v0.40.4
2024-12-22 13:08:38 +01:00
Patrick Stewart
9ddfe1b6a8 Add find_package overrides that also work in CONFIG mode (#498) (#604) v0.40.3 2024-12-20 16:38:22 +01:00
Scott B
0bc73f41ce Additional search path for patch.exe (#581)
* Additional search path for patch.exe

* Style
v0.40.2
2024-08-02 15:44:55 +02:00
Avus-c
8b67fe2344 replace deprecated calls to FetchContent_Populate (#570)
* replace deprecated calls to FetchContent_Populate

The single argument signature for FetchContent_Populate is deprecated with CMake 3.30.
It was used, in order to call add_subdirectory manually with the EXCLUDE_FROM_ALL and SYSTEM flags.
These have been added to FetchContent_Declare with 3.25 and 3.28.
Calling FetchContent_MakeAvailable will internally call add_subdirectory with EXCLUDE_FROM_ALL and SYSTEM.
There is therefore no need to call this manually.

* fix: OPTIONS passed to CPMAddPackage not set

where previously parsed in cpm_add_subdirectory which is not called
on the new code path.

* refactor: remove an unnecessary else branch

* ci: include cmake 3.30 in test matrix

* fix: forward SOURCE_SUBDIR to FetchContent_Declare

For CMake version <3.28 this is done by calling add_subdirectory manually.
For newer version FetchContent_Declare/MakeAvailable handles this for us.

* fix: only set options if download_only is false

this replicates the old behaviour

* fix: DOWNLOAD_ONLY test

* refactor: always use *_Populate to reduce code paths

* Revert "refactor: always use *_Populate to reduce code paths"

This reverts commit 0e8ca2a0e9.

---------

Co-authored-by: Avus <48911667+Avus@users.noreply.github.com>
v0.40.1
2024-07-29 11:19:31 +02:00
Scott B
d416d9b22c Adding PATCHES keyword. (#558)
* Adding PATCHES keyword.

* Formatting fix.

* Move cpm_add_patches() outside if/else scopes.

* cmake-format: add PATCHES to CPMAddPackage.

* Integration tests for PATCHES command.

* Use get_filename_component() in place of cmake_path() for use with all cmake versions 3.14 and above.

* Added an example and improved comment for cpm_add_patches.
v0.40.0
2024-06-12 15:43:27 +02:00
PercentBoat4164
76ca48690b Remove 'bug' from comment (#555)
* Remove 'bug' from comment

* Fix the styling

Oh gosh, I messed up the style...

* Line endings
2024-04-21 21:12:30 +02:00
Gerhard Olsson
0370507fed Custom cache directory name (#543)
* Custom cache directory name

Enable setting a custom directory name for cached packages.
Required if e.g. patch_command uses external variables or
just to set a human readable name.

* fixup! review comment CUSTOM_CACHE_DIR -> CUSTOM_CACHE_KEY

* run cmake-format

---------

Co-authored-by: Olsson Gerhard <gerhard.olsson@volvo.com>
Co-authored-by: Lars Melchior <lars.melchior@gmail.com>
v0.39.0
2024-04-08 18:24:10 +02:00
Project D.D
c0855c9543 Add xxHash example (#549)
* Add xxHash example

* Fix link error

* run code formatters

---------

Co-authored-by: Lars Melchior <lars.melchior@gmail.com>
2024-04-08 16:14:14 +00:00
black-desk
7e81149c1e Use cpm_find_package to check if a package added (#552)
If I have a project, which has:

1. /CMakeLists.txt:

   ```cmake
   cmake_minimum_required(VERSION 3.29)
   project(test)
   include(./cmake/CPM.cmake)
   add_subdirectory(subdir)
   cpmfindpackage(
     NAME
     nlohmann_json
     VERSION
     3.11.2
     URL
     "https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz"
     EXCLUDE_FROM_ALL
     ON)

   if(NOT TARGET nlohmann_json::nlohmann_json)
     message(FATAL_ERROR "BUG")
   endif()
   ```
2. /subdir/CMakeLists.txt

   ```cmake
   cpmfindpackage(
     NAME
     nlohmann_json
     VERSION
     3.11.2
     URL
     "https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz"
     EXCLUDE_FROM_ALL
     ON)
   ```

When nlohmann_json is first founded by find_package,
CPM.cmake register this package and later call to CPMFindPackage will
not actually perform a find_package again, which leads to this buggy
behavior.

As CPM write a FindXXX.cmake file for packages added by CPM to pervert
find_package to get local package, I think directly use cpm_find_package
to check if a package is already added is good enough.
v0.38.8
2024-04-07 23:40:46 +02:00
Simon Gene Gottlieb
0e450ef450 fix,doc: spelling errors (#551) 2024-04-07 21:36:07 +00:00
Scott B
a8144f511d Update Boost example (#531)
* Update CMake and main to add another library and download FASTER.

* Apply style formatters

* Update README.md's boost example and add information on determining source archive location at GitHub.

* Update README.md

---------

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
2024-02-02 18:25:34 +00:00
Claus Klein
3c25130ffa Feature/add missing packageproject options (#524)
* Add missing packageproject options

* Fix typos with codespell

* Update test/style/CMakeLists.txt

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

* fix-cmake-format

---------

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
2024-01-17 09:06:16 +01:00
Chris Wright
369f1316f6 Treat relative paths as relative to parent project's remote (#522)
* Treat relative paths as relative to parent project's remote

* replace unit test case with integration test

* run relative URL test only on supported CMake versions (3.27)

* omit cmake 2.25.x test runner as replaced by 2.27.x

---------

Co-authored-by: Chris Wright <chris.wright@mqa.co.uk>
Co-authored-by: Lars Melchior <lars.melchior@gmail.com>
v0.38.7
2023-11-30 20:01:03 +01:00
Daniel Lemire
a9c8c6fe1b Adding simdjson example (#516)
* Adding simdjson example

* Update README.md

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

* cmake format

---------

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
2023-11-06 17:19:06 +00:00
Daniel Lemire
2fa48378e2 new users (#515) 2023-11-06 17:13:56 +00:00
Lars Melchior
4276c79d28 update catch2 to 3.4.0 (#517) 2023-11-06 18:04:37 +01:00
Alfi Maulana
ee6d879a50 Includes missing arguments in the cpm_prettify_package_arguments function (#511) v0.38.6 2023-10-08 17:48:42 +00:00
Lars Melchior
d6d5d0d5ab Remove logs in get_cpm.cmake script (#508)
* remove all logs from get_cpm.cmake

* simplify get_cpm.cmake script
v0.38.5
2023-09-18 16:11:03 +02:00
Lars Melchior
16c6a3b0af Fix download_command by declaring it a multi-value option (#473) v0.38.4 2023-09-18 15:37:35 +02:00
Lars Melchior
52ee7c9d53 Fix new release script to use correct version and hash sum (#507)
* fix new release script to use correct version and hash sum

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

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

* change system test behaviour based on specified CMake version

* use explicit version strings

* set CMake version for both test steps

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

* add test case for system property

* lock CMake version in test workflow

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

* remove old comment change

* use consistent CMake version and extension for all workflows

* make warning more specific and try to trigger on windows

* another attempt to trigger warning on MSVC

* update readme

* simplify test case and use git tag

* add SYSTEM option to .cmake-format

* forward system arg for source overrides

* enable system implicitly for the single argument syntax

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

* Use SYSTEM option for FetchContent and add_subdirectory

* Add SYSTEM option to syntax and doku

* Update CPM.cmake

* Update .cmake-format

---------

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

---------

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

* Remove old multi-threading implementation.

* Release files instead of removing.

* Lock before choosing to check cache or download.

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

* Fixed formatting.

* Prevent double locking file.

* Fix SegFault from test 2.

* Remove unnecessary debugging messages.

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

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

* Remove unnecessary arguments in conditional statements.

* Change back to locking entire cache directory.

* Only check CPM_HAS_CACHE_LOCK.

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

* Clean up the locked file.

* Unlock then remove to fix Windows.

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

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

* Add unit test.

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

* - Added comments
- Fixed formatting
- Removed unnecessary imports

* convert parallelism test to integration test

* remove comment

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

* Forgot to change variable name.

* Add similar changes to the missed section.

* Fixed formatting.

* Unlock the file, but do not delete it.

* Only unlock the file if it exists.

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

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

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

* - Fix formatting

* Switch to snake case.

---------

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

* update doctest

* update lua

* update google benchmark

* update catch2

* update readme to match updated dependencies

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

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

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

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

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

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

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

* Add comment about re-using fmt for spdlog

* Update examples/spdlog/CMakeLists.txt

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

* run cmake-format

* disable cmake-format around code block

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
2022-11-09 11:23:09 +00:00