Commit Graph

298 Commits

Author SHA1 Message Date
Robert Maynard
4f7af69925 CMake 3.22 allows set/set(CACHE) to behave the same as set(X)/option(x) (#335)
By enabling CMP0126 we tell CMake that when constructing a CACHE variable
with the same name as a local variable to not unset the local variable.

By enabling CMPO126 it makes sure that CPM behavior around `OPTION` is
consistent if the option is created with `set(CACHE)` or with `option`.
2022-01-27 23:36:12 +01:00
Borislav Stanimirov
c58e98a0a0 Initial version of integration tests (#330)
* Initial commit for integration tests. Experimental. Playing with potential syntax

* Some experimental code to setup tests

* Piecewise building of CMakeLists

* First check

* Alternative approach. Using ruby's test/unit

* Parse CMakeCache. Separate lib

* First integration test

* Latest Format.cmake. Passing style

* Allow user-provided integration test dir. Allow reuse

* Separate class with utils for cache (no longer pure Hash)

* Allow running of tests from any dir

* Add integration tests to CI

* Use an in-source integration test directory

* Allow relative integration test dir from env

* Custom assertion for a success of CommandResult

* Windows-latest-latest

* Enrich CMakeCache class with more CPM data

* Added test for CPM-specific CMakeCache values

* Style

* Style

* test_update_single_package

* WiP for source cache test

* Small source_cache test

* Style

* Moved env clean to cleanup to make setup methods simpler (not require super)

* WiP for integration test documentation

* WiP for integration test documentation

* Project file creation tweaks

* Split docs into multiple files. Complete tutorial. Reference.

* Tips

* Typo

* Setup Ruby inistead of requiring windows-2022

* Revert "Setup Ruby inistead of requiring windows-2022"

This reverts commit 8aa2732145.
2022-01-19 00:18:41 +01:00
Lars Melchior
a27c66a3ea Remove badges (#327)
As we now use the unified CI workflow (#326), it seems we unfortunately [can't have separate badges for each OS](https://github.community/t/separate-workflow-badges-when-using-matrix-testing-possible/16708). As the display of the badges was to reference the cross-platform nature of the project, imo it can be replaced by adding a reference in the introduction instead.
2022-01-13 03:44:07 +02:00
Vinpasso
5cb7398a24 [Example] Disable JSON tests being included in ctest (#329)
* Disable JSON tests being included in ctest

If `CPMAddPackage` includes json without setting JSON_BuildTests off first then the target's ctest will include lots of json's tests.

* Bump example JSON version to avoid JSON tests
2022-01-12 20:29:59 +01:00
Borislav Stanimirov
262f1e0602 Unified GitHub workflow for tests on major operating systems (#326) 2022-01-11 21:16:04 +01:00
Dan Raviv
7cbef3efc8 Fix comment out-of-sync with modified code (#321) 2022-01-06 08:46:54 +02:00
DNKpp
939123d1b4 Fix <package>_SOURCE_DIR and _BINARY_DIR handling when caching is active (#314)
* fix: use CACHE variables instead relying on FetchContents mechanism

* apply cmake-format

Signed-off-by: DNKpp <DNKpp2011@gmail.com>
v0.34.3
2021-12-30 16:20:37 +01:00
Lars Melchior
22078d5e0d add quotes around module arguments (#313) 2021-12-30 15:20:16 +02:00
Pavel Sokolov
96c268827b Pass DOWNLOAD_ONLY flag when CPM_pkg_SOURCE is set. (#308)
https://github.com/cpm-cmake/CPM.cmake/issues/307
v0.34.2
2021-12-15 21:23:18 +01:00
Lars Melchior
dad37fbe4e Change example ordering and add note on boost (#305)
Reorders examples from simple to more complex. Also adds note on using `CPM_SOURCE_CACHE` for boost.
2021-12-12 15:09:50 +01:00
Lars Melchior
fed5f8e8a2 use official boost release (#304) v0.34.1 2021-12-05 16:08:47 +01:00
Lars Melchior
d65613e860 add warning when not using release version of CPM.cmake (#303) 2021-12-05 16:08:02 +01:00
Lars Melchior
718ea71759 Allow passing lists in the options (#302)
* allow list options by passing option parameter as string, not value

* add test

* remove debug message

* run formatter
2021-12-05 16:07:20 +01:00
Lars Melchior
6491382204 Remove travis badge from readme (#289)
Follow up on #283 to remove the now obsolete travis badge.
2021-09-29 13:48:40 +03:00
pgorgon-hem
634800c619 Added directory inside cache to make it shown more friendly in CLion (#268)
* Added directory inside cache to make it shown more friendly in CLion

* Changed hash generation to omit collision with old cache scheme. Removed moving old directory for compatibility reason.

* Added CPM_USE_NAMED_CACHE_DIRECTORIES option

* Fixed formatting

* Added description of CPM_USE_NAMED_CACHE_DIRECTORIES into README.md

Co-authored-by: Paweł Gorgoń <pgorgon@hem-e.com>
v0.34.0
2021-09-15 21:39:31 +02:00
Andrea Barbadoro
f552da96bd Detecting when the cache is dirty (#284)
* Check that the cache working directory is clean

* cpm_check_working_dir_is_clean for non git repo will not terminate cmake

* sileneced check for git repo, in case of error

* style(CPM.cmake): fixed indentation for ERROR_QUIET

* refactor(CPM.cmake): added logic to handle a cache folder inside a (not correlated) git repo

this is accomplished by checking if we are in the directory where .git lives

* style(CPM.cmake): stray tab to spaces

* test(dirty-cache-check): added unit test to check cpm_check_working_dir_is_clean

the test creates a file in a folder and then uses git to create a repo in that folder, to check various conditions

* Update test/unit/dirty-cache-check.cmake

added user.name and user.email to comply with test machine where git is not completely configured

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

* feat(cpm_check_working_dir_is_clean): now it takes a git tag (works with hashes too) to check for uncommitted and commited changes

* refactor(cpm_check_working_dir_is_clean): early return for the most common case of uncommited changes in a repo

* refactor(cpm_check_git_working_dir_is_clean): removed edgecase detection (a non-git folder in an unrelated git repo)

now the contract is that com_check_git_working_dir_is_clean is given the base folder of a git repo

Co-authored-by: Andrew Gribble <ag131012@renishaw.com>
Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
v0.33.0
2021-09-15 11:38:49 +02:00
Olivier Le Doeuff
ea6a8eb895 Fix CPMAddPackage when FetchContent_MakeAvailable already added package (#288)
Add fetchcontent_dependency unit test:
* This test should highlight the fact that cpm_add_subdirectory is always called, even when
  cpm_fetch_package isn't populating the dependency
* NO_CACHE YES highlight a bug introduced in 32b063eba5 where
  cpm_fetch_package was checking undefined ${lower_case_name}_POPULATED variable

https://github.com/cpm-cmake/CPM.cmake/issues/287
v0.32.3
2021-08-29 22:02:18 +02:00
MixusMinimax
a5c22bf6e8 use quotes for CPM_FILE when creating FIND.cmake (#286) 2021-08-29 22:01:50 +02:00
Lars Melchior
c5cb85b2f1 Build examples in CI using GitHub (#283)
* build examples in CI using github

* update cxxopts style
2021-08-29 20:27:10 +02:00
pgorgon-hem
91585e3864 Added support for bitbucket repositories (#256)
* Added support for bitbucket repositories:
* added variable BITBUCKET_REPOSITORY
* added short syntax in form "bb:user/repo"
* added description of that to readme.md

* Added test for bitbucket short syntax

* Used elseif syntax in handling of git services (github, gitlab, bitbucket).

* Added HEMRND/TestingFramework example located on bitbucket.org

* Reformatted CMakeLists.txt in TestingFramework example

* Bumped version of TestingFramework. It supports older version of c++ standard.

Co-authored-by: Paweł Gorgoń <pgorgon@hem-e.com>
v0.32.2
2021-06-08 19:15:40 +02:00
Stuart Dootson
9675d46517 Expand relative download directory to prevent unnecessary download (#267)
* Expand relative download directory to prevent unnecessary download

If `CMAKE_SOURCE_CACHE` (and thus `download_directory`) is set to a relative path, the condition `if(EXISTS ${download_directory})` will fail even if the required directory exists. Expanding the variable `download_directory` to an absolute path before the test will rectify this, preventing unnecessary downloads of the sources.

* iFixed up formatting

Co-authored-by: Stuart Dootson <stuart.dootson@rolls-royce.com>
2021-06-08 19:12:20 +02:00
Lars Melchior
7078e8286a Remove branch name references from README (#265)
As noted in #263, setting `GIT_TAG` to a branch name results in unexpected and unreproducible build behaviour, as it does not automatically update when the `HEAD` changes.
2021-06-08 15:55:03 +03:00
Lars Melchior
6a0277f16e Update CMake to 3.20 for integration tests (#264)
This allows us to use more recent projects in the examples
2021-06-08 15:27:31 +03:00
Lars Melchior
4502bf1e04 Forward exclude and subdir options when using local package override (#261)
* forward exclude and subdir options when using local package override.
fixes #260.

* run cmake format

* add SOURCE_SUBDIR parameter to cmake-format
2021-06-08 15:26:39 +03:00
Clare Macrae
dd3ba9792c Fix typo in README - omit -> emit (#258) 2021-06-02 09:36:29 +03:00
Lars Melchior
de5551e42c Update boost-cmake (#252)
* update boost-cmake

* run cmake-format
2021-05-18 16:29:52 +03:00
Paul Taylor
7644c3a40f Respect FETCHCONTENT_BASE_DIR if set by a user (#244)
* Respect `FETCHCONTENT_BASE_DIR` if set by a user

* Use a single `CPM_FETCHCONTENT_BASE_DIR` var
v0.32.1
2021-04-16 17:27:51 +02:00
Lars Melchior
310efb9b17 Update more examples from the readme (#241)
* update examples from the readme

* add explainations to the examples
2021-03-26 18:31:35 +02:00
Lars Melchior
4fad2eac0a remove option consistency check (#240) v0.32.0 2021-03-25 19:24:44 +02:00
flagarde
ee08119642 Scope package options to avoid changing the local scope (#235)
* Fix #222

* Fix #222

* move policy change and local options to cpm_add_subdirectory

* change default policy as well

see https://gitlab.kitware.com/cmake/cmake/-/issues/20312

* add test

* update check to not use the NOT operator

(interestingly it works as expected locally)

* simplify test by not using options

* check options in tests

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
2021-03-25 15:59:34 +01:00
Lars Melchior
259f1be8e2 update cxxopts and add reasonable options (#239) 2021-03-25 14:20:06 +02:00
Lars Melchior
32b063eba5 Fix support for source subdirectories (#238)
* add support for source subdirectories

* style fixes

* remove debug log

* grammar fix in comment
v0.31.2
2021-03-25 10:42:51 +01:00
Lars Melchior
d64d816585 Make CPMFindPackage less prominent in the Readme (#236)
Giving `CPMFindPackage` a less prominent position, as in almost all cases, `CPMAddPackage` should be preferred.

Following a related discussion in #222.
2021-03-22 12:37:11 +01:00
Lars Melchior
8e8dcc9a8d moved test repostitory to CPM.cmake namespace (#228) 2021-03-04 11:01:01 +02:00
Lars Melchior
8afc2af4f9 update more examples to use shorthand syntax (#223)
* update more examples to use shorthand syntax

* revert google-benchmark as tests require googletest to be installed

* update comments

* always quote single-arguments

* undo accidental deletion
2021-02-25 09:53:28 +02:00
Borislav Stanimirov
a3d1048ad6 Infer package name and version from URL (#220)
* Function to extract name and version from url. Some tests

* Rewrite. Previous version was not safe enough. More tests

* Allow underscore as a name-version separator (<name>_<ver>)

* CPMAddPackage can infer name and version from url

* Allow URL parse from single arg and uncomment tests

* Info about shorthand syntax in README

* Fix style

* Fixed typo

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

* Explicit hash algorithm in shorthand URL example.
Also added tests which include a hash algorithm provided
We can't document a default until it's confirmed here: https://gitlab.kitware.com/cmake/cmake/-/issues/21859

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
v0.31.1
2021-02-23 20:15:45 +01:00
Lars Melchior
492e762591 update examples to use new syntax where possible (#218) 2021-02-23 08:14:32 +02:00
Borislav Stanimirov
3f6cbe7383 Single-argument shorthand syntax for CPMAddPackage (#207)
* Added quotes in equality checks so lists can be compared

* Function to parse argument of CPMAddPackage in case a single one was provided

* Error on URL type in CPMAddPackage single-arg

* Fixed format

* Support single argument syntax of CPMAddPackage

* Documenting and showcasing the new shorthand syntax of CPMAddPackage

* Auto EXCLUDE_FROM_ALL for the shorthand syntax

* Fixed accidental paste of TOLOWER

* Document why some test cases are commented out

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

* Update README.md

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

* Removed GitHub as the default package shorthand provider

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
v0.31.0
2021-02-22 21:12:06 +01:00
Borislav Stanimirov
4aadac1972 Improved regex match in cpm_package_name_from_git_uri (#206) 2021-02-19 09:45:04 +01:00
Borislav Stanimirov
4cbf443363 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 :)
v0.30.0
2021-02-17 12:41:25 +01:00
Borislav Stanimirov
2744b87f07 FATAL_ERROR if no NAME is provided (#201)
* FATAL_ERROR if no NAME is provided

* Fixed format
2021-02-16 14:54:31 +00:00
Lars Melchior
fd539b8ff3 Add dependencies using EXCLUDE_FROM_ALL flag (#198)
* add dependencies using EXCLUDE_FROM_ALL flag

* respect DOWNLOAD_ONLY flag

* set EXCLUDE_FROM_ALL as an optional flag

* use one value arg for consistency

* fix argument passing

* add unit test

* update cmake-format
v0.29.0
2021-02-16 10:26:16 +00:00
Lars Melchior
02d57a1601 Update URLs for new CPM.cmake organisation (#194)
* update URLs for new CPM.cmake organisation

* trigger travis
v0.28.4
2021-02-08 21:31:06 +01:00
Claus Klein
5f614e5eb6 update most package versions (#190)
* update most package versions

extent build_all.py to inject cmake modules
and use Ninja generator

* fix build problems while build on debian

use SYSTEM include paths (for clang++)
we should not use local installed header!

* fix banchmark example

finalize cmake project code injection as an option

* fix build problems on travis CI

gtest needs c++17

* Update examples/build_all.py

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

* reindent py script requested by review

indent with only 2 spaces again

* changes according the review

the gtest build error seems to be a make -j cpucount problem

* revert filter too

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
v0.28.3
2021-02-07 17:08:04 +01:00
Xavier Muller
1f5cb903e5 fix superbuild cmake < 3.17 (#193)
* CPM_INDENT in the global scope as suggest

* Fix FetchContent failure with cmake < 3.17

* format
2021-02-07 17:07:47 +01:00
alexandreSalconiDenis
7000572bbe Feature/prettify package lock (#162)
* add prettify macro

* apply the prettier and change the name of the output arg

* add parameter inside macro

* resolve path if its cmake_sourc_dir

* add missing uparsed argument

* add early unit test for prettifier

* retab prettify_cpm_add_package

* rename prettify_cpm_add_package  cpm_prettyfy_package_arguments

* convert macro to function and fix unit test

* fix typo in the name of the parse argument in prettyfy function

* change the unit test to test only the function

* add test for the commented part

* remove dead code

* fix typo

* run cmake-format on CPM.cmake

* reformated unit test prettify

* flip the logic to add space on new argument unparsed to avoir space at the end

* remove debug message

* apply most suggestion from pr 162, disable formating only for small part in unit test

* add unit test to cover defauld source dir added inside lock

* run format tool on unit test

* remove dead code

* change the prettifier from 4 space to 2

* run format on unit test
v0.28.2
2021-01-27 13:29:15 +01:00
Borislav Stanimirov
fe8d15ba82 Expand CPM_SOURCE_CACHE path provided as a configure argument (#186)
Otherwise if one configures with -DCPM_SOURCE_CACHE=~/something (tilde to be expanded to $HOME), https://gitlab.kitware.com/cmake/cmake/-/issues/21729 hits, EXISTS always fails, and file(DOWNLOAD) fails
v0.28.1
2021-01-21 16:31:55 +01:00
Lars Melchior
ab6e8d6d8c Performance improvement: bypass FetchContent for cached dependencies (#182)
* skip FetchContent for cached dependencies

* set default value for CPM_SKIP_FETCH to avoid conflicts

* add tests to check exported values
v0.28.0
2021-01-20 13:15:18 +01:00
Lars Melchior
aad0397beb add further reading section (#177) 2021-01-14 12:28:11 +00:00
Lars Melchior
1ebbac6332 Apply clang-format and cmake-format and add style check workflow (#171)
* apply clang-format and cmake-format and add style check workflow

* add declare package definition

* add additional public methods and rename internals

* change development verison tag to 1.0.0

* rename internal method

* rename public method

* rename test var

* update copyright and fix comment

* typo

* run fix-format

* fix test function names
2021-01-06 14:40:33 +01:00