mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 10:50:16 -06:00
Genex: Restore REMOVE_DUPLICATES preservation of empty elements
Refactoring in commit 72d116ee68 (GenEx: list oriented genexes use
cmList class, 2023-03-29, v3.27.0-rc1~205^2) accidentally caused
empty elements to be dropped by the `REMOVE_DUPLICATES` genex.
Fix it and add a test case.
Fixes: #25080
This commit is contained in:
@@ -384,7 +384,9 @@ static const struct RemoveDuplicatesNode : public cmGeneratorExpressionNode
|
||||
"$<REMOVE_DUPLICATES:...> expression requires one parameter");
|
||||
}
|
||||
|
||||
return cmList{ parameters.front() }.remove_duplicates().to_string();
|
||||
return cmList{ parameters.front(), cmList::EmptyElements::Yes }
|
||||
.remove_duplicates()
|
||||
.to_string();
|
||||
}
|
||||
|
||||
} removeDuplicatesNode;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content)
|
||||
|
||||
set(expected "1;;2;3")
|
||||
if(NOT content STREQUAL expected)
|
||||
set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
|
||||
endif()
|
||||
@@ -0,0 +1,3 @@
|
||||
cmake_policy(VERSION 3.11)
|
||||
|
||||
file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:1$<SEMICOLON>$<SEMICOLON>2$<SEMICOLON>$<SEMICOLON>3>")
|
||||
@@ -36,6 +36,7 @@ run_cmake(TARGET_NAME_IF_EXISTS-alias-target)
|
||||
run_cmake(TARGET_NAME_IF_EXISTS-imported-target)
|
||||
run_cmake(TARGET_NAME_IF_EXISTS-imported-global-target)
|
||||
run_cmake(REMOVE_DUPLICATES-empty)
|
||||
run_cmake(REMOVE_DUPLICATES-empty-element)
|
||||
run_cmake(REMOVE_DUPLICATES-1)
|
||||
run_cmake(REMOVE_DUPLICATES-2)
|
||||
run_cmake(REMOVE_DUPLICATES-3)
|
||||
|
||||
Reference in New Issue
Block a user