Skip to content

Commit

Permalink
Add preliminary support for arm-windows and arm64-windows triplets (#…
Browse files Browse the repository at this point in the history
…2371)

* Add preliminary support for arm-windows and arm64-windows triplets

Visual Studio 15.4 shipped with new VC tools targeting arm and arm64
for desktop. This change allows for recognition and usage of new
triplets supporting arm and arm64 Windows desktop and server targets.

* Remove unnecessary changes

* Part 2

* Part 3

* Make detection of Arm64 _VCPKG_TARGET_ARCHITECTURE precise

* Enforce usage of Visual Studio CMake generatorfor arm and temporarily arm64 targets

* Address code review feedback, clean libjpeg-turbo port.cmake

* [libjpeg-turbo][tiff] Reduce changes to existing libraries.

* [vcpkg-cmake] Simplify toolchain selection logic and improve comments
  • Loading branch information
4creators authored and ras0219-msft committed Jan 3, 2018
1 parent 893c567 commit a28138e
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 26 deletions.
15 changes: 8 additions & 7 deletions ports/libjpeg-turbo/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ vcpkg_apply_patches(
PATCHES "${CMAKE_CURRENT_LIST_DIR}/add-options-for-exes-docs-headers.patch"
)

vcpkg_find_acquire_program(NASM)
get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY)
set(ENV{PATH} "$ENV{PATH};${NASM_EXE_PATH}")
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(LIBJPEGTURBO_SIMD -DWITH_SIMD=OFF)
else()
set(LIBJPEGTURBO_SIMD -DWITH_SIMD=ON)
vcpkg_find_acquire_program(NASM)
get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY)
set(ENV{PATH} "$ENV{PATH};${NASM_EXE_PATH}")
endif()

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" ENABLE_SHARED)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ENABLE_STATIC)
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "dynamic" WITH_CRT_DLL)

if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
set(LIBJPEGTURBO_SIMD -DWITH_SIMD=OFF)
endif()

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
Expand Down
5 changes: 5 additions & 0 deletions ports/tiff/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ vcpkg_apply_patches(
${CMAKE_CURRENT_LIST_DIR}/crt-secure-no-deprecate.patch
)

if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
set (TIFF_CXX_TARGET -Dcxx=OFF)
endif()

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
Expand All @@ -28,6 +32,7 @@ vcpkg_configure_cmake(
-DBUILD_TESTS=OFF
-Djbig=OFF # This is disabled by default due to GPL/Proprietary licensing.
-Djpeg12=OFF
${TIFF_CXX_TARGET}
)

vcpkg_install_cmake()
Expand Down
15 changes: 15 additions & 0 deletions scripts/buildsystems/msbuild/vcpkg.targets
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x64-windows</VcpkgTriplet>
</PropertyGroup>

<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'arm||'">
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">arm-windows</VcpkgTriplet>
</PropertyGroup>

<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'arm64||'">
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">arm64-windows</VcpkgTriplet>
</PropertyGroup>

<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'x64|Windows Store|10.0'">
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x64-uwp</VcpkgTriplet>
Expand All @@ -34,6 +44,11 @@
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">arm-uwp</VcpkgTriplet>
</PropertyGroup>

<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'arm64|Windows Store|10.0'">
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">arm64-uwp</VcpkgTriplet>
</PropertyGroup>

