aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/cppwinrt
diff options
context:
space:
mode:
authorEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
committerEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
commit54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch)
treed915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/cppwinrt
move to own git serverHEADmaster
Diffstat (limited to 'vcpkg/ports/cppwinrt')
-rw-r--r--vcpkg/ports/cppwinrt/cppwinrt-config.cmake.in24
-rw-r--r--vcpkg/ports/cppwinrt/portfile.cmake72
-rw-r--r--vcpkg/ports/cppwinrt/usage6
-rw-r--r--vcpkg/ports/cppwinrt/vcpkg.json9
4 files changed, 111 insertions, 0 deletions
diff --git a/vcpkg/ports/cppwinrt/cppwinrt-config.cmake.in b/vcpkg/ports/cppwinrt/cppwinrt-config.cmake.in
new file mode 100644
index 0000000..bacfdb6
--- /dev/null
+++ b/vcpkg/ports/cppwinrt/cppwinrt-config.cmake.in
@@ -0,0 +1,24 @@
+get_filename_component(_cppwinrt_root "${CMAKE_CURRENT_LIST_DIR}" PATH)
+get_filename_component(_cppwinrt_root "${_cppwinrt_root}" PATH)
+
+set(_cppwinrt_exe "${_cppwinrt_root}/@tool_path@")
+if (EXISTS "${_cppwinrt_exe}")
+
+ 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/@lib_name@"
+ )
+
+ set(cppwinrt_FOUND TRUE)
+ set(CPPWINRT_TOOL ${_cppwinrt_exe})
+
+else()
+
+ set(cppwinrt_FOUND FALSE)
+
+endif()
+
+unset(_cppwinrt_root)
+unset(_cppwinrt_exe)
diff --git a/vcpkg/ports/cppwinrt/portfile.cmake b/vcpkg/ports/cppwinrt/portfile.cmake
new file mode 100644
index 0000000..b172ac0
--- /dev/null
+++ b/vcpkg/ports/cppwinrt/portfile.cmake
@@ -0,0 +1,72 @@
+
+vcpkg_download_distfile(ARCHIVE
+ URLS "https://www.nuget.org/api/v2/package/Microsoft.Windows.CppWinRT/${VERSION}"
+ FILENAME "cppwinrt.${VERSION}.zip"
+ SHA512 ADF9EC7059A58B3E0EB0057DE52900692F58305AEE8BA708D265D273A81127978BEB9BF2599B00855B61B725D4E6EB06206B66897EAEAEF1AEC83948D60BC293
+)
+
+vcpkg_extract_source_archive(
+ src
+ ARCHIVE "${ARCHIVE}"
+ NO_REMOVE_ONE_LEVEL
+)
+
+if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
+ set(CPPWINRT_ARCH win32)
+else()
+ set(CPPWINRT_ARCH ${VCPKG_TARGET_ARCHITECTURE})
+endif()
+
+set(CPPWINRT_TOOL "${src}/bin/cppwinrt.exe")
+
+#--- 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(TO_CMAKE_PATH "$ENV{WindowsSDKDir}References/$ENV{WindowsSDKVersion}" winsdk)
+
+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}")
+
+#--- Generate headers
+string(REGEX MATCH "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" SDKVersion $ENV{WindowsSDKVersion})
+message(STATUS "Generating headers for Windows SDK ${SDKVersion}")
+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(INSTALL "${CPPWINRT_LIB}" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
+if(NOT DEFINED VCPKG_BUILD_TYPE)
+ file(INSTALL "${CPPWINRT_LIB}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
+endif()
+file(INSTALL "${CPPWINRT_TOOL}" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/cppwinrt")
+
+set(tool_path "tools/cppwinrt/cppwinrt.exe")
+set(lib_name "cppwinrt_fast_forwarder.lib")
+
+configure_file("${CMAKE_CURRENT_LIST_DIR}/cppwinrt-config.cmake.in"
+ "${CURRENT_PACKAGES_DIR}/share/${PORT}/${PORT}-config.cmake"
+ @ONLY)
+
+file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
+vcpkg_install_copyright(FILE_LIST "${src}/LICENSE")
diff --git a/vcpkg/ports/cppwinrt/usage b/vcpkg/ports/cppwinrt/usage
new file mode 100644
index 0000000..fa7449e
--- /dev/null
+++ b/vcpkg/ports/cppwinrt/usage
@@ -0,0 +1,6 @@
+The C++/WinRT package provides CMake targets:
+
+ find_package(cppwinrt CONFIG REQUIRED)
+ target_link_libraries(main PRIVATE Microsoft::CppWinRT)
+
+The CMake variable CPPWINRT_TOOL is also set to point to the .winmd to header command-line tool.
diff --git a/vcpkg/ports/cppwinrt/vcpkg.json b/vcpkg/ports/cppwinrt/vcpkg.json
new file mode 100644
index 0000000..764f6fc
--- /dev/null
+++ b/vcpkg/ports/cppwinrt/vcpkg.json
@@ -0,0 +1,9 @@
+{
+ "name": "cppwinrt",
+ "version": "2.0.250303.1",
+ "description": "C++/WinRT is a standard C++ language projection for the Windows Runtime.",
+ "homepage": "https://github.com/microsoft/cppwinrt",
+ "documentation": "https://docs.microsoft.com/windows/uwp/cpp-and-winrt-apis/",
+ "license": "MIT",
+ "supports": "windows"
+}