Re: [cmake-developers] Target's IMPORTED_LOCATION_* when CMAKE_INSTALL_PREFIX or CPACK_PACKAGING_INSTALL_PREFIX is "/"
On 09/06/2016 03:00 PM, Ben Keller wrote: > The workaround we are using for this currently is to compile a > modified version of cmake that appends the following cmake code below > the get_filename_component stanza in Targets.cmake: > > if("${_IMPORT_PREFIX}" STREQUAL "/") > set(_IMPORT_PREFIX "") > endif() I would consider that a fix rather than a workaround. We don't know the prefix that will be computed since this block is meant to make the package relocatable. We do know that references to the prefix are always followed by "/" so it is safe to leave it as an empty string. Please post the patch. Thanks, -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
Re: [cmake-developers] Target's IMPORTED_LOCATION_* when CMAKE_INSTALL_PREFIX or CPACK_PACKAGING_INSTALL_PREFIX is "/"
Thank you On Tue, Sep 6, 2016 at 3:24 PM, Brad King wrote: > On 09/06/2016 03:00 PM, Ben Keller wrote: >> The workaround we are using for this currently is to compile a >> modified version of cmake that appends the following cmake code below >> the get_filename_component stanza in Targets.cmake: >> >> if("${_IMPORT_PREFIX}" STREQUAL "/") >> set(_IMPORT_PREFIX "") >> endif() > > I would consider that a fix rather than a workaround. We don't know > the prefix that will be computed since this block is meant to make > the package relocatable. We do know that references to the prefix > are always followed by "/" so it is safe to leave it as an empty > string. > > Please post the patch. > > Thanks, > -Brad > From ee8736abc1640065b83d6322e2765795b934966e Mon Sep 17 00:00:00 2001 From: Ben Keller Date: Tue, 10 May 2016 11:44:40 -0400 Subject: [PATCH] Correct _IMPORT_PREFIX when CMAKE_INSTALL_PREFIX is "/" When exporting from a project (with install(EXPORT ...)), theTargets.cmake file contains logic for computing the _IMPORT_PREFIX. This _IMPORT_PREFIX is then used in the Targets-.cmake file to generate the IMPORTED_LOCATION_. The generation appears to be accomplished by unconditionally appending a "/" to _IMPORT_PREFIX before appending the rest of the path. If _IMPORT_PREFIX is "/", then the IMPORTED_LOCATION_ properties all start with exactly two leading slashes ("//"). Exactly two leading slashes is apparently a special case in POSIX file paths, such that its interpretation is left up to the implementation. This means that changing the path prefix from "/" to "//" should not be allowed. Per Brad King, references to _IMPORT_PREFIX are always followed by a "/", so setting _IMPORT_PREFIX to "" if it is "/" should safely prevent the leading "//" issue. --- Source/cmExportInstallFileGenerator.cxx | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index ceba69a..9ee5739 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -122,7 +122,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) "PATH)\n"; dest = cmSystemTools::GetFilenamePath(dest); } -os << "\n"; +os << "if(\"${_IMPORT_PREFIX}\" STREQUAL \"/\")\n" + << " set(_IMPORT_PREFIX \"\")\n" + << "endif()\n" + << "\n"; } std::vector missingTargets; -- 1.9.1 -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
Re: [cmake-developers] Target's IMPORTED_LOCATION_* when CMAKE_INSTALL_PREFIX or CPACK_PACKAGING_INSTALL_PREFIX is "/"
On 09/06/2016 04:31 PM, Ben Keller wrote: >> Please post the patch. > Thank you Thanks, applied with minor tweaks: install: Fix computed import prefix in export files when it is "/" https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=290e4ce8 Please try out that version. -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
Re: [cmake-developers] Target's IMPORTED_LOCATION_* when CMAKE_INSTALL_PREFIX or CPACK_PACKAGING_INSTALL_PREFIX is "/"
Thank you, it is working as expected. On Wed, Sep 7, 2016 at 8:26 AM, Brad King wrote: > On 09/06/2016 04:31 PM, Ben Keller wrote: >>> Please post the patch. >> Thank you > > Thanks, applied with minor tweaks: > > install: Fix computed import prefix in export files when it is "/" > https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=290e4ce8 > > Please try out that version. > > -Brad > -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers