CMake adds internal files to custom target sources
I am opening a discussion in response to a forum discussion. There, further examples and tests can be found.
The gist of the previous discussion is the following:
cmake_minimum_required(VERSION 3.20)
project(MyProj LANGUAGES NONE)
add_custom_target(test1 ALL
COMMAND ${CMAKE_COMMAND} -E echo "this line:$<TARGET_PROPERTY:test1,SOURCES>"
SOURCES foo.bar
COMMAND_EXPAND_LISTS
)
produces the following output:
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/test/build
this line:foo.bar /tmp/test/build/CMakeFiles/test1 /tmp/test/build/CMakeFiles/test1.rule
Built target test1
Appart from the source file which i added to the CMakeLists, CMake added 2 additional files, test1
and test1.rule
, after the configure stage.
What is the expected output for this? According to the documentation the use of TARGET_PROPERTY
is not expected to create a target dependency. Why does CMake append internal files to the target sources?
Edited by Arcturus