From a28138eb9ef8d2986227b7cd784be9ffa8492a46 Mon Sep 17 00:00:00 2001 From: Jacek Blaszczynski Date: Thu, 4 Jan 2018 00:19:52 +0100 Subject: [PATCH] Add preliminary support for arm-windows and arm64-windows triplets (#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 --- ports/libjpeg-turbo/portfile.cmake | 15 +++++---- ports/tiff/portfile.cmake | 5 +++ scripts/buildsystems/msbuild/vcpkg.targets | 15 +++++++++ scripts/buildsystems/vcpkg.cmake | 5 +++ scripts/cmake/vcpkg_configure_cmake.cmake | 37 +++++++++++----------- toolsrc/include/vcpkg/triplet.h | 3 ++ toolsrc/src/vcpkg/triplet.cpp | 3 ++ triplets/arm-windows.cmake | 5 +++ triplets/arm64-windows.cmake | 5 +++ 9 files changed, 67 insertions(+), 26 deletions(-) create mode 100644 triplets/arm-windows.cmake create mode 100644 triplets/arm64-windows.cmake diff --git a/ports/libjpeg-turbo/portfile.cmake b/ports/libjpeg-turbo/portfile.cmake index 1d45087b02..a3e882b1f8 100644 --- a/ports/libjpeg-turbo/portfile.cmake +++ b/ports/libjpeg-turbo/portfile.cmake @@ -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 diff --git a/ports/tiff/portfile.cmake b/ports/tiff/portfile.cmake index bfa1c3853a..2923893500 100644 --- a/ports/tiff/portfile.cmake +++ b/ports/tiff/portfile.cmake @@ -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 @@ -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() diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets index 092e013b52..499052e4d7 100644 --- a/scripts/buildsystems/msbuild/vcpkg.targets +++ b/scripts/buildsystems/msbuild/vcpkg.targets @@ -24,6 +24,16 @@ x64-windows + + true + arm-windows + + + + true + arm64-windows + + true x64-uwp @@ -34,6 +44,11 @@ arm-uwp + + true + arm64-uwp + + $(Configuration) Debug diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index 7ebe695fba..f157d3236c 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -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) @@ -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") @@ -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) diff --git a/scripts/cmake/vcpkg_configure_cmake.cmake b/scripts/cmake/vcpkg_configure_cmake.cmake index 4bcf3d2c92..6e2ec4ef53 100644 --- a/scripts/cmake/vcpkg_configure_cmake.cmake +++ b/scripts/cmake/vcpkg_configure_cmake.cmake @@ -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") diff --git a/toolsrc/include/vcpkg/triplet.h b/toolsrc/include/vcpkg/triplet.h index 2cfc2d02ae..10464dc2c9 100644 --- a/toolsrc/include/vcpkg/triplet.h +++ b/toolsrc/include/vcpkg/triplet.h @@ -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; diff --git a/toolsrc/src/vcpkg/triplet.cpp b/toolsrc/src/vcpkg/triplet.cpp index 4cba1523d6..ef0fab1833 100644 --- a/toolsrc/src/vcpkg/triplet.cpp +++ b/toolsrc/src/vcpkg/triplet.cpp @@ -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; } diff --git a/triplets/arm-windows.cmake b/triplets/arm-windows.cmake new file mode 100644 index 0000000000..3aa75933fd --- /dev/null +++ b/triplets/arm-windows.cmake @@ -0,0 +1,5 @@ +set(VCPKG_TARGET_ARCHITECTURE arm) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE dynamic) + + diff --git a/triplets/arm64-windows.cmake b/triplets/arm64-windows.cmake new file mode 100644 index 0000000000..ac911c476c --- /dev/null +++ b/triplets/arm64-windows.cmake @@ -0,0 +1,5 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE dynamic) + +