[CMake] embedded path in shared library linked into another shared library

Michael Hertling mhertling at online.de
Mon Apr 11 22:40:17 EDT 2011


On 04/11/2011 11:10 PM, David Aiken wrote:
> That didn't work for me.. I've got it simplified down to:
> SET(CMAKE_SKIP_RPATH TRUE)
> and in the CMakeCache.txt I see:
> CMAKE_SKIP_RPATH:BOOL=NO

That's not surprising as your SET() command doesn't write to the cache.
It's the CMAKE_SKIP_RPATH variable's value in the current scope which
is - should be - crucial for dropping the RPATH settings, AFAIK.

> and further down:
> CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
> 
> I'm using the codeblocks unix makefile target. The rpath is present in both the build and install shared library.

With the UnixMakefile generator, I can see the following CMakeLists.txt

CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(RPATH C)
SET(CMAKE_VERBOSE_MAKEFILE ON)
SET(CMAKE_SKIP_RPATH TRUE)
FILE(WRITE ${CMAKE_BINARY_DIR}/f.c "void f(void){}\n")
ADD_LIBRARY(f SHARED f.c)
FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){return 0;}\n")
ADD_EXECUTABLE(main main.c)
TARGET_LINK_LIBRARIES(main f)

produce the following command line to link:

.../gcc CMakeFiles/main.dir/main.c.o -o main -rdynamic libf.so

I.e., no RPATH for the executable.

Does the above-noted CMakeLists.txt actually produce different results
w.r.t. the RPATHs when using the CodeBlocksUnixMakefiles generator?

Regards,

Michael

> -----Original Message-----
> From: Eric Noulard [mailto:eric.noulard at gmail.com]
> Sent: Monday, April 11, 2011 12:29 PM
> To: David Aiken
> Cc: cmake at cmake.org
> Subject: Re: [CMake] embedded path in shared library linked into another shared library
> 
> 2011/4/11 David Aiken <david.aiken at cis-vancouver.com>:
>> Hi all..
>>
>>
>>
>> I'm using cmake 2.8.4 on Centos 5.2. I build a libUtility.so and a
>> libSecurity.so which depends on it. The utility library is located in
>> "../../lib/libUtility.so" during the build. If I do an ldd on libSecurity.so
>> I can see this relative path for libUtility.so in both the build and install
>> versions of the libSecurity.so library. I would like to remove it, but have
>> had no luck. From the docs it seems that the rpath would be removed if I add
>> "SET(CMAKE_SKIP_RPATH TRUE)" to the CMakeLists.txt, but there is no change.
> 
> 
> As far as I understand this
> http://www.cmake.org/Wiki/CMake_RPATH_handling
> 
> it should work with CMAKE_SKIP_RPATH set to TRUE
> did you try using a fresh build tree?
> 
> You could try with:
> SET(CMAKE_SKIP_BUILD_RPATH  TRUE)
> SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
> SET(CMAKE_INSTALL_RPATH "")
> 
> 
> --
> Erk
> Membre de l'April - « promouvoir et défendre le logiciel libre » -
> http://www.april.org
> 
> 
> This e-mail and any attachments are intended only for use by the addressee(s) named herein and may contain confidential information. If you are not the intended recipient of this e-mail, you are hereby notified any dissemination, distribution or copying of this email and any attachments is strictly prohibited. If you receive this email in error, please immediately notify the sender by return email and permanently delete the original, any copy and any printout thereof. The integrity and security of e-mail cannot be guaranteed.


More information about the CMake mailing list