[CMake] Set system install prefix

Hendrik Sattler post at hendrik-sattler.de
Tue Dec 3 12:42:47 EST 2013



Theo Diefenthal <diefenthal at ifi.uzh.ch> schrieb:
>Hey there,
>
>First, I already searched quite a while for my question, but couldn't
>find anything related to it, even though I think, it is probably asked
>already somewhere. So I'm sorry if this produces a double post...
>
>But now to my question:
>I wonder if there is a possibility to set a system wide install prefix
>in CMake.
>
>I know, I can call
>	cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr /sourceDir && make all install
>
>And I also know that I can override the install prefix for my own
>projects easily with this piece of code:
>	if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
>		if(DEFINED ENV{CMAKE_DEFAULT_INSTALL_DIR})
>			set (CMAKE_INSTALL_PREFIX
>"$ENV{CMAKE_DEFAULT_INSTALL_DIR}/${MY_PROJECT_NAME}" CACHE PATH
>"Project
>installation path" FORCE )
>		endif()
>	endif()
>
>However, what I would really like to do is to set a global install
>prefix for my system where cmake then installs to, for all projects,
>not
>only my own ones.
>Just like having an environment variable set as
>CMAKE_DEFAULT_INSTALL_DIR which will be read out and replace the
>CMAKE_INSTALL_PREFIX default value with a new default value.
>Setting CMAKE_INSTALL_PREFIX as environment variable on my Windows
>system sadly doesn't change anything, it still uses C:\Program Files\
>
>Sadly, C:\Program Files is a really annyong install directory. If I
>forget to change the install directory and want to test my
>installation,
>I then need to restart Visual Studio with Admin rights to write in
>C:\Program Files or need to reexecute CMake to change the install
>prefix.
>Also, I would like to have the install prefix on a different partition,
>not the same with the system....

On Windows you can add a cmake.bat file and start the real cmake from that file.

>Best regards
>Theo
>
>--
>
>Powered by www.kitware.com
>
>Please keep messages on-topic and check the CMake FAQ at:
>http://www.cmake.org/Wiki/CMake_FAQ
>
>Kitware offers various services to support the CMake community. For
>more information on each offering, please visit:
>
>CMake Support: http://cmake.org/cmake/help/support.html
>CMake Consulting: http://cmake.org/cmake/help/consulting.html
>CMake Training Courses: http://cmake.org/cmake/help/training.html
>
>Visit other Kitware open-source projects at
>http://www.kitware.com/opensource/opensource.html
>
>Follow this link to subscribe/unsubscribe:
>http://www.cmake.org/mailman/listinfo/cmake




More information about the CMake mailing list