aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/bootstrap.ps19
-rw-r--r--scripts/bootstrap.sh2
-rw-r--r--scripts/buildsystems/msbuild/applocal.ps14
-rw-r--r--scripts/cleanEnvironmentHelper.ps12
-rw-r--r--scripts/cmake/vcpkg_build_cmake.cmake133
-rw-r--r--scripts/cmake/vcpkg_build_qmake.cmake6
-rw-r--r--scripts/cmake/vcpkg_check_features.cmake112
-rw-r--r--scripts/cmake/vcpkg_common_definitions.cmake14
-rw-r--r--scripts/cmake/vcpkg_common_functions.cmake2
-rw-r--r--scripts/cmake/vcpkg_configure_cmake.cmake11
-rw-r--r--scripts/cmake/vcpkg_configure_meson.cmake1
-rw-r--r--scripts/cmake/vcpkg_execute_build_process.cmake141
-rw-r--r--scripts/cmake/vcpkg_extract_source_archive_ex.cmake2
-rw-r--r--scripts/cmake/vcpkg_find_acquire_program.cmake14
-rw-r--r--scripts/cmake/vcpkg_fixup_cmake_targets.cmake14
-rw-r--r--scripts/ports.cmake4
-rw-r--r--scripts/toolchains/linux.cmake3
-rw-r--r--scripts/toolchains/windows.cmake6
18 files changed, 338 insertions, 142 deletions
diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1
index b195cc605..6234efaa3 100644
--- a/scripts/bootstrap.ps1
+++ b/scripts/bootstrap.ps1
@@ -339,7 +339,14 @@ if ($disableMetrics)
$platform = "x86"
$vcpkgReleaseDir = "$vcpkgSourcesPath\msbuild.x86.release"
-$architecture=(Get-WmiObject win32_operatingsystem | Select-Object osarchitecture).osarchitecture
+if($PSVersionTable.PSVersion.Major -le 2)
+{
+ $architecture=(Get-WmiObject win32_operatingsystem | Select-Object osarchitecture).osarchitecture
+}
+else
+{
+ $architecture=(Get-CimInstance win32_operatingsystem | Select-Object osarchitecture).osarchitecture
+}
if ($win64)
{
if (-not $architecture -like "*64*")
diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh
index 00d31760a..b0e4f98a5 100644
--- a/scripts/bootstrap.sh
+++ b/scripts/bootstrap.sh
@@ -100,7 +100,7 @@ vcpkgDownloadFile()
url=$1; downloadPath=$2 sha512=$3
vcpkgCheckRepoTool "curl"
rm -rf "$downloadPath.part"
- curl -L $url --create-dirs --output "$downloadPath.part" || exit 1
+ curl -L $url --create-dirs --retry 3 --output "$downloadPath.part" || exit 1
vcpkgCheckEqualFileHash $url "$downloadPath.part" $sha512
mv "$downloadPath.part" "$downloadPath"
diff --git a/scripts/buildsystems/msbuild/applocal.ps1 b/scripts/buildsystems/msbuild/applocal.ps1
index cf363f12e..2fdd9fdb4 100644
--- a/scripts/buildsystems/msbuild/applocal.ps1
+++ b/scripts/buildsystems/msbuild/applocal.ps1
@@ -9,7 +9,7 @@ $g_is_debug = $g_install_root -match '(.*\\)?debug(\\)?$'
# Ensure we create the copied files log, even if we don't end up copying any files
if ($copiedFilesLog)
{
- Set-Content -Path $copiedFilesLog -Value "" -Encoding Ascii
+ Set-Content -Path $copiedFilesLog -Value "" -Encoding UTF8
}
# Note: this function signature is depended upon by the qtdeploy.ps1 script introduced in 5.7.1-7
@@ -28,7 +28,7 @@ function deployBinary([string]$targetBinaryDir, [string]$SourceDir, [string]$tar
Write-Verbose " ${targetBinaryName}: Copying $SourceDir\$targetBinaryName"
Copy-Item "$SourceDir\$targetBinaryName" $targetBinaryDir
}
- if ($copiedFilesLog) { Add-Content $copiedFilesLog "$targetBinaryDir\$targetBinaryName" }
+ if ($copiedFilesLog) { Add-Content $copiedFilesLog "$targetBinaryDir\$targetBinaryName" -Encoding UTF8 }
if ($tlogFile) { Add-Content $tlogFile "$targetBinaryDir\$targetBinaryName" }
}
diff --git a/scripts/cleanEnvironmentHelper.ps1 b/scripts/cleanEnvironmentHelper.ps1
index a3792ecd3..fa5fe869d 100644
--- a/scripts/cleanEnvironmentHelper.ps1
+++ b/scripts/cleanEnvironmentHelper.ps1
@@ -1,6 +1,6 @@
# Capture environment variables for the System and User. Also add some special/built-in variables.
# These will be used to synthesize a clean environment
-$specialEnvironmentMap = @{ "SystemDrive"=$env:SystemDrive; "SystemRoot"=$env:SystemRoot; "UserProfile"=$env:UserProfile } # These are built-in and not set in the registry
+$specialEnvironmentMap = @{ "SystemDrive"=$env:SystemDrive; "SystemRoot"=$env:SystemRoot; "UserProfile"=$env:UserProfile; "TMP"=$env:TMP } # These are built-in and not set in the registry
$machineEnvironmentMap = [Environment]::GetEnvironmentVariables('Machine') # HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
$userEnvironmentMap = [Environment]::GetEnvironmentVariables('User') # HKEY_CURRENT_USER\Environment
diff --git a/scripts/cmake/vcpkg_build_cmake.cmake b/scripts/cmake/vcpkg_build_cmake.cmake
index 3db6597b4..b110d2cc9 100644
--- a/scripts/cmake/vcpkg_build_cmake.cmake
+++ b/scripts/cmake/vcpkg_build_cmake.cmake
@@ -60,10 +60,6 @@ function(vcpkg_build_cmake)
set(TARGET_PARAM)
endif()
- if(_bc_DISABLE_PARALLEL)
- set(PARALLEL_ARG ${NO_PARALLEL_ARG})
- endif()
-
foreach(BUILDTYPE "debug" "release")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL BUILDTYPE)
if(BUILDTYPE STREQUAL "debug")
@@ -75,8 +71,6 @@ function(vcpkg_build_cmake)
endif()
message(STATUS "Building ${TARGET_TRIPLET}-${SHORT_BUILDTYPE}")
- set(LOGPREFIX "${CURRENT_BUILDTREES_DIR}/${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-${SHORT_BUILDTYPE}")
- set(LOGS)
if(_bc_ADD_BIN_TO_PATH)
set(_BACKUP_ENV_PATH "$ENV{PATH}")
@@ -91,121 +85,22 @@ function(vcpkg_build_cmake)
set(ENV{PATH} "${CURRENT_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin${_PATHSEP}$ENV{PATH}")
endif()
endif()
- execute_process(
- COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${PARALLEL_ARG}
- OUTPUT_FILE "${LOGPREFIX}-out.log"
- ERROR_FILE "${LOGPREFIX}-err.log"
- RESULT_VARIABLE error_code
- WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE})
- if(error_code)
- file(READ "${LOGPREFIX}-out.log" out_contents)
- file(READ "${LOGPREFIX}-err.log" err_contents)
-
- if(out_contents)
- list(APPEND LOGS "${LOGPREFIX}-out.log")
- endif()
- if(err_contents)
- list(APPEND LOGS "${LOGPREFIX}-err.log")
- endif()
-
- if(out_contents MATCHES "LINK : fatal error LNK1102:" OR out_contents MATCHES " fatal error C1060: ")
- # The linker ran out of memory during execution. We will try continuing once more, with parallelism disabled.
- message(STATUS "Restarting Build ${TARGET_TRIPLET}-${SHORT_BUILDTYPE} without parallelism because memory exceeded")
- execute_process(
- COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${NO_PARALLEL_ARG}
- OUTPUT_FILE "${LOGPREFIX}-out-1.log"
- ERROR_FILE "${LOGPREFIX}-err-1.log"
- RESULT_VARIABLE error_code
- WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE})
-
- if(error_code)
- file(READ "${LOGPREFIX}-out-1.log" out_contents)
- file(READ "${LOGPREFIX}-err-1.log" err_contents)
-
- if(out_contents)
- list(APPEND LOGS "${LOGPREFIX}-out-1.log")
- endif()
- if(err_contents)
- list(APPEND LOGS "${LOGPREFIX}-err-1.log")
- endif()
- endif()
- elseif(out_contents MATCHES ": No such file or directory")
- # WSL workaround - WSL occassionally fails with no such file or directory. Detect if we are running in WSL and restart.
- execute_process(COMMAND "uname" "-r"
- OUTPUT_VARIABLE UNAME_R ERROR_VARIABLE UNAME_R
- OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE)
-
- if (UNAME_R MATCHES "Microsoft")
- set(ITERATION 0)
- while (ITERATION LESS 10 AND out_contents MATCHES ": No such file or directory")
- MATH(EXPR ITERATION "${ITERATION}+1")
- message(STATUS "Restarting Build ${TARGET_TRIPLET}-${SHORT_BUILDTYPE} because of wsl subsystem issue. Iteration: ${ITERATION}")
- execute_process(
- COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS}
- OUTPUT_FILE "${LOGPREFIX}-out-${ITERATION}.log"
- ERROR_FILE "${LOGPREFIX}-err-${ITERATION}.log"
- RESULT_VARIABLE error_code
- WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE})
- if(error_code)
- file(READ "${LOGPREFIX}-out-${ITERATION}.log" out_contents)
- file(READ "${LOGPREFIX}-err-${ITERATION}.log" err_contents)
-
- if(out_contents)
- list(APPEND LOGS "${LOGPREFIX}-out-${ITERATION}.log")
- endif()
- if(err_contents)
- list(APPEND LOGS "${LOGPREFIX}-err-${ITERATION}.log")
- endif()
- else()
- break()
- endif()
- endwhile()
- endif()
- elseif(out_contents MATCHES "mt : general error c101008d: " OR out_contents MATCHES "mt.exe : general error c101008d: ")
- # Antivirus workaround - occasionally files are locked and cause mt.exe to fail
- set(ITERATION 0)
- while (ITERATION LESS 3 AND (out_contents MATCHES "mt : general error c101008d: " OR out_contents MATCHES "mt.exe : general error c101008d: "))
- MATH(EXPR ITERATION "${ITERATION}+1")
- message(STATUS "Restarting Build ${TARGET_TRIPLET}-${SHORT_BUILDTYPE} because of mt.exe file locking issue. Iteration: ${ITERATION}")
- execute_process(
- COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${PARALLEL_ARG}
- OUTPUT_FILE "${LOGPREFIX}-out-${ITERATION}.log"
- ERROR_FILE "${LOGPREFIX}-err-${ITERATION}.log"
- RESULT_VARIABLE error_code
- WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE})
-
- if(error_code)
- file(READ "${LOGPREFIX}-out-${ITERATION}.log" out_contents)
- file(READ "${LOGPREFIX}-err-${ITERATION}.log" err_contents)
-
- if(out_contents)
- list(APPEND LOGS "${LOGPREFIX}-out-${ITERATION}.log")
- endif()
- if(err_contents)
- list(APPEND LOGS "${LOGPREFIX}-err-${ITERATION}.log")
- endif()
- else()
- break()
- endif()
- endwhile()
- endif()
-
- if(error_code)
- set(STRINGIFIED_LOGS)
- foreach(LOG ${LOGS})
- file(TO_NATIVE_PATH "${LOG}" NATIVE_LOG)
- list(APPEND STRINGIFIED_LOGS " ${NATIVE_LOG}\n")
- endforeach()
- set(_eb_COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${PARALLEL_ARG})
- set(_eb_WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE})
- message(FATAL_ERROR
- " Command failed: ${_eb_COMMAND}\n"
- " Working Directory: ${_eb_WORKING_DIRECTORY}\n"
- " See logs for more information:\n"
- ${STRINGIFIED_LOGS})
- endif()
+ if (_bc_DISABLE_PARALLEL)
+ vcpkg_execute_build_process(
+ COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${NO_PARALLEL_ARG}
+ WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE}
+ LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-${SHORT_BUILDTYPE}"
+ )
+ else()
+ vcpkg_execute_build_process(
+ COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${PARALLEL_ARG}
+ NO_PARALLEL_COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${NO_PARALLEL_ARG}
+ WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE}
+ LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-${SHORT_BUILDTYPE}"
+ )
endif()
+
if(_bc_ADD_BIN_TO_PATH)
set(ENV{PATH} "${_BACKUP_ENV_PATH}")
endif()
diff --git a/scripts/cmake/vcpkg_build_qmake.cmake b/scripts/cmake/vcpkg_build_qmake.cmake
index 80a0aef0d..cf79fe8fc 100644
--- a/scripts/cmake/vcpkg_build_qmake.cmake
+++ b/scripts/cmake/vcpkg_build_qmake.cmake
@@ -11,9 +11,11 @@ function(vcpkg_build_qmake)
cmake_parse_arguments(_csc "SKIP_MAKEFILES" "BUILD_LOGNAME" "TARGETS;RELEASE_TARGETS;DEBUG_TARGETS" ${ARGN})
if(CMAKE_HOST_WIN32)
+ set(_PATHSEP ";")
vcpkg_find_acquire_program(JOM)
set(INVOKE "${JOM}")
else()
+ set(_PATHSEP ":")
find_program(MAKE make)
set(INVOKE "${MAKE}")
endif()
@@ -56,7 +58,7 @@ function(vcpkg_build_qmake)
#First generate the makefiles so we can modify them
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
- set(ENV{PATH} "${CURRENT_INSTALLED_DIR}/debug/lib;${CURRENT_INSTALLED_DIR}/debug/bin;${CURRENT_INSTALLED_DIR}/tools/qt5;${ENV_PATH_BACKUP}")
+ set(ENV{PATH} "${CURRENT_INSTALLED_DIR}/debug/lib${_PATHSEP}${CURRENT_INSTALLED_DIR}/debug/bin${_PATHSEP}${CURRENT_INSTALLED_DIR}/tools/qt5${_PATHSEP}${ENV_PATH_BACKUP}")
if(NOT _csc_SKIP_MAKEFILES)
run_jom(qmake_all makefiles dbg)
@@ -81,7 +83,7 @@ function(vcpkg_build_qmake)
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
- set(ENV{PATH} "${CURRENT_INSTALLED_DIR}/lib;${CURRENT_INSTALLED_DIR}/bin;${CURRENT_INSTALLED_DIR}/tools/qt5;${ENV_PATH_BACKUP}")
+ set(ENV{PATH} "${CURRENT_INSTALLED_DIR}/lib${_PATHSEP}${CURRENT_INSTALLED_DIR}/bin${_PATHSEP}${CURRENT_INSTALLED_DIR}/tools/qt5${_PATHSEP}${ENV_PATH_BACKUP}")
if(NOT _csc_SKIP_MAKEFILES)
run_jom(qmake_all makefiles rel)
diff --git a/scripts/cmake/vcpkg_check_features.cmake b/scripts/cmake/vcpkg_check_features.cmake
new file mode 100644
index 000000000..115b1501f
--- /dev/null
+++ b/scripts/cmake/vcpkg_check_features.cmake
@@ -0,0 +1,112 @@
+## # vcpkg_check_features
+##
+## Check if one or more features are a part of the package installation.
+##
+## ## Usage
+## ```cmake
+## vcpkg_check_features(
+## <feature1> <output_variable1>
+## [<feature2> <output_variable2>]
+## ...
+## )
+## ```
+##
+## `vcpkg_check_features` accepts a list of (feature, output_variable) pairs. If a feature is specified, the corresponding output variable will be set as `ON`, or `OFF` otherwise. The syntax is similar to the `PROPERTIES` argument of `set_target_properties`.
+##
+## `vcpkg_check_features` will create a variable `FEATURE_OPTIONS` in the parent scope, which you can pass as a part of `OPTIONS` argument when calling functions like `vcpkg_config_cmake`:
+## ```cmake
+## vcpkg_config_cmake(
+## SOURCE_PATH ${SOURCE_PATH}
+## PREFER_NINJA
+## OPTIONS
+## -DBUILD_TESTING=ON
+## ${FEATURE_OPTIONS}
+## )
+## ```
+##
+## ## Notes
+## ```cmake
+## vcpkg_check_features(<feature> <output_variable>)
+## ```
+## can be used as a replacement of:
+## ```cmake
+## if(<feature> IN_LIST FEATURES)
+## set(<output_variable> ON)
+## else()
+## set(<output_variable> OFF)
+## endif()
+## ```
+##
+## However, if you have a feature that was checked like this before:
+## ```cmake
+## if(<feature> IN_LIST FEATURES)
+## set(<output_variable> OFF)
+## else()
+## set(<output_variable> ON)
+## endif()
+## ```
+## then you should not use `vcpkg_check_features` instead. [```oniguruma```](https://github.com/microsoft/vcpkg/blob/master/ports/oniguruma/portfile.cmake), for example, has a feature named `non-posix` which is checked with:
+## ```cmake
+## if("non-posix" IN_LIST FEATURES)
+## set(ENABLE_POSIX_API OFF)
+## else()
+## set(ENABLE_POSIX_API ON)
+## endif()
+## ```
+## and by replacing these code with:
+## ```cmake
+## vcpkg_check_features(non-posix ENABLE_POSIX_API)
+## ```
+## is totally wrong.
+##
+## `vcpkg_check_features` is supposed to be called only once. Otherwise, the `FEATURE_OPTIONS` variable set by a previous call will be overwritten.
+##
+## ## Examples
+##
+## * [czmq](https://github.com/microsoft/vcpkg/blob/master/ports/czmq/portfile.cmake)
+## * [xsimd](https://github.com/microsoft/vcpkg/blob/master/ports/xsimd/portfile.cmake)
+## * [xtensor](https://github.com/microsoft/vcpkg/blob/master/ports/xtensor/portfile.cmake)
+function(vcpkg_check_features)
+ cmake_parse_arguments(_vcf "" "" "" ${ARGN})
+
+ list(LENGTH ARGN _vcf_ARGC)
+ math(EXPR _vcf_INCORRECT_ARGN "${_vcf_ARGC} % 2")
+
+ if(_vcf_INCORRECT_ARGN)
+ message(FATAL_ERROR "Called with incorrect number of arguments.")
+ endif()
+
+ set(_vcf_IS_FEATURE_ARG ON)
+ set(_vcf_FEATURE_OPTIONS)
+
+ # Process (feature, output_var) pairs
+ foreach(_vcf_ARG ${ARGN})
+ if(_vcf_IS_FEATURE_ARG)
+ set(_vcf_FEATURE ${_vcf_ARG})
+
+ if(NOT ${_vcf_FEATURE} IN_LIST ALL_FEATURES)
+ message(FATAL_ERROR "Unknown feature: ${_vcf_FEATURE}")
+ endif()
+
+ set(_vcf_IS_FEATURE_ARG OFF)
+ else()
+ set(_vcf_FEATURE_VAR ${_vcf_ARG})
+
+ if(${_vcf_FEATURE} IN_LIST FEATURES)
+ set(${_vcf_FEATURE_VAR} ON PARENT_SCOPE)
+ else()
+ set(${_vcf_FEATURE_VAR} OFF PARENT_SCOPE)
+ endif()
+
+ list(APPEND _vcf_FEATURE_OPTIONS "-D${_vcf_FEATURE_VAR}=${${_vcf_FEATURE_VAR}}")
+
+ set(_vcf_IS_FEATURE_ARG ON)
+ endif()
+ endforeach()
+
+ if(DEFINED FEATURE_OPTIONS)
+ message(WARNING "FEATURE_OPTIONS is already defined and will be overwritten.")
+ endif()
+
+ set(FEATURE_OPTIONS ${_vcf_FEATURE_OPTIONS} PARENT_SCOPE)
+endfunction()
diff --git a/scripts/cmake/vcpkg_common_definitions.cmake b/scripts/cmake/vcpkg_common_definitions.cmake
new file mode 100644
index 000000000..8dc05de3c
--- /dev/null
+++ b/scripts/cmake/vcpkg_common_definitions.cmake
@@ -0,0 +1,14 @@
+if (NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
+ set(VCPKG_TARGET_IS_WINDOWS 1)
+ if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
+ set(VCPKG_TARGET_IS_UWP 1)
+ endif()
+elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ set(VCPKG_TARGET_IS_OSX 1)
+elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(VCPKG_TARGET_IS_LINUX 1)
+elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Android")
+ set(VCPKG_TARGET_IS_ANDROID 1)
+elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+ set(VCPKG_TARGET_IS_FREEBSD 1)
+endif()
diff --git a/scripts/cmake/vcpkg_common_functions.cmake b/scripts/cmake/vcpkg_common_functions.cmake
index d66fc5eff..827d43abe 100644
--- a/scripts/cmake/vcpkg_common_functions.cmake
+++ b/scripts/cmake/vcpkg_common_functions.cmake
@@ -1,5 +1,6 @@
include(vcpkg_acquire_msys)
include(vcpkg_add_to_path)
+include(vcpkg_check_features)
include(vcpkg_check_linkage)
include(vcpkg_clean_msbuild)
include(vcpkg_download_distfile)
@@ -7,6 +8,7 @@ include(vcpkg_extract_source_archive)
include(vcpkg_extract_source_archive_ex)
include(vcpkg_execute_required_process)
include(vcpkg_execute_required_process_repeat)
+include(vcpkg_execute_build_process)
include(vcpkg_find_acquire_program)
include(vcpkg_fixup_cmake_targets)
include(vcpkg_from_github)
diff --git a/scripts/cmake/vcpkg_configure_cmake.cmake b/scripts/cmake/vcpkg_configure_cmake.cmake
index ceff199ab..ab93c3075 100644
--- a/scripts/cmake/vcpkg_configure_cmake.cmake
+++ b/scripts/cmake/vcpkg_configure_cmake.cmake
@@ -7,6 +7,7 @@
## vcpkg_configure_cmake(
## SOURCE_PATH <${SOURCE_PATH}>
## [PREFER_NINJA]
+## [DISABLE_PARALLEL_CONFIGURE]
## [GENERATOR <"NMake Makefiles">]
## [OPTIONS <-DUSE_THIS_IN_ALL_BUILDS=1>...]
## [OPTIONS_RELEASE <-DOPTIMIZE=1>...]
@@ -50,7 +51,7 @@
## * [poco](https://github.com/Microsoft/vcpkg/blob/master/ports/poco/portfile.cmake)
## * [opencv](https://github.com/Microsoft/vcpkg/blob/master/ports/opencv/portfile.cmake)
function(vcpkg_configure_cmake)
- cmake_parse_arguments(_csc "PREFER_NINJA;DISABLE_PARALLEL_CONFIGURE" "SOURCE_PATH;GENERATOR" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" ${ARGN})
+ cmake_parse_arguments(_csc "PREFER_NINJA;DISABLE_PARALLEL_CONFIGURE;NO_CHARSET_FLAG" "SOURCE_PATH;GENERATOR" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" ${ARGN})
if(NOT VCPKG_PLATFORM_TOOLSET)
message(FATAL_ERROR "Vcpkg has been updated with VS2017 support, however you need to rebuild vcpkg.exe by re-running bootstrap-vcpkg.bat\n")
@@ -173,6 +174,11 @@ function(vcpkg_configure_cmake)
else()
message(FATAL_ERROR "You must set both the VCPKG_CXX_FLAGS and VCPKG_C_FLAGS")
endif()
+
+ set(VCPKG_SET_CHARSET_FLAG ON)
+ if(_csc_NO_CHARSET_FLAG)
+ set(VCPKG_SET_CHARSET_FLAG OFF)
+ endif()
if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
list(APPEND _csc_OPTIONS "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}")
@@ -188,8 +194,10 @@ function(vcpkg_configure_cmake)
list(APPEND _csc_OPTIONS "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${VCPKG_ROOT_DIR}/scripts/toolchains/freebsd.cmake")
endif()
+
list(APPEND _csc_OPTIONS
"-DVCPKG_TARGET_TRIPLET=${TARGET_TRIPLET}"
+ "-DVCPKG_SET_CHARSET_FLAG=${VCPKG_SET_CHARSET_FLAG}"
"-DVCPKG_PLATFORM_TOOLSET=${VCPKG_PLATFORM_TOOLSET}"
"-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON"
"-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON"
@@ -207,6 +215,7 @@ function(vcpkg_configure_cmake)
"-DVCPKG_C_FLAGS_DEBUG=${VCPKG_C_FLAGS_DEBUG}"
"-DVCPKG_CRT_LINKAGE=${VCPKG_CRT_LINKAGE}"
"-DVCPKG_LINKER_FLAGS=${VCPKG_LINKER_FLAGS}"
+ "-DVCPKG_TARGET_ARCHITECTURE=${VCPKG_TARGET_ARCHITECTURE}"
"-DCMAKE_INSTALL_LIBDIR:STRING=lib"
"-DCMAKE_INSTALL_BINDIR:STRING=bin"
)
diff --git a/scripts/cmake/vcpkg_configure_meson.cmake b/scripts/cmake/vcpkg_configure_meson.cmake
index f1ae0e65f..f907c76f1 100644
--- a/scripts/cmake/vcpkg_configure_meson.cmake
+++ b/scripts/cmake/vcpkg_configure_meson.cmake
@@ -26,6 +26,7 @@ function(vcpkg_configure_meson)
set(MESON_RELEASE_LDFLAGS "${MESON_RELEASE_LDFLAGS} /INCREMENTAL:NO /OPT:REF /OPT:ICF")
# select meson cmd-line options
+ list(APPEND _vcm_OPTIONS -Dcmake_prefix_path=${CURRENT_INSTALLED_DIR})
list(APPEND _vcm_OPTIONS --buildtype plain --backend ninja --wrap-mode nodownload)
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
list(APPEND _vcm_OPTIONS --default-library shared)
diff --git a/scripts/cmake/vcpkg_execute_build_process.cmake b/scripts/cmake/vcpkg_execute_build_process.cmake
new file mode 100644
index 000000000..d440ba2f6
--- /dev/null
+++ b/scripts/cmake/vcpkg_execute_build_process.cmake
@@ -0,0 +1,141 @@
+## # vcpkg_execute_build_process
+##
+## Execute a required build process
+##
+## ## Usage
+## ```cmake
+## vcpkg_execute_build_process(
+## COMMAND <cmd> [<args>...]
+## [NO_PARALLEL_COMMAND <cmd> [<args>...]]
+## WORKING_DIRECTORY </path/to/dir>
+## LOGNAME <log_name>)
+## )
+## ```
+## ## Parameters
+## ### COMMAND
+## The command to be executed, along with its arguments.
+##
+## ### NO_PARALLEL_COMMAND
+## Optional parameter which specifies a non-parallel command to attempt if a
+## failure potentially due to parallelism is detected.
+##
+## ### WORKING_DIRECTORY
+## The directory to execute the command in.
+##
+## ### LOGNAME
+## The prefix to use for the log files.
+##
+## This should be a unique name for different triplets so that the logs don't
+## conflict when building multiple at once.
+##
+## ## Examples
+##
+## * [icu](https://github.com/Microsoft/vcpkg/blob/master/ports/icu/portfile.cmake)
+function(vcpkg_execute_build_process)
+ cmake_parse_arguments(_ebp "" "WORKING_DIRECTORY;LOGNAME" "COMMAND;NO_PARALLEL_COMMAND" ${ARGN})
+
+ set(LOG_OUT "${CURRENT_BUILDTREES_DIR}/${_ebp_LOGNAME}-out.log")
+ set(LOG_ERR "${CURRENT_BUILDTREES_DIR}/${_ebp_LOGNAME}-err.log")
+
+ execute_process(
+ COMMAND ${_ebp_COMMAND}
+ WORKING_DIRECTORY ${_ebp_WORKING_DIRECTORY}
+ OUTPUT_FILE ${LOG_OUT}
+ ERROR_FILE ${LOG_ERR}
+ RESULT_VARIABLE error_code
+ )
+
+ if(error_code)
+ file(READ ${LOG_OUT} out_contents)
+ file(READ ${LOG_ERR} err_contents)
+
+ if(out_contents)
+ list(APPEND LOGS ${LOG_OUT})
+ endif()
+ if(err_contents)
+ list(APPEND LOGS ${LOG_ERR})
+ endif()
+
+ if(out_contents MATCHES "LINK : fatal error LNK1102:" OR out_contents MATCHES " fatal error C1060: "
+ OR err_contents MATCHES "LINK : fatal error LNK1102:" OR err_contents MATCHES " fatal error C1060: "
+ OR out_contents MATCHES "LINK : fatal error LNK1318: Unexpected PDB error; ACCESS_DENIED"
+ OR out_contents MATCHES "LINK : fatal error LNK1104:"
+ OR out_contents MATCHES "LINK : fatal error LNK1201:")
+ # The linker ran out of memory during execution. We will try continuing once more, with parallelism disabled.
+ message(STATUS "Restarting Build without parallelism because memory exceeded")
+ set(LOG_OUT "${CURRENT_BUILDTREES_DIR}/${_ebp_LOGNAME}-out-1.log")
+ set(LOG_ERR "${CURRENT_BUILDTREES_DIR}/${_ebp_LOGNAME}-err-1.log")
+
+ if(_ebp_NO_PARALLEL_COMMAND)
+ execute_process(
+ COMMAND ${_ebp_NO_PARALLEL_COMMAND}
+ WORKING_DIRECTORY ${_ebp_WORKING_DIRECTORY}
+ OUTPUT_FILE ${LOG_OUT}
+ ERROR_FILE ${LOG_ERR}
+ RESULT_VARIABLE error_code
+ )
+ else()
+ execute_process(
+ COMMAND ${_ebp_COMMAND}
+ WORKING_DIRECTORY ${_ebp_WORKING_DIRECTORY}
+ OUTPUT_FILE ${LOG_OUT}
+ ERROR_FILE ${LOG_ERR}
+ RESULT_VARIABLE error_code
+ )
+ endif()
+
+ if(error_code)
+ file(READ ${LOG_OUT} out_contents)
+ file(READ ${LOG_ERR} err_contents)
+
+ if(out_contents)
+ list(APPEND LOGS ${LOG_OUT})
+ endif()
+ if(err_contents)
+ list(APPEND LOGS ${LOG_ERR})
+ endif()
+ endif()
+ elseif(out_contents MATCHES "mt : general error c101008d: " OR out_contents MATCHES "mt.exe : general error c101008d: ")
+ # Antivirus workaround - occasionally files are locked and cause mt.exe to fail
+ message(STATUS "mt.exe has failed. This may be the result of anti-virus. Disabling anti-virus on the buildtree folder may improve build speed")
+ set(ITERATION 0)
+ while (ITERATION LESS 3 AND (out_contents MATCHES "mt : general error c101008d: " OR out_contents MATCHES "mt.exe : general error c101008d: "))
+ MATH(EXPR ITERATION "${ITERATION}+1")
+ message(STATUS "Restarting Build ${TARGET_TRIPLET}-${SHORT_BUILDTYPE} because of mt.exe file locking issue. Iteration: ${ITERATION}")
+ execute_process(
+ COMMAND ${_ebp_COMMAND}
+ OUTPUT_FILE "${LOGPREFIX}-out-${ITERATION}.log"
+ ERROR_FILE "${LOGPREFIX}-err-${ITERATION}.log"
+ RESULT_VARIABLE error_code
+ WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE})
+
+ if(error_code)
+ file(READ "${LOGPREFIX}-out-${ITERATION}.log" out_contents)
+ file(READ "${LOGPREFIX}-err-${ITERATION}.log" err_contents)
+
+ if(out_contents)
+ list(APPEND LOGS "${LOGPREFIX}-out-${ITERATION}.log")
+ endif()
+ if(err_contents)
+ list(APPEND LOGS "${LOGPREFIX}-err-${ITERATION}.log")
+ endif()
+ else()
+ break()
+ endif()
+ endwhile()
+ endif()
+
+ if(error_code)
+ set(STRINGIFIED_LOGS)
+ foreach(LOG ${LOGS})
+ file(TO_NATIVE_PATH "${LOG}" NATIVE_LOG)
+ list(APPEND STRINGIFIED_LOGS " ${NATIVE_LOG}\n")
+ endforeach()
+ message(FATAL_ERROR
+ " Command failed: ${_ebp_COMMAND}\n"
+ " Working Directory: ${_ebp_WORKING_DIRECTORY}\n"
+ " See logs for more information:\n"
+ ${STRINGIFIED_LOGS})
+ endif(error_code)
+ endif(error_code)
+endfunction(vcpkg_execute_build_process)
diff --git a/scripts/cmake/vcpkg_extract_source_archive_ex.cmake b/scripts/cmake/vcpkg_extract_source_archive_ex.cmake
index a70a5e4a3..a775c2094 100644
--- a/scripts/cmake/vcpkg_extract_source_archive_ex.cmake
+++ b/scripts/cmake/vcpkg_extract_source_archive_ex.cmake
@@ -25,7 +25,7 @@
## This is usually obtained from calling [`vcpkg_download_distfile`](vcpkg_download_distfile.md).
##
## ### REF
-## A friendly name that will be used instead of the filename of the archive.
+## A friendly name that will be used instead of the filename of the archive. If more than 10 characters it will be truncated.
##
## By convention, this is set to the version number or tag fetched
##
diff --git a/scripts/cmake/vcpkg_find_acquire_program.cmake b/scripts/cmake/vcpkg_find_acquire_program.cmake
index 4a77b4b8e..024840223 100644
--- a/scripts/cmake/vcpkg_find_acquire_program.cmake
+++ b/scripts/cmake/vcpkg_find_acquire_program.cmake
@@ -79,9 +79,9 @@ function(vcpkg_find_acquire_program VAR)
set(PROGNAME python)
set(SUBDIR "python3")
set(PATHS ${DOWNLOADS}/tools/python/${SUBDIR})
- set(URL "https://www.python.org/ftp/python/3.5.4/python-3.5.4-embed-win32.zip")
- set(ARCHIVE "python-3.5.4-embed-win32.zip")
- set(HASH b5240fdc95088c2d7f65d2dd598650f8dd106b49589d94156bd4a078b108c6cabbe7a38ef73e2b2cf00e8312a93d2e587eac2c54ce85540d3c7a26cc60013156)
+ set(URL "https://www.python.org/ftp/python/3.7.3/python-3.7.3-embed-win32.zip")
+ set(ARCHIVE "python-3.7.3-embed-win32.zip")
+ set(HASH 2c1b1f0a29d40a91771ae21a5f733eedc10984cd182cb10c2793bbd24191a89f20612a3f23c34047f37fb06369016bfd4a52915ed1b4a56f8bd2b4ca6994eb31)
else()
set(PROGNAME python3)
set(BREW_PACKAGE_NAME "python")
@@ -154,10 +154,10 @@ function(vcpkg_find_acquire_program VAR)
else()
set(SCRIPTNAME meson)
endif()
- set(PATHS ${DOWNLOADS}/tools/meson/meson-0.50.0)
- set(URL "https://github.com/mesonbuild/meson/archive/0.50.0.zip")
- set(ARCHIVE "meson-0.50.0.zip")
- set(HASH 587cafe0cd551e3fb3507ecab904912dc3e053aa95c864b435526a20d52406536ba970a50be6c9f20d83314c5853aaefa102c5ca14623d0928b091a43e7b6d64)
+ set(PATHS ${DOWNLOADS}/tools/meson/meson-0.51.0)
+ set(URL "https://github.com/mesonbuild/meson/archive/0.51.0.zip")
+ set(ARCHIVE "meson-0.51.0.zip")
+ set(HASH bf1df65cde7e0e0a44e4b4be7d68de9897a77c4ea4c694f1d77fe82cd3c7e7818dc034a3313ce885ba6883b4ba6d282b7a589f665fa499d9eb79fc7a23e415cc)
elseif(VAR MATCHES "FLEX")
if(CMAKE_HOST_WIN32)
set(PROGNAME win_flex)
diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake
index 982f414b6..1e0f2493d 100644
--- a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake
+++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake
@@ -4,7 +4,8 @@
# Transform all /debug/share/<port>/*targets-debug.cmake files and move them to /share/<port>.
# Removes all /debug/share/<port>/*targets.cmake and /debug/share/<port>/*config.cmake
#
-# Transform all references matching /bin/*.exe to /tools/<port>/*.exe
+# Transform all references matching /bin/*.exe to /tools/<port>/*.exe on Windows
+# Transform all references matching /bin/* to /tools/<port>/* on other platforms
#
# Fix ${_IMPORT_PREFIX} in auto generated targets to be one folder deeper.
# Replace ${CURRENT_INSTALLED_DIR} with ${_IMPORT_PREFIX} in configs/targets.
@@ -27,6 +28,13 @@ function(vcpkg_fixup_cmake_targets)
set(_vfct_TARGET_PATH share/${PORT})
endif()
+
+ if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
+ set(EXECUTABLE_SUFFIX "\\.exe")
+ else()
+ set(EXECUTABLE_SUFFIX)
+ endif()
+
set(DEBUG_SHARE ${CURRENT_PACKAGES_DIR}/debug/${_vfct_TARGET_PATH})
set(RELEASE_SHARE ${CURRENT_PACKAGES_DIR}/${_vfct_TARGET_PATH})
@@ -107,7 +115,7 @@ function(vcpkg_fixup_cmake_targets)
foreach(RELEASE_TARGET IN LISTS RELEASE_TARGETS)
file(READ ${RELEASE_TARGET} _contents)
string(REPLACE "${CURRENT_INSTALLED_DIR}" "\${_IMPORT_PREFIX}" _contents "${_contents}")
- string(REGEX REPLACE "\\\${_IMPORT_PREFIX}/bin/([^ \"]+\\.exe)" "\${_IMPORT_PREFIX}/tools/${PORT}/\\1" _contents "${_contents}")
+ string(REGEX REPLACE "\\\${_IMPORT_PREFIX}/bin/([^ \"]+${EXECUTABLE_SUFFIX})" "\${_IMPORT_PREFIX}/tools/${PORT}/\\1" _contents "${_contents}")
file(WRITE ${RELEASE_TARGET} "${_contents}")
endforeach()
@@ -120,7 +128,7 @@ function(vcpkg_fixup_cmake_targets)
file(READ ${DEBUG_TARGET} _contents)
string(REPLACE "${CURRENT_INSTALLED_DIR}" "\${_IMPORT_PREFIX}" _contents "${_contents}")
- string(REGEX REPLACE "\\\${_IMPORT_PREFIX}/bin/([^ \";]+\\.exe)" "\${_IMPORT_PREFIX}/tools/${PORT}/\\1" _contents "${_contents}")
+ string(REGEX REPLACE "\\\${_IMPORT_PREFIX}/bin/([^ \";]+${EXECUTABLE_SUFFIX})" "\${_IMPORT_PREFIX}/tools/${PORT}/\\1" _contents "${_contents}")
string(REPLACE "\${_IMPORT_PREFIX}/lib" "\${_IMPORT_PREFIX}/debug/lib" _contents "${_contents}")
string(REPLACE "\${_IMPORT_PREFIX}/bin" "\${_IMPORT_PREFIX}/debug/bin" _contents "${_contents}")
file(WRITE ${RELEASE_SHARE}/${DEBUG_TARGET_REL} "${_contents}")
diff --git a/scripts/ports.cmake b/scripts/ports.cmake
index 7a5f2749f..860d08893 100644
--- a/scripts/ports.cmake
+++ b/scripts/ports.cmake
@@ -32,7 +32,7 @@ endif()
if(CMD MATCHES "^BUILD$")
- set(CMAKE_TRIPLET_FILE ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake)
+ set(CMAKE_TRIPLET_FILE ${TARGET_TRIPLET_FILE})
if(NOT EXISTS ${CMAKE_TRIPLET_FILE})
message(FATAL_ERROR "Unsupported target triplet. Triplet file does not exist: ${CMAKE_TRIPLET_FILE}")
endif()
@@ -68,6 +68,8 @@ if(CMD MATCHES "^BUILD$")
include(${CMAKE_TRIPLET_FILE})
set(TRIPLET_SYSTEM_ARCH ${VCPKG_TARGET_ARCHITECTURE})
+ include(${CMAKE_CURRENT_LIST_DIR}/cmake/vcpkg_common_definitions.cmake)
+ include(${CMAKE_CURRENT_LIST_DIR}/cmake/vcpkg_common_functions.cmake)
include(${CURRENT_PORT_DIR}/portfile.cmake)
set(BUILD_INFO_FILE_PATH ${CURRENT_PACKAGES_DIR}/BUILD_INFO)
diff --git a/scripts/toolchains/linux.cmake b/scripts/toolchains/linux.cmake
index b9cbc0ff3..70f224da9 100644
--- a/scripts/toolchains/linux.cmake
+++ b/scripts/toolchains/linux.cmake
@@ -4,6 +4,9 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_CROSSCOMPILING OFF CACHE BOOL "")
endif()
set(CMAKE_SYSTEM_NAME Linux CACHE STRING "")
+if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
+ set(CMAKE_SYSTEM_PROCESSOR x86_64 CACHE STRING "")
+endif()
get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
if(NOT _CMAKE_IN_TRY_COMPILE)
diff --git a/scripts/toolchains/windows.cmake b/scripts/toolchains/windows.cmake
index 12b1ae7f9..d5d7f8db5 100644
--- a/scripts/toolchains/windows.cmake
+++ b/scripts/toolchains/windows.cmake
@@ -9,7 +9,8 @@ if(NOT _CMAKE_IN_TRY_COMPILE)
message(FATAL_ERROR "Invalid setting for VCPKG_CRT_LINKAGE: \"${VCPKG_CRT_LINKAGE}\". It must be \"static\" or \"dynamic\"")
endif()
- if(VCPKG_PLATFORM_TOOLSET MATCHES "v120")
+ set(CHARSET_FLAG "/utf-8")
+ if (NOT VCPKG_SET_CHARSET_FLAG OR VCPKG_PLATFORM_TOOLSET MATCHES "v120")
# VS 2013 does not support /utf-8
set(CHARSET_FLAG)
endif()
@@ -17,7 +18,7 @@ if(NOT _CMAKE_IN_TRY_COMPILE)
set(CMAKE_CXX_FLAGS " /DWIN32 /D_WINDOWS /W3 ${CHARSET_FLAG} /GR /EHsc /MP ${VCPKG_CXX_FLAGS}" CACHE STRING "")
set(CMAKE_C_FLAGS " /DWIN32 /D_WINDOWS /W3 ${CHARSET_FLAG} /MP ${VCPKG_C_FLAGS}" CACHE STRING "")
set(CMAKE_RC_FLAGS "-c65001 /DWIN32" CACHE STRING "")
-
+
unset(CHARSET_FLAG)
set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG ${VCPKG_CRT_LINK_FLAG_PREFIX}d /Z7 /Ob0 /Od /RTC1 ${VCPKG_CXX_FLAGS_DEBUG}" CACHE STRING "")
@@ -27,5 +28,4 @@ if(NOT _CMAKE_IN_TRY_COMPILE)
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS}" CACHE STRING "")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS}" CACHE STRING "")
-
endif()