[CMake] Getting an RPath set in a Library
Clark J. Wang
dearvoid at gmail.com
Sun Jul 1 00:47:19 EDT 2007
On 7/1/07, Mike Jackson <imikejackson at gmail.com> wrote:
>
>
>
> On Jun 30, 2007, at 3:12 PM, Alan W. Irwin wrote:
>
> > On 2007-06-30 11:50-0400 Mike Jackson wrote:
> >
> >> So I tried various incantations of SET_TARGET_PROPERTIES and all
> >> had no effect:
> >>
> >> IF ( APPLE )
> >> SET_TARGET_PROPERTIES (${MXADATAMODEL_LIB_NAME}
> >> PROPERTIES
> >> INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib
> >> )
> >>
> >> ENDIF ( APPLE )
> >>
> >> So I am obviously not seeing the forest for the trees..
> >
> > Hmm. I have no access to Mac OS X, but the PLplot developer who
> > has access
> > to that platform dealt with this issue to his own satisfaction. To
> > follow
> > what we do, please look at
> > http://plplot.svn.sourceforge.net/viewvc/plplot/trunk/.
> >
> > cmake/modules/rpath.cmake leaves USE_RPATH undefined in the Darwin
> > case
> > because we found that setting anything to do with RPATH on Mac OS X
> > caused
> > problems (at least according to the note in that file).
> >
> > LIB_DIR is defined in cmake/modules/instdirs.cmake. Bydefault it
> > is equivalent to ${CMAKE_INSTALL_PREFIX}/lib
> >
> > src/CMakeLists.txt invokes SET_TARGET_PROPERTIES (for the USE_RPATH
> > undefined case) as follows:
> >
> > set_target_properties(
> > plplot${LIB_TAG}
> > PROPERTIES SOVERSION ${plplot_SOVERSION}
> > VERSION ${plplot_VERSION}
> > INSTALL_NAME_DIR "${LIB_DIR}"
> > )
> >
> > So that is not essentially different from what you did aside from
> > the quotes
> > on ${LIB_DIR}. You might want to try the quotes to see if they
> > matter.
> >
> > Other considerations that come to mind are did you try the test
> > starting
> > from an empty build tree and actually run "make install" in the
> > build tree
> > before testing run-time access to the library in the install tree?
> >
> > Alan
> > __________________________
> > Alan W. Irwin
> >
>
>
> Yes, my library is small enough where I can start completely fresh
> each time. After running make install I run "otool -L ..." on the
> installed library which reports back NO rpath is set. Just the
> libname, which means I have to add the path to my DYLD_LIBRARY_PATH,
> which will cause a problem for other reasons.
>
> THanks for the suggestions. I will try them later this weekend.
The following CMakeLists.txt works fine on my iBook G4 (Mac OS X 10.4):
$ ls
CMakeLists.txt hello.c main.c
$ cat CMakeLists.txt
PROJECT(hello)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
SET(CMAKE_INSTALL_PREFIX /usr/local/hello)
ADD_LIBRARY(hello SHARED hello.c)
SET_TARGET_PROPERTIES(hello PROPERTIES
INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib
)
ADD_EXECUTABLE(main main.c)
TARGET_LINK_LIBRARIES(main hello)
INSTALL(
TARGETS hello main
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
$
--
> Mike Jackson Senior Research Engineer
> Innovative Management & Technology Services
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20070701/8a55c982/attachment.htm
More information about the CMake
mailing list