Generator expression doesn't work on set_source_files_properties
The below minimal example works if I hard coded the path of the generated test.cpp
cmake_minimum_required(VERSION 3.20)
project(example)
add_executable(example main.cpp)
add_executable(example2 ${CMAKE_BINARY_DIR}/test.cpp)
set_source_files_properties(${CMAKE_BINARY_DIR}/test.cpp PROPERTIES GENERATED TRUE)
however, due to #23106 (closed), hard coding the path with ${CMAKE_BINARY_DIR}/$<CONFIGURATION>/test.cpp
wouldn't work on Xcode, so I tried
cmake_minimum_required(VERSION 3.20)
project(example)
add_executable(example main.cpp)
add_executable(example2 $<TARGET_FILE_DIR:example>/test.cpp)
set_source_files_properties($<TARGET_FILE_DIR:example>/test.cpp PROPERTIES GENERATED TRUE)
but this not only doesn't work on Xcode, it also doesn't work on Visual Studio. After some debugging, it's because set_source_files_properties
is unable to process the generator expression $<TARGET_FILE_DIR:example>
. I believe this is a bug because I think set_source_files_properties
should be able to understand generator expression $<TARGET_FILE_DIR:example>
.