[CMake] project directive overwrites CMAKE_INSTALL_PREFIX?
Chris Johnson
cxjohnson at gmail.com
Thu Dec 4 22:27:31 EST 2014
I have a global include file used by all of the CMakeLists.txt files in my
project. In it, I set the value of CMAKE_INSTALL_PREFIX, as well as a
number of other variables and functions.
In my CMakeLists.txt file, I had this:
cmake_minimum_require(VERSION 2.8.4)
include(global.inc)
project(whatever)
When I run cmake, the value of CMAKE_INSTALL_PREFIX is lost! Instead, in
the resulting cmake_install.cmake file has been defaulted back to
/usr/local which is completely wrong.
However, if I change the order to this:
cmake_minimum_require(VERSION 2.8.4)
project(whatever)
include(global.inc)
It appears to work.
I find nothing in the documentation saying that the project() directive
will set CMAKE_INSTALL_PREFIX.
Even more strangely, if I run cmake a second time with the first
configuration (include before project), it will rewrite cmake_install.cmake
with the correct value.
That is, the behavior of cmake appears to be different based on whether the
build directory is empty or already contains cmake_install.cmake and
CMakeCache.txt files
, even though they contain the wrong path value for CMAKE_INSTALL_PREFIX.
What is going on here?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20141204/688f5a57/attachment.html>
More information about the CMake
mailing list