mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
cmTarget: Don't allow relative paths in INTERFACE_SOURCES
Follow the pattern of checks that are made for INTERFACE_INCLUDE_DIRECTORIES. Existence is already checked by cmSourceFile::GetFullPath. Add a check to disallow relative paths in source directories. Otherwise code such as target_sources(lib1 INTERFACE foo.cpp) would fail if consumed by a target in a different directory. Unlike the INTERFACE_INCLUDE_DIRECTORIES behavior, we don't care whether the entry comes from an IMPORTED target or not. In the include directories case, the directory for a non-imported target might not exist yet but might be created. In the sources case, a file which does not yet exist in the filesystem must be explicitly marked with the GENERATED property. Adjust existing tests and add a new test for the error.
This commit is contained in:
@@ -5,9 +5,9 @@ project(ConfigSources)
|
||||
|
||||
add_library(iface INTERFACE)
|
||||
set_property(TARGET iface PROPERTY INTERFACE_SOURCES
|
||||
iface_src.cpp
|
||||
$<$<CONFIG:Debug>:iface_debug_src.cpp>
|
||||
$<$<CONFIG:Release>:does_not_exist.cpp>
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/iface_src.cpp"
|
||||
"$<$<CONFIG:Debug>:${CMAKE_CURRENT_SOURCE_DIR}/iface_debug_src.cpp>"
|
||||
"$<$<CONFIG:Release>:${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist.cpp>"
|
||||
)
|
||||
|
||||
add_executable(ConfigSources
|
||||
|
||||
Reference in New Issue
Block a user