[CMake] CMAKE_INSTALL_PREFIX and DESTDIR

Fernando Cacciola fernando.cacciola at gmail.com
Fri Feb 22 09:40:31 EST 2008


Hi people,

In 2.4.5

make install DESTDIR=/path/to/dir

puts files in /path/to/dir/usr/local

that's because the actual destination is 
$ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX}

Is this the expected behaviour? or is it a bug in 2.4.5?

If this is expected, what is the best way to allow users to have DESTDIR 
*override* CMAKE_INSTALL_PREFIX? (which IMO is the right thing to do)



Here's what I'm doing now, which seems to work, but is too hacky for my 
taste:
(the string length business is there just because if ( $ENV(DESTDIR) ) 
doesn't work as I expected)


string( LENGTH "$ENV{DESTDIR}" DESTDIRLEN )

if ( ${DESTDIRLEN} GREATER 0 )
  message( STATUS "DESTDIR specified ($ENV{DESTDIR}). Overriding 
CMAKE_INSTALL_PREFIX (${CMAKE_INSTALL_PREFIX})" )
  set( CMAKE_INSTALL_PREFIX "" CACHE PATH "Use DESTDIR *instead* of 
CMAKE_INSTALL_PREFIX" FORCE )
endif()


TIA


-- 
Fernando Cacciola
SciSoft
http://fcacciola.50webs.com
http://groups.google.com/group/cppba







More information about the CMake mailing list