Prevent unintended removal of local CMake variables

Without quotes list expansion happens inside the set-call, if the list is empty,
this actually unsets the variable. This is not intended and could lead to
unwanted side effects. List expansion is not required there, quoting the
variable results in setting the variable to empty for empty lists.
This commit is contained in:
Steffen Olszewski 2023-10-20 19:13:54 +02:00
parent b85a565351
commit 0b73f01703

View File

@ -74,28 +74,28 @@ function(set_target_source_groups arg_TARGET)
endif() endif()
endforeach() endforeach()
set(filterSources ${sourceFiles}) set(filterSources "${sourceFiles}")
list(FILTER filterSources INCLUDE REGEX "/.+\\.h(h|pp)?$") list(FILTER filterSources INCLUDE REGEX "/.+\\.h(h|pp)?$")
source_group( source_group(
TREE "${sourceTreeDir}" TREE "${sourceTreeDir}"
PREFIX "Header Files" PREFIX "Header Files"
FILES ${filterSources} FILES ${filterSources}
) )
set(filterSources ${sourceFiles}) set(filterSources "${sourceFiles}")
list(FILTER filterSources INCLUDE REGEX "/.+\\.h(h|pp)?\\.in$") list(FILTER filterSources INCLUDE REGEX "/.+\\.h(h|pp)?\\.in$")
source_group( source_group(
TREE "${sourceTreeDir}" TREE "${sourceTreeDir}"
PREFIX "Header Templates" PREFIX "Header Templates"
FILES ${filterSources} FILES ${filterSources}
) )
set(filterSources ${sourceFiles}) set(filterSources "${sourceFiles}")
list(FILTER filterSources INCLUDE REGEX "/.+\\.c(c|xx|pp)?$") list(FILTER filterSources INCLUDE REGEX "/.+\\.c(c|xx|pp)?$")
source_group( source_group(
TREE "${sourceTreeDir}" TREE "${sourceTreeDir}"
PREFIX "Source Files" PREFIX "Source Files"
FILES ${filterSources} FILES ${filterSources}
) )
set(filterSources ${sourceFiles}) set(filterSources "${sourceFiles}")
list(FILTER filterSources INCLUDE REGEX "/.+\\.c(c|xx|pp)?\\.in$") list(FILTER filterSources INCLUDE REGEX "/.+\\.c(c|xx|pp)?\\.in$")
source_group( source_group(
TREE "${sourceTreeDir}" TREE "${sourceTreeDir}"
@ -103,7 +103,7 @@ function(set_target_source_groups arg_TARGET)
FILES ${filterSources} FILES ${filterSources}
) )
set(filterSources ${binaryFiles}) set(filterSources "${binaryFiles}")
source_group( source_group(
TREE "${binaryTreeDir}" TREE "${binaryTreeDir}"
PREFIX "Generated Files" PREFIX "Generated Files"