forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cmake: use ENV{VCPKG_ROOT}, fix msgfmt + minor.
Set VCPKG_DIR from ENV{VCPKG_ROOT} if set, otherwise set ENV{VCPKG_ROOT}. Set VCPKG_ARCH from VCPKG_TARGET_TRIPLET if set. Fix check for VCPKG_ARCH being defined. Describe options in comment at the top of the file. Add build*/ out-of-source build dirs to toplevel .gitignore. Change vcpkg_install.bat to use %VCPKG_ROOT% set by cmake or present in the environment, and update/install only what's necessary. Use Gettext.Tools from nuget on Windows for msgfmt. Fix cmake hardlinking script invocation by adding WORKING_DIRECTORY. Signed-off-by: Rafael Kitover <[email protected]>
- Loading branch information
Showing
5 changed files
with
174 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,3 +245,4 @@ Release/ | |
*.dSYM | ||
/contrib/buildsystems/out | ||
CMakeSettings.json | ||
build*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
include(Utilities) | ||
|
||
# | ||
# nuget_install([pkg_name]) | ||
# | ||
# Installs nuget.exe in the output directory if not already present | ||
# and uses it to install pkg_name if provided. | ||
# | ||
# If the package contains a 'tools/bin' directory, it will be | ||
# appended to CMAKE_PROGRAM_PATH. | ||
# | ||
# Throws a fatal error if any problems are encountered. | ||
# | ||
# Feel free to expand this function to support any other package | ||
# features you need. | ||
# | ||
function(nuget_install pkg) | ||
if(NOT EXISTS "${CMAKE_BINARY_DIR}/nuget.exe") | ||
file_download("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" "${CMAKE_BINARY_DIR}/nuget.exe" REQUIRED) | ||
|
||
# Add nuget package source if not already present. | ||
execute_process( | ||
COMMAND nuget sources add -Name "NuGet official package source" -Source "https://api.nuget.org/v3/index.json" | ||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" | ||
OUTPUT_QUIET | ||
ERROR_QUIET | ||
) | ||
endif() | ||
|
||
if("${pkg}" STREQUAL "") | ||
return() | ||
endif() | ||
|
||
execute_process( | ||
COMMAND nuget.exe install "${pkg}" -OutputDirectory "${CMAKE_BINARY_DIR}/nuget" | ||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" | ||
OUTPUT_VARIABLE install_output | ||
RESULT_VARIABLE install_exit_status | ||
) | ||
|
||
if(NOT install_exit_status EQUAL 0) | ||
message(FATAL_ERROR "NuGet installation of package '${pkg}' failed, exit code: ${install_exit_status}") | ||
endif() | ||
|
||
string(REGEX REPLACE ".* package '[^0-9]+([0-9.]+)'.*" "\\1" pkg_ver "${install_output}") | ||
|
||
set(pkg_dir "${CMAKE_BINARY_DIR}/nuget/${pkg}.${pkg_ver}") | ||
|
||
if(NOT IS_DIRECTORY "${pkg_dir}") | ||
message(FATAL_ERROR "NuGet installation of package '${pkg}' failed, package directory '${pkg_dir}' does not exist.") | ||
endif() | ||
|
||
set(pkg_bin "${pkg_dir}/tools/bin") | ||
|
||
if(IS_DIRECTORY "${pkg_bin}") | ||
list(APPEND CMAKE_PROGRAM_PATH "${pkg_bin}") | ||
set(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH}" PARENT_SCOPE) | ||
set(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH}" CACHE STRING "External Program Search Path" FORCE) | ||
endif() | ||
endfunction() | ||
|
||
# vim:set sw=8 ts=8 noet: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# | ||
# file_download(url dest_path [OPTIONS]) | ||
# | ||
# OPTIONS: | ||
# | ||
# - REQUIRED: Download must succeed, or fata error is thrown. | ||
# | ||
# - STATUS <out_var>: Store status list in out_var, see cmake | ||
# file(DOWNLOAD ...) STATUS parameter. | ||
# | ||
function(file_download url dest_path) | ||
if(NOT url OR NOT dest_path) | ||
message(FATAL_ERROR "file_download: syntax: file_download(url destination_path [OPTIONS]") | ||
endif() | ||
|
||
file(DOWNLOAD "${url}" "${dest_path}" STATUS status_list) | ||
list(GET status_list 0 status) | ||
|
||
if("STATUS" IN_LIST ARGN) | ||
list(FIND ARGN STATUS status_idx) | ||
math(EXPR out_var_idx "${status_idx} + 1") | ||
list(GET ARGN "${out_var_idx}" out_var) | ||
|
||
if("${out_var}" STREQUAL "") | ||
message(FATAL_ERROR "STATUS must be followed by output variable name for the status list.") | ||
endif() | ||
|
||
set("${out_var}" "${status_list}" PARENT_SCOPE) | ||
endif() | ||
|
||
if ("REQUIRED" IN_LIST ARGN) | ||
if(NOT status EQUAL 0) | ||
list(GET status_list 1 error_str) | ||
message(FATAL_ERROR "Download of '${url}' failed: ${error_str}") | ||
endif() | ||
endif() | ||
endfunction() | ||
|
||
# vim:set sw=8 ts=8 noet: |