Commit Graph

39 Commits

Author SHA1 Message Date
Craig Scott
e5a9ccbcc8 project: Always set <PROJECT-NAME>_* as normal variables
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
2024-10-08 10:07:11 -04:00
Craig Scott
fa07ddfebf project: Only check non-cache vars when setting project vars
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
2024-10-07 10:24:37 -04:00
Craig Scott
86ad7cc886 project: Only define non-cache vars if already defined
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
2024-09-20 10:33:25 -04:00
Craig Scott
4c152752da Help: State valid scopes for using proj_SOURCE_DIR and proj_BINARY_DIR
Issue: #25714
2024-09-20 10:33:25 -04:00
Craig Scott
dcb894fb00
Help: Update project() code injection for new 3.29 include behavior
Specifically, the various CMAKE_PROJECT_...INCLUDE... variables can
now take a list of things, and those things can be module names
too, not just file names.
2024-03-16 17:43:25 +11:00
Brad King
9dd2dd5b77 Help: Restore project command docs for default languages and NONE
In commit b787be2714 (Help: Update supported languages in project and
enable_language, 2023-01-20, v3.26.0-rc1~53^2) the relevant paragraph
was accidentally moved to the `enable_language` command documentation.

Fixes: #25016
2023-06-22 13:12:24 -04:00
Robert Maynard
b787be2714 Help: Update supported languages in project and enable_language 2023-01-20 13:55:38 -05:00
friendlyanon
59573bf5b9 project: Warn at top-level if cmake_minimum_required wasn't called
The top-level project() call will now issue an AUTHOR_WARNING if it
wasn't called after cmake_minimum_required().

Fixes: #24071
2022-11-11 22:49:36 +01:00
Craig Scott
a6c34b0353 project(): Add new CMAKE_PROJECT_TOP_LEVEL_INCLUDES file injection point
Fixes: #22685
2022-05-13 18:03:36 +10:00
Robert Maynard
b50bfc8913 HIP: Add language to CMake 2021-06-07 19:25:33 +00:00
friendlyanon
96a7040107 project: Define variables indicating whether project is top level
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
2021-03-26 09:35:34 -04:00
Brad King
3706e9c97c Help: Convert project() directory variables to a definition list 2021-03-26 09:34:18 -04:00
Nikita Nemkin
5000f93a91 Help: Fix grammar in .. versionadded directives
Issue: #19715
2020-12-02 21:00:31 +05:00
Nikita Nemkin
ea59b0cd34 Help: Fix version note for CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE
This variable predates 3.0.

Fixes: #21522
2020-12-02 21:00:29 +05:00
Nikita Nemkin
c705279bae Help: Add .. versionadded directives to commands documentation
This change ony concerns directives that appear in the document body.

The guidelines for inserting version directives:

 * Baseline version is CMake 3.0, i.e. directives start at 3.1.
 * Always use `.. versionadded::` directive, avoid ad-hoc version
   references. Exception: policy pages.
 * For new command signatures, put `versionadded` on a separate line
   after the signature.
 * For a group of new signatures in a new document section,
   a single version note at the beginning of the section is sufficient.
 * For new options, put `versionadded` on a separate line before
   option description.
 * If all the option descriptions in the list are short one-liners,
   it's fine to put `versionadded` on the same line as the description.
 * If multiple option descriptions in close proximity would have
   the same ..versionadded directive, consider adding a single
   directive after the list, mentioning all added options.
 * For compact value lists and sub-option lists, put a single
  `versionadded` directive after the list mentioning all additions.
 * When a change is described in a single paragraph, put
   `versionadded` into that paragraph.
 * When only part of the paragraph has changed, separate the changed
   part if it doesn't break the flow. Otherwise, write a follow-up
   clarification paragraph and apply version directive to that.
 * When multiple version directives are close by, order earlier
   additions before later additions.
 * Indent related lists and code blocks to include them in the scope
   of `versionadded` directive.

