[Cmake-commits] CMake branch, next, updated. v2.8.11.2-3680-g299d7e4

Patrick Gansterer paroga at paroga.com
Mon Aug 5 14:06:14 EDT 2013


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  299d7e408ed7435e5265ef8acde75fa133901f23 (commit)
       via  bd827f98efc1d4294b9a7d0fc134629b7507f4a1 (commit)
      from  03789fe34fad71cea77b1feb57adc0d241021233 (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=299d7e408ed7435e5265ef8acde75fa133901f23
commit 299d7e408ed7435e5265ef8acde75fa133901f23
Merge: 03789fe bd827f9
Author:     Patrick Gansterer <paroga at paroga.com>
AuthorDate: Mon Aug 5 14:06:12 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Aug 5 14:06:12 2013 -0400

    Merge topic 'peheader' into next
    
    bd827f9 WIN: Use COFF file header header for architecture detection (#14083)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bd827f98efc1d4294b9a7d0fc134629b7507f4a1
commit bd827f98efc1d4294b9a7d0fc134629b7507f4a1
Author:     Patrick Gansterer <paroga at paroga.com>
AuthorDate: Mon Aug 5 20:04:44 2013 +0200
Commit:     Patrick Gansterer <paroga at paroga.com>
CommitDate: Mon Aug 5 20:04:44 2013 +0200

    WIN: Use COFF file header header for architecture detection (#14083)
    
    Read the machine field from the COFF file header to get the exact
    target architecture for ARM and SHx on the Windows platform.

diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index ae91a29..71bf293 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -341,6 +341,35 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
       endif()
     endforeach()
 
+    # Detect the exact architecture from the PE header.
+    if(WIN32)
+      # The offset to the PE signature is stored at 0x3c.
+      file(READ ${file} peoffsethex LIMIT 1 OFFSET 60 HEX)
+      string(SUBSTRING "${peoffsethex}" 0 1 peoffsethex1)
+      string(SUBSTRING "${peoffsethex}" 1 1 peoffsethex2)
+      set(peoffsetexpression "${peoffsethex1} * 16 + ${peoffsethex2}")
+      string(REPLACE "a" "10" peoffsetexpression "${peoffsetexpression}")
+      string(REPLACE "b" "11" peoffsetexpression "${peoffsetexpression}")
+      string(REPLACE "c" "12" peoffsetexpression "${peoffsetexpression}")
+      string(REPLACE "d" "13" peoffsetexpression "${peoffsetexpression}")
+      string(REPLACE "e" "14" peoffsetexpression "${peoffsetexpression}")
+      string(REPLACE "f" "15" peoffsetexpression "${peoffsetexpression}")
+      math(EXPR peoffset "${peoffsetexpression}")
+
+      file(READ ${file} peheader LIMIT 6 OFFSET ${peoffset} HEX)
+      if(peheader STREQUAL "50450000a201")
+        set(ARCHITECTURE_ID "SH3")
+      elseif(peheader STREQUAL "50450000a301")
+        set(ARCHITECTURE_ID "SH3DSP")
+      elseif(peheader STREQUAL "50450000a601")
+        set(ARCHITECTURE_ID "SH4")
+      elseif(peheader STREQUAL "50450000a801")
+        set(ARCHITECTURE_ID "SH5")
+      elseif(peheader STREQUAL "50450000c201")
+        set(ARCHITECTURE_ID "THUMB")
+      endif()
+    endif()
+
     # Check if a valid compiler and platform were found.
     if(COMPILER_ID AND NOT COMPILER_ID_TWICE)
       set(CMAKE_${lang}_COMPILER_ID "${COMPILER_ID}")
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index 9f97570..1a2d3e9 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -171,13 +171,6 @@ set(_MACHINE_ARCH_FLAG ${MSVC_C_ARCHITECTURE_ID})
 if(NOT _MACHINE_ARCH_FLAG)
   set(_MACHINE_ARCH_FLAG ${MSVC_CXX_ARCHITECTURE_ID})
 endif()
-if(WINCE)
-  if(_MACHINE_ARCH_FLAG MATCHES "ARM")
-    set(_MACHINE_ARCH_FLAG "THUMB")
-  elseif(_MACHINE_ARCH_FLAG MATCHES "SH")
-    set(_MACHINE_ARCH_FLAG "SH4")
-  endif()
-endif()
 set (CMAKE_EXE_LINKER_FLAGS_INIT
     "${CMAKE_EXE_LINKER_FLAGS_INIT} /machine:${_MACHINE_ARCH_FLAG}")
 

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

Summary of changes:
 Modules/CMakeDetermineCompilerId.cmake |   29 +++++++++++++++++++++++++++++
 Modules/Platform/Windows-MSVC.cmake    |    7 -------
 2 files changed, 29 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list