----- Mail original ----- > De: "Alexander Neundorf" <a.neundorf-w...@gmx.net> > À: "Franck Houssen" <franck.hous...@inria.fr> > Cc: cmake@cmake.org > Envoyé: Jeudi 4 Janvier 2018 22:04:02 > Objet: Re: [CMake] RPATH for pkg-config > > On 2018 M01 4, Thu 10:06:26 CET Franck Houssen wrote: > ... > > ... > > target_include_directories(main PUBLIC ${PETSc_INCLUDE_DIRS}) > > foreach(lib ${PETSc_LDFLAGS}) > > target_link_libraries(main PUBLIC ${lib}) > > message("target_link_libraries - lib is ${lib}") > > endforeach(lib) > > > > foreach(dir ${PETSc_LIBRARY_DIRS}) > > link_directories(main PUBLIC ${dir}) # Not sure: is this needed ? > > message("link_directories - dir is ${dir}") > > endforeach(dir) > > > > This gives: > > >> cmake ..; make > > > > ... > > target_link_libraries - lib is -L/path/to/petsc/local/lib > > target_link_libraries - lib is -lpetsc > > link_directories - dir is /path/to/petsc/local/lib > > yes, so cmake doesn't know that it will link to /path/to/petsc/local/lib/ > libpetsc.so . > I usually recommend to use the results from pkgconfig as input to > find_library() > etc. calls, ie. put the directory reported by pkgconfig in the HINTS section > of > find_library(). This should then return the full path to the library, which > you > can then use in target_link_libraries(), and cmake will take care of the > rpath.
Nice recommendation. I wouldn't have thought to do that. I'll give it a try. > > you can also use readelf or objdump to see the RPATH entry in the ELF file > directly. > > Alex > > -- 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: https://cmake.org/mailman/listinfo/cmake