Issue: #19715
2020-11-09 20:51:57 +05:00
Robert Maynard
8976817d6d ISPC: Update help documentation to include ISPC 2020-08-28 11:21:31 -04:00
Deniz Bahadir
f7acc1266c project: Add variable CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE
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
2019-10-18 14:44:24 -04:00
Steve Wilson
9e66397c28 Languages: Add support for Objective-C++
Add entries in Modules and Modules/Platform to support
Objective-C++ compiler determination and identification.
Add Modules to check Objective-C++ compiler flags, source
compilations, program checks, etc...

Use OBJCXX as the designator of the language, eg:

project(foo OBJCXX)

Add various tests for Objective-C++ language features.  Add
tests to preserve C++ handling of .M and .mm files when
Objective-C++ is not a configured language.

Co-authored-by: Cristian Adam <cristian.adam@gmail.com>
2019-09-28 15:56:53 +02:00
Steve Wilson
80f120a85f Languages: Add support for Objective-C
Add entries in Modules and Modules/Platform to support
Objective-C compiler determination and identification.
Add Modules to check Objective-C compiler flags, source
compilations, program checks, etc...

Use OBJC as the designator of the language, eg:

project(foo OBJC)

Add various tests for Objective-C language features.  Add
tests to preserve C++ handling of .m and .mm files when
OBJC is not a configured language.

Co-Authored-By: Cristian Adam <cristian.adam@gmail.com>
2019-09-28 15:56:46 +02:00
Craig Scott
42294f43bd Help: move code injection vars to their own section
The docs for CMAKE_PROJECT_<projName>_INCLUDE and
CMAKE_PROJECT_INCLUDE did not define the order of
inclusion if both were set.
2019-07-01 08:01:49 +10:00
Craig Scott
9e0775cb6a Help: Remove self-references from project() docs 2019-06-29 22:21:18 +10:00
Bartosz Kosiorek
1527defbfe cmMakefile: Enforce explicit use of project() command
Fixes: 17714
2019-05-06 10:58:10 +02:00
Ruslan Baratov
0761186949 project: Add variable CMAKE_PROJECT_INCLUDE_BEFORE 2019-04-01 20:30:19 +03:00
Ruslan Baratov
dda0190458 project: Add variable CMAKE_PROJECT_INCLUDE 2019-03-27 22:39:02 +03:00
Joachim Wuttke (o)
2f43bd3b6c Help: move description of CMAKE_PROJECT_* variables
Describe these variables along with the other variables.
2018-10-09 15:28:53 +02:00
Joachim Wuttke (l)
e3e5445d83 Help: Describe options of command project in a definition list.
Also add section headers;
explain default setting of optional argument variables.
2018-10-09 14:29:57 +02:00
Joachim Wuttke (l)
5b56795d57 Help: make the two signatures of command "project" orthogonal 2018-10-09 14:22:09 +02:00
Craig Scott
f8a086a86b project(): Ensure DESCRIPTION and HOMEPAGE_URL variables are set
If a project() call does not have DESCRIPTION or HOMEPAGE_URL
options, it must still set the relevant variables or else those variables will
inherit values from an earlier project() call. That is inconsistent with how
VERSION is handled and is likely to be unexpected. The docs were also
ambiguous about what should happen in such cases.
2018-10-08 08:28:17 +11:00
Alex Turbov
af1c48871c CPack: Use project version as default for CPACK_PACKAGE_VERSION
* Introduce `CMAKE_PROJECT_VERSION` and the corresponsing components:
  `CMAKE_PROJECT_VERSION_MAJOR`, `CMAKE_PROJECT_VERSION_MINOR`,
  `CMAKE_PROJECT_VERSION_PATCH` and `CMAKE_PROJECT_VERSION_TWEAK`.

* `CPack` module use `CMAKE_PROJECT_VERSION_MAJOR`,
  `CMAKE_PROJECT_VERSION_MINOR` and `CMAKE_PROJECT_VERSION_PATCH`
  to initialize corresponsing CPack variables.
