From 0b73f017031b8520a17db17e193acbc936a0a224 Mon Sep 17 00:00:00 2001 From: Steffen Olszewski Date: Fri, 20 Oct 2023 19:13:54 +0200 Subject: [PATCH] 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. --- cmake/project.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/project.cmake b/cmake/project.cmake index 9b7ed689..7eb29aa4 100644 --- a/cmake/project.cmake +++ b/cmake/project.cmake @@ -74,28 +74,28 @@ function(set_target_source_groups arg_TARGET) endif() endforeach() - set(filterSources ${sourceFiles}) + set(filterSources "${sourceFiles}") list(FILTER filterSources INCLUDE REGEX "/.+\\.h(h|pp)?$") source_group( TREE "${sourceTreeDir}" PREFIX "Header Files" FILES ${filterSources} ) - set(filterSources ${sourceFiles}) + set(filterSources "${sourceFiles}") list(FILTER filterSources INCLUDE REGEX "/.+\\.h(h|pp)?\\.in$") source_group( TREE "${sourceTreeDir}" PREFIX "Header Templates" FILES ${filterSources} ) - set(filterSources ${sourceFiles}) + set(filterSources "${sourceFiles}") list(FILTER filterSources INCLUDE REGEX "/.+\\.c(c|xx|pp)?$") source_group( TREE "${sourceTreeDir}" PREFIX "Source Files" FILES ${filterSources} ) - set(filterSources ${sourceFiles}) + set(filterSources "${sourceFiles}") list(FILTER filterSources INCLUDE REGEX "/.+\\.c(c|xx|pp)?\\.in$") source_group( TREE "${sourceTreeDir}" @@ -103,7 +103,7 @@ function(set_target_source_groups arg_TARGET) FILES ${filterSources} ) - set(filterSources ${binaryFiles}) + set(filterSources "${binaryFiles}") source_group( TREE "${binaryTreeDir}" PREFIX "Generated Files"