[CMake] About CMAKE_INSTALL_PREFIX

Rolf Eike Beer eike at sf-mail.de
Tue Jan 24 03:48:55 EST 2012


> Hello everbody,
>
> I would like to understand a bit more one feature related to
> CMAKE_INSTALL_PREFIX initialization.
>
> When reading the documentation, it is specified that this variable
contains the directory that will be pre-pended to all install
> directories and that it should be defaulted to C:/Program Files on
Windows. However, in my current build the variable is not defaulted to
C:/Program Files but to C:/Program Files/libcrysfml where "crysfml " is
the name of my base project.
>
> This unexpected feature (at least to my understanding !) leads me to my
second question.
>
> I would like to get rid of the "crysfml " subdirectory in the value of
CMAKE_INSTALL_PREFIX. I could obvioulsy
> use:
>     get_filename_component(MY_CMAKE_INSTALL_PREFIX
> ${CMAKE_INSTALL_PREFIX} PATH)
> but this would fail if CMAKE_INSTALL_PREFIX is set on the cmake command
line by the user because, in such case, the installation will not be
done in the directory that he provided but in its parent directory.
Rather counter-intuitive.
>
> What I would need is a mechanism to detect whether the
> CMAKE_INSTALL_PREFIX has been set or not by the user on the
> command-line. If so, I take directly the values he provided, and if not
so, I take the parent directory of the default value.
>
> Is that possible ?

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
 ...
endif ()

Eike




More information about the CMake mailing list