Re: [CMake] RPATH for external library
>> > If I understand things correctly, pkg-config does not return the >> > RPATH-arguments necessary to link with. IOW, if used in a GNU >> > Makefile you would also need to add these by yourself, right? So >> > your problem is not a cmake-problem. >> IMHO it's not fair to say - if it's not supported by GNUmake, it >> shouldn't be supported by CMake. > That was not my intention to say. But rather I thought that somewhere > this problem was already solved, as it is not a cmake-only-problem, but > a general build problem when using pkg-config on libraries which are not > in default search-pathes. Agree. >> In any case, the CMake documentation says that >> INSTALL_RPATH_USE_LINK_PATH "...will append directories in the linker >> search path and outside the project to the INSTALL_RPATH...", there >> is no statement that it only applies to linker search paths that were >> supplied in a certain way. > That applies only to libraries, not the linker-flags which have > been added behind the back of cmake's library-dependency mechanism. Right, so it's not all search paths. I would advocate for changing the documentation so it is clear. >> [skipped] > This skipped part was trying to point out a solution based on the -l > and -L arguments returned by pkg-config and some cmake parsing. It > wouldn't be beautiful, but it'll work. Agree. I just didn't have any other comment for that. -- 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
Re: [CMake] RPATH for external library
On Wed, 17 May 2017 17:13:13 -0700 Pawel Veselovwrote: > On Wed, May 17, 2017 at 2:55 AM, Patrick Boettcher > > My reason of preferring pkg-config is > because it may have all > >> other kind of stuff in it that the maintainer thought is necessary. > >> I'd imagine some .pc files export a boatload of flags for all 3 > >> stages, and I rather not ignored them. It is also quite important > >> when there are chained dependencies. > > > > Understandable. > > > > If I understand things correctly, pkg-config does not return the > > RPATH-arguments necessary to link with. IOW, if used in a GNU > > Makefile you would also need to add these by yourself, right? So > > your problem is not a cmake-problem. > > IMHO it's not fair to say - if it's not supported by GNUmake, it > shouldn't be supported by CMake. That was not my intention to say. But rather I thought that somewhere this problem was already solved, as it is not a cmake-only-problem, but a general build problem when using pkg-config on libraries which are not in default search-pathes. > In any case, the CMake documentation says that > INSTALL_RPATH_USE_LINK_PATH "...will append directories in the linker > search path and outside the project to the INSTALL_RPATH...", there > is no statement that it only applies to linker search paths that were > supplied in a certain way. That applies only to libraries, not the linker-flags which have been added behind the back of cmake's library-dependency mechanism. > [skipped] This skipped part was trying to point out a solution based on the -l and -L arguments returned by pkg-config and some cmake parsing. It wouldn't be beautiful, but it'll work. -- Patrick. -- 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
Re: [CMake] RPATH for external library
On Wed, May 17, 2017 at 2:55 AM, Patrick Boettcher> My reason of preferring pkg-config is because it may have all >> other kind of stuff in it that the maintainer thought is necessary. >> I'd imagine some .pc files export a boatload of flags for all 3 >> stages, and I rather not ignored them. It is also quite important >> when there are chained dependencies. > > Understandable. > > If I understand things correctly, pkg-config does not return the > RPATH-arguments necessary to link with. IOW, if used in a GNU > Makefile you would also need to add these by yourself, right? So your > problem is not a cmake-problem. IMHO it's not fair to say - if it's not supported by GNUmake, it shouldn't be supported by CMake. In any case, the CMake documentation says that INSTALL_RPATH_USE_LINK_PATH "...will append directories in the linker search path and outside the project to the INSTALL_RPATH...", there is no statement that it only applies to linker search paths that were supplied in a certain way. [skipped] -- 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
Re: [CMake] RPATH for external library
On Tue, 16 May 2017 12:32:11 -0700 Pawel Veselovwrote: > > I was once in a situation where I could have used pkg-config with a > > custom path to have pkg-config look for the .pc-file. I then > > switched to find_library with the custom-path slightly adapted and > > it worked at least as good as with pkg-config, if not better. For > > my case. > > Right. My reason of preferring pkg-config is because it may have all > other kind of stuff in it that the maintainer thought is necessary. > I'd imagine some .pc files export a boatload of flags for all 3 > stages, and I rather not ignored them. It is also quite important > when there are chained dependencies. Understandable. If I understand things correctly, pkg-config does not return the RPATH-arguments necessary to link with. IOW, if used in a GNU Makefile you would also need to add these by yourself, right? So your problem is not a cmake-problem. If this is the case, what you're looking for is a macro/script which transforms -l and -L-arguments to the fully-qualified filename. That should be doable with a combination of string(SUBSTRING) and find_library() - if you dare ;-) . > AFAIU, find_library() is not > capable of tracking down dependencies. No, find_library only returns the (complete) filename of a library found via its arguments. -- Patrick. -- 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
Re: [CMake] RPATH for external library
On Tue, May 16, 2017 at 12:09 PM, Patrick Boettcherwrote: > On Tue, 16 May 2017 11:50:47 -0700 > Pawel Veselov wrote: > >> >> I'm trying to make CMake add to the linker RPATH automatically. >> >> There is a library that is installed in a non-default location. >> >> I'm discovering the library using PkgConfig (custom >> >> CMAKE_APPBUNDLE_PATH) and add the library build options to the >> >> LINK_FLAGS (using set_property). >> > Instead of setting the LINK_FLAGS to your external library try using >> > target_link_libraries() with the full path name to the library. >> That doesn't really play well with FindPkgConfig then. AFAIK, there is >> no way to ask pkg-config to dish out full libraries paths, one would >> have to sift through all -l and -L and figure them out... > Could you switch from pkg-config to find_library() ? In this case I guess I could. For the record, RPATH kicks in just fine if adding a module dependency (target-link-libraries pointing to a library created with add_library) > I was once in a situation where I could have used pkg-config with a > custom path to have pkg-config look for the .pc-file. I then switched to > find_library with the custom-path slightly adapted and it worked at > least as good as with pkg-config, if not better. For my case. Right. My reason of preferring pkg-config is because it may have all other kind of stuff in it that the maintainer thought is necessary. I'd imagine some .pc files export a boatload of flags for all 3 stages, and I rather not ignored them. It is also quite important when there are chained dependencies. AFAIU, find_library() is not capable of tracking down dependencies. -- 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
Re: [CMake] RPATH for external library
On Tue, 16 May 2017 11:50:47 -0700 Pawel Veselovwrote: > >> I'm trying to make CMake add to the linker RPATH automatically. > >> There is a library that is installed in a non-default location. > >> I'm discovering the library using PkgConfig (custom > >> CMAKE_APPBUNDLE_PATH) and add the library build options to the > >> LINK_FLAGS (using set_property). > > Instead of setting the LINK_FLAGS to your external library try using > > target_link_libraries() with the full path name to the library. > > > > For example this will work as expected, cmake with set an RPATH > > to "/path/to": > > > > set(LIB "/path/to/libsomething.so") > > target_link_libraries(test1 ${LIB}) > > That doesn't really play well with FindPkgConfig then. AFAIK, there is > no way to ask pkg-config to dish out full libraries paths, one would > have to sift through all -l and -L and figure them out... Could you switch from pkg-config to find_library() ? I was once in a situation where I could have used pkg-config with a custom path to have pkg-config look for the .pc-file. I then switched to find_library with the custom-path slightly adapted and it worked at least as good as with pkg-config, if not better. For my case. regards, -- Patrick. -- 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
Re: [CMake] RPATH for external library
>> I'm trying to make CMake add to the linker RPATH automatically. >> There is a library that is installed in a non-default location. >> I'm discovering the library using PkgConfig (custom >> CMAKE_APPBUNDLE_PATH) and add the library build options to the >> LINK_FLAGS (using set_property). > Instead of setting the LINK_FLAGS to your external library try using > target_link_libraries() with the full path name to the library. > > For example this will work as expected, cmake with set an RPATH > to "/path/to": > > set(LIB "/path/to/libsomething.so") > target_link_libraries(test1 ${LIB}) That doesn't really play well with FindPkgConfig then. AFAIK, there is no way to ask pkg-config to dish out full libraries paths, one would have to sift through all -l and -L and figure them out... Thank you, Pawel. -- 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
Re: [CMake] RPATH for external library
On Mon, 15 May 2017 13:32:15 -0700 Pawel Veselovwrote: > Hello. > > I'm trying to make CMake add to the linker RPATH automatically. > There is a library that is installed in a non-default location. > I'm discovering the library using PkgConfig (custom > CMAKE_APPBUNDLE_PATH) and add the library build options to the > LINK_FLAGS (using set_property). Instead of setting the LINK_FLAGS to your external library try using target_link_libraries() with the full path name to the library. For example this will work as expected, cmake with set an RPATH to "/path/to": set(LIB "/path/to/libsomething.so") target_link_libraries(test1 ${LIB}) HTH, -- Patrick. -- 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