On 04/29/2011 03:39 PM, Pere Mato Vila wrote:
> Perhaps somebody can give me some hints on this problem I have. I build a 
> project and install it in <path>/install with "make install".  Then I do 
> change the installation prefix with 
>  cmake -DCMAKE_INSTALL_PREFIX=<path>/install2 ../root_cmake/
> and if I execute again "make install" it rebuilds basically every library of 
> the project.  I have traced the dependency to the generated link.txt file, 
> which contains the link command. In one case the contents of the file is: 
> 
> /usr/bin/c++  -fPIC  -pipe -m64 -Wall -W -Woverloaded-virtual -fPIC -O2 -g  
> -shared -Wl,-soname,libCint.so -o ../../lib/libCint.so 
> CMakeFiles/Cint.dir/src/loadfile.o ../../lib/libCint_static.a -lpthread 
> -Wl,-rpath,:::::::::::::::::::::::::::: 
> 
> and in the other is:
> 
> /usr/bin/c++  -fPIC  -pipe -m64 -Wall -W -Woverloaded-virtual -fPIC -O2 -g  
> -shared -Wl,-soname,libCint.so -o ../../lib/libCint.so 
> CMakeFiles/Cint.dir/src/loadfile.o ../../lib/libCint_static.a -lpthread 
> -Wl,-rpath,::::::::::::::::::::::::::::: 
> 
> Notice the different number of colons in the -rpath settings. The first 
> question I have is what is the origin of these many colons in the rpath 
> settings? The second question, why is different when I choose another 
> installation directory. My CMake variables that control RPATH are the 
> following:
> 
> first 
> 
> CMAKE_INSTALL_RPATH -->/build/mato/ROOT/install/lib
> CMAKE_INSTALL_RPATH_USE_LINK_PATH -->TRUE
> CMAKE_SKIP_BUILD_RPATH -->FALSE
> CMAKE_BUILD_WITH_INSTALL_RPATH -->FALSE
> 
> and later 
> 
> CMAKE_INSTALL_RPATH -->/build/mato/ROOT/install2/lib
> CMAKE_INSTALL_RPATH_USE_LINK_PATH -->TRUE
> CMAKE_SKIP_BUILD_RPATH -->FALSE
> CMAKE_BUILD_WITH_INSTALL_RPATH -->FALSE

AFAIK, changing CMAKE_INSTALL_PREFIX - or any other variable in CMake's
cache - doesn't trigger a recompilation or relinking by itself. Look at
the following CMakeLists.txt

CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(PREFIX C)
SET(CMAKE_VERBOSE_MAKEFILE ON)
ADD_LIBRARY(f SHARED f.c)
INSTALL(TARGETS f
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib)

with ${CMAKE_SOURCE_DIR}/f.c containing just "void f(void){}". After
configuring/building/installing, a reconfiguration with a modified
CMAKE_INSTALL_PREFIX does not result in recompiling or relinking.

Nevertheless, what may be very well is that there are files which get
generated during a (re)configuration, typically configured headers, so
their regeneration will invalidate other files that depend on them and,
thus, trigger recompilations and the relinking of the affected targets.

There's a further mechanism beyond the regeneration of headers or
source files that triggers recompilations in this regard: Add

SET_SOURCE_FILES_PROPERTIES(
    ${CMAKE_SOURCE_DIR}/f.c
    PROPERTIES
    COMPILE_DEFINITIONS "PREFIX=${CMAKE_INSTALL_PREFIX}")

to the above-noted CMakeLists.txt and you'll see that a modified
CMAKE_INSTALL_PREFIX does result in a rebuild now. Refer to the
${CMAKE_BINARY_DIR}/CMakeFiles/f.dir/flags.make file for the
reason.

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