[CMake] Setting default install prefix?

David Cole david.cole at kitware.com
Sat Aug 11 12:41:37 EDT 2007


Q: What is the appropriate way of doing this?
A: Not sure about "appropriate", but here's one way that I achieve that
goal... :-)

SET(MY_OWN_INSTALL_PREFIX "/usr/thispkg" CACHE PATH "Prefix prepended to
install directories")
SET(CMAKE_INSTALL_PREFIX "${MY_OWN_INSTALL_PREFIX}" CACHE INTERNAL "Prefix
prepended to install directories" FORCE)

That way, you have a cache variable that CMake knows nothing about (and
hence, has no default value for it) that you are in charge of priming, but
that the user can still change through the ccmake/CMakeSetup guis... that
always gets propagated into CMAKE_INSTALL_PREFIX because of the FORCE. (And
gets hidden from the guis because of the INTERNAL.)

Of course, the FORCE means you cannot override via -DCMAKE_INSTALL_PREFIX,
but you could still override via -DMY_OWN_INSTALL_PREFIX.


HTH,
David


On 8/11/07, Lee Butler <iraytrace at mac.com> wrote:
>
> Is there a way to override CMAKE_INSTALL_PREFIX in a multi-level CMake
> project?  Since my package has a long history of being installed in a
> location other than /usr/local, I really want to have the default match
> previous practice.
> For example, I have a source tree that looks like this:
> root_dir
>     src
>     lib
>
> In the root_dir/CMakeLists.txt file I set:
>
> SET(CMAKE_INSTALL_PREFIX "/usr/thispkg" CACHE PATH "Prefix prepended to
> install directories")
>
> However this default setting does not show up when running ccmake or
> cmake.
>
> Changing this to:
>
> SET(CMAKE_INSTALL_PREFIX "/usr/thispkg")
>
> causes the value to show up in the root cmake_install.cmake file but
> nowhere else.
>
> What is the appropriate way of doing this?
>
> Lee Butler
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20070811/ea613af3/attachment.htm


More information about the CMake mailing list