mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
cmTarget: Don't crash on empty IMPORTED_CONFIGURATIONS
The logic to select an imported configuration handled the case when `IMPORTED_CONFIGURATIONS` was missing, but assumed that if it was present, it was non-empty, which could cause CMake to crash if that happens. (To be fair, I believe this would never happen for imports generated by CMake.) Adjust the logic slightly to follow the same code path when `IMPORTED_CONFIGURATIONS` is empty as is taken if it's missing. Fixes: #28065
This commit is contained in:
+2
-1
@@ -3580,7 +3580,8 @@ bool cmTarget::GetMappedConfigNew(std::string desiredConfig, cmValue& loc,
|
||||
}
|
||||
|
||||
// Get imported configurations, if specified.
|
||||
if (cmValue iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) {
|
||||
cmValue const iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS");
|
||||
if (!iconfigs.IsEmpty()) {
|
||||
cmList const availableConfigs{ cmSystemTools::UpperCase(*iconfigs) };
|
||||
|
||||
if (!mappedConfigs.empty()) {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,6 @@
|
||||
(CMake Error in CMakeLists.txt:
|
||||
IMPORTED_LOCATION not set for imported target "imported"( configuration
|
||||
"[A-Za-z]+")?\.
|
||||
|
||||
)+
|
||||
CMake Generate step failed\. Build files cannot be regenerated correctly\.
|
||||
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 4.4)
|
||||
project(empty_imported_configuration NONE)
|
||||
|
||||
add_library(imported UNKNOWN IMPORTED)
|
||||
set_property(TARGET imported PROPERTY IMPORTED_CONFIGURATIONS "")
|
||||
|
||||
file(GENERATE OUTPUT out.txt CONTENT "$<TARGET_FILE:imported>")
|
||||
@@ -160,6 +160,8 @@ run_cmake_build(CMP0200-NEW)
|
||||
|
||||
run_cmake_build(CMP0199-NEW+CMP0200-NEW)
|
||||
|
||||
run_cmake(Empty-IMPORTED_CONFIGURATIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0085:STRING=OLD)
|
||||
run_cmake(CMP0085-OLD)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
Reference in New Issue
Block a user