On 05/10/2011 11:24 AM, Pere Mato Vila wrote:
>>
>> To my regret, I don't see any easy solution for your concern, but if
>> the unnecessary rebuilds due to the the RPATH placeholder mechanism
>> are a serious issue in your project, the above-noted approach can
>> possibly be adapted to your needs.
>>
>> 'hope that helps.
> Dear Michael,
> 
> Thank-you very much for your interest and the time you have spend developing 
> this solution. But I am afraid that the added complexity  in the coding and 
> procedure does not balance with benefits of having an installation RPATH. We 
> will continue with what we have been doing and set the LD_LIBRARY_PATH when 
> using the installed project. Nevertheless I must say that this solution has 
> been very educative for me, since I have learnt a few things (or tricks) that 
> I was not aware you could do with CMake. Thanks again.  
> 
> Pere

Hi Pere,

sorry for re-entering this thread so late, but recently, I stumbled over
the CMAKE_NO_BUILTIN_CHRPATH variable which possibly provides an easy
solution for your issue. Look at the following exemplary project:

# CMakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(RPATH C)
SET(CMAKE_VERBOSE_MAKEFILE ON)
SET(CMAKE_NO_BUILTIN_CHRPATH ON)
ADD_EXECUTABLE(gen gen.c)
ADD_CUSTOM_COMMAND(OUTPUT main.c COMMAND gen > main.c DEPENDS gen)
ADD_EXECUTABLE(main main.c)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ADD_LIBRARY(f SHARED f.c)
ADD_LIBRARY(g SHARED g.c)
INSTALL(TARGETS f g LIBRARY DESTINATION lib)
TARGET_LINK_LIBRARIES(gen f g)

/* f.c: */
void f(void){}

/* g.c: */
void g(void){}

/* gen.c: */
#include <stdio.h>
int main(void)
{
    printf("int main(void){return 0;}\n"); return 0;
}

Essentially, it's the same as in my previous posting, but without the
somewhat weird gen-on-f/g dependency. Instead, it is the usual simple
setup of a code generator which depends on two libraries. Without the
CMAKE_NO_BUILTIN_CHRPATH set to ON, a change in CMAKE_INSTALL_PREFIX
would result in relinking the f/g libraries, and subsequently in re-
building gen and main due to their dependency relations. This is what
you complained about, IIRC. Now, with CMAKE_NO_BUILTIN_CHRPATH set to
ON, the concerned binaries are actually relinked at installation time
to get the RPATHs right, so there's no need anymore to provide enough
space for the final RPATHs at build time. As a consequence, the f/g
libraries aren't relinked when CMAKE_INSTALL_PREFIX changes, and gen
along with main doesn't become out-of-date. However, lib{f,g}.so are
relinked at installation time, but this should be by far a cheaper
alternative to the nearly complete project's recompilation you've
reported.

'hope that helps.

Regards,

Michael
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to