[CMake] Custom install target

Michael Hertling mhertling at online.de
Thu Oct 6 22:36:46 EDT 2011


On 10/06/2011 08:23 AM, ycollette.nospam at free.fr wrote:
> Hello,
> 
> I would like to create a custom install target: install-update
> The things done by this target are:
> - change CMAKE_INSTALL_PREFIX to a specific directory: CMAKE_BINARY_PREFIX/PROJECT_NAME-REVISION_NUMBER
> - run "make install"
> 
> I don't know how to launch a defined target from within cmake. Is there any simple solution to do that ?
> 
> Best regards,
> 
> YC

Look at the attached exemplary CMakeLists.txt file. However, note that

- changing the CMAKE_INSTALL_PREFIX means invalidating the build tree,
  so the whole project is built anew when install-update is triggered,
- triggering install-update means rebuilding *and* installing, so you
  possibly need root privileges for this to succeed; building as root
  is inadvisable, so you should perhaps limit yourself to a target
  "build-update" without the install step and run "make install"
  in the end as usual.

'hope that helps.

Regards,

Michael
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CMakeLists.txt
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111007/73bce741/attachment.txt>


More information about the CMake mailing list