target_link_libraries adding cpp files to project.
I am trying to modernize my cmake style so I may of misunderstood, but I have never seen this behavior before. cmake 3.21.0-rc2
I have a static lib project that has used target_sources with a list of PUBLIC sources. target_sources(${PROJECT_NAME} PUBLIC ${GENERATED_SOURCES} ${GSOAP_DIR}/custom/duration.h )
and I have a alias
add_library(${PROJECT_NAME} STATIC "")
add_library({PROJECT_NAME}::
{PROJECT_NAME} ALIAS ${PROJECT_NAME})
In the same tree I have a Test project that target_link_libraries
This causes all cpp files from the lib to be added to the test project.
${GENERATED_SOURCES} has both header and cpp files from copy from gsoap and onvif wsdl generation
When I make 2 variables, one for headers and one for sources, the cpp files do not end up in the using project. target_sources(${PROJECT_NAME} PRIVATE ${GENERATED_SOURCES} ${GSOAP_DIR}/custom/duration.h PUBLIC ${GENERATED_HEADERS} )
In both cases it does not add the headers to the project.
While access to the headers is all I expect, I do not expect source files to be added to my project. Is this a bug?