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)
118
115
if(NOT "${vs_version}" VERSION_LESS 10)
129
if("${id_arch}" STREQUAL "x64")
130
set(id_machine_10 MachineX64)
131
elseif("${id_arch}" STREQUAL "Itanium")
132
set(id_machine_10 MachineIA64)
135
set(id_machine_6 x86)
136
set(id_machine_10 MachineX86)
126
if("${id_platform}" STREQUAL "Itanium")
127
set(id_platform ia64)
138
129
if(CMAKE_VS_PLATFORM_TOOLSET)
139
130
set(id_toolset "<PlatformToolset>${CMAKE_VS_PLATFORM_TOOLSET}</PlatformToolset>")
143
134
if(CMAKE_VS_WINCE_VERSION)
144
135
set(id_entrypoint "mainACRTStartup")
136
if("${vs_version}" VERSION_LESS 9)
147
142
set(id_subsystem 1)
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]")
337
# Detect the exact architecture from the PE header.
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}")
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")
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}")