Commit Graph

233 Commits

Author SHA1 Message Date
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
Yotam Gingold
cf3f62b6f2 Fixed typo in help message (#165) 2020-11-26 17:52:34 +01:00
Xavier Muller
3b404296b5 fix: GIT_TAG not parsed inside CPMFindPackage (#159)
When using CPMFindPackage, if no VERSION is given then GIT_TAG is used as fallback if defined, which is a good idea.
The issue is that GIT_TAG is missing inside the oneValueArgs variable therefore GIT_TAG is not parsed. This is resolved by this little change.
v0.27.5
2020-10-19 09:34:42 +02:00
Leonardo Lima
18e09b07ba Implemented GitHub Actions cache example (#156)
* Implemented GitHub Actions cache example

* Updated GitHub Actions example

* Update README.md

* Fixed consistency

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

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
2020-10-06 13:07:00 +02:00
Kai Germaschewski
aeef56ea85 fix passing options when using CPM_<pkg>_SOURCE (#155)
When I used CPM_<pkg>_SOURCE to point to a locally modified copy,
the options ended up not being passed on. I think they should be, so
this patch does so.
v0.27.4
2020-09-27 22:56:32 +02:00
The Gitter Badger
4271d5981f Add Gitter badge (#154) 2020-09-25 17:42:02 +02:00
Prabir Shrestha
d17500b0be ignore lua.c and luac.c from lua (#149)
* ignore lua.c and luac.c from lua

* Update README.md

* update CMakeLists.txt for sol2
2020-09-13 12:00:19 +02:00
Leonardo
5e0c3855c7 Implemented spdlog library example (#150) 2020-09-08 14:08:35 +02:00
Lars Melchior
f96cff720e switch to on-demand download script as the recommended way to get CPM.cmake (#147) 2020-08-20 10:31:08 +02:00
Lars Melchior
c3c7e2d9a3 add on-demand download script to release (#146) v0.27.3 2020-08-20 09:32:03 +02:00
Lars Melchior
30b98af416 Add link to tutorial (#143) 2020-08-12 13:41:40 +02:00
Lars Melchior
5063c7d992 Add built with CPM.cmake section (#142)
* add built with cpm.cmake section

* update text

* explicitly set width
2020-08-11 14:49:21 +02:00
Lars Melchior
3cfb309f3c add comparisons to other approaches (#141) 2020-08-11 12:49:37 +02:00
Lars Melchior
25603ac4ad Update publish script to set CPM.cmake version automatically (#139)
* update publish script to set CPM.cmake version automatically

* set a minimum development version to avoid deprecated error handler call
2020-08-04 13:12:35 +02:00
Lars Melchior
ac872f6908 Bump version and add gitlab source to examples (#138)
* use gitlab as source for example library

* bump CPM.cmake version
v0.27.2
2020-08-04 12:24:06 +02:00
jecassis
bd14ccbd5a Fix indeterminate command for GitLab argument (#137) 2020-08-04 11:40:58 +02:00