[CMake] RPATH for pkg-config
Franck Houssen
franck.houssen at inria.fr
Fri Jan 5 03:16:57 EST 2018
----- Mail original -----
> De: "Alexander Neundorf" <a.neundorf-work at gmx.net>
> À: "Franck Houssen" <franck.houssen at inria.fr>
> Cc: cmake at 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
>
>
More information about the CMake
mailing list