[Cmake-commits] CMake branch, next, updated. v2.8.2-724-g9f061b1

David Cole david.cole at kitware.com
Thu Sep 9 08:33:51 EDT 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  9f061b1486bbce0be4e414138639856082ce8baa (commit)
       via  2f98dac486726c67681ea51a57e19518d7119b1b (commit)
       via  fcbdd3129e7edec4b07f96662aa21371d671cb83 (commit)
      from  1865e7c8666189ff5bcabff7e97c946ede2fbbf0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9f061b1486bbce0be4e414138639856082ce8baa
commit 9f061b1486bbce0be4e414138639856082ce8baa
Merge: 1865e7c 2f98dac
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Thu Sep 9 08:33:49 2010 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Sep 9 08:33:49 2010 -0400

    Merge topic 'fix-9992' into next
    
    2f98dac Correct CMAKE_INSTALL_PREFIX value for Win64 apps (#9992)
    fcbdd31 CMake: quote ':' in Windows NMake Makefiles (#9963)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2f98dac486726c67681ea51a57e19518d7119b1b
commit 2f98dac486726c67681ea51a57e19518d7119b1b
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Thu Sep 9 07:26:03 2010 -0400
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Thu Sep 9 08:32:42 2010 -0400

    Correct CMAKE_INSTALL_PREFIX value for Win64 apps (#9992)
    
    The default value for CMAKE_INSTALL_PREFIX should be
    based on what architecture the built targets are, not
    what architecture CMake itself is.
    
    This fix merely guesses better what the built targets
    architecture is. It still may guess incorrectly in some
    cases. For those cases, it will have to be up to build
    scripts and developers on projects to pass in a correct
    value for CMAKE_INSTALL_PREFIX with -D on the command line
    or via 'force cache value' logic in CMakeLists.txt files.

diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake
index 7d2d8cd..b5d3072 100644
--- a/Modules/CMakeGenericSystem.cmake
+++ b/Modules/CMakeGenericSystem.cmake
@@ -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(

-----------------------------------------------------------------------

Summary of changes:
 Modules/CMakeGenericSystem.cmake |  102 +++++++++++++++++++++++++++++++++-----
 Source/kwsys/System.c            |    3 +-
 2 files changed, 91 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list