Generator expression regression in CMake 3.23
Between CMake 3.22.0 and CMake 3.23.0-rc1, we get inconsistent results for the following:
cmake_minimum_required(VERSION 3.22)
project(CMakeBug CXX)
add_library(test-iface INTERFACE)
set(TEST_FLAG1 1)
target_link_libraries(
test-iface
INTERFACE
$<${TEST_FLAG1}: -fsanitize=address -static-libasan>
)
add_executable(test test.cpp)
target_link_libraries(test test-iface)
With CMake 3.22.0, we would see the -fsanitize=address -static-libasan
flags enabled and disabled depending on the value of TEST_FLAG1
.
With CMake 3.23.0-rc1, we get errors like:
ninja: error: build.ninja:1378: bad $-escape (literal $ must be written as $$)
I suspect this has something to do with a change in when generator expressions are expanded. Or maybe the above isn't supposed to be valid CMake but it accidentally worked before?
Edited by Bret Brown