It probably works "accidentally" if you do the set before the project command.
Unfortunately, the project command has significant side effects. Setting a default (cached) value for CMAKE_INSTALL_PREFIX might be one of those... On Tuesday, November 30, 2010, Tyler Roscoe <ty...@cryptio.net> wrote: > On Thu, Nov 25, 2010 at 02:01:31PM +0100, Marcel Loose wrote: >> >>> On 24-11-2010 at 17:45, in message >> <20101124164507.gg23...@cryptio.net>, Tyler >> Roscoe <ty...@cryptio.net> wrote: >> > On Wed, Nov 24, 2010 at 12:11:56PM +0100, Micha Renner wrote: >> >> >> >> > SET(CMAKE_INSTALL_PREFIX "/foo/bar" CACHE PATH "Foo install >> prefix") >> >> > >> >> > So, without the test to >> CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT, >> >> > and without the FORCE option. >> >> >> >> No, as I mentioned, there was an article of one the >> CMake-maintainers >> >> who recommended this. >> > >> > Micha is correct. CMAKE_INSTALL_PREFIX is set before your >> CMakeLists.txt >> > is processed, so the above will never do anything. >> > >> > tyler >> >> Well, I tested this before I posted my reply. It does work the way I >> describe it. Try it yourself. > > It doesn't work for me: > > [tyle...@tpb006:~/cmake-test-install-prefix]$ cmake --version > cmake version 2.8.3 > > [tyle...@tpb006:~/cmake-test-install-prefix]$ cat CMakeLists.txt > cmake_minimum_required(VERSION 2.8) > project(p) > > set (CMAKE_INSTALL_PREFIX "foo" CACHE PATH "docstring") > message ("CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}") > > [tyle...@tpb006:~/cmake-test-install-prefix]$ mkdir b && cd b && cmake .. > -- The C compiler identification is GNU > -- The CXX compiler identification is GNU > -- Check for working C compiler: /usr/bin/gcc > -- Check for working C compiler: /usr/bin/gcc -- works > -- Detecting C compiler ABI info > -- Detecting C compiler ABI info - done > -- Check for working CXX compiler: /usr/bin/c++ > -- Check for working CXX compiler: /usr/bin/c++ -- works > -- Detecting CXX compiler ABI info > -- Detecting CXX compiler ABI info - done > CMAKE_INSTALL_PREFIX = /usr/local > -- Configuring done > -- Generating done > -- Build files have been written to: > /tpb006/tylermr/cmake-test-install-prefix/b > _______________________________________________ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake > _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake