diff options
author | Brad King <brad.king@kitware.com> | 2015-02-25 14:03:03 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-02-25 14:03:03 (GMT) |
commit | 71a610ff2997bd0d92c332572c0dd35405a77682 (patch) | |
tree | e83e1911fb9a3f58e51061b79c0e92a0e7ba54da /Modules/Platform | |
parent | b38f535eaa648005d700e214ac77c774b4a7509e (diff) | |
parent | 3d612c735285d9a63d4981a2ca7bff44cd741e4b (diff) | |
download | CMake-71a610ff2997bd0d92c332572c0dd35405a77682.zip CMake-71a610ff2997bd0d92c332572c0dd35405a77682.tar.gz CMake-71a610ff2997bd0d92c332572c0dd35405a77682.tar.bz2 |
Merge topic 'refine-MSVC-ARM-WinCE'
3d612c73 MSVC: Compile with arch-specific flags on ARM platforms (#14552)
886dcaa7 MSVC: Distinguish among ARM architectures more precisely (#14552)
ea986676 MSVC: Define /DWINCE when building for WinCE platforms (#14552)
Diffstat (limited to 'Modules/Platform')
-rw-r--r-- | Modules/Platform/Windows-MSVC.cmake | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 2440f89..267de3c 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -131,14 +131,18 @@ endif() # default to Debug builds set(CMAKE_BUILD_TYPE_INIT Debug) +# Compute an architecture family from the architecture id. +foreach(lang C CXX) + set(_MSVC_${lang}_ARCHITECTURE_FAMILY "${MSVC_${lang}_ARCHITECTURE_ID}") + if(_MSVC_${lang}_ARCHITECTURE_FAMILY MATCHES "^ARM") + set(_MSVC_${lang}_ARCHITECTURE_FAMILY "ARM") + elseif(_MSVC_${lang}_ARCHITECTURE_FAMILY MATCHES "^SH") + set(_MSVC_${lang}_ARCHITECTURE_FAMILY "SHx") + endif() +endforeach() + if(WINCE) foreach(lang C CXX) - set(_MSVC_${lang}_ARCHITECTURE_FAMILY "${MSVC_${lang}_ARCHITECTURE_ID}") - if(_MSVC_${lang}_ARCHITECTURE_FAMILY STREQUAL "THUMB") - set(_MSVC_${lang}_ARCHITECTURE_FAMILY "ARM") - elseif(_MSVC_${lang}_ARCHITECTURE_FAMILY MATCHES "^SH") - set(_MSVC_${lang}_ARCHITECTURE_FAMILY "SHx") - endif() string(TOUPPER "${_MSVC_${lang}_ARCHITECTURE_FAMILY}" _MSVC_${lang}_ARCHITECTURE_FAMILY_UPPER) endforeach() @@ -150,12 +154,23 @@ if(WINCE) message(FATAL_ERROR "Invalid Windows CE version: ${CMAKE_SYSTEM_VERSION}") endif() - set(_PLATFORM_DEFINES "/D_WIN32_WCE=0x${_CE_VERSION} /DUNDER_CE") + set(_PLATFORM_DEFINES "/D_WIN32_WCE=0x${_CE_VERSION} /DUNDER_CE /DWINCE") set(_PLATFORM_DEFINES_C " /D${_MSVC_C_ARCHITECTURE_FAMILY} /D_${_MSVC_C_ARCHITECTURE_FAMILY_UPPER}_") set(_PLATFORM_DEFINES_CXX " /D${_MSVC_CXX_ARCHITECTURE_FAMILY} /D_${_MSVC_CXX_ARCHITECTURE_FAMILY_UPPER}_") set(_RTC1 "") + set(_FLAGS_C "") set(_FLAGS_CXX " /GR /EHsc") + + foreach(lang C CXX) + if(_MSVC_${lang}_ARCHITECTURE_FAMILY STREQUAL "ARM") + set(_PLATFORM_DEFINES_${lang} "${_PLATFORM_DEFINES_${lang}} /D${MSVC_${lang}_ARCHITECTURE_ID}") + if(MSVC_${lang}_ARCHITECTURE_ID MATCHES "^ARMV([45])I$") + set(_FLAGS_${lang} "${_FLAGS_${lang}} /QRarch${CMAKE_MATCH_1}T") + endif() + endif() + endforeach() + set(CMAKE_C_STANDARD_LIBRARIES_INIT "coredll.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib") set(CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} /NODEFAULTLIB:libc.lib /NODEFAULTLIB:oldnames.lib") @@ -168,7 +183,7 @@ elseif(WINDOWS_PHONE OR WINDOWS_STORE) set(_FLAGS_CXX " /DUNICODE /D_UNICODE /GR /EHsc") if(WINDOWS_PHONE) set(CMAKE_C_STANDARD_LIBRARIES_INIT "WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib") - elseif(MSVC_C_ARCHITECTURE_ID STREQUAL ARM OR MSVC_CXX_ARCHITECTURE_ID STREQUAL ARM) + elseif(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM") set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib") else() set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib") @@ -176,7 +191,7 @@ elseif(WINDOWS_PHONE OR WINDOWS_STORE) else() set(_PLATFORM_DEFINES "/DWIN32") - if(MSVC_C_ARCHITECTURE_ID STREQUAL ARM OR MSVC_CXX_ARCHITECTURE_ID STREQUAL ARM) + if(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM") set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib") elseif(MSVC_VERSION GREATER 1310) set(_RTC1 "/RTC1") @@ -200,9 +215,21 @@ set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") set (CMAKE_LINK_DEF_FILE_FLAG "/DEF:") # set the machine type if(MSVC_C_ARCHITECTURE_ID) - set(_MACHINE_ARCH_FLAG "/machine:${MSVC_C_ARCHITECTURE_ID}") + if(MSVC_C_ARCHITECTURE_ID MATCHES "^ARMV.I") + set(_MACHINE_ARCH_FLAG "/machine:THUMB") + elseif(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM") + set(_MACHINE_ARCH_FLAG "/machine:ARM") + else() + set(_MACHINE_ARCH_FLAG "/machine:${MSVC_C_ARCHITECTURE_ID}") + endif() elseif(MSVC_CXX_ARCHITECTURE_ID) - set(_MACHINE_ARCH_FLAG "/machine:${MSVC_CXX_ARCHITECTURE_ID}") + if(MSVC_CXX_ARCHITECTURE_ID MATCHES "^ARMV.I") + set(_MACHINE_ARCH_FLAG "/machine:THUMB") + elseif(_MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM") + set(_MACHINE_ARCH_FLAG "/machine:ARM") + else() + set(_MACHINE_ARCH_FLAG "/machine:${MSVC_CXX_ARCHITECTURE_ID}") + endif() elseif(MSVC_Fortran_ARCHITECTURE_ID) set(_MACHINE_ARCH_FLAG "/machine:${MSVC_Fortran_ARCHITECTURE_ID}") endif() |