Working directory for install-time CMake scripts?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Working directory for install-time CMake scripts?

Kevin Ushey

It's possible to request a CMake script to be run at installation time, with e.g.

    install(SCRIPT <script>.cmake)

I think this is most commonly used for fixing up bundles generating during install time (e.g. rpath munging or other muckery). Within such a script, I'd like to execute a shell script that does the heavy lifting, e.g. within the above script I might have:

    execute_process(COMMAND sh <script>.sh)

I'd like to have this bash script run within the install directory. It seems like one can get this directory with e.g.


but this sort of usage seems somewhat thinly documented. suggests DESTDIR can be used when one is using 'make' to build the project, but I'm guessing this may not be portable to other generators. For example, NSIS suggests that the following build directory is used (


For what it's worth, I'm trying this out on Linux when using CPack to generate DEB/RPM packages, and all seems well so far, but I suspect there may be a simpler, or more idiomatic, way to accomplish what I'm trying to do.

tl;dr: Is there a portable way to get the path to the directory being used during the install phase? Or do I need to rethink the way I'm approaching this?



Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: