<div dir="ltr">I find it's better to define CMAKE_INSTALL_PREFIX on the command line when building<div><br></div><div>I do have this bit of code...</div><div><br></div><div><div>IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)</div><div>  SET(CMAKE_INSTALL_PREFIX<br></div><div>    ${CMAKE_BINARY_DIR}/../${CMAKE_BUILD_TYPE}_out CACHE PATH "Install default 'out' in this directory." FORCE</div><div>    )</div><div>ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)<br></div></div><div><br></div><div><br></div><div>which keeps it from overwriting an already set value (from the command line); and make sure it's in the cache so cmake-gui can edit it... </div><div><br></div><div>(if  project() does something with cmake_isnstall_prefix might also be a bug) </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 4, 2014 at 7:27 PM, Chris Johnson <span dir="ltr"><<a href="mailto:cxjohnson@gmail.com" target="_blank">cxjohnson@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><font face="monospace">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.</font><br><br><font face="monospace">In my CMakeLists.txt file, I had this:</font><br><br><font face="monospace">cmake_minimum_require(VERSION 2.8.4)</font><br><font face="monospace">include(global.inc)</font><br><font face="monospace">project(whatever)</font><br><br><font face="monospace">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.</font><br><br><font face="monospace">However, if I change the order to this:</font><br><br><font face="monospace">cmake_minimum_require(VERSION 2.8.4)</font><br><font face="monospace">project(whatever)</font><br><font face="monospace">include(global.inc)</font><br><br><font face="monospace">It appears to work.</font><br><br><font face="monospace">I find nothing in the documentation saying that the project() directive will set CMAKE_INSTALL_PREFIX.</font><br><br><font face="monospace">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. </font><div class="gmail_default" style="font-family:'courier new',monospace;display:inline">​ ​</div><font face="monospace">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</font><div class="gmail_default" style="display:inline"><font face="courier new, monospace">​, even though they contain the wrong path value for CMAKE_INSTALL_PREFIX.​</font></div><div><font face="monospace"><br>What is going on here?</font><br></div><div><font face="monospace"><br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace"><br></font></div></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div>