mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-19 22:38:33 -05:00
cmake: Allow CMAKE_INSTALL_PREFIX to be set by environment variable
Fixes: #25023
This commit is contained in:
committed by
Brad King
parent
b0d8b857d8
commit
06af18b9db
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user