This variable contains list of output files. It makes as follow:
set( OUTPUT_DIR “${CMAKE_BINARY_DIR}/” )
set( OUTPUT_FILES “” )
<here some code prepares OUT, related vars and first part of COMMANDS>
foreach( OUT ${OUTPUTS} )
set( OUTPUT_FILE “${OUTPUT_DIR}${${OUT}_FILENAME}.obj” )
list( APPEND OUTPUT_FILES ${OUTPUT_FILE} )
list( APPEND COMMANDS COMMAND objcopy -I binary -O pe-x86-64 ${${OUT}_FILENAME}.bin ${${OUT}_FILENAME}.obj )
endforeach()
add_custom_command(…)
endfunction()
This code is placed in a function. The function is called one time per source file. The function may generate different number of output files. OUTPUT_FILES is used in this function only. make and VS properly handle these source files, if these files are modified then script re-build them, all output files are generated properly and I can add them manually in VS by changing ‘Link Objects’ to true in ‘Custom Build Tool’ and everything will build successful. or I can add them as source files into project in VS and also everything will be fine, but if I tried to add these output files as sources in cmake script - nothing is happen and build fails.
I though this is common practice - project has specific files used to generate object files and then add it to target. I am not familiar with cmake and I though community will show right practice how to do it with cmake. I tried to find this with no success.