Commit e1348056 authored by Stephen Kelly's avatar Stephen Kelly

Export: Disallow export of targets with INTERFACE_SOURCES

This can be allowed in the next release, but it needs to have some
features present and tested such as

* Ensuring that relative paths do not appear in the generated property.
* Ensuring that paths to the source or build directories do not appear.
* Generating a check in the file for CMake 3.1 or later so that the
    resulting property will be consumed.
* Ensuring that any referenced targets are part of an export set and
    generating a check for them.
* INSTALL_INTERFACE and BUILD_INTERFACE content.

All of these checks are already done for INTERFACE_INCLUDE_DIRECTORIES,
but it is too late to add them for INTERFACE_SOURCES for CMake 3.1.
As the checks introduce some new error conditions, it is better to
disallow exporting fully for this case and introduce proper error
conditions later instead of policies.
parent bb5905bb
......@@ -68,6 +68,16 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
tei != this->Exports.end(); ++tei)
{
cmTarget* te = *tei;
if (te->GetProperty("INTERFACE_SOURCES"))
{
cmOStringStream e;
e << "Target \""
<< te->GetName()
<< "\" has a populated INTERFACE_SOURCES property. This is not "
"currently supported.";
cmSystemTools::Error(e.str().c_str());
return false;
}
this->GenerateImportTargetCode(os, te);
te->AppendBuildInterfaceIncludes();
......
......@@ -123,6 +123,17 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
{
cmTarget* te = (*tei)->Target;
if (te->GetProperty("INTERFACE_SOURCES"))
{
cmOStringStream e;
e << "Target \""
<< te->GetName()
<< "\" has a populated INTERFACE_SOURCES property. This is not "
"currently supported.";
cmSystemTools::Error(e.str().c_str());
return false;
}
requiresConfigFiles = requiresConfigFiles
|| te->GetType() != cmTarget::INTERFACE_LIBRARY;
......
CMake Error: Target "iface" has a populated INTERFACE_SOURCES property. This is not currently supported.
add_library(iface INTERFACE)
target_sources(iface INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/empty_1.cpp")
export(TARGETS iface FILE ${CMAKE_CURRENT_BINARY_DIR}/targets.cmake)
CMake Error: Target "iface" has a populated INTERFACE_SOURCES property. This is not currently supported.
add_library(iface INTERFACE)
target_sources(iface INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/empty_1.cpp")
install(TARGETS iface EXPORT exp)
install(EXPORT exp DESTINATION cmake)
......@@ -9,3 +9,5 @@ endif()
run_cmake(CMP0026-LOCATION)
run_cmake(RelativePathInInterface)
run_cmake(ExportBuild)
run_cmake(ExportInstall)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment