Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ __pycache__/
!triplets/community/x86-android.cmake
!triplets/community/arm-android.cmake
!triplets/community/arm64-android.cmake
!triplets/community/arm64-ios.cmake
!triplets/community/arm-ios.cmake
!triplets/community/x64-ios.cmake
!triplets/community/x86-ios.cmake
!triplets/arm-uwp.cmake
!triplets/x64-uwp.cmake
!triplets/x64-windows.cmake
Expand Down
4 changes: 4 additions & 0 deletions docs/users/triplets.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ Sets the minimum macOS version for compiled binaries. This also changes what ver
### VCPKG_OSX_SYSROOT
Set the name or path of the macOS platform SDK that will be used by CMake. See the CMake documentation for [CMAKE_OSX_SYSROOT](https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_SYSROOT.html) for more information.


### VCPKG_OSX_ARCHITECTURES
Set the macOS / iOS target architecture which will be used by CMake. See the CMake documentation for [CMAKE_OSX_ARCHITECTURES](https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_ARCHITECTURES.html) for more information.

## Per-port customization
The CMake Macro `PORT` will be set when interpreting the triplet file and can be used to change settings (such as `VCPKG_LIBRARY_LINKAGE`) on a per-port basis.

Expand Down
2 changes: 1 addition & 1 deletion ports/libpng/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: libpng
Version: 1.6.37-6
Version: 1.6.37-7
Build-Depends: zlib
Homepage: https://github.com/glennrp/libpng
Description: libpng is a library implementing an interface for reading and writing PNG (Portable Network Graphics) format files.
Expand Down
6 changes: 6 additions & 0 deletions ports/libpng/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ else()
set(PNG_SHARED_LIBS OFF)
endif()

set(LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION )
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL iOS)
set(LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION "-DPNG_HARDWARE_OPTIMIZATIONS=OFF")
endif()

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
${LIBPNG_APNG_OPTION}
${LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION}
-DPNG_STATIC=${PNG_STATIC_LIBS}
-DPNG_SHARED=${PNG_SHARED_LIBS}
-DPNG_TESTS=OFF
Expand Down
2 changes: 1 addition & 1 deletion ports/pcre2/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Source: pcre2
Version: 10.30-6
Version: 10.30-7
Homepage: https://pcre.org/
Description: PCRE2 is a re-working of the original Perl Compatible Regular Expressions library
2 changes: 1 addition & 1 deletion ports/pcre2/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ vcpkg_extract_source_archive_ex(
fix-uwp.patch
)

if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Emscripten" OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(JIT OFF)
else()
set(JIT ON)
Expand Down
50 changes: 49 additions & 1 deletion scripts/buildsystems/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,37 @@ else()
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_NAME STREQUAL "Darwin" AND DEFINED CMAKE_SYSTEM_NAME AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
list(LENGTH CMAKE_OSX_ARCHITECTURES arch_count)
if(arch_count EQUAL 0)
message(WARNING "Unable to determine target architecture. "
"Consider providing a value for the CMAKE_OSX_ARCHITECTURES cache variable. "
"Continuing without vcpkg.")
set(VCPKG_TOOLCHAIN ON)
return()
else()
if(arch_count GREATER 1)
message(WARNING "Detected more than one target architecture. Using the first one.")
endif()
list(GET CMAKE_OSX_ARCHITECTURES 0 target_arch)
if(target_arch STREQUAL arm64)
set(_VCPKG_TARGET_TRIPLET_ARCH arm64)
elseif(target_arch STREQUAL arm64s)
set(_VCPKG_TARGET_TRIPLET_ARCH arm64s)
elseif(target_arch STREQUAL armv7s)
set(_VCPKG_TARGET_TRIPLET_ARCH armv7s)
elseif(target_arch STREQUAL armv7)
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(target_arch STREQUAL x86_64)
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(target_arch STREQUAL i386)
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
else()
message(WARNING "Unable to determine target architecture, continuing without vcpkg.")
set(VCPKG_TOOLCHAIN ON)
return()
endif()
endif()
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
else()
Expand All @@ -96,6 +127,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR (NOT CMAKE_SYSTEM_NAME AND CMAKE_HO
set(_VCPKG_TARGET_TRIPLET_PLAT linux)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR (NOT CMAKE_SYSTEM_NAME AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin"))
set(_VCPKG_TARGET_TRIPLET_PLAT osx)
elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(_VCPKG_TARGET_TRIPLET_PLAT ios)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR (NOT CMAKE_SYSTEM_NAME AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows"))
set(_VCPKG_TARGET_TRIPLET_PLAT windows)
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR (NOT CMAKE_SYSTEM_NAME AND CMAKE_HOST_SYSTEM_NAME STREQUAL "FreeBSD"))
Expand Down Expand Up @@ -146,6 +179,8 @@ else() #Release build: Put Release paths before Debug paths. Debug Paths are req
)
endif()

set(VCPKG_CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH})

file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
set(_PROGRAMFILESX86 "PROGRAMFILES(x86)")
file(TO_CMAKE_PATH "$ENV{${_PROGRAMFILESX86}}" _programfiles_x86)
Expand Down Expand Up @@ -235,7 +270,15 @@ if(NOT DEFINED VCPKG_OVERRIDE_FIND_PACKAGE_NAME)
set(VCPKG_OVERRIDE_FIND_PACKAGE_NAME find_package)
endif()
macro(${VCPKG_OVERRIDE_FIND_PACKAGE_NAME} name)
# Workaround to set the ROOT_PATH until upstream CMake stops overriding
# the ROOT_PATH at apple OS initialization phase.
# See https://gitlab.kitware.com/cmake/cmake/merge_requests/3273
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
set(BACKUP_CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH})
list(APPEND CMAKE_FIND_ROOT_PATH ${VCPKG_CMAKE_FIND_ROOT_PATH})
endif()
string(TOLOWER "${name}" _vcpkg_lowercase_name)

if(EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/${_vcpkg_lowercase_name}/vcpkg-cmake-wrapper.cmake")
set(ARGS "${ARGV}")
include(${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/${_vcpkg_lowercase_name}/vcpkg-cmake-wrapper.cmake)
Expand Down Expand Up @@ -285,6 +328,9 @@ macro(${VCPKG_OVERRIDE_FIND_PACKAGE_NAME} name)
else()
_find_package(${ARGV})
endif()
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
set(CMAKE_FIND_ROOT_PATH "${BACKUP_CMAKE_FIND_ROOT_PATH}")
endif()
endmacro()

set(VCPKG_TOOLCHAIN ON)
Expand All @@ -301,13 +347,15 @@ if(NOT _CMAKE_IN_TRY_COMPILE)
file(TO_CMAKE_PATH "${_VCPKG_ROOT_DIR}" _root_dir)
file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/vcpkg.config.cmake"
"set(VCPKG_TARGET_TRIPLET \"${VCPKG_TARGET_TRIPLET}\" CACHE STRING \"\")\n"
"set(VCPKG_TARGET_ARCHITECTURE \"${VCPKG_TARGET_ARCHITECTURE}\" CACHE STRING \"\")\n"
"set(VCPKG_APPLOCAL_DEPS \"${VCPKG_APPLOCAL_DEPS}\" CACHE STRING \"\")\n"
"set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE \"${_chainload_file}\" CACHE STRING \"\")\n"
"set(_VCPKG_ROOT_DIR \"${_root_dir}\" CACHE STRING \"\")\n"
)
else()
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
VCPKG_TARGET_TRIPLET
VCPKG_TARGET_ARCHITECTURE
VCPKG_APPLOCAL_DEPS
VCPKG_CHAINLOAD_TOOLCHAIN_FILE
_VCPKG_ROOT_DIR
Expand Down
4 changes: 3 additions & 1 deletion scripts/cmake/vcpkg_configure_cmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ function(vcpkg_configure_cmake)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/android.cmake")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/osx.cmake")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/ios.cmake")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/freebsd.cmake")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "MinGW")
Expand Down Expand Up @@ -243,7 +245,7 @@ function(vcpkg_configure_cmake)
endif()

# Sets configuration variables for macOS builds
foreach(config_var INSTALL_NAME_DIR OSX_DEPLOYMENT_TARGET OSX_SYSROOT)
foreach(config_var INSTALL_NAME_DIR OSX_DEPLOYMENT_TARGET OSX_SYSROOT OSX_ARCHITECTURES)
if(DEFINED VCPKG_${config_var})
list(APPEND _csc_OPTIONS "-DCMAKE_${config_var}=${VCPKG_${config_var}}")
endif()
Expand Down
54 changes: 54 additions & 0 deletions scripts/toolchains/ios.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
if(NOT _VCPKG_IOS_TOOLCHAIN)
set(_VCPKG_IOS_TOOLCHAIN 1)

# Set the CMAKE_SYSTEM_NAME for try_compile calls.
set(CMAKE_SYSTEM_NAME iOS CACHE STRING "")

macro(_vcpkg_setup_ios_arch arch)
unset(_vcpkg_ios_system_processor)
unset(_vcpkg_ios_sysroot)
unset(_vcpkg_ios_target_architecture)

if ("${arch}" STREQUAL "arm64")
set(_vcpkg_ios_system_processor "aarch64")
set(_vcpkg_ios_target_architecture "arm64")
elseif("${arch}" STREQUAL "arm")
set(_vcpkg_ios_system_processor "arm")
set(_vcpkg_ios_target_architecture "armv7")
elseif("${arch}" STREQUAL "x64")
set(_vcpkg_ios_sysroot "iphonesimulator")
set(_vcpkg_ios_target_architecture "x86_64")
elseif("${arch}" STREQUAL "x86")
set(_vcpkg_ios_sysroot "iphonesimulator")
set(_vcpkg_ios_target_architecture "i386")
else()
message(FATAL_ERROR
"Unknown VCPKG_TARGET_ARCHITECTURE value provided for triplet ${VCPKG_TARGET_TRIPLET}: ${arch}")
endif()
endmacro()

_vcpkg_setup_ios_arch("${VCPKG_TARGET_ARCHITECTURE}")
if(_vcpkg_ios_system_processor AND NOT CMAKE_SYSTEM_PROCESSOR)
set(CMAKE_SYSTEM_PROCESSOR ${_vcpkg_ios_system_processor})
endif()

# If VCPKG_OSX_ARCHITECTURES or VCPKG_OSX_SYSROOT is set in the triplet, they will take priority,
# so the following will be no-ops.
set(CMAKE_OSX_ARCHITECTURES "${_vcpkg_ios_target_architecture}" CACHE STRING "Build architectures for iOS")
if(_vcpkg_ios_sysroot)
set(CMAKE_OSX_SYSROOT ${_vcpkg_ios_sysroot} CACHE STRING "iOS sysroot")
endif()

get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
if(NOT _CMAKE_IN_TRY_COMPILE)
string(APPEND CMAKE_C_FLAGS_INIT " -fPIC ${VCPKG_C_FLAGS} ")
string(APPEND CMAKE_CXX_FLAGS_INIT " -fPIC ${VCPKG_CXX_FLAGS} ")
string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " ${VCPKG_C_FLAGS_DEBUG} ")
string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " ${VCPKG_CXX_FLAGS_DEBUG} ")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " ${VCPKG_C_FLAGS_RELEASE} ")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " ${VCPKG_CXX_FLAGS_RELEASE} ")

string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
endif()
endif()
4 changes: 4 additions & 0 deletions triplets/community/arm-ios.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE arm)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME iOS)
4 changes: 4 additions & 0 deletions triplets/community/arm64-ios.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME iOS)
4 changes: 4 additions & 0 deletions triplets/community/x64-ios.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME iOS)
4 changes: 4 additions & 0 deletions triplets/community/x86-ios.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME iOS)