Files
CMake/Tests/RunCMake/project/RunCMakeTest.cmake
T
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

72 lines
2.1 KiB
CMake

include(RunCMake)
# Use an initial cache file to define the project() variables
# to avoid long command lines. Also see the CMakeOnly test case
# which tests some of the individual variables one at a time.
# Here, we are focused on testing that the variables are all injected
# at the expected points in the expected order.
run_cmake_with_options(CodeInjection1
-C "${CMAKE_CURRENT_LIST_DIR}/CodeInjection/initial_cache_1.cmake"
)
# This checks that List variables are allowed.
run_cmake_with_options(CodeInjection2
-C "${CMAKE_CURRENT_LIST_DIR}/CodeInjection/initial_cache_2.cmake"
)
# This checks that module names are also allowed.
run_cmake_with_options(CodeInjection3
-C "${CMAKE_CURRENT_LIST_DIR}/CodeInjection/initial_cache_3.cmake"
)
if(CMake_TEST_RESOURCES)
run_cmake(ExplicitRC)
endif()
set(RunCMake_DEFAULT_stderr .)
run_cmake(LanguagesDuplicate)
unset(RunCMake_DEFAULT_stderr)
run_cmake(LanguagesImplicit)
run_cmake(LanguagesEmpty)
run_cmake(LanguagesNONE)
run_cmake(LanguagesTwice)
run_cmake(LanguagesUnordered)
if(RunCMake_GENERATOR MATCHES "Make|Ninja")
run_cmake(LanguagesUsedButNotEnabled)
endif()
run_cmake(ProjectCMP0126)
run_cmake(ProjectDescription)
run_cmake(ProjectDescription2)
run_cmake(ProjectDescriptionNoArg)
run_cmake(ProjectDescriptionNoArg2)
run_cmake(ProjectHomepage)
run_cmake(ProjectHomepage2)
run_cmake(ProjectHomepageNoArg)
run_cmake(ProjectIsTopLevel)
run_cmake(ProjectIsTopLevelMultiple)
run_cmake(ProjectIsTopLevelSubdirectory)
run_cmake(ProjectTwice)
run_cmake(VersionAndLanguagesEmpty)
run_cmake(VersionEmpty)
run_cmake(VersionInvalid)
run_cmake(VersionMissingLanguages)
run_cmake(VersionMissingValueOkay)
run_cmake(VersionTwice)
run_cmake(VersionMax)
run_cmake(CMP0048-OLD)
run_cmake(CMP0048-OLD-VERSION)
run_cmake(CMP0048-WARN)
run_cmake(CMP0048-NEW)
run_cmake(CMP0096-WARN)
run_cmake(CMP0096-OLD)
run_cmake(CMP0096-NEW)
# We deliberately run these twice to verify behavior of the second CMake run
run_cmake(SameProjectVarsSubdir)
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake(SameProjectVarsSubdir)
set(RunCMake_TEST_NO_CLEAN 0)
run_cmake(NoMinimumRequired)