2018-05-03 08:26:03 +10:00
Alex Turbov
73f9b2974c project: Add HOMEPAGE_URL named parameter
This sets variables like PROJECT_HOMEPAGE_URL, which can be
used as default values for various things (packaging modules,
doxygen defaults, etc.). Some packaging modules have been
updated to do this as part of this commit.

Co-Author: Craig Scott <craig.scott@crascit.com>
2018-03-17 08:25:48 +11:00
Craig Scott
fd28c382b4 project: Add <PROJECT-NAME>_DESCRIPTION
For consistency with the VERSION keyword, also define the
<PROJECT-NAME>_DESCRIPTION variable.
2018-03-17 08:25:48 +11:00
Craig Scott
6a2a9d107d Help: Fix incorrect CMAKE_PROJECT_xxx docs
The docs for CMAKE_PROJECT_NAME and CMAKE_PROJECT_DESCRIPTION
were erroneously documenting the behavior of PROJECT_NAME and
PROJECT_DESCRIPTION respectively. Fix these and update the
project() docs to also mention CMAKE_PROJECT_NAME and
CMAKE_PROJECT_DESCRIPTION.

Fixes: #17815
2018-03-14 07:33:38 +11:00
Brad King
6ecd8b601b Help: Document that ASM should be enabled last
ASM should be enabled after C and/or CXX because we consider the
compilers for those languages as possible assemblers.

Issue: #17532
2017-12-06 06:48:06 -05:00
Alex Turbov
3b4848717a project: Add DESCRIPTION parameter
It is quite often the project description has used in a real world software.
Examples include:

* part of a help screen of the application
* builtin resources (`*.rc` files, data for "About" dialog of a GUI app, & etc)
* most generators for CPack can use it
* it could be used by documentary software (Doxygen, Sphinx) which is usually
  integrated to CMake based projects via `add_custom_target()`

Now `project()` call learned an optional `DESCRIPTION` parameter with a
short string describing a project. Being specified, it would set the
`PROJECT_DESCRIPTION` variable which could be used in `configure_file()`
or whatever user wants.  Also `PROJECT_DESCRIPTION` is a default value
for `CPACK_PACKAGE_DESCRIPTION_SUMMARY`.
2017-04-11 10:17:00 -04:00
Brad King
6ac3712da0 Help: Document that cmake_minimum_required should be called first
Many projects put their project() call first, but the actions taken
by this command can be influenced by policies and other information
set by a call to cmake_minimum_required.  Document in each of these
two commands that cmake_minimum_required should be called first.

Suggested-by: Alan W. Irwin
2015-04-29 08:49:59 -04:00
Brad King
7e142c5ac2 project: Manage VERSION variables
Teach the project() command to set variables

  {PROJECT,<PROJECT-NAME>}_VERSION{,_MAJOR,_MINOR,_PATCH,_TWEAK}

holding the project version number and its components.  Add project()
command option "VERSION" to specify the version explicitly, and default
to the empty string when it is not given.

Since this clears variables when no VERSION is given, this may change
behavior for existing projects that set the version variables themselves
prior to calling project().  Add policy CMP0048 for compatibility.

Suggested-by: Alex Neundorf <neundorf@kde.org>
2014-01-29 09:45:18 -05:00
Brad King
16d040c958 project: Add optional LANGUAGES keyword
Teach the project() command to recognize an optional "LANGUAGES"
keyword after the project name and prior to the list of languages.
Do not allow multiple copies of the keyword.  If the keyword is
specified and no languages are listed, imply NONE.
2014-01-29 09:40:51 -05:00
Brad King
00007dcc36 Help: Format project command and variable documentation
Also add document for CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE variable.
2014-01-29 09:15:20 -05:00
Kitware Robot
f051814ed0 Convert builtin help to reStructuredText source files
Run the convert-help.bash script to convert documentation:

 ./convert-help.bash "/path/to/CMake-build/bin"

Then remove it.
2013-10-15 14:12:03 -04:00