This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake".
The branch, next has been updated via afd97471ab39ab780ae72c8477852ce09df0a2e2 (commit) via f38d80c6e8252c2f299b7fdab99dc5f20994a219 (commit) via 84f2cba57e2fe3ae13ffba6ea74c0e7faa30504d (commit) via 495ae31f63c65c362d6633942f0f2dff46c68f16 (commit) from b3b133e2685bb73fd7ec3ed75d88cb05194f57c1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=afd97471ab39ab780ae72c8477852ce09df0a2e2 commit afd97471ab39ab780ae72c8477852ce09df0a2e2 Merge: b3b133e f38d80c Author: Stephen Kelly <steve...@gmail.com> AuthorDate: Fri Nov 28 12:51:20 2014 -0500 Commit: CMake Topic Stage <kwro...@kitware.com> CommitDate: Fri Nov 28 12:51:20 2014 -0500 Merge topic 'target-sources-error-conditions' into next f38d80c6 Help: Document the export limitation of INTERFACE_SOURCES. 84f2cba5 Export: Disallow export of targets with INTERFACE_SOURCES 495ae31f cmTarget: Don't allow relative paths in INTERFACE_SOURCES diff --cc Help/prop_tgt/INTERFACE_SOURCES.rst index a224b68,c8ca2e8..696ee95 --- a/Help/prop_tgt/INTERFACE_SOURCES.rst +++ b/Help/prop_tgt/INTERFACE_SOURCES.rst @@@ -1,17 -1,18 +1,21 @@@ INTERFACE_SOURCES ----------------- -List of interface sources to pass to the compiler. +List of interface sources to compile into consuming targets. Targets may populate this property to publish the sources -for consuming targets to compile. Consuming -targets can add entries to their own :prop_tgt:`SOURCES` property -such as ``$<TARGET_PROPERTY:foo,INTERFACE_SOURCES>`` to use the -sources specified in the interface of ``foo``. +for consuming targets to compile. The :command:`target_sources` command +populates this property with values given to the ``PUBLIC`` and +``INTERFACE`` keywords. Projects may also get and set the property directly. + +When target dependencies are specified using :command:`target_link_libraries`, +CMake will read this property from all target dependencies to determine the +sources of the consumer. + Targets with ``INTERFACE_SOURCES`` may not be exported with the + :command:`export` or :command:`install(EXPORT)` commands. This limitation may be + lifted in a future version of CMake. + Contents of ``INTERFACE_SOURCES`` may use "generator expressions" with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)` http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f38d80c6e8252c2f299b7fdab99dc5f20994a219 commit f38d80c6e8252c2f299b7fdab99dc5f20994a219 Author: Stephen Kelly <steve...@gmail.com> AuthorDate: Fri Nov 28 18:46:12 2014 +0100 Commit: Stephen Kelly <steve...@gmail.com> CommitDate: Fri Nov 28 18:50:27 2014 +0100 Help: Document the export limitation of INTERFACE_SOURCES. diff --git a/Help/command/target_sources.rst b/Help/command/target_sources.rst index d6f148d..832240a 100644 --- a/Help/command/target_sources.rst +++ b/Help/command/target_sources.rst @@ -22,6 +22,10 @@ items will populate the :prop_tgt:`SOURCES` property of following arguments specify sources. Repeated calls for the same ``<target>`` append items in the order called. +Targets with :prop_tgt:`INTERFACE_SOURCES` may not be exported with the +:command:`export` or :command:`install(EXPORT)` commands. This limitation may be +lifted in a future version of CMake. + Arguments to ``target_sources`` may use "generator expressions" with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)` diff --git a/Help/prop_tgt/INTERFACE_SOURCES.rst b/Help/prop_tgt/INTERFACE_SOURCES.rst index fb28231..c8ca2e8 100644 --- a/Help/prop_tgt/INTERFACE_SOURCES.rst +++ b/Help/prop_tgt/INTERFACE_SOURCES.rst @@ -9,6 +9,10 @@ targets can add entries to their own :prop_tgt:`SOURCES` property such as ``$<TARGET_PROPERTY:foo,INTERFACE_SOURCES>`` to use the sources specified in the interface of ``foo``. +Targets with ``INTERFACE_SOURCES`` may not be exported with the +:command:`export` or :command:`install(EXPORT)` commands. This limitation may be +lifted in a future version of CMake. + Contents of ``INTERFACE_SOURCES`` may use "generator expressions" with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)` http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=84f2cba57e2fe3ae13ffba6ea74c0e7faa30504d commit 84f2cba57e2fe3ae13ffba6ea74c0e7faa30504d Author: Stephen Kelly <steve...@gmail.com> AuthorDate: Thu Nov 27 19:26:54 2014 +0100 Commit: Stephen Kelly <steve...@gmail.com> CommitDate: Thu Nov 27 23:55:49 2014 +0100 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. diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 30a52d4..134ee98 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -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(); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 89071c0..23180f1 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -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; diff --git a/Tests/RunCMake/TargetSources/ExportBuild-result.txt b/Tests/RunCMake/TargetSources/ExportBuild-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetSources/ExportBuild-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetSources/ExportBuild-stderr.txt b/Tests/RunCMake/TargetSources/ExportBuild-stderr.txt new file mode 100644 index 0000000..0d65a55 --- /dev/null +++ b/Tests/RunCMake/TargetSources/ExportBuild-stderr.txt @@ -0,0 +1 @@ +CMake Error: Target "iface" has a populated INTERFACE_SOURCES property. This is not currently supported. diff --git a/Tests/RunCMake/TargetSources/ExportBuild.cmake b/Tests/RunCMake/TargetSources/ExportBuild.cmake new file mode 100644 index 0000000..b626aa6 --- /dev/null +++ b/Tests/RunCMake/TargetSources/ExportBuild.cmake @@ -0,0 +1,5 @@ + +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) diff --git a/Tests/RunCMake/TargetSources/ExportInstall-result.txt b/Tests/RunCMake/TargetSources/ExportInstall-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetSources/ExportInstall-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetSources/ExportInstall-stderr.txt b/Tests/RunCMake/TargetSources/ExportInstall-stderr.txt new file mode 100644 index 0000000..0d65a55 --- /dev/null +++ b/Tests/RunCMake/TargetSources/ExportInstall-stderr.txt @@ -0,0 +1 @@ +CMake Error: Target "iface" has a populated INTERFACE_SOURCES property. This is not currently supported. diff --git a/Tests/RunCMake/TargetSources/ExportInstall.cmake b/Tests/RunCMake/TargetSources/ExportInstall.cmake new file mode 100644 index 0000000..8e7c9f9 --- /dev/null +++ b/Tests/RunCMake/TargetSources/ExportInstall.cmake @@ -0,0 +1,6 @@ + +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) diff --git a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake index c6d7f43..1b4ef0b 100644 --- a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake @@ -9,3 +9,5 @@ endif() run_cmake(CMP0026-LOCATION) run_cmake(RelativePathInInterface) +run_cmake(ExportBuild) +run_cmake(ExportInstall) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=495ae31f63c65c362d6633942f0f2dff46c68f16 commit 495ae31f63c65c362d6633942f0f2dff46c68f16 Author: Stephen Kelly <steve...@gmail.com> AuthorDate: Thu Nov 27 01:04:33 2014 +0100 Commit: Stephen Kelly <steve...@gmail.com> CommitDate: Thu Nov 27 19:23:11 2014 +0100 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. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b476a27..6c2f9e1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -649,6 +649,8 @@ static bool processSources(cmTarget const* tgt, for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator it = entries.begin(), end = entries.end(); it != end; ++it) { + cmLinkImplItem const& item = (*it)->LinkImplItem; + std::string const& targetName = item; std::vector<std::string> entrySources; cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, config, @@ -667,11 +669,10 @@ static bool processSources(cmTarget const* tgt, i != entrySources.end(); ++i) { std::string& src = *i; - cmSourceFile* sf = mf->GetOrCreateSource(src); std::string e; - src = sf->GetFullPath(&e); - if(src.empty()) + std::string fullPath = sf->GetFullPath(&e); + if(fullPath.empty()) { if(!e.empty()) { @@ -681,6 +682,25 @@ static bool processSources(cmTarget const* tgt, } return contextDependent; } + + if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src.c_str())) + { + cmOStringStream e; + if (!targetName.empty()) + { + e << "Target \"" << targetName << "\" contains relative " + "path in its INTERFACE_SOURCES:\n" + " \"" << src << "\""; + } + else + { + e << "Found relative path while evaluating sources of " + "\"" << tgt->GetName() << "\":\n \"" << src << "\"\n"; + } + tgt->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + return contextDependent; + } + src = fullPath; } std::string usedSources; for(std::vector<std::string>::iterator diff --git a/Tests/ConfigSources/CMakeLists.txt b/Tests/ConfigSources/CMakeLists.txt index c272257..748aad8 100644 --- a/Tests/ConfigSources/CMakeLists.txt +++ b/Tests/ConfigSources/CMakeLists.txt @@ -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 diff --git a/Tests/RunCMake/TargetSources/OriginDebug.cmake b/Tests/RunCMake/TargetSources/OriginDebug.cmake index 5fe9ba7..d40a1d8 100644 --- a/Tests/RunCMake/TargetSources/OriginDebug.cmake +++ b/Tests/RunCMake/TargetSources/OriginDebug.cmake @@ -7,7 +7,7 @@ set(CMAKE_DEBUG_TARGET_PROPERTIES SOURCES) add_library(iface INTERFACE) set_property(TARGET iface PROPERTY INTERFACE_SOURCES - empty_1.cpp + "${CMAKE_CURRENT_SOURCE_DIR}/empty_1.cpp" ) add_library(OriginDebug empty_2.cpp) diff --git a/Tests/RunCMake/TargetSources/RelativePathInInterface-result.txt b/Tests/RunCMake/TargetSources/RelativePathInInterface-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInInterface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetSources/RelativePathInInterface-stderr.txt b/Tests/RunCMake/TargetSources/RelativePathInInterface-stderr.txt new file mode 100644 index 0000000..d47dd4d --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInInterface-stderr.txt @@ -0,0 +1,4 @@ +CMake Error in CMakeLists.txt: + Target "iface" contains relative path in its INTERFACE_SOURCES: + + "empty_1.cpp" diff --git a/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake b/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake new file mode 100644 index 0000000..8bb6149 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake @@ -0,0 +1,6 @@ + +add_library(iface INTERFACE) +target_sources(iface INTERFACE empty_1.cpp) + +add_executable(main main.cpp) +target_link_libraries(main iface) diff --git a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake index 1d2eaec..c6d7f43 100644 --- a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake @@ -8,3 +8,4 @@ else() endif() run_cmake(CMP0026-LOCATION) +run_cmake(RelativePathInInterface) diff --git a/Tests/RunCMake/TargetSources/main.cpp b/Tests/RunCMake/TargetSources/main.cpp new file mode 100644 index 0000000..766b775 --- /dev/null +++ b/Tests/RunCMake/TargetSources/main.cpp @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/SourcesProperty/CMakeLists.txt b/Tests/SourcesProperty/CMakeLists.txt index 6c99e00..d1c35d8 100644 --- a/Tests/SourcesProperty/CMakeLists.txt +++ b/Tests/SourcesProperty/CMakeLists.txt @@ -4,7 +4,9 @@ cmake_minimum_required(VERSION 3.0) project(SourcesProperty) add_library(iface INTERFACE) -set_property(TARGET iface PROPERTY INTERFACE_SOURCES iface.cpp) +set_property(TARGET iface PROPERTY INTERFACE_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/iface.cpp" +) add_executable(SourcesProperty main.cpp) target_link_libraries(SourcesProperty iface) ----------------------------------------------------------------------- Summary of changes: Help/command/target_sources.rst | 4 +++ Help/prop_tgt/INTERFACE_SOURCES.rst | 4 +++ Source/cmExportBuildFileGenerator.cxx | 10 ++++++++ Source/cmExportInstallFileGenerator.cxx | 11 +++++++++ Source/cmTarget.cxx | 26 +++++++++++++++++--- Tests/ConfigSources/CMakeLists.txt | 6 ++--- .../ExportBuild-result.txt} | 0 .../RunCMake/TargetSources/ExportBuild-stderr.txt | 1 + Tests/RunCMake/TargetSources/ExportBuild.cmake | 5 ++++ .../ExportInstall-result.txt} | 0 .../TargetSources/ExportInstall-stderr.txt | 1 + Tests/RunCMake/TargetSources/ExportInstall.cmake | 6 +++++ Tests/RunCMake/TargetSources/OriginDebug.cmake | 2 +- .../RelativePathInInterface-result.txt} | 0 .../RelativePathInInterface-stderr.txt | 4 +++ .../TargetSources/RelativePathInInterface.cmake | 6 +++++ Tests/RunCMake/TargetSources/RunCMakeTest.cmake | 3 +++ .../simple.cxx => RunCMake/TargetSources/main.cpp} | 0 Tests/SourcesProperty/CMakeLists.txt | 4 ++- 19 files changed, 85 insertions(+), 8 deletions(-) copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => TargetSources/ExportBuild-result.txt} (100%) create mode 100644 Tests/RunCMake/TargetSources/ExportBuild-stderr.txt create mode 100644 Tests/RunCMake/TargetSources/ExportBuild.cmake copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => TargetSources/ExportInstall-result.txt} (100%) create mode 100644 Tests/RunCMake/TargetSources/ExportInstall-stderr.txt create mode 100644 Tests/RunCMake/TargetSources/ExportInstall.cmake copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => TargetSources/RelativePathInInterface-result.txt} (100%) create mode 100644 Tests/RunCMake/TargetSources/RelativePathInInterface-stderr.txt create mode 100644 Tests/RunCMake/TargetSources/RelativePathInInterface.cmake copy Tests/{CTestTestCycle/simple.cxx => RunCMake/TargetSources/main.cpp} (100%) hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org http://public.kitware.com/mailman/listinfo/cmake-commits