Generator expression $<CONFIGURATION> doesn't work on set_source_file_properties
Please see below minimal example,
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/bin/$<CONFIGURATION>/file.txt
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/file.txt
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/file.txt
${CMAKE_BINARY_DIR}/bin/$<CONFIGURATION>/file.txt)
add_custom_target(filegen
DEPENDS ${CMAKE_BINARY_DIR}/bin/$<CONFIGURATION>/file.txt)
set_source_files_properties(${CMAKE_BINARY_DIR}/bin/$<CONFIGURATION>/file.txt
PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
add_library(Foo foo.cpp foo.h ${CMAKE_BINARY_DIR}/bin/$<CONFIGURATION>/file.txt)
set_target_properties(Foo PROPERTIES FRAMEWORK TRUE)
In this example, file.txt
does not show up successfully in the Resources folder of the framework, and this is most likely caused by the generator expression $<CONFIGURATION>
not working in set_source_files_properties, because the below works,
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/bin/file.txt
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/file.txt
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/file.txt
${CMAKE_BINARY_DIR}/bin/file.txt)
add_custom_target(filegen
DEPENDS ${CMAKE_BINARY_DIR}/bin/file.txt)
set_source_files_properties(${CMAKE_BINARY_DIR}/bin/file.txt
PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
add_library(Foo foo.cpp foo.h ${CMAKE_BINARY_DIR}/bin/file.txt)
set_target_properties(Foo PROPERTIES FRAMEWORK TRUE)
eventually I figured out a workaround that works as below,
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/bin/$<CONFIGURATION>/file.txt
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/file.txt
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/file.txt
${CMAKE_BINARY_DIR}/bin/$<CONFIGURATION>/file.txt)
add_custom_target(filegen
DEPENDS ${CMAKE_BINARY_DIR}/bin/$<CONFIGURATION>/file.txt)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/Foo.framework/Versions/A/Resources/file.txt
DEPENDS ${CMAKE_BINARY_DIR}/bin/$<CONFIGURATION>/file.txt
COMMAND
${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bin/$<CONFIGURATION>/file.txt
${CMAKE_BINARY_DIR}/Foo.framework/Versions/A/Resources/file.txt)
add_custom_target(
filecopy
DEPENDS ${CMAKE_BINARY_DIR}/Foo.framework/Versions/A/Resources/file.txt)
add_library(Foo foo.cpp foo.h)
set_target_properties(Foo PROPERTIES FRAMEWORK TRUE)
add_dependencies(Foo filecopy)
so I believe it should be possible for cmake to make $<CONFIGURATION>
work with set_source_files_properties