CMP0076 is broken with source lists in generator expressions
Given this source:
cmake_minimum_required(VERSION 3.10)
project(cmakeplayground VERSION 1.2.3)
set(ifaceFiles
${CMAKE_CURRENT_SOURCE_DIR}/somefile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/otherfile.cpp
)
add_library(iface INTERFACE)
target_sources(iface INTERFACE $<BUILD_INTERFACE:${ifaceFiles}>)
get_property(srcs TARGET iface PROPERTY INTERFACE_SOURCES)
message("SRCS ${srcs}")
add_executable(mn)
target_link_libraries(mn PRIVATE iface)
CMake 3.10 output:
stephen@j5:~/dev/src/playground/cmake/build$ /usr/bin/cmake ..
SRCS $<BUILD_INTERFACE:/home/stephen/dev/src/playground/cmake/somefile.cpp;/home/stephen/dev/src/playground/cmake/otherfile.cpp>
-- Configuring done
-- Generating done
-- Build files have been written to: /home/stephen/dev/src/playground/cmake/build
CMake 3.15, CMP0076=WARN
CMake Warning (dev) at CMakeLists.txt:10 (target_sources):
Policy CMP0076 is not set: target_sources() command converts relative paths
to absolute. Run "cmake --help-policy CMP0076" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
An interface source of target "iface" has a relative path.
This warning is for project developers. Use -Wno-dev to suppress it.
SRCS $<BUILD_INTERFACE:/home/stephen/dev/src/playground/cmake/somefile.cpp;/home/stephen/dev/src/playground/cmake/otherfile.cpp>
-- Configuring done
-- Generating done
-- Build files have been written to: /home/stephen/dev/src/playground/cmake/build
CMake 3.15, CMP0076=NEW
SRCS /home/stephen/dev/src/playground/cmake/$<BUILD_INTERFACE:/home/stephen/dev/src/playground/cmake/somefile.cpp;/home/stephen/dev/src/playground/cmake/otherfile.cpp>
-- Configuring done
CMake Error at CMakeLists.txt:14 (add_executable):
Cannot find source file:
/home/stephen/dev/src/playground/cmake/home/stephen/dev/src/playground/cmake/somefile.cpp
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
.hpp .hxx .in .txx
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
Note that in the last invocation, an absolute path is prepended to a genex which expands to a list in SRCS
.