summaryrefslogtreecommitdiffstats
path: root/Source/cmProjectCommand.cxx
Commit message (Collapse)AuthorAgeFilesLines
* Merge topic 'project-version-fix'Brad King2025-09-031-5/+35
|\ | | | | | | | | | | | | | | aa16b8eb9a project: Revert changes to VERSION handling Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !11131
| * project: Revert changes to VERSION handlingVito Gamberini2025-09-021-5/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In c4d12d7d we changed how the project command handles various variables and made the behavior consistent across all variables controlled by the project command. The conditions under which project() modifies the various VERSION variables are non-intuitive, but can be observed as side-effects. Because this behavior is observable, it requires a policy to be changed. This commit reverts to the previous behavior until a policy is added and adds a test for that behavior. Fixes: #27142
* | Merge topic 'keyword-project-name-fix'Brad King2025-07-091-16/+26
|\ \ | |/ | | | | | | | | | | | | | | a38e594340 project: fix keyword argument as project name 7238c8c999 ArgumentParser: implement HasKeyword helper Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !10935
| * project: fix keyword argument as project nameVito Gamberini2025-07-081-16/+26
| | | | | | | | Fixes: #27051
* | project: Add SPDX_LICENSE argumentMatthew Woehlke2025-06-201-2/+5
|/ | | | | | | | | | Add an argument to the `project` command to allow specifying a license for a project as a whole. This is in addition to specifying licenses on individual targets, and will be used to set the license(s) on exported packages. Also, move listing of `COMPAT_VERSION` variables to follow lexicographical order.
* project: Always set COMPAT_VERSION variablesMatthew Woehlke2025-06-101-4/+1
| | | | | | | | Modify the project command to always set COMPAT_VERSION variables, not just if experimental CPS export support is enabled. This ensures that these values are (at least as of the call to the project command) empty and cannot be "preset" e.g. by command line arguments in the case that experimental support is enabled after the project command is called.
* project: Fix handling of COMPAT_VERSIONMatthew Woehlke2025-05-281-1/+1
| | | | | | | In cmProjectCommand, after validating the VERSION, we move it into a local variable. Later, however, we were comparing COMPAT_VERSION against the VERSION stored in the arguments. Compare to the local variable instead.
* project: add COMPAT_VERSION keywordVito Gamberini2025-04-251-15/+55
| | | | Fixes: #26893
* project: cleanup variable creationVito Gamberini2025-04-231-76/+18
|
* project: use argument parserVito Gamberini2025-04-181-168/+125
|
* LICENSE: Replace references to Copyright.txt with LICENSE.rstKitware Robot2025-03-031-1/+1
| | | | | | | | | | ``` git grep -lz 'Copyright.txt or https://cmake.org/licensing ' | while IFS= read -r -d $'\0' f ; do sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / { s/Copyright.txt/LICENSE.rst/ }' "$f" ; done ```
* Revise C++ coding style using clang-format with "east const"Kitware Robot2025-01-231-4/+4
| | | | | | | | | | | | | | | Run the `clang-format.bash` script to update all our C and C++ code to a new style defined by `.clang-format`, now with "east const" enforcement. Use `clang-format` version 18. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit. Issue: #26123
* CMP0048: Remove support for OLD behaviorBrad King2025-01-191-29/+2
|
* project: Always set <PROJECT-NAME>_* as normal variablesCraig Scott2024-10-081-3/+5
| | | | | | | | | | Re-introduce the behavior originally introduced in CMake 3.30.3 by commit c1ece78d11 (project: non cache <project> prefix variables are also created, 2024-08-27, v3.30.3~2^2), but this time with a policy for compatibility. Issue: #25714 Issue: #26243
* project: Only check non-cache vars when setting project varsCraig Scott2024-10-071-3/+3
| | | | | | | | | | | | | | The change in commit 86ad7cc886 (project: Only define non-cache vars if already defined, 2024-09-15, v3.30.4~2^2) was meant to only check for non-cache variables when deciding whether to set non-cache project variables for the current call. However, it erroneously checked for any variable, including cache variables. This gives the intended result on the first run, but on subsequent runs a cache variable will exist that did not on the first run, leading to different behavior between the two runs. Fix the logic to only check for a pre-existing non-cache variable, as was originally intended. Fixes: #26355
* project: Only define non-cache vars if already definedCraig Scott2024-09-201-12/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In c1ece78d11 (project: non cache <project> prefix variables are also created, 2024-08-27), we started explicitly setting the non-cache variable for <projectName>_SOURCE_DIR, <projectName>_BINARY_DIR, and <projectName>_IS_TOP_LEVEL in addition to setting them as cache variables. This changed the behavior when a project name was used more than once, and the second project call happens in the same scope or a child scope of the first. Previously, the first project call would set cache variables, and the second project call would not overwrite those cache variables. With the change in c1ece78d11, after the second project call the non-cache variables would mask the cache variables and the project code would see a different value to what it did before. Setting the non-cache variable was added to handle the case where a call to FetchContent_MakeAvailable() would set some non-cache variables, and it just so happened those matched the same cache variables that the project() command would set in the project being fetched. The fetched project would then see a different set of project-specific variables compared to when it was built standalone. This commit here narrows the change from c1ece78d11 such that the non-cache variable is only set by project() if there was already a non-cache variable set. This still fixes the motivating problem c1ece78d11 was intended to solve, but it avoids changing the variable values seen by a project that re-uses the same project name in related scopes. Issue: #26243, #25714 Fixes: #26281
* project: non cache <project> prefix variables are also createdRobert Maynard2024-08-271-0/+7
| | | | Fixes #26243, #25714
* CMAKE_PROJECT_INCLUDE: Allow to run module filesCristian Le2023-10-181-1/+15
| | | | Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
* CMAKE_PROJECT_INCLUDE: Add support for including multiple filesCristian Le2023-10-181-19/+32
| | | | | Fixes: #25341 Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
* IWYU: Update for Debian 12 CI jobBrad King2023-07-281-1/+0
| | | | | | `include-what-you-use` diagnostics, in practice, are specific to the environment's compiler and standard library. Update includes to satisfy IWYU for our CI job under Debian 12.
* project: Warn at top-level if `cmake_minimum_required` wasn't calledfriendlyanon2022-11-111-0/+9
| | | | | | | The top-level project() call will now issue an AUTHOR_WARNING if it wasn't called after cmake_minimum_required(). Fixes: #24071
* cmSystemTools: Fix 'ErrorOccurred' spellingFeRD (Frank Dana)2022-06-131-8/+8
| | | | | | | | Rename the booleans 's_ErrorOccured' and 's_FatalErrorOccured' to 's_ErrorOccurred' and 's_FatalErrorOccurred', respectively. Rename the getters and setters to 'Get[Fatal]ErrorOccurred' and 'Set[Fatal]ErrorOccurred', and fix all uses across the codebase.
* clang-tidy: address `google-readability-casting` lintsBen Boeckel2022-05-241-2/+2
| | | | At least those involving `static_cast`.
* Source: Replace most calls to sprintf with snprintfSean McBride2021-10-251-3/+4
|
* Rename cmProp in cmValueMarc Chevrier2021-09-211-3/+3
|
* CMP0126: Add control for warningsMarc Chevrier2021-06-291-2/+2
| | | | Fixes: #22353
* project: Define variables indicating whether project is top levelfriendlyanon2021-03-261-0/+5
| | | | | | | | | Define `PROJECT_IS_TOP_LEVEL` and `<PROJECT-NAME>_IS_TOP_LEVEL`. The latter is a STATIC cache entry just like other `<PROJECT-NAME>_*` variables so that it is globally scoped. Issue: #20310 Fixes: #21961
* include: refactor call sites of cmMakefile::ReadDependentFileAsit Dhal2020-10-211-1/+12
| | | | Fixes: #16773
* cmMakefile::GetDefinition: return cmPropVitaly Stakhovsky2020-09-021-4/+5
|
* Source: use cmNonempty()Vitaly Stakhovsky2020-07-281-1/+1
|
* cmMakefile::AddCacheDefinition: Add overload that accepts std::string valueVitaly Stakhovsky2020-03-111-4/+4
|
* Merge topic 'project-version-buffer-overflow'Craig Scott2019-10-281-1/+2
|\ | | | | | | | | | | | | | | 82cdb26c93 project: Fix potential buffer write-past-end for version components 15a0b0d046 Help: math() expressions must be representable as signed 64-bit Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3948
| * project: Fix potential buffer write-past-end for version componentsCraig Scott2019-10-261-1/+2
| | | | | | | | This fixes two errors: not accounting for the trailing null and a misunderstanding of what std::numeric_limits::digits10 means.
* | project: Add variable CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFOREDeniz Bahadir2019-10-181-0/+5
|/ | | | | | | | | | Follow up commit 0761186949 (project: Add variable CMAKE_PROJECT_INCLUDE_BEFORE, 2019-03-28, v3.15.0-rc1~294^2) with a project-specific variant. This variable will be used similar to the already existing `CMAKE_PROJECT_INCLUDE_BEFORE` and `CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE` variables. Fixes: #19854
* Revise include order using clang-format-6.0Kitware Robot2019-10-011-1/+2
| | | | | Run the `clang-format.bash` script to update our C and C++ code to a new include order `.clang-format`. Use `clang-format` version 6.0.
* cmProjectCommand: Port away from cmCommandRegina Pfeifer2019-09-211-104/+92
|
* Refactor: Use cmStrCat to construct error stringsAsit Dhal2019-09-181-5/+4
| | | | | Replace string construction using std::stringstream with cmStrCat and cmWrap.
* IWYU: Add missing cstddef includes for size_t and nullptr_tBrad King2019-09-031-0/+1
| | | | The IWYU tool we use for CI now diagnoses these.
* Source sweep: Use cmStrCat for string concatenationSebastian Holtermann2019-08-221-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is generated by a python script that uses regular expressions to search for string concatenation patterns of the kind ``` std::string str = <ARG0>; str += <ARG1>; str += <ARG2>; ... ``` and replaces them with a single `cmStrCat` call ``` std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...); ``` If any `<ARGX>` is itself a concatenated string of the kind ``` a + b + c + ...; ``` then `<ARGX>` is split into multiple arguments for the `cmStrCat` call. If there's a sequence of literals in the `<ARGX>`, then all literals in the sequence are concatenated and merged into a single literal argument for the `cmStrCat` call. Single character strings are converted to single char arguments for the `cmStrCat` call. `std::to_string(...)` wrappings are removed from `cmStrCat` arguments, because it supports numeric types as well as string types. `arg.substr(x)` arguments to `cmStrCat` are replaced with `cm::string_view(arg).substr(x)`
* cmStringAlgorithms: Move string functions to the new cmStringAlgorithms.hSebastian Holtermann2019-07-291-1/+1
| | | | | This adds the `cmStringAlgorithms.h` header and moves all string functions from `cmAlgorithms.h` to `cmStringAlgorithms.h`.
* cmMakefile: Let AddDefinition accept a value as cm::string_viewSebastian Holtermann2019-07-241-22/+20
| | | | | | | | | | | | | | | | This changes `cmMakefile::AddDefinition` to take a `cm::string_view` as value argument instead of a `const char *`. Benefits are: - `std::string` can be passed to `cmMakefile::AddDefinition` directly without the `c_str()` plus string length recomputation fallback. - Lengths of literals passed to `cmMakefile::AddDefinition` can be computed at compile time. In various sources uses of `cmMakefile::AddDefinition` are adapted to avoid `std::string::c_str` calls and the `std::string` is passed directly. Uses of `cmMakefile::AddDefinition`, where a `nullptr` `const char*` might be passed to `cmMakefile::AddDefinition` are extended with `nullptr` checks.
* project: Keep leading `0` in PROJECT_VERSION componentsAlex Turbov2019-07-161-28/+56
| | | | | | | | | Introduce CMake policy `CMP0096` to make `project()` keep leading zeros in version components. As a side effect, it now allows really long version numbers. Fixes: #19421 Co-Author: Brad King <brad.king@kitware.com>
* Refactor: Use raw string literals instead of escapingAlex Turbov2019-07-151-1/+1
|
* Refactor: Use initializer lists instead of `push_back` seriesAlex Turbov2019-07-151-13/+11
|
* Refactor: Add some `const` to varsAlex Turbov2019-07-151-3/+3
|
* Refactor: Replace a "magic" number w/ a named constantAlex Turbov2019-07-151-4/+5
|
* Refactor: Eliminate one-time-used variablesAlex Turbov2019-07-151-12/+6
|
* Refactor: Eliminate `sep` from the loopAlex Turbov2019-07-151-3/+1
|
* Merge topic 'pr.projectbefore'Brad King2019-04-041-0/+4
|\ | | | | | | | | | | | | 0761186949 project: Add variable CMAKE_PROJECT_INCLUDE_BEFORE Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3175
| * project: Add variable CMAKE_PROJECT_INCLUDE_BEFORERuslan Baratov2019-04-011-0/+4
| |