mirror of
https://github.com/microsoft/vcpkg
synced 2024-11-20 16:06:00 -07:00
[vcpkg-cmake] Update parallel vcpkg_cmake_configure (#21507)
* Revise generator selection If the host is x86, assume that msbuild is requested for windows. If msbuild is requested and suitable, use it. Else if a particular generator is requested, use it. Else if ninja is available, use it. Else on non-windows host, use "Unix Makefiles". * Revise ninja_host detection * Revise parallel configure detection * Consolidate ninja path setup * Update documentation * Use portable chdir * [ms-gltf] Use new generator selection * Update versions
This commit is contained in:
parent
1aa8ac7a05
commit
49868fd552
9 changed files with 48 additions and 40 deletions
|
@ -55,16 +55,17 @@ Disables passing `/utf-8` when using the [built-in Windows toolchain][VCPKG_CHAI
|
|||
This is needed for libraries that set their own source code's character set when targeting MSVC. See the [MSVC documentation for `/utf-8`](https://docs.microsoft.com/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8) for more information.
|
||||
|
||||
### WINDOWS_USE_MSBUILD
|
||||
Use MSBuild instead of [Ninja][ninja] when targeting a Windows platform.
|
||||
Use MSBuild instead of another generator when targeting a Windows platform.
|
||||
|
||||
By default vcpkg prefers to use Ninja as the CMake Generator for all platforms. However, there are edge cases where MSBuild has different behavior than Ninja. This flag should only be passed if the project requires MSBuild to build correctly.
|
||||
This flag has no effect for MinGW targets.
|
||||
|
||||
### GENERATOR
|
||||
Specifies the Generator to use.
|
||||
|
||||
This is useful if the project-specific buildsystem has been wrapped in a CMake script that won't perform an actual build. If used for this purpose, it should be set to `"Ninja"`.
|
||||
|
||||
This should not be passed alongside [`WINDOWS_USE_MSBUILD`](#windows_use_msbuild).
|
||||
By default vcpkg prefers to use Ninja as the CMake Generator for all platforms,
|
||||
or "Unix Makefiles" for non-Windows platforms when Ninja is not available.
|
||||
This parameter can be used for edge cases where project-specific buildsystems depend on a particular generator.
|
||||
|
||||
### LOGFILE_BASE
|
||||
An alternate root name for the configure logs.
|
||||
|
|
|
@ -23,14 +23,9 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
|||
# note: Platform-native buildsystem will be more helpful to launch/debug the tests/samples.
|
||||
# note: The PDB file path is making Ninja fails to install.
|
||||
# For Windows, we rely on /MP. The other platforms should be able to build with PREFER_NINJA.
|
||||
set(WINDOWS_USE_MSBUILD)
|
||||
if(VCPKG_TARGET_IS_WINDOWS)
|
||||
set(WINDOWS_USE_MSBUILD "WINDOWS_USE_MSBUILD")
|
||||
endif()
|
||||
|
||||
vcpkg_cmake_configure(
|
||||
SOURCE_PATH "${SOURCE_PATH}"
|
||||
${WINDOWS_USE_MSBUILD}
|
||||
WINDOWS_USE_MSBUILD
|
||||
OPTIONS
|
||||
${FEATURE_OPTIONS}
|
||||
)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name": "ms-gltf",
|
||||
"version-date": "2022-06-28",
|
||||
"port-version": 1,
|
||||
"description": "glTF-SDK is a C++ Software Development Kit for glTF",
|
||||
"homepage": "https://github.com/microsoft/glTF-SDK",
|
||||
"license": "MIT",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "vcpkg-cmake",
|
||||
"version-date": "2022-07-02",
|
||||
"version-date": "2022-07-18",
|
||||
"documentation": "https://vcpkg.io/en/docs/maintainers/ports/vcpkg-cmake.html",
|
||||
"license": "MIT"
|
||||
}
|
||||
|
|
|
@ -60,22 +60,28 @@ function(vcpkg_cmake_configure)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
set(ninja_can_be_used ON) # Ninja as generator
|
||||
set(ninja_host ON) # Ninja as parallel configurator
|
||||
|
||||
if(host_architecture STREQUAL "x86")
|
||||
set(ninja_host ON) # Ninja availability
|
||||
if(host_architecture STREQUAL "x86" OR DEFINED ENV{VCPKG_FORCE_SYSTEM_BINARIES})
|
||||
# Prebuilt ninja binaries are only provided for x64 hosts
|
||||
set(ninja_can_be_used OFF)
|
||||
set(ninja_host OFF)
|
||||
find_program(NINJA NAMES ninja ninja-build)
|
||||
if(NOT NINJA)
|
||||
set(ninja_host OFF)
|
||||
set(arg_DISABLE_PARALLEL_CONFIGURE ON)
|
||||
set(arg_WINDOWS_USE_MSBUILD ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(generator "Ninja")
|
||||
if(DEFINED arg_GENERATOR)
|
||||
set(generator "${arg_GENERATOR}")
|
||||
elseif(arg_WINDOWS_USE_MSBUILD OR NOT ninja_can_be_used)
|
||||
set(generator "")
|
||||
set(arch "")
|
||||
set(generator "")
|
||||
set(architecture_options "")
|
||||
if(arg_WINDOWS_USE_MSBUILD AND VCPKG_HOST_IS_WINDOWS AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
|
||||
z_vcpkg_get_visual_studio_generator(OUT_GENERATOR generator OUT_ARCH arch)
|
||||
vcpkg_list(APPEND architecture_options "-A${arch}")
|
||||
elseif(DEFINED arg_GENERATOR)
|
||||
set(generator "${arg_GENERATOR}")
|
||||
elseif(ninja_host)
|
||||
set(generator "Ninja")
|
||||
elseif(NOT VCPKG_HOST_IS_WINDOWS)
|
||||
set(generator "Unix Makefiles")
|
||||
endif()
|
||||
|
||||
if(NOT generator)
|
||||
|
@ -86,12 +92,13 @@ function(vcpkg_cmake_configure)
|
|||
"${VCPKG_CMAKE_SYSTEM_NAME}-${VCPKG_TARGET_ARCHITECTURE}-${VCPKG_PLATFORM_TOOLSET}")
|
||||
endif()
|
||||
|
||||
# If we use Ninja, make sure it's on PATH
|
||||
if(generator STREQUAL "Ninja" AND NOT DEFINED ENV{VCPKG_FORCE_SYSTEM_BINARIES})
|
||||
if(generator STREQUAL "Ninja")
|
||||
vcpkg_find_acquire_program(NINJA)
|
||||
vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_MAKE_PROGRAM=${NINJA}")
|
||||
# If we use Ninja, it must be on PATH for CMake's ExternalProject,
|
||||
# cf. https://gitlab.kitware.com/cmake/cmake/-/issues/23355.
|
||||
get_filename_component(ninja_path "${NINJA}" DIRECTORY)
|
||||
vcpkg_add_to_path("${ninja_path}")
|
||||
vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_MAKE_PROGRAM=${NINJA}")
|
||||
endif()
|
||||
|
||||
set(build_dir_release "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
|
||||
|
@ -172,10 +179,6 @@ function(vcpkg_cmake_configure)
|
|||
"-DVCPKG_MANIFEST_INSTALL=OFF"
|
||||
)
|
||||
|
||||
if(DEFINED arch AND NOT arch STREQUAL "")
|
||||
vcpkg_list(APPEND arg_OPTIONS "-A${arch}")
|
||||
endif()
|
||||
|
||||
# Sets configuration variables for macOS builds
|
||||
foreach(config_var IN ITEMS INSTALL_NAME_DIR OSX_DEPLOYMENT_TARGET OSX_SYSROOT OSX_ARCHITECTURES)
|
||||
if(DEFINED VCPKG_${config_var})
|
||||
|
@ -197,25 +200,22 @@ function(vcpkg_cmake_configure)
|
|||
vcpkg_list(SET rel_command
|
||||
"${CMAKE_COMMAND}" "${arg_SOURCE_PATH}"
|
||||
-G "${generator}"
|
||||
${architecture_options}
|
||||
"-DCMAKE_BUILD_TYPE=Release"
|
||||
"-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}"
|
||||
${arg_OPTIONS} ${arg_OPTIONS_RELEASE})
|
||||
vcpkg_list(SET dbg_command
|
||||
"${CMAKE_COMMAND}" "${arg_SOURCE_PATH}"
|
||||
-G "${generator}"
|
||||
${architecture_options}
|
||||
"-DCMAKE_BUILD_TYPE=Debug"
|
||||
"-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/debug"
|
||||
${arg_OPTIONS} ${arg_OPTIONS_DEBUG})
|
||||
|
||||
if(ninja_host AND CMAKE_HOST_WIN32 AND NOT arg_DISABLE_PARALLEL_CONFIGURE)
|
||||
if(NOT arg_DISABLE_PARALLEL_CONFIGURE)
|
||||
vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_DISABLE_SOURCE_CHANGES=ON")
|
||||
|
||||
vcpkg_find_acquire_program(NINJA)
|
||||
if(NOT DEFINED ninja_path)
|
||||
# if ninja_path was defined above, we've already done this
|
||||
get_filename_component(ninja_path "${NINJA}" DIRECTORY)
|
||||
vcpkg_add_to_path("${ninja_path}")
|
||||
endif()
|
||||
|
||||
#parallelize the configure step
|
||||
set(ninja_configure_contents
|
||||
|
|
|
@ -7,11 +7,12 @@ function(z_vcpkg_configure_cmake_both_or_neither_set var1 var2)
|
|||
endif()
|
||||
endfunction()
|
||||
function(z_vcpkg_configure_cmake_build_cmakecache out_var whereat build_type)
|
||||
set(line "build ${whereat}/CMakeCache.txt: CreateProcess\n process = cmd /c \"cd ${whereat} &&")
|
||||
set(line "build ${whereat}/CMakeCache.txt: CreateProcess\n")
|
||||
string(APPEND line " process = \"${CMAKE_COMMAND}\" -E chdir \"${whereat}\"")
|
||||
foreach(arg IN LISTS "${build_type}_command")
|
||||
string(APPEND line " \"${arg}\"")
|
||||
endforeach()
|
||||
set("${out_var}" "${${out_var}}${line}\"\n\n" PARENT_SCOPE)
|
||||
set("${out_var}" "${${out_var}}${line}\n\n" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(z_vcpkg_get_visual_studio_generator)
|
||||
|
|
|
@ -4742,7 +4742,7 @@
|
|||
},
|
||||
"ms-gltf": {
|
||||
"baseline": "2022-06-28",
|
||||
"port-version": 0
|
||||
"port-version": 1
|
||||
},
|
||||
"ms-gsl": {
|
||||
"baseline": "4.0.0",
|
||||
|
@ -7421,7 +7421,7 @@
|
|||
"port-version": 0
|
||||
},
|
||||
"vcpkg-cmake": {
|
||||
"baseline": "2022-07-02",
|
||||
"baseline": "2022-07-18",
|
||||
"port-version": 0
|
||||
},
|
||||
"vcpkg-cmake-config": {
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "b189e4d23ebe85437573b386d94b06b3f9fb6238",
|
||||
"version-date": "2022-06-28",
|
||||
"port-version": 1
|
||||
},
|
||||
{
|
||||
"git-tree": "a9a91635168ea77faa39adb73b27483797fa8967",
|
||||
"version-date": "2022-06-28",
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "a7b618b7782f3c841d7fd2d84a6ba3619815362a",
|
||||
"version-date": "2022-07-18",
|
||||
"port-version": 0
|
||||
},
|
||||
{
|
||||
"git-tree": "94abbd71a7fe495e883b13c077312f6d419cbc41",
|
||||
"version-date": "2022-07-02",
|
||||
|
|
Loading…
Reference in a new issue