<PropertyGroup Condition="'$(VcpkgEnabled)' == 'true'">
<VcpkgConfiguration Condition="'$(VcpkgConfiguration)' == ''">$(Configuration)</VcpkgConfiguration>
<VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Debug'))">Debug</VcpkgNormalizedConfiguration>
Expand Down
5 changes: 5 additions & 0 deletions scripts/buildsystems/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm64)
else()
if(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 Win64$")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
Expand All @@ -41,6 +43,8 @@ else()
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(_VCPKG_CL MATCHES "arm/cl.exe$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(_VCPKG_CL MATCHES "arm64/cl.exe$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm64)
elseif(_VCPKG_CL MATCHES "bin/cl.exe$" OR _VCPKG_CL MATCHES "x86/cl.exe$")
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
Expand Down Expand Up @@ -105,6 +109,7 @@ if (NOT DEFINED CMAKE_SYSTEM_VERSION AND _VCPKG_TARGET_TRIPLET_PLAT MATCHES "win
vcpkg_get_windows_sdk(WINDOWS_SDK_VERSION)
unset(VCPKG_ROOT_DIR)
set(CMAKE_SYSTEM_VERSION ${WINDOWS_SDK_VERSION} CACHE STRING "Windows SDK version")
message(STATUS "Found Windows SDK ${WINDOWS_SDK_VERSION}")
endif()

file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
Expand Down
37 changes: 18 additions & 19 deletions scripts/cmake/vcpkg_configure_cmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,40 +57,39 @@ function(vcpkg_configure_cmake)
set(_csc_HOST_ARCHITECTURE $ENV{PROCESSOR_ARCHITECTURE})
endif()

set(NINJA_CAN_BE_USED ON)
if(_csc_HOST_ARCHITECTURE STREQUAL "x86")
# Prebuilt ninja binaries are only provided for x64 hosts
set(NINJA_CAN_BE_USED OFF)
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
# Ninja and MSBuild have many differences when targetting UWP, so use MSBuild to maximize existing compatibility
set(NINJA_CAN_BE_USED OFF)
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
# Arm64 usage should be allowed once github issue #2375 is resolved
set(NINJA_CAN_BE_USED OFF)
endif()

if(_csc_GENERATOR)
set(GENERATOR ${_csc_GENERATOR})
elseif(_csc_PREFER_NINJA AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND NOT _csc_HOST_ARCHITECTURE STREQUAL "x86")
elseif(_csc_PREFER_NINJA AND NINJA_CAN_BE_USED)
set(GENERATOR "Ninja")
elseif(VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
set(GENERATOR "Ninja")

elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v120")
set(GENERATOR "Visual Studio 12 2013")
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v120")
set(GENERATOR "Visual Studio 12 2013 Win64")
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v120")
set(GENERATOR "Visual Studio 12 2013 ARM")
elseif(VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
set(GENERATOR "Ninja")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140")
set(GENERATOR "Visual Studio 14 2015")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140")
set(GENERATOR "Visual Studio 14 2015 Win64")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140")
set(GENERATOR "Visual Studio 14 2015 ARM")

elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140")
set(GENERATOR "Visual Studio 14 2015")
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140")
set(GENERATOR "Visual Studio 14 2015 Win64")
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140")
set(GENERATOR "Visual Studio 14 2015 ARM")

elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141")
set(GENERATOR "Visual Studio 15 2017")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141")
set(GENERATOR "Visual Studio 15 2017 Win64")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141")
set(GENERATOR "Visual Studio 15 2017 ARM")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141")
set(GENERATOR "Visual Studio 15 2017")
set(ARCH "ARM64")
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141")
set(GENERATOR "Visual Studio 15 2017")
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141")
Expand Down
3 changes: 3 additions & 0 deletions toolsrc/include/vcpkg/triplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ namespace vcpkg
static const Triplet X86_UWP;
static const Triplet X64_UWP;
static const Triplet ARM_UWP;
static const Triplet ARM64_UWP;
static const Triplet ARM_WINDOWS;
static const Triplet ARM64_WINDOWS;

const std::string& canonical_name() const;
const std::string& to_string() const;
Expand Down
3 changes: 3 additions & 0 deletions toolsrc/src/vcpkg/triplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ namespace vcpkg
const Triplet Triplet::X86_UWP = from_canonical_name("x86-uwp");
const Triplet Triplet::X64_UWP = from_canonical_name("x64-uwp");
const Triplet Triplet::ARM_UWP = from_canonical_name("arm-uwp");
const Triplet Triplet::ARM64_UWP = from_canonical_name("arm64-uwp");
const Triplet Triplet::ARM_WINDOWS = from_canonical_name("arm-windows");
const Triplet Triplet::ARM64_WINDOWS = from_canonical_name("arm64-windows");

bool Triplet::operator==(const Triplet& other) const { return this->m_instance == other.m_instance; }

Expand Down
5 changes: 5 additions & 0 deletions triplets/arm-windows.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(VCPKG_TARGET_ARCHITECTURE arm)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)


5 changes: 5 additions & 0 deletions triplets/arm64-windows.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)


0 comments on commit a28138e

Please sign in to comment.