mirror of
https://github.com/reactos/CMake.git
synced 2024-12-10 12:55:12 +00:00
Merge topic 'fix-9992'
2f98dac
Correct CMAKE_INSTALL_PREFIX value for Win64 apps (#9992)
This commit is contained in:
commit
913437da72
@ -52,6 +52,94 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles")
|
||||
ENDIF(DEFINED CMAKE_RULE_MESSAGES)
|
||||
ENDIF(CMAKE_GENERATOR MATCHES "Makefiles")
|
||||
|
||||
|
||||
# GetDefaultWindowsPrefixBase
|
||||
#
|
||||
# Compute the base directory for CMAKE_INSTALL_PREFIX based on:
|
||||
# - is this 32-bit or 64-bit Windows
|
||||
# - is this 32-bit or 64-bit CMake running
|
||||
# - what architecture targets will be built
|
||||
#
|
||||
function(GetDefaultWindowsPrefixBase var)
|
||||
|
||||
# Try to guess what architecture targets will end up being built as,
|
||||
# even if CMAKE_SIZEOF_VOID_P is not computed yet... We need to know
|
||||
# the architecture of the targets being built to choose the right
|
||||
# default value for CMAKE_INSTALL_PREFIX.
|
||||
#
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Win64")
|
||||
set(arch_hint "x64")
|
||||
elseif("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
|
||||
set(arch_hint "x64")
|
||||
elseif("$ENV{LIB}" MATCHES "(amd64|ia64)")
|
||||
set(arch_hint "x64")
|
||||
endif()
|
||||
|
||||
if(NOT arch_hint)
|
||||
set(arch_hint "x86")
|
||||
endif()
|
||||
|
||||
# default env in a 64-bit app on Win64:
|
||||
# ProgramFiles=C:\Program Files
|
||||
# ProgramFiles(x86)=C:\Program Files (x86)
|
||||
# ProgramW6432=C:\Program Files
|
||||
#
|
||||
# default env in a 32-bit app on Win64:
|
||||
# ProgramFiles=C:\Program Files (x86)
|
||||
# ProgramFiles(x86)=C:\Program Files (x86)
|
||||
# ProgramW6432=C:\Program Files
|
||||
#
|
||||
# default env in a 32-bit app on Win32:
|
||||
# ProgramFiles=C:\Program Files
|
||||
# ProgramFiles(x86) NOT DEFINED
|
||||
# ProgramW6432 NOT DEFINED
|
||||
|
||||
# By default, use the ProgramFiles env var as the base value of
|
||||
# CMAKE_INSTALL_PREFIX:
|
||||
#
|
||||
set(_PREFIX_ENV_VAR "ProgramFiles")
|
||||
|
||||
if ("$ENV{ProgramW6432}" STREQUAL "")
|
||||
# running on 32-bit Windows
|
||||
# must be a 32-bit CMake, too...
|
||||
#message("guess: this is a 32-bit CMake running on 32-bit Windows")
|
||||
else()
|
||||
# running on 64-bit Windows
|
||||
if ("$ENV{ProgramW6432}" STREQUAL "$ENV{ProgramFiles}")
|
||||
# 64-bit CMake
|
||||
#message("guess: this is a 64-bit CMake running on 64-bit Windows")
|
||||
if(NOT "${arch_hint}" STREQUAL "x64")
|
||||
# building 32-bit targets
|
||||
set(_PREFIX_ENV_VAR "ProgramFiles(x86)")
|
||||
endif()
|
||||
else()
|
||||
# 32-bit CMake
|
||||
#message("guess: this is a 32-bit CMake running on 64-bit Windows")
|
||||
if("${arch_hint}" STREQUAL "x64")
|
||||
# building 64-bit targets
|
||||
set(_PREFIX_ENV_VAR "ProgramW6432")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#if("${arch_hint}" STREQUAL "x64")
|
||||
# message("guess: you are building a 64-bit app")
|
||||
#else()
|
||||
# message("guess: you are building a 32-bit app")
|
||||
#endif()
|
||||
|
||||
if(NOT "$ENV{${_PREFIX_ENV_VAR}}" STREQUAL "")
|
||||
file(TO_CMAKE_PATH "$ENV{${_PREFIX_ENV_VAR}}" _base)
|
||||
elseif(NOT "$ENV{SystemDrive}" STREQUAL "")
|
||||
set(_base "$ENV{SystemDrive}/Program Files")
|
||||
else()
|
||||
set(_base "C:/Program Files")
|
||||
endif()
|
||||
|
||||
set(${var} "${_base}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
# 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
|
||||
@ -65,23 +153,11 @@ IF(CMAKE_HOST_UNIX)
|
||||
SET(CMAKE_INSTALL_PREFIX "/usr/local"
|
||||
CACHE PATH "Install path prefix, prepended onto install directories.")
|
||||
ELSE(CMAKE_HOST_UNIX)
|
||||
IF("$ENV{ProgramFiles}" MATCHES "^$")
|
||||
IF("$ENV{SystemDrive}" MATCHES "^$")
|
||||
SET(CMAKE_GENERIC_PROGRAM_FILES "C:/Program Files")
|
||||
ELSE("$ENV{SystemDrive}" MATCHES "^$")
|
||||
SET(CMAKE_GENERIC_PROGRAM_FILES "$ENV{SystemDrive}/Program Files")
|
||||
ENDIF("$ENV{SystemDrive}" MATCHES "^$")
|
||||
ELSE("$ENV{ProgramFiles}" MATCHES "^$")
|
||||
SET(CMAKE_GENERIC_PROGRAM_FILES "$ENV{ProgramFiles}")
|
||||
ENDIF("$ENV{ProgramFiles}" MATCHES "^$")
|
||||
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)
|
||||
|
||||
# Make sure the prefix uses forward slashes.
|
||||
STRING(REGEX REPLACE "\\\\" "/"
|
||||
CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
ENDIF(CMAKE_HOST_UNIX)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
|
Loading…
Reference in New Issue
Block a user