From f8be791afd718b078aa6e9dc4258836bbfd18538 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 27 May 2022 16:49:53 -0700 Subject: [PATCH 01/23] [cppwinrt] rewrote port to leverage cppwinrt.exe tool from nuget.org --- ports/cppwinrt/CMakeLists.txt.in | 143 ++++++++++++++++++++++++ ports/cppwinrt/CppWinRT-config.cmake.in | 23 ++++ ports/cppwinrt/portfile.cmake | 41 +++++-- ports/cppwinrt/vcpkg.json | 20 +++- 4 files changed, 216 insertions(+), 11 deletions(-) create mode 100644 ports/cppwinrt/CMakeLists.txt.in create mode 100644 ports/cppwinrt/CppWinRT-config.cmake.in diff --git a/ports/cppwinrt/CMakeLists.txt.in b/ports/cppwinrt/CMakeLists.txt.in new file mode 100644 index 00000000000000..dbbcfc634e4c12 --- /dev/null +++ b/ports/cppwinrt/CMakeLists.txt.in @@ -0,0 +1,143 @@ +cmake_minimum_required (VERSION 3.20) + +set(CPPWINRT_VERSION @CPPWINRT_VERSION@) + +project(CppWinRT + VERSION ${CPPWINRT_VERSION} + DESCRIPTION "C++/WinRT vcpkg support" + HOMEPAGE_URL "https://github.com/Microsoft/cppwinrt" + LANGUAGES CXX) + +if (DEFINED VCPKG_TARGET_ARCHITECTURE) + if (VCPKG_TARGET_ARCHITECTURE MATCHES "[Xx]86$") + set(CPPWINRT_ARCH win32) + else() + set(CPPWINRT_ARCH ${VCPKG_TARGET_ARCHITECTURE}) + endif() +elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$") + set(CPPWINRT_ARCH win32) +elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$") + set(CPPWINRT_ARCH x64) +elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$") + set(CPPWINRT_ARCH arm) +elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64$") + set(CPPWINRT_ARCH arm64) +elseif(NOT DEFINED CPPWINRT_ARCH) + message(FATAL_ERROR "ERROR: Unknown target architecture") +endif() + +message(STATUS "Targeting ${CPPWINRT_ARCH}") + +include(GNUInstallDirs) + +find_program(CPPWINRT_TOOL "cppwinrt.exe" + PATHS ${CMAKE_CURRENT_SOURCE_DIR}/bin + REQUIRED NO_DEFAULT_PATH) + +find_library(CPPWINRT_LIB "cppwinrt_fast_forwarder.lib" + PATHS "${CMAKE_CURRENT_SOURCE_DIR}/build/native/lib/${CPPWINRT_ARCH}" + REQUIRED NO_DEFAULT_PATH) + +#--- Find Windows SDK Version +set(WINDOWS_SDK_VERSIONS + 10.0.22000.0 # Windows SDK for Windows 11 + 10.0.20348.0 # Windows SDK, version 2104 + 10.0.19041.0 # Windows 10 "20H1" SDK + 10.0.18362.0 # Windows 10 May 2019 Update SDK + 10.0.17763.0 # Windows 10 October 2018 Update SDK + 10.0.17134.0 # Windows 10 April 2018 Update SDK + 10.0.16299.0 # Windows 10 Fall Creators Update SDK + 10.0.15063.0 # Windows 10 Creators Update SDK + 10.0.14393.0 # Windows 10 Anniversary Update SDK +) + +if(NOT DEFINED WindowsSDKDir) + if(EXISTS "$ENV{WindowsSDKDir}" AND (NOT "$ENV{WindowsSDKDir}" STREQUAL "")) + get_filename_component(WindowsSDKDir "$ENV{WindowsSDKDir}" ABSOLUTE) + else() + set(WindowsSDKDir "$ENV{ProgramFiles\(x86\)}/Windows Kits/10") + endif() +endif() + +if (NOT (EXISTS "${WindowsSDKDir}")) + message(FATAL_ERROR "ERROR: Cannot locate the Windows SDK") +endif() + +if (CMAKE_SYSTEM_VERSION MATCHES "^10\\.0\\.[0-9]+\\.0$") + set(WindowsSDKVersion ${CMAKE_SYSTEM_VERSION}) +elseif(CMAKE_SYSTEM_VERSION MATCHES "^10\\.0\\.[0-9]+$") + set(WindowsSDKVersion "${CMAKE_SYSTEM_VERSION}.0") +endif() + +if(NOT DEFINED WindowsSDKVersion) + if(NOT ("$ENV{WindowsSDKVersion}" STREQUAL "")) + set(WindowsSDKVersion $ENV{WindowsSDKVersion}) + if (EXISTS "${WindowsSDKDir}/References/${WindowsSDKVersion}") + message(STATUS "Found Windows SDK and version from environment variables") + string(REPLACE "\\" "" WindowsSDKVersion ${WindowsSDKVersion}) + else() + set(WindowsSDKVersion "") + endif() + endif() +endif() + +if (NOT (EXISTS "${WindowsSDKDir}/References/${WindowsSDKVersion}/Windows.Foundation.FoundationContract")) + set(WindowsSDKVersion "") + foreach(sdkver IN LISTS WINDOWS_SDK_VERSIONS) + if (EXISTS "${WindowsSDKDir}/References/${sdkver}/Windows.Foundation.FoundationContract") + cmake_path(CONVERT "${WindowsSDKDir}/References/${sdkver}" TO_CMAKE_PATH_LIST WinMDRoot NORMALIZE) + set(WindowsSDKVersion ${sdkver}) + break() + endif() + endforeach() + + if ("${WindowsSDKVersion}" STREQUAL "") + message(FATAL_ERROR "ERROR: Cannot locate the Windows SDK (14393) or later.") + endif() +endif() + +#--- Generate headers +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/winrt/base.h" + COMMENT "Generating C++/WinRT headers for SDK ${WindowsSDKVersion}" + COMMAND ${CPPWINRT_TOOL} -in ${WindowsSDKVersion} -out ${CMAKE_CURRENT_BINARY_DIR} + USES_TERMINAL) + +add_library(${PROJECT_NAME} INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/winrt/base.h") + +target_include_directories(${PROJECT_NAME} INTERFACE + $ + $) + +#--- Package +include(CMakePackageConfigHelpers) + +string(TOLOWER ${PROJECT_NAME} PACKAGE_NAME) + +write_basic_package_version_file( + ${PACKAGE_NAME}-config-version.cmake + VERSION ${CPPWINRT_VERSION} + COMPATIBILITY AnyNewerVersion) + +install(TARGETS ${PROJECT_NAME} + EXPORT ${PROJECT_NAME}-targets) + +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}/cmake/}) + +install(EXPORT ${PROJECT_NAME}-targets + FILE ${PROJECT_NAME}-targets.cmake + NAMESPACE Microsoft:: + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}/cmake/) + +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/winrt + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PACKAGE_NAME}) + +install(FILES ${CPPWINRT_LIB} + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}/cmake/) diff --git a/ports/cppwinrt/CppWinRT-config.cmake.in b/ports/cppwinrt/CppWinRT-config.cmake.in new file mode 100644 index 00000000000000..78ffadbc37c423 --- /dev/null +++ b/ports/cppwinrt/CppWinRT-config.cmake.in @@ -0,0 +1,23 @@ +@PACKAGE_INIT@ + +include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake) + +get_filename_component(_cppwinrt_root "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_cppwinrt_root "${_cppwinrt_root}" PATH) +get_filename_component(_cppwinrt_root "${_cppwinrt_root}" PATH) + +set(_cppwinrt_root_lib "${_cppwinrt_root}/lib/cppwinrt_fast_forwarder.lib") +if (EXISTS "${_cppwinrt_root_lib}") + + set_target_properties(Microsoft::CppWinRT PROPERTIES + INTERFACE_LINK_LIBRARIES "${_cppwinrt_root_lib}") + +endif() + +set_target_properties(Microsoft::CppWinRT PROPERTIES + INTERFACE_COMPILE_FEATURES cxx_std_17) + +unset(_cppwinrt_root_lib) +unset(_cppwinrt_root) + +check_required_components("@PROJECT_NAME@") diff --git a/ports/cppwinrt/portfile.cmake b/ports/cppwinrt/portfile.cmake index a875a5a5e84b84..0b01b5390a431b 100644 --- a/ports/cppwinrt/portfile.cmake +++ b/ports/cppwinrt/portfile.cmake @@ -1,10 +1,37 @@ -find_path(CPPWINRT_BASE_H - NAMES winrt/base.h - PATHS $ENV{INCLUDE} +if (NOT VCPKG_HOST_IS_WINDOWS) + message(FATAL_ERROR "The cppwinrt.exe tool published on NuGet requires a Windows 32-bit compatible host") +endif() + +set(CPPWINRT_VERSION 2.0.220418.1) + +vcpkg_download_distfile(ARCHIVE + URLS "https://www.nuget.org/api/v2/package/Microsoft.Windows.CppWinRT/${CPPWINRT_VERSION}" + FILENAME "cppwinrt.${CPPWINRT_VERSION}.zip" + SHA512 67738587f7b1ca98a7c2c2c0733dd09612deb5ef6bcfa788ca0bcccbbfde2c706a675316085a41e79ab2c8796a0dd3bdba87d5c996dc0b6f76b438b5d75d2567 ) -if(NOT CPPWINRT_BASE_H) - message(FATAL_ERROR "Unable to locate cppwinrt. Please install Windows SDK version 10.0.17134.0 or newer.") -endif() +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + NO_REMOVE_ONE_LEVEL +) + +configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in" "${SOURCE_PATH}/CMakeLists.txt" @ONLY) +file(COPY "${CMAKE_CURRENT_LIST_DIR}/CppWinRT-config.cmake.in" DESTINATION ${SOURCE_PATH}) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH share/cppwinrt/cmake) + +file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/cppwinrt/") + +file(INSTALL + "${SOURCE_PATH}/bin/cppwinrt.exe" + DESTINATION "${CURRENT_PACKAGES_DIR}/tools/cppwinrt") + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") -SET(VCPKG_POLICY_EMPTY_PACKAGE enabled) \ No newline at end of file +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/ports/cppwinrt/vcpkg.json b/ports/cppwinrt/vcpkg.json index 7ff77b5d7502a7..711ef7fceee0f5 100644 --- a/ports/cppwinrt/vcpkg.json +++ b/ports/cppwinrt/vcpkg.json @@ -1,7 +1,19 @@ { "name": "cppwinrt", - "version-string": "windows-sdk", + "version": "2.0.220418.1", "description": "C++/WinRT is a standard C++ language projection for the Windows Runtime.", - "homepage": "https://github.com/Microsoft/cppwinrt", - "supports": "windows" -} + "homepage": "https://github.com/microsoft/cppwinrt", + "documentation": "https://docs.microsoft.com/windows/uwp/cpp-and-winrt-apis/", + "license": "MIT", + "supports": "windows", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} \ No newline at end of file From c72ca5a9fd191d7fe02f5162938e71bce31f8db9 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 27 May 2022 16:51:51 -0700 Subject: [PATCH 02/23] Reformat --- ports/cppwinrt/vcpkg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/cppwinrt/vcpkg.json b/ports/cppwinrt/vcpkg.json index 711ef7fceee0f5..8dd5c2ef812598 100644 --- a/ports/cppwinrt/vcpkg.json +++ b/ports/cppwinrt/vcpkg.json @@ -16,4 +16,4 @@ "host": true } ] -} \ No newline at end of file +} From d91cfad355bd0863db6c01578c6b4dd5dc310fd1 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 27 May 2022 16:52:03 -0700 Subject: [PATCH 03/23] Update baseline --- versions/baseline.json | 2 +- versions/c-/cppwinrt.json | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/versions/baseline.json b/versions/baseline.json index a7c8df0db7c7cf..3b3584409dc4d7 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -1649,7 +1649,7 @@ "port-version": 2 }, "cppwinrt": { - "baseline": "windows-sdk", + "baseline": "2.0.220418.1", "port-version": 0 }, "cppxaml": { diff --git a/versions/c-/cppwinrt.json b/versions/c-/cppwinrt.json index da64d482478525..5e2843a85fb2a1 100644 --- a/versions/c-/cppwinrt.json +++ b/versions/c-/cppwinrt.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "da4c6dd987474ee70f7d28715d791d5fa625264b", + "version": "2.0.220418.1", + "port-version": 0 + }, { "git-tree": "191643fbd9c127658cf1724216a3b393951bd68e", "version-string": "windows-sdk", From ff9fe89d6ecefeb55668702d310ce5bf0c90c765 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 2 Jun 2022 15:59:25 -0700 Subject: [PATCH 04/23] Update ports/cppwinrt/portfile.cmake Co-authored-by: Robert Schumacher --- ports/cppwinrt/portfile.cmake | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ports/cppwinrt/portfile.cmake b/ports/cppwinrt/portfile.cmake index 0b01b5390a431b..edafb5f99e35db 100644 --- a/ports/cppwinrt/portfile.cmake +++ b/ports/cppwinrt/portfile.cmake @@ -1,7 +1,3 @@ -if (NOT VCPKG_HOST_IS_WINDOWS) - message(FATAL_ERROR "The cppwinrt.exe tool published on NuGet requires a Windows 32-bit compatible host") -endif() - set(CPPWINRT_VERSION 2.0.220418.1) vcpkg_download_distfile(ARCHIVE From 70b7c831accf82d48d7d472e2960fc1fba47c769 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 2 Jun 2022 16:00:31 -0700 Subject: [PATCH 05/23] Update ports/cppwinrt/CMakeLists.txt.in Co-authored-by: Robert Schumacher --- ports/cppwinrt/CMakeLists.txt.in | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/ports/cppwinrt/CMakeLists.txt.in b/ports/cppwinrt/CMakeLists.txt.in index dbbcfc634e4c12..31556790ae1d77 100644 --- a/ports/cppwinrt/CMakeLists.txt.in +++ b/ports/cppwinrt/CMakeLists.txt.in @@ -8,22 +8,10 @@ project(CppWinRT HOMEPAGE_URL "https://github.com/Microsoft/cppwinrt" LANGUAGES CXX) -if (DEFINED VCPKG_TARGET_ARCHITECTURE) - if (VCPKG_TARGET_ARCHITECTURE MATCHES "[Xx]86$") - set(CPPWINRT_ARCH win32) - else() - set(CPPWINRT_ARCH ${VCPKG_TARGET_ARCHITECTURE}) - endif() -elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$") +if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") set(CPPWINRT_ARCH win32) -elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$") - set(CPPWINRT_ARCH x64) -elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$") - set(CPPWINRT_ARCH arm) -elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64$") - set(CPPWINRT_ARCH arm64) -elseif(NOT DEFINED CPPWINRT_ARCH) - message(FATAL_ERROR "ERROR: Unknown target architecture") +else() + set(CPPWINRT_ARCH ${VCPKG_TARGET_ARCHITECTURE}) endif() message(STATUS "Targeting ${CPPWINRT_ARCH}") From ecbd3450043a1746900f4c607e636bbf496f1d3d Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 2 Jun 2022 16:03:22 -0700 Subject: [PATCH 06/23] Update ports/cppwinrt/portfile.cmake Co-authored-by: Robert Schumacher --- ports/cppwinrt/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/cppwinrt/portfile.cmake b/ports/cppwinrt/portfile.cmake index edafb5f99e35db..58631d6bb96339 100644 --- a/ports/cppwinrt/portfile.cmake +++ b/ports/cppwinrt/portfile.cmake @@ -20,7 +20,7 @@ vcpkg_cmake_configure( ) vcpkg_cmake_install() -vcpkg_cmake_config_fixup(CONFIG_PATH share/cppwinrt/cmake) +vcpkg_cmake_config_fixup() file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/cppwinrt/") From ab78e5e0519c11c582dbfbf752e23cddea79fadf Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 2 Jun 2022 16:04:01 -0700 Subject: [PATCH 07/23] Update ports/cppwinrt/portfile.cmake Co-authored-by: Robert Schumacher --- ports/cppwinrt/portfile.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ports/cppwinrt/portfile.cmake b/ports/cppwinrt/portfile.cmake index 58631d6bb96339..7201eca769ec7e 100644 --- a/ports/cppwinrt/portfile.cmake +++ b/ports/cppwinrt/portfile.cmake @@ -12,8 +12,11 @@ vcpkg_extract_source_archive_ex( NO_REMOVE_ONE_LEVEL ) -configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in" "${SOURCE_PATH}/CMakeLists.txt" @ONLY) -file(COPY "${CMAKE_CURRENT_LIST_DIR}/CppWinRT-config.cmake.in" DESTINATION ${SOURCE_PATH}) +file(COPY + "${CMAKE_CURRENT_LIST_DIR}/CppWinRT-config.cmake.in" + "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" + DESTINATION "${SOURCE_PATH}" +) vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" From 795ff21f77e5e2523e3afdc8cdb5e92e75af6da7 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 2 Jun 2022 16:04:28 -0700 Subject: [PATCH 08/23] Update ports/cppwinrt/CMakeLists.txt.in Co-authored-by: Robert Schumacher --- ports/cppwinrt/CMakeLists.txt.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ports/cppwinrt/CMakeLists.txt.in b/ports/cppwinrt/CMakeLists.txt.in index 31556790ae1d77..03c01cd83cbe35 100644 --- a/ports/cppwinrt/CMakeLists.txt.in +++ b/ports/cppwinrt/CMakeLists.txt.in @@ -18,9 +18,7 @@ message(STATUS "Targeting ${CPPWINRT_ARCH}") include(GNUInstallDirs) -find_program(CPPWINRT_TOOL "cppwinrt.exe" - PATHS ${CMAKE_CURRENT_SOURCE_DIR}/bin - REQUIRED NO_DEFAULT_PATH) +set(CPPWINRT_TOOL "${CMAKE_CURRENT_SOURCE_DIR}/bin/cppwinrt.exe") find_library(CPPWINRT_LIB "cppwinrt_fast_forwarder.lib" PATHS "${CMAKE_CURRENT_SOURCE_DIR}/build/native/lib/${CPPWINRT_ARCH}" From c05f2e36118ed806dc021508bcce5f4407a51de1 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 2 Jun 2022 16:04:40 -0700 Subject: [PATCH 09/23] Update ports/cppwinrt/CMakeLists.txt.in Co-authored-by: Robert Schumacher --- ports/cppwinrt/CMakeLists.txt.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ports/cppwinrt/CMakeLists.txt.in b/ports/cppwinrt/CMakeLists.txt.in index 03c01cd83cbe35..cd544986ccade4 100644 --- a/ports/cppwinrt/CMakeLists.txt.in +++ b/ports/cppwinrt/CMakeLists.txt.in @@ -20,9 +20,7 @@ include(GNUInstallDirs) set(CPPWINRT_TOOL "${CMAKE_CURRENT_SOURCE_DIR}/bin/cppwinrt.exe") -find_library(CPPWINRT_LIB "cppwinrt_fast_forwarder.lib" - PATHS "${CMAKE_CURRENT_SOURCE_DIR}/build/native/lib/${CPPWINRT_ARCH}" - REQUIRED NO_DEFAULT_PATH) +set(CPPWINRT_LIB "${CMAKE_CURRENT_SOURCE_DIR}/build/native/lib/${CPPWINRT_ARCH}/cppwinrt_fast_forwarder.lib") #--- Find Windows SDK Version set(WINDOWS_SDK_VERSIONS From 3def5815deb448a7d34d065149ffbe67ec568e24 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 2 Jun 2022 16:05:02 -0700 Subject: [PATCH 10/23] Update ports/cppwinrt/CppWinRT-config.cmake.in Co-authored-by: Robert Schumacher --- ports/cppwinrt/CppWinRT-config.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/cppwinrt/CppWinRT-config.cmake.in b/ports/cppwinrt/CppWinRT-config.cmake.in index 78ffadbc37c423..1d13fc195966ab 100644 --- a/ports/cppwinrt/CppWinRT-config.cmake.in +++ b/ports/cppwinrt/CppWinRT-config.cmake.in @@ -20,4 +20,4 @@ set_target_properties(Microsoft::CppWinRT PROPERTIES unset(_cppwinrt_root_lib) unset(_cppwinrt_root) -check_required_components("@PROJECT_NAME@") +check_required_components(cppwinrt) From 9d2c885fae29e0b113bc243bd38427588a97bad0 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 2 Jun 2022 16:18:35 -0700 Subject: [PATCH 11/23] Simplifed CMakeLists.txt --- .../{CMakeLists.txt.in => CMakeLists.txt} | 31 ++++--------------- ports/cppwinrt/portfile.cmake | 1 + 2 files changed, 7 insertions(+), 25 deletions(-) rename ports/cppwinrt/{CMakeLists.txt.in => CMakeLists.txt} (75%) diff --git a/ports/cppwinrt/CMakeLists.txt.in b/ports/cppwinrt/CMakeLists.txt similarity index 75% rename from ports/cppwinrt/CMakeLists.txt.in rename to ports/cppwinrt/CMakeLists.txt index cd544986ccade4..635ccac1568852 100644 --- a/ports/cppwinrt/CMakeLists.txt.in +++ b/ports/cppwinrt/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required (VERSION 3.20) -set(CPPWINRT_VERSION @CPPWINRT_VERSION@) +if(NOT DEFINED CPPWINRT_VERSION) + message(FATAL_ERROR "Requires CPPWINRT_VERSION value") +endif() project(CppWinRT VERSION ${CPPWINRT_VERSION} @@ -23,18 +25,6 @@ set(CPPWINRT_TOOL "${CMAKE_CURRENT_SOURCE_DIR}/bin/cppwinrt.exe") set(CPPWINRT_LIB "${CMAKE_CURRENT_SOURCE_DIR}/build/native/lib/${CPPWINRT_ARCH}/cppwinrt_fast_forwarder.lib") #--- Find Windows SDK Version -set(WINDOWS_SDK_VERSIONS - 10.0.22000.0 # Windows SDK for Windows 11 - 10.0.20348.0 # Windows SDK, version 2104 - 10.0.19041.0 # Windows 10 "20H1" SDK - 10.0.18362.0 # Windows 10 May 2019 Update SDK - 10.0.17763.0 # Windows 10 October 2018 Update SDK - 10.0.17134.0 # Windows 10 April 2018 Update SDK - 10.0.16299.0 # Windows 10 Fall Creators Update SDK - 10.0.15063.0 # Windows 10 Creators Update SDK - 10.0.14393.0 # Windows 10 Anniversary Update SDK -) - if(NOT DEFINED WindowsSDKDir) if(EXISTS "$ENV{WindowsSDKDir}" AND (NOT "$ENV{WindowsSDKDir}" STREQUAL "")) get_filename_component(WindowsSDKDir "$ENV{WindowsSDKDir}" ABSOLUTE) @@ -66,20 +56,11 @@ if(NOT DEFINED WindowsSDKVersion) endif() if (NOT (EXISTS "${WindowsSDKDir}/References/${WindowsSDKVersion}/Windows.Foundation.FoundationContract")) - set(WindowsSDKVersion "") - foreach(sdkver IN LISTS WINDOWS_SDK_VERSIONS) - if (EXISTS "${WindowsSDKDir}/References/${sdkver}/Windows.Foundation.FoundationContract") - cmake_path(CONVERT "${WindowsSDKDir}/References/${sdkver}" TO_CMAKE_PATH_LIST WinMDRoot NORMALIZE) - set(WindowsSDKVersion ${sdkver}) - break() - endif() - endforeach() - - if ("${WindowsSDKVersion}" STREQUAL "") - message(FATAL_ERROR "ERROR: Cannot locate the Windows SDK (14393) or later.") - endif() + message(FATAL_ERROR "ERROR: Cannot locate the Windows SDK.") endif() +message(STATUS "Using .winmd files from ${WindowsSDKVersion} in ${WindowsSDKDir}") + #--- Generate headers add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/winrt/base.h" diff --git a/ports/cppwinrt/portfile.cmake b/ports/cppwinrt/portfile.cmake index 7201eca769ec7e..866f9a5ba627a6 100644 --- a/ports/cppwinrt/portfile.cmake +++ b/ports/cppwinrt/portfile.cmake @@ -20,6 +20,7 @@ file(COPY vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" + OPTIONS -DCPPWINRT_VERSION=${CPPWINRT_VERSION} ) vcpkg_cmake_install() From fe87a2d98148f183e99199aeb792384933e6f0fc Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 2 Jun 2022 16:18:55 -0700 Subject: [PATCH 12/23] Update baseline --- versions/c-/cppwinrt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/c-/cppwinrt.json b/versions/c-/cppwinrt.json index 5e2843a85fb2a1..513a7b1757645a 100644 --- a/versions/c-/cppwinrt.json +++ b/versions/c-/cppwinrt.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "da4c6dd987474ee70f7d28715d791d5fa625264b", + "git-tree": "ff0b0e37642ae2f1798430f20ce763264e477b85", "version": "2.0.220418.1", "port-version": 0 }, From f3b85391f961069dc6ce203b643f041ee569d2cb Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 2 Jun 2022 20:08:19 -0700 Subject: [PATCH 13/23] Fix build break --- ports/cppwinrt/CMakeLists.txt | 2 +- ports/cppwinrt/portfile.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/cppwinrt/CMakeLists.txt b/ports/cppwinrt/CMakeLists.txt index 635ccac1568852..8af1c84db8f7d7 100644 --- a/ports/cppwinrt/CMakeLists.txt +++ b/ports/cppwinrt/CMakeLists.txt @@ -72,7 +72,7 @@ add_library(${PROJECT_NAME} INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/winrt/base.h" target_include_directories(${PROJECT_NAME} INTERFACE $ - $) + $) #--- Package include(CMakePackageConfigHelpers) diff --git a/ports/cppwinrt/portfile.cmake b/ports/cppwinrt/portfile.cmake index 866f9a5ba627a6..865e18075dd9fa 100644 --- a/ports/cppwinrt/portfile.cmake +++ b/ports/cppwinrt/portfile.cmake @@ -24,7 +24,7 @@ vcpkg_cmake_configure( ) vcpkg_cmake_install() -vcpkg_cmake_config_fixup() +vcpkg_cmake_config_fixup(CONFIG_PATH share/cppwinrt/cmake) file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/cppwinrt/") From ca084a19c8eaf3b454ddee5d8fcdaf1ff981a294 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 2 Jun 2022 20:10:05 -0700 Subject: [PATCH 14/23] Update baseline --- versions/c-/cppwinrt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/c-/cppwinrt.json b/versions/c-/cppwinrt.json index 513a7b1757645a..0bb5a73b14004b 100644 --- a/versions/c-/cppwinrt.json +++ b/versions/c-/cppwinrt.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "ff0b0e37642ae2f1798430f20ce763264e477b85", + "git-tree": "2332b10338616af4bd8ac79a8d5f8787dafe99a8", "version": "2.0.220418.1", "port-version": 0 }, From 15761c73c54e52e12b57c55098177a177acf4b3c Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 2 Jun 2022 20:29:25 -0700 Subject: [PATCH 15/23] Still need SDK version scanning fallback for ADO pipelines --- ports/cppwinrt/CMakeLists.txt | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ports/cppwinrt/CMakeLists.txt b/ports/cppwinrt/CMakeLists.txt index 8af1c84db8f7d7..d0e08e5023bd07 100644 --- a/ports/cppwinrt/CMakeLists.txt +++ b/ports/cppwinrt/CMakeLists.txt @@ -55,8 +55,31 @@ if(NOT DEFINED WindowsSDKVersion) endif() endif() +set(WINDOWS_SDK_VERSIONS + 10.0.22000.0 # Windows SDK for Windows 11 + 10.0.20348.0 # Windows SDK, version 2104 + 10.0.19041.0 # Windows 10 "20H1" SDK + 10.0.18362.0 # Windows 10 May 2019 Update SDK + 10.0.17763.0 # Windows 10 October 2018 Update SDK + 10.0.17134.0 # Windows 10 April 2018 Update SDK + 10.0.16299.0 # Windows 10 Fall Creators Update SDK + 10.0.15063.0 # Windows 10 Creators Update SDK + 10.0.14393.0 # Windows 10 Anniversary Update SDK +) + if (NOT (EXISTS "${WindowsSDKDir}/References/${WindowsSDKVersion}/Windows.Foundation.FoundationContract")) - message(FATAL_ERROR "ERROR: Cannot locate the Windows SDK.") + set(WindowsSDKVersion "") + foreach(sdkver IN LISTS WINDOWS_SDK_VERSIONS) + if (EXISTS "${WindowsSDKDir}/References/${sdkver}/Windows.Foundation.FoundationContract") + cmake_path(CONVERT "${WindowsSDKDir}/References/${sdkver}" TO_CMAKE_PATH_LIST WinMDRoot NORMALIZE) + set(WindowsSDKVersion ${sdkver}) + break() + endif() + endforeach() + + if ("${WindowsSDKVersion}" STREQUAL "") + message(FATAL_ERROR "ERROR: Cannot locate the Windows SDK (14393) or later.") + endif() endif() message(STATUS "Using .winmd files from ${WindowsSDKVersion} in ${WindowsSDKDir}") From 1e0b42c22b64c2fb7798afa001f5dbef85349742 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 2 Jun 2022 20:29:56 -0700 Subject: [PATCH 16/23] Refresh baseline --- versions/c-/cppwinrt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/c-/cppwinrt.json b/versions/c-/cppwinrt.json index 0bb5a73b14004b..bf5c3f85e10192 100644 --- a/versions/c-/cppwinrt.json +++ b/versions/c-/cppwinrt.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "2332b10338616af4bd8ac79a8d5f8787dafe99a8", + "git-tree": "91d7dcf218137560ec9cea4256f8a011e9ded375", "version": "2.0.220418.1", "port-version": 0 }, From 5fc61e091ea6038264df68ebc3eb7f4f15489eaf Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 3 Jun 2022 00:06:08 -0700 Subject: [PATCH 17/23] Additional code review --- ports/cppwinrt/CMakeLists.txt | 6 +++--- ports/cppwinrt/portfile.cmake | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/cppwinrt/CMakeLists.txt b/ports/cppwinrt/CMakeLists.txt index d0e08e5023bd07..1c35f95e13592c 100644 --- a/ports/cppwinrt/CMakeLists.txt +++ b/ports/cppwinrt/CMakeLists.txt @@ -112,12 +112,12 @@ install(TARGETS ${PROJECT_NAME} configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}/cmake/}) + INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}) install(EXPORT ${PROJECT_NAME}-targets FILE ${PROJECT_NAME}-targets.cmake NAMESPACE Microsoft:: - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}/cmake/) + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/winrt DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PACKAGE_NAME}) @@ -128,4 +128,4 @@ install(FILES ${CPPWINRT_LIB} install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}/cmake/) + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}) diff --git a/ports/cppwinrt/portfile.cmake b/ports/cppwinrt/portfile.cmake index 865e18075dd9fa..866f9a5ba627a6 100644 --- a/ports/cppwinrt/portfile.cmake +++ b/ports/cppwinrt/portfile.cmake @@ -24,7 +24,7 @@ vcpkg_cmake_configure( ) vcpkg_cmake_install() -vcpkg_cmake_config_fixup(CONFIG_PATH share/cppwinrt/cmake) +vcpkg_cmake_config_fixup() file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/cppwinrt/") From 4af8e7c43ccbbdd273da5d73c280630204bff03b Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 3 Jun 2022 00:06:26 -0700 Subject: [PATCH 18/23] Update baseline --- versions/c-/cppwinrt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/c-/cppwinrt.json b/versions/c-/cppwinrt.json index bf5c3f85e10192..3b8370b9b42711 100644 --- a/versions/c-/cppwinrt.json +++ b/versions/c-/cppwinrt.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "91d7dcf218137560ec9cea4256f8a011e9ded375", + "git-tree": "0f76bed14360d1ab8ad5b476dfc87f1afae77b5a", "version": "2.0.220418.1", "port-version": 0 }, From 1ef408ac8101df820849ac63831713f48acd7973 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 3 Jun 2022 00:19:56 -0700 Subject: [PATCH 19/23] Don't need a config-version file for a VCPKG only CMake --- ports/cppwinrt/CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ports/cppwinrt/CMakeLists.txt b/ports/cppwinrt/CMakeLists.txt index 1c35f95e13592c..322e200705b830 100644 --- a/ports/cppwinrt/CMakeLists.txt +++ b/ports/cppwinrt/CMakeLists.txt @@ -102,11 +102,6 @@ include(CMakePackageConfigHelpers) string(TOLOWER ${PROJECT_NAME} PACKAGE_NAME) -write_basic_package_version_file( - ${PACKAGE_NAME}-config-version.cmake - VERSION ${CPPWINRT_VERSION} - COMPATIBILITY AnyNewerVersion) - install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets) @@ -127,5 +122,4 @@ install(FILES ${CPPWINRT_LIB} install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}) From eac884fba17ea3dcf0c0fa39bfa616c85d8cc650 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 3 Jun 2022 00:20:15 -0700 Subject: [PATCH 20/23] Baseline update --- versions/c-/cppwinrt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/c-/cppwinrt.json b/versions/c-/cppwinrt.json index 3b8370b9b42711..c08a6b55a69572 100644 --- a/versions/c-/cppwinrt.json +++ b/versions/c-/cppwinrt.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "0f76bed14360d1ab8ad5b476dfc87f1afae77b5a", + "git-tree": "40c763984c8b72e65c8484a258fdedd26eb99e42", "version": "2.0.220418.1", "port-version": 0 }, From 11e5262c5e6514211f3f76c6334f86ac1fde3b82 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Fri, 3 Jun 2022 19:43:15 -0700 Subject: [PATCH 21/23] [cppwinrt] Simplify port --- ports/cppwinrt/CMakeLists.txt | 125 ------------------------ ports/cppwinrt/CppWinRT-config.cmake.in | 23 ----- ports/cppwinrt/cppwinrt-config.cmake | 14 +++ ports/cppwinrt/portfile.cmake | 69 +++++++++---- ports/cppwinrt/usage | 4 + ports/cppwinrt/vcpkg.json | 4 - versions/c-/cppwinrt.json | 2 +- 7 files changed, 70 insertions(+), 171 deletions(-) delete mode 100644 ports/cppwinrt/CMakeLists.txt delete mode 100644 ports/cppwinrt/CppWinRT-config.cmake.in create mode 100644 ports/cppwinrt/cppwinrt-config.cmake create mode 100644 ports/cppwinrt/usage diff --git a/ports/cppwinrt/CMakeLists.txt b/ports/cppwinrt/CMakeLists.txt deleted file mode 100644 index 322e200705b830..00000000000000 --- a/ports/cppwinrt/CMakeLists.txt +++ /dev/null @@ -1,125 +0,0 @@ -cmake_minimum_required (VERSION 3.20) - -if(NOT DEFINED CPPWINRT_VERSION) - message(FATAL_ERROR "Requires CPPWINRT_VERSION value") -endif() - -project(CppWinRT - VERSION ${CPPWINRT_VERSION} - DESCRIPTION "C++/WinRT vcpkg support" - HOMEPAGE_URL "https://github.com/Microsoft/cppwinrt" - LANGUAGES CXX) - -if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") - set(CPPWINRT_ARCH win32) -else() - set(CPPWINRT_ARCH ${VCPKG_TARGET_ARCHITECTURE}) -endif() - -message(STATUS "Targeting ${CPPWINRT_ARCH}") - -include(GNUInstallDirs) - -set(CPPWINRT_TOOL "${CMAKE_CURRENT_SOURCE_DIR}/bin/cppwinrt.exe") - -set(CPPWINRT_LIB "${CMAKE_CURRENT_SOURCE_DIR}/build/native/lib/${CPPWINRT_ARCH}/cppwinrt_fast_forwarder.lib") - -#--- Find Windows SDK Version -if(NOT DEFINED WindowsSDKDir) - if(EXISTS "$ENV{WindowsSDKDir}" AND (NOT "$ENV{WindowsSDKDir}" STREQUAL "")) - get_filename_component(WindowsSDKDir "$ENV{WindowsSDKDir}" ABSOLUTE) - else() - set(WindowsSDKDir "$ENV{ProgramFiles\(x86\)}/Windows Kits/10") - endif() -endif() - -if (NOT (EXISTS "${WindowsSDKDir}")) - message(FATAL_ERROR "ERROR: Cannot locate the Windows SDK") -endif() - -if (CMAKE_SYSTEM_VERSION MATCHES "^10\\.0\\.[0-9]+\\.0$") - set(WindowsSDKVersion ${CMAKE_SYSTEM_VERSION}) -elseif(CMAKE_SYSTEM_VERSION MATCHES "^10\\.0\\.[0-9]+$") - set(WindowsSDKVersion "${CMAKE_SYSTEM_VERSION}.0") -endif() - -if(NOT DEFINED WindowsSDKVersion) - if(NOT ("$ENV{WindowsSDKVersion}" STREQUAL "")) - set(WindowsSDKVersion $ENV{WindowsSDKVersion}) - if (EXISTS "${WindowsSDKDir}/References/${WindowsSDKVersion}") - message(STATUS "Found Windows SDK and version from environment variables") - string(REPLACE "\\" "" WindowsSDKVersion ${WindowsSDKVersion}) - else() - set(WindowsSDKVersion "") - endif() - endif() -endif() - -set(WINDOWS_SDK_VERSIONS - 10.0.22000.0 # Windows SDK for Windows 11 - 10.0.20348.0 # Windows SDK, version 2104 - 10.0.19041.0 # Windows 10 "20H1" SDK - 10.0.18362.0 # Windows 10 May 2019 Update SDK - 10.0.17763.0 # Windows 10 October 2018 Update SDK - 10.0.17134.0 # Windows 10 April 2018 Update SDK - 10.0.16299.0 # Windows 10 Fall Creators Update SDK - 10.0.15063.0 # Windows 10 Creators Update SDK - 10.0.14393.0 # Windows 10 Anniversary Update SDK -) - -if (NOT (EXISTS "${WindowsSDKDir}/References/${WindowsSDKVersion}/Windows.Foundation.FoundationContract")) - set(WindowsSDKVersion "") - foreach(sdkver IN LISTS WINDOWS_SDK_VERSIONS) - if (EXISTS "${WindowsSDKDir}/References/${sdkver}/Windows.Foundation.FoundationContract") - cmake_path(CONVERT "${WindowsSDKDir}/References/${sdkver}" TO_CMAKE_PATH_LIST WinMDRoot NORMALIZE) - set(WindowsSDKVersion ${sdkver}) - break() - endif() - endforeach() - - if ("${WindowsSDKVersion}" STREQUAL "") - message(FATAL_ERROR "ERROR: Cannot locate the Windows SDK (14393) or later.") - endif() -endif() - -message(STATUS "Using .winmd files from ${WindowsSDKVersion} in ${WindowsSDKDir}") - -#--- Generate headers -add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/winrt/base.h" - COMMENT "Generating C++/WinRT headers for SDK ${WindowsSDKVersion}" - COMMAND ${CPPWINRT_TOOL} -in ${WindowsSDKVersion} -out ${CMAKE_CURRENT_BINARY_DIR} - USES_TERMINAL) - -add_library(${PROJECT_NAME} INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/winrt/base.h") - -target_include_directories(${PROJECT_NAME} INTERFACE - $ - $) - -#--- Package -include(CMakePackageConfigHelpers) - -string(TOLOWER ${PROJECT_NAME} PACKAGE_NAME) - -install(TARGETS ${PROJECT_NAME} - EXPORT ${PROJECT_NAME}-targets) - -configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}) - -install(EXPORT ${PROJECT_NAME}-targets - FILE ${PROJECT_NAME}-targets.cmake - NAMESPACE Microsoft:: - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}) - -install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/winrt - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PACKAGE_NAME}) - -install(FILES ${CPPWINRT_LIB} - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}) diff --git a/ports/cppwinrt/CppWinRT-config.cmake.in b/ports/cppwinrt/CppWinRT-config.cmake.in deleted file mode 100644 index 1d13fc195966ab..00000000000000 --- a/ports/cppwinrt/CppWinRT-config.cmake.in +++ /dev/null @@ -1,23 +0,0 @@ -@PACKAGE_INIT@ - -include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake) - -get_filename_component(_cppwinrt_root "${CMAKE_CURRENT_LIST_FILE}" PATH) -get_filename_component(_cppwinrt_root "${_cppwinrt_root}" PATH) -get_filename_component(_cppwinrt_root "${_cppwinrt_root}" PATH) - -set(_cppwinrt_root_lib "${_cppwinrt_root}/lib/cppwinrt_fast_forwarder.lib") -if (EXISTS "${_cppwinrt_root_lib}") - - set_target_properties(Microsoft::CppWinRT PROPERTIES - INTERFACE_LINK_LIBRARIES "${_cppwinrt_root_lib}") - -endif() - -set_target_properties(Microsoft::CppWinRT PROPERTIES - INTERFACE_COMPILE_FEATURES cxx_std_17) - -unset(_cppwinrt_root_lib) -unset(_cppwinrt_root) - -check_required_components(cppwinrt) diff --git a/ports/cppwinrt/cppwinrt-config.cmake b/ports/cppwinrt/cppwinrt-config.cmake new file mode 100644 index 00000000000000..c3e7575257e085 --- /dev/null +++ b/ports/cppwinrt/cppwinrt-config.cmake @@ -0,0 +1,14 @@ +set(CppWinRT_FOUND TRUE) + +if(NOT TARGET Microsoft::CppWinRT) + get_filename_component(cppwinrt_root "${CMAKE_CURRENT_LIST_DIR}" PATH) + get_filename_component(cppwinrt_root "${cppwinrt_root}" PATH) + + add_library(Microsoft::CppWinRT INTERFACE IMPORTED) + set_target_properties(Microsoft::CppWinRT PROPERTIES + INTERFACE_COMPILE_FEATURES cxx_std_17 + INTERFACE_INCLUDE_DIRECTORIES "${cppwinrt_root}/include" + INTERFACE_LINK_LIBRARIES "${cppwinrt_root}/lib/cppwinrt_fast_forwarder.lib" + ) + unset(cppwinrt_root) +endif() diff --git a/ports/cppwinrt/portfile.cmake b/ports/cppwinrt/portfile.cmake index 866f9a5ba627a6..7a3cd021c0e039 100644 --- a/ports/cppwinrt/portfile.cmake +++ b/ports/cppwinrt/portfile.cmake @@ -7,31 +7,64 @@ vcpkg_download_distfile(ARCHIVE ) vcpkg_extract_source_archive_ex( - OUT_SOURCE_PATH SOURCE_PATH + OUT_SOURCE_PATH src ARCHIVE ${ARCHIVE} NO_REMOVE_ONE_LEVEL ) -file(COPY - "${CMAKE_CURRENT_LIST_DIR}/CppWinRT-config.cmake.in" - "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" - DESTINATION "${SOURCE_PATH}" -) +if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + set(CPPWINRT_ARCH win32) +else() + set(CPPWINRT_ARCH ${VCPKG_TARGET_ARCHITECTURE}) +endif() -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS -DCPPWINRT_VERSION=${CPPWINRT_VERSION} -) +set(CPPWINRT_TOOL "${src}/bin/cppwinrt.exe") -vcpkg_cmake_install() -vcpkg_cmake_config_fixup() +#--- Find Windows SDK Version +if (NOT EXISTS "$ENV{WindowsSDKDir}/Lib/$ENV{WindowsSDKVersion}.") + message(FATAL_ERROR "ERROR: Cannot locate the Windows SDK. Please define %WindowsSDKDir% and %WindowsSDKVersion%. +(Expected file to exist: $ENV{WindowsSDKDir}/Lib/$ENV{WindowsSDKVersion})") +endif() +if (NOT EXISTS "$ENV{WindowsSDKDir}References/$ENV{WindowsSDKVersion}Windows.Foundation.FoundationContract") + message(FATAL_ERROR "ERROR: The Windows SDK is too old (needs 14393 or later, found $ENV{WindowsSDKVersion}).") +endif() -file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/cppwinrt/") +file(TO_CMAKE_PATH "$ENV{WindowsSDKDir}References/$ENV{WindowsSDKVersion}" winsdk) -file(INSTALL - "${SOURCE_PATH}/bin/cppwinrt.exe" - DESTINATION "${CURRENT_PACKAGES_DIR}/tools/cppwinrt") +file(GLOB winmds "${winsdk}/*/*/*.winmd") + +#--- Create response file +set(args "") +foreach(winmd IN LISTS winmds) + string(APPEND args "-input \"${winmd}\"\n") +endforeach() + +file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}") +file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}") +file(WRITE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/cppwinrt.rsp" "${args}") -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +#--- Generate headers +message(STATUS "Generating headers for Windows SDK $ENV{WindowsSDKVersion}") +vcpkg_execute_required_process( + COMMAND "${CPPWINRT_TOOL}" + "@${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/cppwinrt.rsp" + -output "${CURRENT_PACKAGES_DIR}/include" + -verbose + WORKING_DIRECTORY "${CURRENT_PACKAGES_DIR}" + LOGNAME "cppwinrt-generate-${TARGET_TRIPLET}" +) + +set(CPPWINRT_LIB "${src}/build/native/lib/${CPPWINRT_ARCH}/cppwinrt_fast_forwarder.lib") +file(COPY "${CPPWINRT_LIB}" DESTINATION "${CURRENT_PACKAGES_DIR}/lib") +if(NOT VCPKG_BUILD_TYPE) + file(COPY "${CPPWINRT_LIB}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib") +endif() +file(COPY + "${CPPWINRT_TOOL}" + DESTINATION "${CURRENT_PACKAGES_DIR}/tools/cppwinrt") +file(COPY + "${CMAKE_CURRENT_LIST_DIR}/cppwinrt-config.cmake" + "${CMAKE_CURRENT_LIST_DIR}/usage" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/cppwinrt") -file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +configure_file("${src}/LICENSE" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" COPYONLY) diff --git a/ports/cppwinrt/usage b/ports/cppwinrt/usage new file mode 100644 index 00000000000000..a83a44a7e4c6d8 --- /dev/null +++ b/ports/cppwinrt/usage @@ -0,0 +1,4 @@ +cppwinrt provides CMake targets: + + find_package(cppwinrt CONFIG REQUIRED) + target_link_libraries(main PRIVATE Microsoft::CppWinRT) diff --git a/ports/cppwinrt/vcpkg.json b/ports/cppwinrt/vcpkg.json index 8dd5c2ef812598..718f6929667fb8 100644 --- a/ports/cppwinrt/vcpkg.json +++ b/ports/cppwinrt/vcpkg.json @@ -7,10 +7,6 @@ "license": "MIT", "supports": "windows", "dependencies": [ - { - "name": "vcpkg-cmake", - "host": true - }, { "name": "vcpkg-cmake-config", "host": true diff --git a/versions/c-/cppwinrt.json b/versions/c-/cppwinrt.json index c08a6b55a69572..97d0e8c3ba7d17 100644 --- a/versions/c-/cppwinrt.json +++ b/versions/c-/cppwinrt.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "40c763984c8b72e65c8484a258fdedd26eb99e42", + "git-tree": "d4e517abedddb8d20362bc9cbae6716ecf3a7f62", "version": "2.0.220418.1", "port-version": 0 }, From 3d528c35e2e1e5355934746400124e3637b2a6f3 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Sun, 5 Jun 2022 23:46:44 -0700 Subject: [PATCH 22/23] Update ports/cppwinrt/vcpkg.json Co-authored-by: LilyWangLL <94091114+LilyWangLL@users.noreply.github.com> --- ports/cppwinrt/vcpkg.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ports/cppwinrt/vcpkg.json b/ports/cppwinrt/vcpkg.json index 718f6929667fb8..679191ebebb88c 100644 --- a/ports/cppwinrt/vcpkg.json +++ b/ports/cppwinrt/vcpkg.json @@ -5,11 +5,5 @@ "homepage": "https://github.com/microsoft/cppwinrt", "documentation": "https://docs.microsoft.com/windows/uwp/cpp-and-winrt-apis/", "license": "MIT", - "supports": "windows", - "dependencies": [ - { - "name": "vcpkg-cmake-config", - "host": true - } - ] + "supports": "windows" } From 52db78b0375fe322f61d3bdce0b0ff8634169120 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Sun, 5 Jun 2022 23:50:43 -0700 Subject: [PATCH 23/23] Update baseline --- versions/c-/cppwinrt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/c-/cppwinrt.json b/versions/c-/cppwinrt.json index 97d0e8c3ba7d17..bdff431eb4dfe7 100644 --- a/versions/c-/cppwinrt.json +++ b/versions/c-/cppwinrt.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "d4e517abedddb8d20362bc9cbae6716ecf3a7f62", + "git-tree": "18d6860cc0a36639fe348d27ab4cb763dfc0e879", "version": "2.0.220418.1", "port-version": 0 },