~ubuntu-branches/ubuntu/utopic/cmake/utopic

« back to all changes in this revision

Viewing changes to Modules/CMakeDetermineCompilerId.cmake

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-10-10 12:54:39 UTC
  • mfrom: (1.14.7)
  • Revision ID: package-import@ubuntu.com-20131010125439-h0ahaj004on6oj92
Tags: 2.8.12-0ubuntu1
New upstream release LP: #1246701

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
  # Compile the compiler identification source.
110
110
  if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)")
111
111
    set(vs_version ${CMAKE_MATCH_1})
112
 
    set(id_arch ${CMAKE_VS_PLATFORM_NAME})
 
112
    set(id_platform ${CMAKE_VS_PLATFORM_NAME})
113
113
    set(id_lang "${lang}")
114
114
    set(id_cl cl.exe)
115
 
    if(NOT id_arch)
116
 
      set(id_arch Win32)
117
 
    endif()
118
115
    if(NOT "${vs_version}" VERSION_LESS 10)
119
116
      set(v 10)
120
117
      set(ext vcxproj)
126
123
      set(v 6)
127
124
      set(ext dsp)
128
125
    endif()
129
 
    if("${id_arch}" STREQUAL "x64")
130
 
      set(id_machine_10 MachineX64)
131
 
    elseif("${id_arch}" STREQUAL "Itanium")
132
 
      set(id_machine_10 MachineIA64)
133
 
      set(id_arch ia64)
134
 
    else()
135
 
      set(id_machine_6 x86)
136
 
      set(id_machine_10 MachineX86)
 
126
    if("${id_platform}" STREQUAL "Itanium")
 
127
      set(id_platform ia64)
137
128
    endif()
138
129
    if(CMAKE_VS_PLATFORM_TOOLSET)
139
130
      set(id_toolset "<PlatformToolset>${CMAKE_VS_PLATFORM_TOOLSET}</PlatformToolset>")
142
133
    endif()
143
134
    if(CMAKE_VS_WINCE_VERSION)
144
135
      set(id_entrypoint "mainACRTStartup")
145
 
      set(id_subsystem 9)
 
136
      if("${vs_version}" VERSION_LESS 9)
 
137
        set(id_subsystem 9)
 
138
      else()
 
139
        set(id_subsystem 8)
 
140
      endif()
146
141
    else()
147
142
      set(id_subsystem 1)
148
143
    endif()
149
144
    if("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Bb][Uu][Ii][Ll][Dd]")
150
 
      set(build /p:Configuration=Debug /p:Platform=@id_arch@ /p:VisualStudioVersion=${vs_version}.0)
 
145
      set(build /p:Configuration=Debug /p:Platform=@id_platform@ /p:VisualStudioVersion=${vs_version}.0)
151
146
    elseif("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Dd][Ee][Vv]")
152
147
      set(build /make)
153
148
    else()
339
334
      endif()
340
335
    endforeach()
341
336
 
 
337
    # Detect the exact architecture from the PE header.
 
338
    if(WIN32)
 
339
      # The offset to the PE signature is stored at 0x3c.
 
340
      file(READ ${file} peoffsethex LIMIT 1 OFFSET 60 HEX)
 
341
      string(SUBSTRING "${peoffsethex}" 0 1 peoffsethex1)
 
342
      string(SUBSTRING "${peoffsethex}" 1 1 peoffsethex2)
 
343
      set(peoffsetexpression "${peoffsethex1} * 16 + ${peoffsethex2}")
 
344
      string(REPLACE "a" "10" peoffsetexpression "${peoffsetexpression}")
 
345
      string(REPLACE "b" "11" peoffsetexpression "${peoffsetexpression}")
 
346
      string(REPLACE "c" "12" peoffsetexpression "${peoffsetexpression}")
 
347
      string(REPLACE "d" "13" peoffsetexpression "${peoffsetexpression}")
 
348
      string(REPLACE "e" "14" peoffsetexpression "${peoffsetexpression}")
 
349
      string(REPLACE "f" "15" peoffsetexpression "${peoffsetexpression}")
 
350
      math(EXPR peoffset "${peoffsetexpression}")
 
351
 
 
352
      file(READ ${file} peheader LIMIT 6 OFFSET ${peoffset} HEX)
 
353
      if(peheader STREQUAL "50450000a201")
 
354
        set(ARCHITECTURE_ID "SH3")
 
355
      elseif(peheader STREQUAL "50450000a301")
 
356
        set(ARCHITECTURE_ID "SH3DSP")
 
357
      elseif(peheader STREQUAL "50450000a601")
 
358
        set(ARCHITECTURE_ID "SH4")
 
359
      elseif(peheader STREQUAL "50450000a801")
 
360
        set(ARCHITECTURE_ID "SH5")
 
361
      elseif(peheader STREQUAL "50450000c201")
 
362
        set(ARCHITECTURE_ID "THUMB")
 
363
      endif()
 
364
    endif()
 
365
 
342
366
    # Check if a valid compiler and platform were found.
343
367
    if(COMPILER_ID AND NOT COMPILER_ID_TWICE)
344
368
      set(CMAKE_${lang}_COMPILER_ID "${COMPILER_ID}")