<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>De: </b>"Don Hinton" <hintonda@gmail.com><br><b>À: </b>"Franck Houssen" <franck.houssen@inria.fr><br><b>Cc: </b>"Andreas Naumann" <Andreas-Naumann@gmx.net>, cmake@cmake.org<br><b>Envoyé: </b>Jeudi 4 Janvier 2018 10:43:28<br><b>Objet: </b>Re: [CMake] RPATH for pkg-config<br><div><br></div><div><div dir="auto">The cmake rpath settings handle build/install directories more or less automatically, but you need to add a completely different path.</div></div></blockquote><div><br></div><div>Yes. That's the problem: I need to add a completely different path.<br></div><div><br></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div><div dir="auto"><br></div><div dir="auto">Try adding the additional path (pretty much every -L you added) to CMAKE_INSTALL_RPATH, and set CMAKE_BUILD_WITH_INSTALL_RPATH=TRUE.</div></div></blockquote><div><br></div><div>See does not work<br></div><div><br></div><div>>> more ../CMakeLists.txt <br>...<br>foreach(dir ${PETSc_LIBRARY_DIRS})<br>  link_directories(main PUBLIC ${dir})<br>  message("link_directories - dir is ${dir}")<br>  set(CMAKE_INSTALL_RPATH "${dir}:${CMAKE_INSTALL_RPATH}")<br>endforeach(dir)<br>...</div><div>SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)<br>...<br></div><div><br></div><div>>> cmake ..; make VERBOSE=1<br></div><div>...<br>target_link_libraries - lib is -L/home/fghoussen/Documents/INRIA/petsc/local/lib<br>target_link_libraries - lib is -lpetsc<br>link_directories - dir is /home/fghoussen/Documents/INRIA/petsc/local/lib</div><div>...<br>[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o<br>/usr/bin/c++   -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent/include -I/usr/lib/x86_64-linux-gnu/openmpi/include -I/home/fghoussen/Documents/INRIA/petsc/local/include   -o CMakeFiles/main.dir/main.cpp.o -c /home/fghoussen/Downloads/cmake/rpath-pkgconfig/main.cpp<br>[100%] Linking CXX executable main<br>/usr/bin/cmake -E cmake_link_script CMakeFiles/main.dir/link.txt --verbose=1<br>/usr/bin/c++     CMakeFiles/main.dir/main.cpp.o  -o main -Wl,-rpath,/usr/lib/x86_64-linux-gnu/openmpi/lib /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so -L/home/fghoussen/Documents/INRIA/petsc/local/lib -lpetsc <br>make[2]: Leaving directory '/home/fghoussen/Downloads/cmake/rpath-pkgconfig/BUILD'<br>[100%] Built target main<br>make[1]: Leaving directory '/home/fghoussen/Downloads/cmake/rpath-pkgconfig/BUILD'<br>/usr/bin/cmake -E cmake_progress_start /home/fghoussen/Downloads/cmake/rpath-pkgconfig/BUILD/CMakeFiles 0<br></div><div><br></div><div>>> ldd main<br></div><div>    linux-vdso.so.1 (0x00007ffcd876b000)<br>    libmpi_cxx.so.20 => /usr/lib/x86_64-linux-gnu/libmpi_cxx.so.20 (0x00007f9eaba1f000)<br>    libmpi.so.20 => /usr/lib/x86_64-linux-gnu/libmpi.so.20 (0x00007f9eab729000)<br>    libpetsc.so.3.8 => not found<br><br><br></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div><div dir="auto">Then run cmake with the ‘-v’ option and look at the link command to verify rpath was passed correctly.</div><div dir="auto"><br></div><div dir="auto">You can also examine it in a library or executable with ‘objdump-x’.</div><div dir="auto"><br></div><div dir="auto">You may want to customize this for your project, but this should get you started.</div><div dir="auto"><br></div><div dir="auto">hth...</div><div dir="auto">don</div><br><div class="gmail_quote"><div>On Thu, Jan 4, 2018 at 1:25 AM Franck Houssen <<a href="mailto:franck.houssen@inria.fr" target="_blank" data-mce-href="mailto:franck.houssen@inria.fr">franck.houssen@inria.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;">My understanding is that you need a local copy of FindPETSc.cmake: if this changes, you don't know it.<br> That's why I tried to go with the pc file.<br><br> ----- Mail original -----<br> > De: "Andreas Naumann" <<a href="mailto:Andreas-Naumann@gmx.net" target="_blank" data-mce-href="mailto:Andreas-Naumann@gmx.net">Andreas-Naumann@gmx.net</a>><br> > À: <a href="mailto:cmake@cmake.org" target="_blank" data-mce-href="mailto:cmake@cmake.org">cmake@cmake.org</a><br> > Envoyé: Mercredi 3 Janvier 2018 21:41:51<br> > Objet: Re: [CMake] RPATH for pkg-config<br> ><br> > What about using a FindPETSC-Module? Some hints are<br> >      *<a href="http://jacobmerson.com/2016/01/17/cmake-petsc2.html" rel="noreferrer" target="_blank" data-mce-href="http://jacobmerson.com/2016/01/17/cmake-petsc2.html">http://jacobmerson.com/2016/01/17/cmake-petsc2.html</a><br> >      *<a href="http://www.mcs.anl.gov/petsc/documentation/faq.html#cmake" rel="noreferrer" target="_blank" data-mce-href="http://www.mcs.anl.gov/petsc/documentation/faq.html#cmake">http://www.mcs.anl.gov/petsc/documentation/faq.html#cmake</a><br> ><br> > Regards,<br> > Andreas<br> ><br> > Am 03.01.2018 um 21:35 schrieb Alexander Neundorf:<br> > > On 2018 M01 3, Wed 10:08:09 CET Franck Houssen wrote:<br> > >> Hello,<br> > >><br> > >> How to ask cmake to add a library path (coming from pc file) to rpath ?<br> > >><br> > >> I checked this <a href="https://cmake.org/Wiki/CMake_RPATH_handling" rel="noreferrer" target="_blank" data-mce-href="https://cmake.org/Wiki/CMake_RPATH_handling">https://cmake.org/Wiki/CMake_RPATH_handling</a>, but still not<br> > >> working. Can somebody help ?<br> > >>>> more main.cpp<br> > >> #include <petsc.h><br> > >><br> > >> int main(int argc, char ** argv) {<br> > >> PetscInitialize(&argc, &argv, NULL, "");<br> > >> PetscFinalize();<br> > >> return 0;<br> > >> }<br> > >><br> > >>>> more CMakeLists.txt<br> > >> cmake_minimum_required(VERSION 3.7)<br> > >> enable_language(CXX)<br> > >><br> > >> find_package(MPI REQUIRED)<br> > >> find_package(PkgConfig REQUIRED) # Get pkg_check_modules.<br> > >> pkg_check_modules(PETSc REQUIRED PETSc)<br> > >><br> > >> project(main)<br> > >> add_executable(main main.cpp)<br> > >><br> > >> target_include_directories(main PUBLIC ${MPI_CXX_INCLUDE_PATH})<br> > >> target_link_libraries(main PUBLIC ${MPI_CXX_LIBRARIES})<br> > >><br> > >> target_include_directories(main PUBLIC ${PETSc_INCLUDE_DIRS})<br> > >> foreach(lib ${PETSc_LDFLAGS})<br> > >> target_link_libraries(main PUBLIC ${lib})<br> > >> endforeach(lib)<br> > > How does each ${lib} look like ?<br> > > Is it "-lpetsc" or does it have the full path to the libraries ?<br> > > You should use the full path to the libraries, otherwise cmake doesn't know<br> > > where they are and the RPATH computation will not work.<br> > ><br> > >> foreach(dir ${PETSc_LIBRARY_DIRS})<br> > >> link_directories(main PUBLIC ${dir}) # Not sure: is this needed ?<br> > >> endforeach(dir)<br> > > no, link_directories() in general should not be used.<br> > ><br> > >> # use, i.e. don't skip the full RPATH for the build tree<br> > >> SET(CMAKE_SKIP_BUILD_RPATH FALSE)<br> > >> # when building, don't use the install RPATH already<br> > >> # (but later on when installing)<br> > >> SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)<br> > >> SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")<br> > > If the automatic computation fails, you could add the petsc lib dir here as<br> > > INSTALL_RPATH<br> > ><br> > > Alex<br> > ><br> ><br> > --<br> ><br> > Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank" data-mce-href="http://www.kitware.com">www.kitware.com</a><br> ><br> > Please keep messages on-topic and check the CMake FAQ at:<br> > <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank" data-mce-href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a><br> ><br> > Kitware offers various services to support the CMake community. For more<br> > information on each offering, please visit:<br> ><br> > CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank" data-mce-href="http://cmake.org/cmake/help/support.html">http://cmake.org/cmake/help/support.html</a><br> > CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank" data-mce-href="http://cmake.org/cmake/help/consulting.html">http://cmake.org/cmake/help/consulting.html</a><br> > CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank" data-mce-href="http://cmake.org/cmake/help/training.html">http://cmake.org/cmake/help/training.html</a><br> ><br> > Visit other Kitware open-source projects at<br> > <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank" data-mce-href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br> ><br> > Follow this link to subscribe/unsubscribe:<br> > <a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank" data-mce-href="https://cmake.org/mailman/listinfo/cmake">https://cmake.org/mailman/listinfo/cmake</a><br> ><br> --<br><br> Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank" data-mce-href="http://www.kitware.com">www.kitware.com</a><br><br> Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank" data-mce-href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a><br><br> Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br><br> CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank" data-mce-href="http://cmake.org/cmake/help/support.html">http://cmake.org/cmake/help/support.html</a><br> CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank" data-mce-href="http://cmake.org/cmake/help/consulting.html">http://cmake.org/cmake/help/consulting.html</a><br> CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank" data-mce-href="http://cmake.org/cmake/help/training.html">http://cmake.org/cmake/help/training.html</a><br><br> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank" data-mce-href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br> Follow this link to subscribe/unsubscribe:<br><a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank" data-mce-href="https://cmake.org/mailman/listinfo/cmake">https://cmake.org/mailman/listinfo/cmake</a><br></blockquote></div></div></blockquote><div><br></div></div></body></html>