diff options
author | Brad King <brad.king@kitware.com> | 2024-01-31 14:03:10 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-01-31 14:03:21 (GMT) |
commit | 16b1f0c3e99023316b12fdabd1980a18b738d942 (patch) | |
tree | deb2853897370754c302aef05328f275a791ca57 /Modules | |
parent | 2a008138420b0a2cc867f5d3e47accc7d2fda5e0 (diff) | |
parent | 06af18b9db267926dfd8fd346328a64a41238aa3 (diff) | |
download | CMake-16b1f0c3e99023316b12fdabd1980a18b738d942.zip CMake-16b1f0c3e99023316b12fdabd1980a18b738d942.tar.gz CMake-16b1f0c3e99023316b12fdabd1980a18b738d942.tar.bz2 |
Merge topic 'env-cmake-install-prefix'
06af18b9db cmake: Allow CMAKE_INSTALL_PREFIX to be set by environment variable
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9200
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeGenericSystem.cmake | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index 77c1780..ccfde60 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -177,20 +177,27 @@ endfunction() # 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) +if(NOT DEFINED CMAKE_INSTALL_PREFIX AND + NOT DEFINED ENV{CMAKE_INSTALL_PREFIX}) set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT 1) endif() -# Choose a default install prefix for this platform. -if(CMAKE_HOST_UNIX) - set(CMAKE_INSTALL_PREFIX "/usr/local" +if(DEFINED ENV{CMAKE_INSTALL_PREFIX}) + set(CMAKE_INSTALL_PREFIX "$ENV{CMAKE_INSTALL_PREFIX}" CACHE PATH "Install path prefix, prepended onto install directories.") else() - GetDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES) - set(CMAKE_INSTALL_PREFIX - "${CMAKE_GENERIC_PROGRAM_FILES}/${PROJECT_NAME}" - CACHE PATH "Install path prefix, prepended onto install directories.") - set(CMAKE_GENERIC_PROGRAM_FILES) + # If CMAKE_INSTALL_PREFIX env variable is not set, + # choose a default install prefix for this platform. + if(CMAKE_HOST_UNIX) + set(CMAKE_INSTALL_PREFIX "/usr/local" + CACHE PATH "Install path prefix, prepended onto install directories.") + else() + GetDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES) + set(CMAKE_INSTALL_PREFIX + "${CMAKE_GENERIC_PROGRAM_FILES}/${PROJECT_NAME}" + CACHE PATH "Install path prefix, prepended onto install directories.") + set(CMAKE_GENERIC_PROGRAM_FILES) + endif() endif() # Set a variable which will be used as component name in install() commands |