diff --git a/docs/maintainers/portfile-functions.md b/docs/maintainers/portfile-functions.md index e16147f7df9..6a05d884d0b 100644 --- a/docs/maintainers/portfile-functions.md +++ b/docs/maintainers/portfile-functions.md @@ -5,6 +5,7 @@ - [vcpkg\_apply\_patches](vcpkg_apply_patches.md) - [vcpkg\_build\_cmake](vcpkg_build_cmake.md) - [vcpkg\_build\_msbuild](vcpkg_build_msbuild.md) +- [vcpkg\_check\_linkage](vcpkg_check_linkage.md) - [vcpkg\_configure\_cmake](vcpkg_configure_cmake.md) - [vcpkg\_copy\_pdbs](vcpkg_copy_pdbs.md) - [vcpkg\_copy\_tool\_dependencies](vcpkg_copy_tool_dependencies.md) @@ -15,3 +16,4 @@ - [vcpkg\_from\_bitbucket](vcpkg_from_bitbucket.md) - [vcpkg\_from\_github](vcpkg_from_github.md) - [vcpkg\_install\_cmake](vcpkg_install_cmake.md) +- [vcpkg\_install\_msbuild](vcpkg_install_msbuild.md) diff --git a/docs/maintainers/vcpkg_build_msbuild.md b/docs/maintainers/vcpkg_build_msbuild.md index 37f8d8df273..862587eb4f1 100644 --- a/docs/maintainers/vcpkg_build_msbuild.md +++ b/docs/maintainers/vcpkg_build_msbuild.md @@ -1,6 +1,6 @@ # vcpkg_build_msbuild -Build an msbuild-based project. +Build an msbuild-based project. Deprecated in favor of `vcpkg_install_msbuild()`. ## Usage ```cmake @@ -15,6 +15,7 @@ vcpkg_build_msbuild( [OPTIONS ...] [OPTIONS_RELEASE ...] [OPTIONS_DEBUG ...] + [USE_VCPKG_INTEGRATION] ) ``` diff --git a/docs/maintainers/vcpkg_check_linkage.md b/docs/maintainers/vcpkg_check_linkage.md new file mode 100644 index 00000000000..406325dba08 --- /dev/null +++ b/docs/maintainers/vcpkg_check_linkage.md @@ -0,0 +1,34 @@ +# vcpkg_check_linkage + +Asserts the available library and CRT linkage options for the port. + +## Usage +```cmake +vcpkg_check_linkage( + [ONLY_STATIC_LIBRARY | ONLY_DYNAMIC_LIBRARY] + [ONLY_STATIC_CRT | ONLY_DYNAMIC_CRT] +) +``` + +## Parameters +### ONLY_STATIC_LIBRARY +Indicates that this port can only be built with static library linkage. + +### ONLY_DYNAMIC_LIBRARY +Indicates that this port can only be built with dynamic/shared library linkage. + +### ONLY_STATIC_CRT +Indicates that this port can only be built with static CRT linkage. + +### ONLY_DYNAMIC_CRT +Indicates that this port can only be built with dynamic/shared CRT linkage. + +## Notes +This command will either alter the settings for `VCPKG_LIBRARY_LINKAGE` or fail, depending on what was requested by the user versus what the library supports. + +## Examples + +* [libimobiledevice](https://github.com/Microsoft/vcpkg/blob/master/ports/libimobiledevice/portfile.cmake) + +## Source +[scripts/cmake/vcpkg_check_linkage.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_check_linkage.cmake) diff --git a/docs/maintainers/vcpkg_install_msbuild.md b/docs/maintainers/vcpkg_install_msbuild.md new file mode 100644 index 00000000000..76578c2ef33 --- /dev/null +++ b/docs/maintainers/vcpkg_install_msbuild.md @@ -0,0 +1,88 @@ +# vcpkg_install_msbuild + +Build and install an msbuild-based project. This replaces `vcpkg_build_msbuild()`. + +## Usage +```cmake +vcpkg_install_msbuild( + SOURCE_PATH <${SOURCE_PATH}> + PROJECT_SUBPATH + [INCLUDES_SUBPATH ] + [LICENSE_SUBPATH ] + [RELEASE_CONFIGURATION ] + [DEBUG_CONFIGURATION ] + [TARGET ] + [TARGET_PLATFORM_VERSION <10.0.15063.0>] + [PLATFORM <${TRIPLET_SYSTEM_ARCH}>] + [PLATFORM_TOOLSET <${VCPKG_PLATFORM_TOOLSET}>] + [OPTIONS ...] + [OPTIONS_RELEASE ...] + [OPTIONS_DEBUG ...] + [USE_VCPKG_INTEGRATION] + [ALLOW_ROOT_INCLUDES | REMOVE_ROOT_INCLUDES] +) +``` + +## Parameters +### SOURCE_PATH +The path to the root of the source tree. + +Because MSBuild uses in-source builds, the source tree will be copied into a temporary location for the build. This +parameter is the base for that copy and forms the base for all XYZ_SUBPATH options. + +### USE_VCPKG_INTEGRATION +Apply the normal `integrate install` integration for building the project. + +By default, projects built with this command will not automatically link libraries or have header paths set. + +### PROJECT_SUBPATH +The subpath to the solution (`.sln`) or project (`.vcxproj`) file relative to `SOURCE_PATH`. + +### LICENSE_SUBPATH +The subpath to the license file relative to `SOURCE_PATH`. + +### INCLUDES_SUBPATH +The subpath to the includes directory relative to `SOURCE_PATH`. + +This parameter should be a directory and should not end in a trailing slash. + +### ALLOW_ROOT_INCLUDES +Indicates that top-level include files (e.g. `include/zlib.h`) should be allowed. + +### REMOVE_ROOT_INCLUDES +Indicates that top-level include files (e.g. `include/Makefile.am`) should be removed. + +### RELEASE_CONFIGURATION +The configuration (``/p:Configuration`` msbuild parameter) used for Release builds. + +### DEBUG_CONFIGURATION +The configuration (``/p:Configuration`` msbuild parameter) +used for Debug builds. + +### TARGET_PLATFORM_VERSION +The WindowsTargetPlatformVersion (``/p:WindowsTargetPlatformVersion`` msbuild parameter) + +### TARGET +The MSBuild target to build. (``/t:``) + +### PLATFORM +The platform (``/p:Platform`` msbuild parameter) used for the build. + +### PLATFORM_TOOLSET +The platform toolset (``/p:PlatformToolset`` msbuild parameter) used for the build. + +### OPTIONS +Additional options passed to msbuild for all builds. + +### OPTIONS_RELEASE +Additional options passed to msbuild for Release builds. These are in addition to `OPTIONS`. + +### OPTIONS_DEBUG +Additional options passed to msbuild for Debug builds. These are in addition to `OPTIONS`. + +## Examples + +* [libimobiledevice](https://github.com/Microsoft/vcpkg/blob/master/ports/libimobiledevice/portfile.cmake) + +## Source +[scripts/cmake/vcpkg_install_msbuild.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_install_msbuild.cmake) diff --git a/ports/getopt-win32/CONTROL b/ports/getopt-win32/CONTROL new file mode 100644 index 00000000000..d80fa0b00ee --- /dev/null +++ b/ports/getopt-win32/CONTROL @@ -0,0 +1,3 @@ +Source: getopt-win32 +Version: 0.1 +Description: An implementation of getopt provided by https://github.com/libimobiledevice-win32 diff --git a/ports/getopt-win32/portfile.cmake b/ports/getopt-win32/portfile.cmake new file mode 100644 index 00000000000..50ffc2b88ab --- /dev/null +++ b/ports/getopt-win32/portfile.cmake @@ -0,0 +1,24 @@ +include(vcpkg_common_functions) + +if(VCPKG_CMAKE_SYSTEM_NAME) + message(FATAL_ERROR "getopt-win32 only supports building on Windows Desktop") +endif() + +vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY ONLY_DYNAMIC_CRT) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libimobiledevice-win32/getopt + REF 0.1 + SHA512 40e2a901241a5d751cec741e5de423c8f19b105572c7cae18adb6e69be0b408efc6c9a2ecaeb62f117745eac0d093f30d6b91d88c1a27e1f7be91f0e84fdf199 + HEAD_REF master +) + +vcpkg_install_msbuild( + SOURCE_PATH ${SOURCE_PATH} + PROJECT_SUBPATH getopt.vcxproj + LICENSE_SUBPATH LICENSE +) + +# Copy header +file(COPY ${SOURCE_PATH}/getopt.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/) diff --git a/ports/getopt/CONTROL b/ports/getopt/CONTROL index ce6fbb776a0..bae137bbd5c 100644 --- a/ports/getopt/CONTROL +++ b/ports/getopt/CONTROL @@ -1,3 +1,4 @@ Source: getopt -Version: 0.1 +Version: 0 Description: The getopt and getopt_long functions automate some of the chore involved in parsing typical unix command line options. +Build-Depends: getopt-win32 (windows) diff --git a/ports/getopt/portfile.cmake b/ports/getopt/portfile.cmake index 681d37938cc..21d59ebcb38 100644 --- a/ports/getopt/portfile.cmake +++ b/ports/getopt/portfile.cmake @@ -1,64 +1,5 @@ -# Common Ambient Variables: -# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT} -# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET} -# CURRENT_PORT_DIR = ${VCPKG_ROOT_DIR}\ports\${PORT} -# PORT = current port name (zlib, etc) -# TARGET_TRIPLET = current triplet (x86-windows, x64-windows-static, etc) -# VCPKG_CRT_LINKAGE = C runtime linkage type (static, dynamic) -# VCPKG_LIBRARY_LINKAGE = target library linkage type (static, dynamic) -# VCPKG_ROOT_DIR = -# VCPKG_TARGET_ARCHITECTURE = target architecture (x64, x86, arm) -# - -include(vcpkg_common_functions) -set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/getopt-0.1) - -if(VCPKG_TARGET_ARCHITECTURE STREQUAL x64) - set(MSBUILD_PLATFORM x64) -else() - set(MSBUILD_PLATFORM Win32) +if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + message(FATAL_ERROR "No implementation of getopt is currently available for UWP targets") endif() -set(DEBUG_CONFIG Debug) -set(RELEASE_CONFIG Release) - -vcpkg_download_distfile(ARCHIVE - URLS "https://github.com/libimobiledevice-win32/getopt/archive/0.1.zip" - FILENAME "getopt-0.1.zip" - SHA512 7d9786222b6934b80ff2d03e20f211bf289e494ec388842b245f86a5c6bb3a403baba088ceb2e05a460c5523f63f4dd2dc6854a4cc50b1360f168b4f34573a3d -) -vcpkg_extract_source_archive(${ARCHIVE}) - -vcpkg_build_msbuild( - PROJECT_PATH ${SOURCE_PATH}/getopt.vcxproj - DEBUG_CONFIGURATION ${DEBUG_CONFIG} - RELEASE_CONFIGURATION ${RELEASE_CONFIG} -) - -# Copy headers -file(COPY ${SOURCE_PATH}/getopt.h - DESTINATION ${CURRENT_PACKAGES_DIR}/include/) - -# Copy binary files -file (MAKE_DIRECTORY - ${CURRENT_PACKAGES_DIR}/bin - ${CURRENT_PACKAGES_DIR}/debug/bin) -file (MAKE_DIRECTORY - ${CURRENT_PACKAGES_DIR}/lib - ${CURRENT_PACKAGES_DIR}/debug/lib) - -file(COPY ${SOURCE_PATH}/${MSBUILD_PLATFORM}/${DEBUG_CONFIG}/getopt.dll - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) -file(COPY ${SOURCE_PATH}/${MSBUILD_PLATFORM}/${RELEASE_CONFIG}/getopt.dll - DESTINATION ${CURRENT_PACKAGES_DIR}/bin) -file(COPY ${SOURCE_PATH}/${MSBUILD_PLATFORM}/${DEBUG_CONFIG}/getopt.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) -file(COPY ${SOURCE_PATH}/${MSBUILD_PLATFORM}/${RELEASE_CONFIG}/getopt.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/lib) -file(COPY ${SOURCE_PATH}/${MSBUILD_PLATFORM}/${DEBUG_CONFIG}/getopt.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) -file(COPY ${SOURCE_PATH}/${MSBUILD_PLATFORM}/${RELEASE_CONFIG}/getopt.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/bin) - -# Handle copyright -file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/getopt RENAME copyright) +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/ports/ideviceinstaller/CONTROL b/ports/ideviceinstaller/CONTROL new file mode 100644 index 00000000000..3697611a4e7 --- /dev/null +++ b/ports/ideviceinstaller/CONTROL @@ -0,0 +1,4 @@ +Source: ideviceinstaller +Version: 1.1.2.23-1 +Description: Manage apps of iOS devices +Build-Depends: libimobiledevice, libzip \ No newline at end of file diff --git a/ports/ideviceinstaller/portfile.cmake b/ports/ideviceinstaller/portfile.cmake new file mode 100644 index 00000000000..ca6b7928730 --- /dev/null +++ b/ports/ideviceinstaller/portfile.cmake @@ -0,0 +1,18 @@ +include(vcpkg_common_functions) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libimobiledevice-win32/ideviceinstaller + REF 1.1.2.23 + SHA512 d0801b3a38eb02206a6f06e05cc19b794c69a87c06895165f64522c61e07030046499c5f0e436981682f9e17f91eae87913cca091e2e039a74ee35a5136100d4 + HEAD_REF master +) + +vcpkg_install_msbuild( + SOURCE_PATH ${SOURCE_PATH} + PROJECT_SUBPATH ideviceinstaller.vcxproj + LICENSE_SUBPATH COPYING + USE_VCPKG_INTEGRATION +) + +set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) diff --git a/ports/idevicerestore/CONTROL b/ports/idevicerestore/CONTROL new file mode 100644 index 00000000000..dc781eb5cce --- /dev/null +++ b/ports/idevicerestore/CONTROL @@ -0,0 +1,4 @@ +Source: idevicerestore +Version: 1.0.12-1 +Description: Restore/upgrade firmware of iOS devices +Build-Depends: libimobiledevice, curl, libirecovery, libzip \ No newline at end of file diff --git a/ports/idevicerestore/portfile.cmake b/ports/idevicerestore/portfile.cmake new file mode 100644 index 00000000000..81d302a4023 --- /dev/null +++ b/ports/idevicerestore/portfile.cmake @@ -0,0 +1,18 @@ +include(vcpkg_common_functions) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libimobiledevice-win32/idevicerestore + REF 1.0.12 + SHA512 ba623be56c2f37853516d7d4c32e16f1ec72f33d512f18aa812ce6830af4b9e389f7af5321888dd0ddd168e282b652e379b60f90970680e213eabf489f406915 + HEAD_REF master +) + +vcpkg_install_msbuild( + SOURCE_PATH ${SOURCE_PATH} + PROJECT_SUBPATH idevicerestore.vcxproj + LICENSE_SUBPATH COPYING + USE_VCPKG_INTEGRATION +) + +set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) diff --git a/ports/libideviceactivation/CONTROL b/ports/libideviceactivation/CONTROL new file mode 100644 index 00000000000..2d5e236619e --- /dev/null +++ b/ports/libideviceactivation/CONTROL @@ -0,0 +1,4 @@ +Source: libideviceactivation +Version: 1.0.38-1 +Description: A library to handle the activation process of iOS devices +Build-Depends: libimobiledevice, libxml2, curl \ No newline at end of file diff --git a/ports/libideviceactivation/portfile.cmake b/ports/libideviceactivation/portfile.cmake new file mode 100644 index 00000000000..117d8f4723f --- /dev/null +++ b/ports/libideviceactivation/portfile.cmake @@ -0,0 +1,22 @@ +include(vcpkg_common_functions) + +vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY ONLY_DYNAMIC_CRT) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libimobiledevice-win32/libideviceactivation + REF 1.0.38 + SHA512 2fd2d5636e83a6740251dca58c04429628f47661a56e573fc14f45ef68c54990717515305902cf04759a7c8fd19e66a30c8eb2ea20e6257d2c5405b690ea25a6 + HEAD_REF master +) + +vcpkg_install_msbuild( + SOURCE_PATH ${SOURCE_PATH} + PROJECT_SUBPATH libideviceactivation.sln + INCLUDES_SUBPATH include + LICENSE_SUBPATH COPYING + USE_VCPKG_INTEGRATION + ALLOW_ROOT_INCLUDES +) + +file(REMOVE ${CURRENT_PACKAGES_DIR}/include/Makefile.am) diff --git a/ports/libimobiledevice/CONTROL b/ports/libimobiledevice/CONTROL new file mode 100644 index 00000000000..b6d3c2960c2 --- /dev/null +++ b/ports/libimobiledevice/CONTROL @@ -0,0 +1,4 @@ +Source: libimobiledevice +Version: 1.2.1.215-1 +Description: A cross-platform protocol library to communicate with iOS devices +Build-Depends: libplist, libusbmuxd, openssl, dirent, getopt \ No newline at end of file diff --git a/ports/libimobiledevice/portfile.cmake b/ports/libimobiledevice/portfile.cmake new file mode 100644 index 00000000000..c17e43de5fb --- /dev/null +++ b/ports/libimobiledevice/portfile.cmake @@ -0,0 +1,20 @@ +include(vcpkg_common_functions) + +vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY ONLY_DYNAMIC_CRT) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libimobiledevice-win32/libimobiledevice + REF 1.2.1.215 + SHA512 192ac12eb4fdf518a934cb8061d4a40e48f483e969e34167f2a5346efac1d745e4041eff84d7175d106b1a3b3f806d5e69643daa1459e48e69bc9c38d722be3c + HEAD_REF master +) + +vcpkg_install_msbuild( + SOURCE_PATH ${SOURCE_PATH} + PROJECT_SUBPATH libimobiledevice.sln + INCLUDES_SUBPATH include + LICENSE_SUBPATH COPYING + REMOVE_ROOT_INCLUDES + USE_VCPKG_INTEGRATION +) diff --git a/ports/libirecovery/CONTROL b/ports/libirecovery/CONTROL new file mode 100644 index 00000000000..0916cd6986b --- /dev/null +++ b/ports/libirecovery/CONTROL @@ -0,0 +1,4 @@ +Source: libirecovery +Version: 1.0.25-1 +Description: Library and utility to talk to iBoot/iBSS via USB on Mac OS X, Windows, and Linux +Build-Depends: libusbmuxd, readline \ No newline at end of file diff --git a/ports/libirecovery/portfile.cmake b/ports/libirecovery/portfile.cmake new file mode 100644 index 00000000000..f03e7e44cd3 --- /dev/null +++ b/ports/libirecovery/portfile.cmake @@ -0,0 +1,22 @@ +include(vcpkg_common_functions) + +vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY ONLY_DYNAMIC_CRT) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libimobiledevice-win32/libirecovery + REF 1.0.25 + SHA512 0dd91d4fe3ded2bc1bbd91aea964e31e7f59bce18be01aa096e974f37dc1be281644d6c44e3f9b49470dd961e3df2e3ff8a09bcc6b803a959073e7d7d9a8d3e7 + HEAD_REF master +) + +vcpkg_install_msbuild( + SOURCE_PATH ${SOURCE_PATH} + PROJECT_SUBPATH libirecovery.sln + INCLUDES_SUBPATH include + LICENSE_SUBPATH COPYING + USE_VCPKG_INTEGRATION + ALLOW_ROOT_INCLUDES +) + +file(REMOVE ${CURRENT_PACKAGES_DIR}/include/Makefile.am) diff --git a/ports/libplist/CONTROL b/ports/libplist/CONTROL new file mode 100644 index 00000000000..22e209d14c5 --- /dev/null +++ b/ports/libplist/CONTROL @@ -0,0 +1,3 @@ +Source: libplist +Version: 2.0.1.197-1 +Description: A library to handle Apple Property List format in binary or XML diff --git a/ports/libplist/dllexport.patch b/ports/libplist/dllexport.patch new file mode 100644 index 00000000000..f5e0062104b --- /dev/null +++ b/ports/libplist/dllexport.patch @@ -0,0 +1,37 @@ +diff --git a/include/plist/plist.h b/include/plist/plist.h +index 2863c74..9cdb219 100644 +--- a/include/plist/plist.h ++++ b/include/plist/plist.h +@@ -42,7 +42,7 @@ extern "C" + #include + #endif + +-#ifdef _MSC_VER ++#if defined(_MSC_VER) && defined(LIBPLIST_EXPORTS) + #define PLIST_API_MSC __declspec( dllexport ) + #else + #define PLIST_API_MSC +diff --git a/src/plist.h b/src/plist.h +index 1e5d0d1..6690343 100644 +--- a/src/plist.h ++++ b/src/plist.h +@@ -39,10 +39,7 @@ + #include + #endif + +-#ifdef _MSC_VER +- #define PLIST_API __declspec( dllexport ) +-#else +-#ifdef WIN32 ++#if (defined(_MSC_VER) || defined(WIN32)) && defined(LIBPLIST_EXPORTS) + #define PLIST_API __declspec( dllexport ) + #else + #ifdef HAVE_FVISIBILITY +@@ -51,7 +48,6 @@ + #define PLIST_API + #endif + #endif +-#endif + + struct plist_data_s + { diff --git a/ports/libplist/portfile.cmake b/ports/libplist/portfile.cmake new file mode 100644 index 00000000000..71e12fd4cba --- /dev/null +++ b/ports/libplist/portfile.cmake @@ -0,0 +1,20 @@ +include(vcpkg_common_functions) + +vcpkg_check_linkage(ONLY_STATIC_LIBRARY ONLY_DYNAMIC_CRT) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libimobiledevice-win32/libplist + REF 2.0.1.197 + SHA512 55e1817c61d608b11646eb9c28c445f9ee801c7beb2121bd810235561117262adb73dbecb23b9ef5b0c54b0fc8089e0a46acc0e8f4845329a50a663ab004052c + HEAD_REF master + PATCHES dllexport.patch +) + +vcpkg_install_msbuild( + SOURCE_PATH ${SOURCE_PATH} + PROJECT_SUBPATH libplist.sln + INCLUDES_SUBPATH include + LICENSE_SUBPATH COPYING.lesser + REMOVE_ROOT_INCLUDES +) diff --git a/ports/libusbmuxd/CONTROL b/ports/libusbmuxd/CONTROL new file mode 100644 index 00000000000..b93c9d3790b --- /dev/null +++ b/ports/libusbmuxd/CONTROL @@ -0,0 +1,4 @@ +Source: libusbmuxd +Version: 1.0.107-1 +Description: A client library to multiplex connections from and to iOS devices +Build-Depends: libplist diff --git a/ports/libusbmuxd/dllexport.patch b/ports/libusbmuxd/dllexport.patch new file mode 100644 index 00000000000..15996ec0143 --- /dev/null +++ b/ports/libusbmuxd/dllexport.patch @@ -0,0 +1,26 @@ +diff --git a/include/usbmuxd.h b/include/usbmuxd.h +index 5a3b0c0..aa1c8d9 100644 +--- a/include/usbmuxd.h ++++ b/include/usbmuxd.h +@@ -24,7 +24,7 @@ + #define USBMUXD_H + #include + +-#ifdef _MSC_VER ++#if defined(_MSC_VER) && defined(USBMUXD_EXPORTS) + #define USBMUXD_API_MSC __declspec( dllexport ) + #else + #ifdef HAVE_FVISIBILITY +diff --git a/src/libusbmuxd.c b/src/libusbmuxd.c +index b94c83c..1902a55 100644 +--- a/src/libusbmuxd.c ++++ b/src/libusbmuxd.c +@@ -34,7 +34,7 @@ + #include + #include + +-#ifdef _MSC_VER ++#if defined(_MSC_VER) && defined(USBMUXD_EXPORTS) + #define USBMUXD_API __declspec( dllexport ) + #else + #define USBMUXD_API diff --git a/ports/libusbmuxd/portfile.cmake b/ports/libusbmuxd/portfile.cmake new file mode 100644 index 00000000000..b8eb19b2b73 --- /dev/null +++ b/ports/libusbmuxd/portfile.cmake @@ -0,0 +1,23 @@ +include(vcpkg_common_functions) + +vcpkg_check_linkage(ONLY_STATIC_LIBRARY ONLY_DYNAMIC_CRT) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libimobiledevice-win32/libusbmuxd + REF 1.0.109 + SHA512 104205ebcac96765f4bf0b42dbe5df084be4f87fc64454b4e02049fbd18caf9282d070f8949935977eda76fba68b6a909571afea58d4ad4091f02d0e6b7a08e0 + HEAD_REF master + PATCHES dllexport.patch +) + +vcpkg_install_msbuild( + SOURCE_PATH ${SOURCE_PATH} + PROJECT_SUBPATH libusbmuxd.sln + INCLUDES_SUBPATH include + LICENSE_SUBPATH COPYING + USE_VCPKG_INTEGRATION + ALLOW_ROOT_INCLUDES +) + +file(REMOVE "${CURRENT_PACKAGES_DIR}/include/Makefile.am") diff --git a/ports/libzip/CONTROL b/ports/libzip/CONTROL index e82f0fee280..52681ed04f9 100644 --- a/ports/libzip/CONTROL +++ b/ports/libzip/CONTROL @@ -1,4 +1,4 @@ Source: libzip -Version: rel-1-5-1 +Version: rel-1-5-1-vcpkg1 Build-Depends: zlib Description: A library for reading, creating, and modifying zip archives. diff --git a/ports/libzip/LICENSE b/ports/libzip/LICENSE deleted file mode 100644 index 1c2e86bf266..00000000000 --- a/ports/libzip/LICENSE +++ /dev/null @@ -1,66 +0,0 @@ -Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner - -The authors can be contacted at - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - -3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS -OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -For AES encryption support, files under the following license are used: - ---------------------------------------------------------------------------- -Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK. -All rights reserved. - -LICENSE TERMS - -The free distribution and use of this software in both source and binary -form is allowed (with or without changes) provided that: - - 1. distributions of this source code include the above copyright - notice, this list of conditions and the following disclaimer; - - 2. distributions in binary form include the above copyright - notice, this list of conditions and the following disclaimer - in the documentation and/or other associated materials; - - 3. the copyright holder's name is not used to endorse products - built using this software without specific written permission. - -ALTERNATIVELY, provided that this notice is retained in full, this product -may be distributed under the terms of the GNU General Public License (GPL), -in which case the provisions of the GPL apply INSTEAD OF those given above. - -DISCLAIMER - -This software is provided 'as is' with no explicit or implied warranties -in respect of its properties, including, but not limited to, correctness -and/or fitness for purpose. ---------------------------------------------------------------------------- -Issue Date: 18th November 2008 diff --git a/ports/libzip/portfile.cmake b/ports/libzip/portfile.cmake index b509c5eb0d7..de7940b3afa 100644 --- a/ports/libzip/portfile.cmake +++ b/ports/libzip/portfile.cmake @@ -4,13 +4,8 @@ vcpkg_from_github( REPO nih-at/libzip REF rel-1-5-1 SHA512 778f438f6354f030656baa5497b3154ad8fb764011d2a6925136f32e06dc0dcd1ed93fe05dbf7be619004a68cdabe5e34a83b988c1501ed67e9cfa4fa540350f -) - -# Patch cmake and configuration to allow static builds -vcpkg_apply_patches( - SOURCE_PATH ${SOURCE_PATH} - PATCHES - "${CMAKE_CURRENT_LIST_DIR}/cmake_dont_build_more_than_needed.patch" + HEAD_REF master + PATCHES cmake_dont_build_more_than_needed.patch ) vcpkg_configure_cmake( @@ -20,13 +15,13 @@ vcpkg_configure_cmake( vcpkg_install_cmake() -# Move zipconf.h to include and remove include directories from lib +# Remove include directories from lib file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/libzip ${CURRENT_PACKAGES_DIR}/debug/lib/libzip) # Remove debug include file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) # Copy copright information -file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libzip RENAME copyright) +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libzip RENAME copyright) vcpkg_copy_pdbs() diff --git a/ports/readline/CMakeLists.txt b/ports/readline-win32/CMakeLists.txt similarity index 71% rename from ports/readline/CMakeLists.txt rename to ports/readline-win32/CMakeLists.txt index 7a2e403da0e..ac062d0dc9c 100644 --- a/ports/readline/CMakeLists.txt +++ b/ports/readline-win32/CMakeLists.txt @@ -1,23 +1,16 @@ cmake_minimum_required(VERSION 3.0) project(readline C) -if(CMAKE_BUILD_TYPE STREQUAL Debug) - set(LIB_SUFFIX d) -endif() - add_definitions(-DREADLINE_LIBRARY) -add_definitions(-DBUILD_READLINE_DLL) add_definitions(-DHAVE_CONFIG_H) add_definitions(-D_CRT_SECURE_NO_WARNINGS) -if(CMAKE_BUILD_TYPE STREQUAL Debug) - add_definitions(-D_DEBUG) +if(BUILD_SHARED_LIBS) + add_definitions(-DBUILD_READLINE_DLL) +else() + add_definitions(-DREADLINE_STATIC) endif() -add_definitions(-D_WINDOWS) -add_definitions(-D_USRDLL) -add_definitions(-DREADLINE_EXPORTS) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR} # thats where the config.h is located ) diff --git a/ports/readline-win32/CONTROL b/ports/readline-win32/CONTROL new file mode 100644 index 00000000000..d04614bacdd --- /dev/null +++ b/ports/readline-win32/CONTROL @@ -0,0 +1,3 @@ +Source: readline-win32 +Version: 5.0-2 +Description: Implementation of readline for Windows Desktop provided by https://github.com/lltcggie \ No newline at end of file diff --git a/ports/readline/config.h b/ports/readline-win32/config.h similarity index 100% rename from ports/readline/config.h rename to ports/readline-win32/config.h diff --git a/ports/readline-win32/portfile.cmake b/ports/readline-win32/portfile.cmake new file mode 100644 index 00000000000..51ad377e77a --- /dev/null +++ b/ports/readline-win32/portfile.cmake @@ -0,0 +1,31 @@ +include(vcpkg_common_functions) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO lltcggie/readline + REF ea414b4e98475e3976198738061824e8a8379a50 + SHA512 82d54ab3e19fb2673fe97eff07117d36704791669baa283ec737c704635f872e4c7cd30485a6648d445cb2912e4364286e664e9425444f456a4c862b9e4de843 + HEAD_REF master +) + +set(SOURCE_PATH "${SOURCE_PATH}/src/readline/5.0/readline-5.0-src") + +file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) +file(COPY ${CMAKE_CURRENT_LIST_DIR}/config.h DESTINATION ${SOURCE_PATH}) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA +) + +vcpkg_install_cmake() + +# Copy headers +file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/include/readline) +file(GLOB headers "${SOURCE_PATH}/*.h") +file(COPY ${headers} DESTINATION ${CURRENT_PACKAGES_DIR}/include/readline) + +vcpkg_copy_pdbs() + +# Handle copyright +file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/ports/readline/CONTROL b/ports/readline/CONTROL index 669e1da1212..4fdb10939fb 100644 --- a/ports/readline/CONTROL +++ b/ports/readline/CONTROL @@ -1,3 +1,4 @@ Source: readline -Version: 5.0-1 -Description: GNU readline \ No newline at end of file +Version: 0 +Description: GNU readline and history libraries +Build-Depends: readline-win32 (windows) diff --git a/ports/readline/portfile.cmake b/ports/readline/portfile.cmake index 24114c05960..45db4f37a1f 100644 --- a/ports/readline/portfile.cmake +++ b/ports/readline/portfile.cmake @@ -1,48 +1,5 @@ -# Common Ambient Variables: -# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT} -# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET} -# CURRENT_PORT_DIR = ${VCPKG_ROOT_DIR}\ports\${PORT} -# PORT = current port name (zlib, etc) -# TARGET_TRIPLET = current triplet (x86-windows, x64-windows-static, etc) -# VCPKG_CRT_LINKAGE = C runtime linkage type (static, dynamic) -# VCPKG_LIBRARY_LINKAGE = target library linkage type (static, dynamic) -# VCPKG_ROOT_DIR = -# VCPKG_TARGET_ARCHITECTURE = target architecture (x64, x86, arm) -# - -include(vcpkg_common_functions) -set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/readline-vs/src/readline/5.0/readline-5.0-src) - -vcpkg_download_distfile(ARCHIVE - URLS "https://github.com/lltcggie/readline/archive/vs.zip" - FILENAME "readline-5.0-1-src.zip" - SHA512 c67908b9c868aa611a48dfc4db43718169cbdc6784107beb22cd1a4d28f0c4aa88f30cae0839a530c481c74173e1d7a2bf0000596099ed9b940c05c9dc7d5ebc -) - -vcpkg_extract_source_archive(${ARCHIVE}) - -file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) -file(COPY ${CMAKE_CURRENT_LIST_DIR}/config.h DESTINATION ${SOURCE_PATH}) - -if(VCPKG_CRT_LINKAGE STREQUAL static) - set(LIBVPX_CRT_LINKAGE --enable-static-msvcrt) - set(LIBVPX_CRT_SUFFIX mt) -else() - set(LIBVPX_CRT_SUFFIX md) +if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + message(FATAL_ERROR "No implementation of readline is currently available for UWP targets") endif() -vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA) - -vcpkg_install_cmake() - -# Copy headers -file (MAKE_DIRECTORY - ${CURRENT_PACKAGES_DIR}/include/readline) - -file(GLOB headers "${SOURCE_PATH}/*.h") -file(COPY ${headers} DESTINATION ${CURRENT_PACKAGES_DIR}/include/readline) - -# Handle copyright -file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/readline RENAME copyright) +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/ports/usbmuxd/CONTROL b/ports/usbmuxd/CONTROL new file mode 100644 index 00000000000..6d7978bad4f --- /dev/null +++ b/ports/usbmuxd/CONTROL @@ -0,0 +1,4 @@ +Source: usbmuxd +Version: 1.1.1.133-1 +Description: A socket daemon to multiplex connections from and to iOS devices +Build-Depends: libimobiledevice, libusb, libusb-win32, pthreads \ No newline at end of file diff --git a/ports/usbmuxd/portfile.cmake b/ports/usbmuxd/portfile.cmake new file mode 100644 index 00000000000..56066e19eef --- /dev/null +++ b/ports/usbmuxd/portfile.cmake @@ -0,0 +1,19 @@ +include(vcpkg_common_functions) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libimobiledevice-win32/usbmuxd + REF 1.1.1.133 + SHA512 1a5f9abc239deeb15e2aab419ba9e88ef41ffa80396546fb65bc06b0f419cbabc80cdf95995caf71d5628d1537fb0329a73d923202e91ea43fcc7c32b840d047 + HEAD_REF master +) + +vcpkg_install_msbuild( + SOURCE_PATH ${SOURCE_PATH} + PROJECT_SUBPATH usbmuxd.vcxproj + LICENSE_SUBPATH COPYING.GPLv2 + USE_VCPKG_INTEGRATION +) + +# No headers +set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets index 499052e4d70..456783f4d30 100644 --- a/scripts/buildsystems/msbuild/vcpkg.targets +++ b/scripts/buildsystems/msbuild/vcpkg.targets @@ -47,13 +47,14 @@ true arm64-uwp - + $(Configuration) Debug Release $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), .vcpkg-root))\installed\$(VcpkgTriplet)\ + true @@ -77,7 +78,7 @@ - + diff --git a/scripts/cmake/vcpkg_apply_patches.cmake b/scripts/cmake/vcpkg_apply_patches.cmake index d62fbbf8446..ac0b78e20c2 100644 --- a/scripts/cmake/vcpkg_apply_patches.cmake +++ b/scripts/cmake/vcpkg_apply_patches.cmake @@ -37,10 +37,11 @@ function(vcpkg_apply_patches) find_program(GIT NAMES git git.cmd) set(PATCHNUM 0) foreach(PATCH ${_ap_PATCHES}) + get_filename_component(ABSOLUTE_PATCH "${PATCH}" ABSOLUTE BASE_DIR "${CURRENT_PORT_DIR}") message(STATUS "Applying patch ${PATCH}") set(LOGNAME patch-${TARGET_TRIPLET}-${PATCHNUM}) execute_process( - COMMAND ${GIT} --work-tree=. --git-dir=.git apply "${PATCH}" --ignore-whitespace --whitespace=nowarn --verbose + COMMAND ${GIT} --work-tree=. --git-dir=.git apply "${ABSOLUTE_PATCH}" --ignore-whitespace --whitespace=nowarn --verbose OUTPUT_FILE ${CURRENT_BUILDTREES_DIR}/${LOGNAME}-out.log ERROR_FILE ${CURRENT_BUILDTREES_DIR}/${LOGNAME}-err.log WORKING_DIRECTORY ${_ap_SOURCE_PATH} diff --git a/scripts/cmake/vcpkg_build_msbuild.cmake b/scripts/cmake/vcpkg_build_msbuild.cmake index fdf519f2c27..7a65127f044 100644 --- a/scripts/cmake/vcpkg_build_msbuild.cmake +++ b/scripts/cmake/vcpkg_build_msbuild.cmake @@ -1,6 +1,6 @@ ## # vcpkg_build_msbuild ## -## Build an msbuild-based project. +## Build an msbuild-based project. Deprecated in favor of `vcpkg_install_msbuild()`. ## ## ## Usage ## ```cmake diff --git a/scripts/cmake/vcpkg_check_linkage.cmake b/scripts/cmake/vcpkg_check_linkage.cmake new file mode 100644 index 00000000000..022e2b8602b --- /dev/null +++ b/scripts/cmake/vcpkg_check_linkage.cmake @@ -0,0 +1,53 @@ +## # vcpkg_check_linkage +## +## Asserts the available library and CRT linkage options for the port. +## +## ## Usage +## ```cmake +## vcpkg_check_linkage( +## [ONLY_STATIC_LIBRARY | ONLY_DYNAMIC_LIBRARY] +## [ONLY_STATIC_CRT | ONLY_DYNAMIC_CRT] +## ) +## ``` +## +## ## Parameters +## ### ONLY_STATIC_LIBRARY +## Indicates that this port can only be built with static library linkage. +## +## ### ONLY_DYNAMIC_LIBRARY +## Indicates that this port can only be built with dynamic/shared library linkage. +## +## ### ONLY_STATIC_CRT +## Indicates that this port can only be built with static CRT linkage. +## +## ### ONLY_DYNAMIC_CRT +## Indicates that this port can only be built with dynamic/shared CRT linkage. +## +## ## Notes +## This command will either alter the settings for `VCPKG_LIBRARY_LINKAGE` or fail, depending on what was requested by the user versus what the library supports. +## +## ## Examples +## +## * [libimobiledevice](https://github.com/Microsoft/vcpkg/blob/master/ports/libimobiledevice/portfile.cmake) +function(vcpkg_check_linkage) + cmake_parse_arguments(_csc "ONLY_STATIC_LIBRARY;ONLY_DYNAMIC_LIBRARY;ONLY_DYNAMIC_CRT;ONLY_STATIC_CRT" "" "" ${ARGN}) + + if(_csc_ONLY_STATIC_LIBRARY AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + message(STATUS "Note: ${PORT} only supports static library linkage. Building static library.") + set(VCPKG_LIBRARY_LINKAGE static) + endif() + if(_csc_ONLY_DYNAMIC_LIBRARY AND VCPKG_LIBRARY_LINKAGE STREQUAL "static") + message(STATUS "Note: ${PORT} only supports dynamic library linkage. Building dynamic library.") + if(VCPKG_CRT_LINKAGE STREQUAL "static") + message(FATAL_ERROR "Refusing to build unexpected dynamic library against the static CRT. If this is desired, please configure your triplet to directly request this configuration.") + endif() + set(VCPKG_LIBRARY_LINKAGE dynamic) + endif() + + if(_csc_ONLY_DYNAMIC_CRT AND VCPKG_CRT_LINKAGE STREQUAL "static") + message(FATAL_ERROR "${PORT} only supports dynamic crt linkage") + endif() + if(_csc_ONLY_STATIC_CRT AND VCPKG_CRT_LINKAGE STREQUAL "dynamic") + message(FATAL_ERROR "${PORT} only supports static crt linkage") + endif() +endfunction() diff --git a/scripts/cmake/vcpkg_common_functions.cmake b/scripts/cmake/vcpkg_common_functions.cmake index 8914ac549b8..6677af00a9c 100644 --- a/scripts/cmake/vcpkg_common_functions.cmake +++ b/scripts/cmake/vcpkg_common_functions.cmake @@ -1,4 +1,5 @@ include(vcpkg_acquire_msys) +include(vcpkg_check_linkage) include(vcpkg_download_distfile) include(vcpkg_extract_source_archive) include(vcpkg_execute_required_process) @@ -13,6 +14,7 @@ include(vcpkg_build_msbuild) include(vcpkg_build_qmake) include(vcpkg_install_cmake) include(vcpkg_install_meson) +include(vcpkg_install_msbuild) include(vcpkg_configure_cmake) include(vcpkg_configure_meson) include(vcpkg_configure_qmake) diff --git a/scripts/cmake/vcpkg_from_github.cmake b/scripts/cmake/vcpkg_from_github.cmake index fbceb2aaec8..68baa908ed7 100644 --- a/scripts/cmake/vcpkg_from_github.cmake +++ b/scripts/cmake/vcpkg_from_github.cmake @@ -117,7 +117,8 @@ function(vcpkg_from_github) # Hash the archive hash along with the patches. Take the first 10 chars of the hash set(PATCHSET_HASH "${_vdud_SHA512}") foreach(PATCH IN LISTS _vdud_PATCHES) - file(SHA512 ${PATCH} CURRENT_HASH) + get_filename_component(ABSOLUTE_PATCH "${PATCH}" ABSOLUTE BASE_DIR "${CURRENT_PORT_DIR}") + file(SHA512 ${ABSOLUTE_PATCH} CURRENT_HASH) string(APPEND PATCHSET_HASH ${CURRENT_HASH}) endforeach() diff --git a/scripts/cmake/vcpkg_install_msbuild.cmake b/scripts/cmake/vcpkg_install_msbuild.cmake new file mode 100644 index 00000000000..ad700dd359e --- /dev/null +++ b/scripts/cmake/vcpkg_install_msbuild.cmake @@ -0,0 +1,220 @@ +## # vcpkg_install_msbuild +## +## Build and install an msbuild-based project. This replaces `vcpkg_build_msbuild()`. +## +## ## Usage +## ```cmake +## vcpkg_install_msbuild( +## SOURCE_PATH <${SOURCE_PATH}> +## PROJECT_SUBPATH +## [INCLUDES_SUBPATH ] +## [LICENSE_SUBPATH ] +## [RELEASE_CONFIGURATION ] +## [DEBUG_CONFIGURATION ] +## [TARGET ] +## [TARGET_PLATFORM_VERSION <10.0.15063.0>] +## [PLATFORM <${TRIPLET_SYSTEM_ARCH}>] +## [PLATFORM_TOOLSET <${VCPKG_PLATFORM_TOOLSET}>] +## [OPTIONS ...] +## [OPTIONS_RELEASE ...] +## [OPTIONS_DEBUG ...] +## [USE_VCPKG_INTEGRATION] +## [ALLOW_ROOT_INCLUDES | REMOVE_ROOT_INCLUDES] +## ) +## ``` +## +## ## Parameters +## ### SOURCE_PATH +## The path to the root of the source tree. +## +## Because MSBuild uses in-source builds, the source tree will be copied into a temporary location for the build. This +## parameter is the base for that copy and forms the base for all XYZ_SUBPATH options. +## +## ### USE_VCPKG_INTEGRATION +## Apply the normal `integrate install` integration for building the project. +## +## By default, projects built with this command will not automatically link libraries or have header paths set. +## +## ### PROJECT_SUBPATH +## The subpath to the solution (`.sln`) or project (`.vcxproj`) file relative to `SOURCE_PATH`. +## +## ### LICENSE_SUBPATH +## The subpath to the license file relative to `SOURCE_PATH`. +## +## ### INCLUDES_SUBPATH +## The subpath to the includes directory relative to `SOURCE_PATH`. +## +## This parameter should be a directory and should not end in a trailing slash. +## +## ### ALLOW_ROOT_INCLUDES +## Indicates that top-level include files (e.g. `include/zlib.h`) should be allowed. +## +## ### REMOVE_ROOT_INCLUDES +## Indicates that top-level include files (e.g. `include/Makefile.am`) should be removed. +## +## ### RELEASE_CONFIGURATION +## The configuration (``/p:Configuration`` msbuild parameter) used for Release builds. +## +## ### DEBUG_CONFIGURATION +## The configuration (``/p:Configuration`` msbuild parameter) +## used for Debug builds. +## +## ### TARGET_PLATFORM_VERSION +## The WindowsTargetPlatformVersion (``/p:WindowsTargetPlatformVersion`` msbuild parameter) +## +## ### TARGET +## The MSBuild target to build. (``/t:``) +## +## ### PLATFORM +## The platform (``/p:Platform`` msbuild parameter) used for the build. +## +## ### PLATFORM_TOOLSET +## The platform toolset (``/p:PlatformToolset`` msbuild parameter) used for the build. +## +## ### OPTIONS +## Additional options passed to msbuild for all builds. +## +## ### OPTIONS_RELEASE +## Additional options passed to msbuild for Release builds. These are in addition to `OPTIONS`. +## +## ### OPTIONS_DEBUG +## Additional options passed to msbuild for Debug builds. These are in addition to `OPTIONS`. +## +## ## Examples +## +## * [libimobiledevice](https://github.com/Microsoft/vcpkg/blob/master/ports/libimobiledevice/portfile.cmake) + +function(vcpkg_install_msbuild) + cmake_parse_arguments( + _csc + "USE_VCPKG_INTEGRATION;ALLOW_ROOT_INCLUDES;REMOVE_ROOT_INCLUDES" + "SOURCE_PATH;PROJECT_SUBPATH;INCLUDES_SUBPATH;LICENSE_SUBPATH;RELEASE_CONFIGURATION;DEBUG_CONFIGURATION;PLATFORM;PLATFORM_TOOLSET;TARGET_PLATFORM_VERSION;TARGET" + "OPTIONS;OPTIONS_RELEASE;OPTIONS_DEBUG" + ${ARGN} + ) + + if(NOT DEFINED _csc_RELEASE_CONFIGURATION) + set(_csc_RELEASE_CONFIGURATION Release) + endif() + if(NOT DEFINED _csc_DEBUG_CONFIGURATION) + set(_csc_DEBUG_CONFIGURATION Debug) + endif() + if(NOT DEFINED _csc_PLATFORM) + if(VCPKG_TARGET_ARCHITECTURE STREQUAL x64) + set(_csc_PLATFORM x64) + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL x86) + set(_csc_PLATFORM Win32) + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL ARM) + set(_csc_PLATFORM ARM) + else() + message(FATAL_ERROR "Unsupported target architecture") + endif() + endif() + if(NOT DEFINED _csc_PLATFORM_TOOLSET) + set(_csc_PLATFORM_TOOLSET ${VCPKG_PLATFORM_TOOLSET}) + endif() + if(NOT DEFINED _csc_TARGET_PLATFORM_VERSION) + vcpkg_get_windows_sdk(_csc_TARGET_PLATFORM_VERSION) + endif() + if(NOT DEFINED _csc_TARGET) + set(_csc_TARGET Rebuild) + endif() + + list(APPEND _csc_OPTIONS + /t:${_csc_TARGET} + /p:Platform=${_csc_PLATFORM} + /p:PlatformToolset=${_csc_PLATFORM_TOOLSET} + /p:VCPkgLocalAppDataDisabled=true + /p:UseIntelMKL=No + /p:WindowsTargetPlatformVersion=${_csc_TARGET_PLATFORM_VERSION} + /m + ) + + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + # Disable LTCG for static libraries because this setting introduces ABI incompatibility between minor compiler versions + # TODO: Add a way for the user to override this if they want to opt-in to incompatibility + list(APPEND _csc_OPTIONS /p:WholeProgramOptimization=false) + endif() + + if(_csc_USE_VCPKG_INTEGRATION) + list(APPEND _csc_OPTIONS /p:ForceImportBeforeCppTargets=${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/vcpkg.targets /p:VcpkgApplocalDeps=false) + endif() + + get_filename_component(SOURCE_PATH_SUFFIX "${_csc_SOURCE_PATH}" NAME) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + message(STATUS "Building ${_csc_PROJECT_SUBPATH} for Release") + file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) + file(COPY ${_csc_SOURCE_PATH} DESTINATION ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) + set(SOURCE_COPY_PATH ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/${SOURCE_PATH_SUFFIX}) + vcpkg_execute_required_process( + COMMAND msbuild ${SOURCE_COPY_PATH}/${_csc_PROJECT_SUBPATH} + /p:Configuration=${_csc_RELEASE_CONFIGURATION} + ${_csc_OPTIONS} + ${_csc_OPTIONS_RELEASE} + WORKING_DIRECTORY ${SOURCE_COPY_PATH} + LOGNAME build-${TARGET_TRIPLET}-rel + ) + file(GLOB_RECURSE LIBS ${SOURCE_COPY_PATH}/*.lib) + file(GLOB_RECURSE DLLS ${SOURCE_COPY_PATH}/*.dll) + file(GLOB_RECURSE EXES ${SOURCE_COPY_PATH}/*.exe) + if(LIBS) + file(COPY ${LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/lib) + endif() + if(DLLS) + file(COPY ${DLLS} DESTINATION ${CURRENT_PACKAGES_DIR}/bin) + endif() + if(EXES) + file(COPY ${EXES} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/${PORT}) + vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT}) + endif() + endif() + + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + message(STATUS "Building ${_csc_PROJECT_SUBPATH} for Debug") + file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + file(COPY ${_csc_SOURCE_PATH} DESTINATION ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + set(SOURCE_COPY_PATH ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/${SOURCE_PATH_SUFFIX}) + vcpkg_execute_required_process( + COMMAND msbuild ${SOURCE_COPY_PATH}/${_csc_PROJECT_SUBPATH} + /p:Configuration=${_csc_DEBUG_CONFIGURATION} + ${_csc_OPTIONS} + ${_csc_OPTIONS_DEBUG} + WORKING_DIRECTORY ${SOURCE_COPY_PATH} + LOGNAME build-${TARGET_TRIPLET}-dbg + ) + file(GLOB_RECURSE LIBS ${SOURCE_COPY_PATH}/*.lib) + file(GLOB_RECURSE DLLS ${SOURCE_COPY_PATH}/*.dll) + if(LIBS) + file(COPY ${LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) + endif() + if(DLLS) + file(COPY ${DLLS} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) + endif() + endif() + + vcpkg_copy_pdbs() + + file(REMOVE_RECURSE + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel + ) + + if(DEFINED _csc_INCLUDES_SUBPATH) + file(COPY ${_csc_SOURCE_PATH}/${_csc_INCLUDES_SUBPATH}/ DESTINATION ${CURRENT_PACKAGES_DIR}/include/) + file(GLOB ROOT_INCLUDES LIST_DIRECTORIES false ${CURRENT_PACKAGES_DIR}/include/*) + if(ROOT_INCLUDES) + if(_csc_REMOVE_ROOT_INCLUDES) + file(REMOVE ${ROOT_INCLUDES}) + elseif(_csc_ALLOW_ROOT_INCLUDES) + else() + message(FATAL_ERROR "Top-level files were found in ${CURRENT_PACKAGES_DIR}/include; this may indicate a problem with the call to `vcpkg_install_msbuild()`.\nTo avoid conflicts with other libraries, it is recommended to not put includes into the root `include/` directory.\nPass either ALLOW_ROOT_INCLUDES or REMOVE_ROOT_INCLUDES to handle these files.\n") + endif() + endif() + endif() + + if(DEFINED _csc_LICENSE_SUBPATH) + file(INSTALL ${_csc_SOURCE_PATH}/${_csc_LICENSE_SUBPATH} DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) + endif() +endfunction()