Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vcpkg-cmake] Update parallel vcpkg_cmake_configure #21507

Merged
merged 8 commits into from
Jul 25, 2022
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
9 changes: 5 additions & 4 deletions docs/maintainers/vcpkg_cmake_configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 1 addition & 6 deletions ports/ms-gltf/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Expand Down
1 change: 1 addition & 0 deletions ports/ms-gltf/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion ports/vcpkg-cmake/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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"
}
50 changes: 25 additions & 25 deletions ports/vcpkg-cmake/vcpkg_cmake_configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand Down Expand Up @@ -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})
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions scripts/cmake/vcpkg_configure_cmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4742,7 +4742,7 @@
},
"ms-gltf": {
"baseline": "2022-06-28",
"port-version": 0
"port-version": 1
},
"ms-gsl": {
"baseline": "4.0.0",
Expand Down Expand Up @@ -7421,7 +7421,7 @@
"port-version": 0
},
"vcpkg-cmake": {
"baseline": "2022-07-02",
"baseline": "2022-07-18",
"port-version": 0
},
"vcpkg-cmake-config": {
Expand Down
5 changes: 5 additions & 0 deletions versions/m-/ms-gltf.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "b189e4d23ebe85437573b386d94b06b3f9fb6238",
"version-date": "2022-06-28",
"port-version": 1
},
{
"git-tree": "a9a91635168ea77faa39adb73b27483797fa8967",
"version-date": "2022-06-28",
Expand Down
5 changes: 5 additions & 0 deletions versions/v-/vcpkg-cmake.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "a7b618b7782f3c841d7fd2d84a6ba3619815362a",
"version-date": "2022-07-18",
"port-version": 0
},
{
"git-tree": "94abbd71a7fe495e883b13c077312f6d419cbc41",
"version-date": "2022-07-02",
Expand Down