CMake/Help
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
..
command project: Only define non-cache vars if already defined 2024-09-20 10:33:25 -04:00
cpack_gen Help: CPack/NuGet avoid deprecated variables in the usage example 2024-06-17 11:57:18 -04:00
dev importstd: clarify when the experimental UUID must be available 2024-05-15 07:15:05 -04:00
envvar Drop Visual Studio 9 2008 generator 2024-05-08 10:37:34 -04:00
generator Merge topic 'ninja-parallel' 2024-05-24 10:29:57 -04:00
guide Tutorial: Fix grammar typo in Step 11 2024-05-17 11:25:39 -04:00
include
manual Help: Move deprecated modules and variables to dedicated sections 2024-07-15 16:55:38 -04:00
module Help:Check*: include CMAKE_REQUIRED_* vars to dedupe 2023-03-14 16:48:25 -04:00
policy Help: Minor grammar and formatting cleanup 2024-06-14 16:19:28 +10:00
prop_cache
prop_dir Merge topic 'doc-add_subdirectory-EXCLUDE_FROM_ALL' into release-3.30 2024-06-06 08:41:58 -04:00
prop_gbl Help: Minor grammar and formatting cleanup 2024-06-14 16:19:28 +10:00
prop_inst Help: Convert http URLs to https 2024-03-07 09:42:45 -05:00
prop_sf Drop Visual Studio 9 2008 generator 2024-05-08 10:37:34 -04:00
prop_test add_test: Optionally use a launcher for tests running in-project targets 2023-12-13 10:20:43 -05:00
prop_tgt Merge topic 'doc-swift-module-dir-caveat' 2024-05-29 08:32:08 -04:00
release CMake 3.30.3 2024-08-29 15:37:11 -04:00
variable Link feature attributes: stabilization 2024-06-21 11:18:20 +02:00
index.rst Help: add a manpage for cxxmodule support 2023-10-02 10:17:31 -04:00