Browse Source

ENH: Allow user project code to distinguish between an install prefix set on the command line and one set by CMake as a default. This is useful for changing the default prefix while still allowing the user to override it.

Brad King 19 years ago
parent
commit
e55ff93748
1 changed files with 8 additions and 0 deletions
  1. 8 0
      Modules/CMakeGenericSystem.cmake

+ 8 - 0
Modules/CMakeGenericSystem.cmake

@@ -41,6 +41,14 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles")
   MARK_AS_ADVANCED(CMAKE_COLOR_MAKEFILE)
 ENDIF(CMAKE_GENERATOR MATCHES "Makefiles")
 
+# Set a variable to indicate whether the value of CMAKE_INSTALL_PREFIX
+# was initialized by the block below.  This is useful for user
+# projects to change the default prefix while still allowing the
+# command line to override it.
+IF(NOT DEFINED CMAKE_INSTALL_PREFIX)
+  SET(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT 1)
+ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)
+
 # Choose a default install prefix for this platform.
 IF(UNIX)
   SET(CMAKE_INSTALL_PREFIX "/usr/local"