mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-28 02:11:39 +08:00
Merge pull request #1873 from glachancecmaisonneuve/buildinstallcmakescriptsfix
Fix for BUILD_ARGS being always added in non ninja build (vcpkg_build_cmake,vcpkg_install_cmake)
This commit is contained in:
commit
74bab196c9
@ -3,6 +3,7 @@
|
||||
# Portfile helper functions
|
||||
- [vcpkg\_acquire\_msys](vcpkg_acquire_msys.md)
|
||||
- [vcpkg\_apply\_patches](vcpkg_apply_patches.md)
|
||||
- [vcpkg\_build\_cmake](vcpkg_build_cmake.md)
|
||||
- [vcpkg\_build\_msbuild](vcpkg_build_msbuild.md)
|
||||
- [vcpkg\_configure\_cmake](vcpkg_configure_cmake.md)
|
||||
- [vcpkg\_copy\_pdbs](vcpkg_copy_pdbs.md)
|
||||
@ -11,5 +12,6 @@
|
||||
- [vcpkg\_execute\_required\_process](vcpkg_execute_required_process.md)
|
||||
- [vcpkg\_extract\_source\_archive](vcpkg_extract_source_archive.md)
|
||||
- [vcpkg\_find\_acquire\_program](vcpkg_find_acquire_program.md)
|
||||
- [vcpkg\_from\_bitbucket](vcpkg_from_bitbucket.md)
|
||||
- [vcpkg\_from\_github](vcpkg_from_github.md)
|
||||
- [vcpkg\_install\_cmake](vcpkg_install_cmake.md)
|
||||
|
@ -32,7 +32,7 @@ message(STATUS "Installing MSYS Packages")
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND
|
||||
${BASH} --noprofile --norc -c
|
||||
"pacman -Sy --noconfirm --needed make"
|
||||
'PATH=/usr/bin:\$PATH pacman -Sy --noconfirm --needed make'
|
||||
WORKING_DIRECTORY ${MSYS_ROOT}
|
||||
LOGNAME pacman-${TARGET_TRIPLET})
|
||||
```
|
||||
|
31
docs/maintainers/vcpkg_build_cmake.md
Normal file
31
docs/maintainers/vcpkg_build_cmake.md
Normal file
@ -0,0 +1,31 @@
|
||||
# vcpkg_build_cmake
|
||||
|
||||
Build a cmake project.
|
||||
|
||||
## Usage:
|
||||
```cmake
|
||||
vcpkg_build_cmake([DISABLE_PARALLEL] [TARGET <target>])
|
||||
```
|
||||
|
||||
## Parameters:
|
||||
### DISABLE_PARALLEL
|
||||
The underlying buildsystem will be instructed to not parallelize
|
||||
|
||||
### TARGET
|
||||
The target passed to the cmake build command (`cmake --build . --target <target>`). If not specified, no target will
|
||||
be passed.
|
||||
|
||||
## Notes:
|
||||
This command should be preceeded by a call to [`vcpkg_configure_cmake()`](vcpkg_configure_cmake.md).
|
||||
You can use the alias [`vcpkg_install_cmake()`](vcpkg_configure_cmake.md) function if your CMake script supports the
|
||||
"install" target
|
||||
|
||||
## Examples:
|
||||
|
||||
* [zlib](https://github.com/Microsoft/vcpkg/blob/master/ports/zlib/portfile.cmake)
|
||||
* [cpprestsdk](https://github.com/Microsoft/vcpkg/blob/master/ports/cpprestsdk/portfile.cmake)
|
||||
* [poco](https://github.com/Microsoft/vcpkg/blob/master/ports/poco/portfile.cmake)
|
||||
* [opencv](https://github.com/Microsoft/vcpkg/blob/master/ports/opencv/portfile.cmake)
|
||||
|
||||
## Source
|
||||
[scripts/cmake/vcpkg_build_cmake.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_build_cmake.cmake)
|
@ -16,6 +16,7 @@ The current list of programs includes:
|
||||
- 7Z
|
||||
- BISON
|
||||
- FLEX
|
||||
- GASPREPROCESSOR
|
||||
- PERL
|
||||
- PYTHON2
|
||||
- PYTHON3
|
||||
@ -24,7 +25,6 @@ The current list of programs includes:
|
||||
- NASM
|
||||
- NINJA
|
||||
- YASM
|
||||
- GASPREPROCESSOR
|
||||
|
||||
Note that msys2 has a dedicated helper function: [`vcpkg_acquire_msys`](vcpkg_acquire_msys.md).
|
||||
|
||||
|
53
docs/maintainers/vcpkg_from_bitbucket.md
Normal file
53
docs/maintainers/vcpkg_from_bitbucket.md
Normal file
@ -0,0 +1,53 @@
|
||||
# vcpkg_from_bitbucket
|
||||
|
||||
Download and extract a project from Bitbucket.
|
||||
Enables support for installing HEAD `vcpkg.exe install --head <port>`.
|
||||
|
||||
## Usage:
|
||||
```cmake
|
||||
vcpkg_from_bitbucket(
|
||||
OUT_SOURCE_PATH <SOURCE_PATH>
|
||||
REPO <Microsoft/cpprestsdk>
|
||||
[REF <v2.0.0>]
|
||||
[SHA512 <45d0d7f8cc350...>]
|
||||
[HEAD_REF <master>]
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters:
|
||||
### OUT_SOURCE_PATH
|
||||
Specifies the out-variable that will contain the extracted location.
|
||||
|
||||
This should be set to `SOURCE_PATH` by convention.
|
||||
|
||||
### REPO
|
||||
The organization or user and repository on GitHub.
|
||||
|
||||
### REF
|
||||
A stable git commit-ish (ideally a tag) that will not change contents. **This should not be a branch.**
|
||||
|
||||
For repositories without official releases, this can be set to the full commit id of the current latest master.
|
||||
|
||||
If `REF` is specified, `SHA512` must also be specified.
|
||||
|
||||
### SHA512
|
||||
The SHA512 hash that should match the archive (https://bitbucket.com/${REPO}/get/${REF}.tar.gz).
|
||||
|
||||
This is most easily determined by first setting it to `1`, then trying to build the port. The error message will contain the full hash, which can be copied back into the portfile.
|
||||
|
||||
### HEAD_REF
|
||||
The unstable git commit-ish (ideally a branch) to pull for `--head` builds.
|
||||
|
||||
For most projects, this should be `master`. The chosen branch should be one that is expected to be always buildable on all supported platforms.
|
||||
|
||||
## Notes:
|
||||
At least one of `REF` and `HEAD_REF` must be specified, however it is preferable for both to be present.
|
||||
|
||||
This exports the `VCPKG_HEAD_VERSION` variable during head builds.
|
||||
|
||||
## Examples:
|
||||
|
||||
* [blaze](https://github.com/Microsoft/vcpkg/blob/master/ports/blaze/portfile.cmake)
|
||||
|
||||
## Source
|
||||
[scripts/cmake/vcpkg_from_bitbucket.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_from_bitbucket.cmake)
|
@ -23,7 +23,9 @@ This should be set to `SOURCE_PATH` by convention.
|
||||
The organization or user and repository on GitHub.
|
||||
|
||||
### REF
|
||||
A stable git commit-ish (ideally a tag) that will not change contents.
|
||||
A stable git commit-ish (ideally a tag) that will not change contents. **This should not be a branch.**
|
||||
|
||||
For repositories without official releases, this can be set to the full commit id of the current latest master.
|
||||
|
||||
If `REF` is specified, `SHA512` must also be specified.
|
||||
|
||||
@ -38,7 +40,7 @@ The unstable git commit-ish (ideally a branch) to pull for `--head` builds.
|
||||
For most projects, this should be `master`. The chosen branch should be one that is expected to be always buildable on all supported platforms.
|
||||
|
||||
## Notes:
|
||||
At least one of `REF` and `HEAD_REF` must be specified.
|
||||
At least one of `REF` and `HEAD_REF` must be specified, however it is preferable for both to be present.
|
||||
|
||||
This exports the `VCPKG_HEAD_VERSION` variable during head builds.
|
||||
|
||||
|
@ -4,15 +4,15 @@ Build and install a cmake project.
|
||||
|
||||
## Usage:
|
||||
```cmake
|
||||
vcpkg_install_cmake([MSVC_64_TOOLSET])
|
||||
vcpkg_install_cmake(...)
|
||||
```
|
||||
|
||||
## Parameters:
|
||||
### MSVC_64_TOOLSET
|
||||
This adds the `/p:PreferredToolArchitecture=x64` switch if the underlying buildsystem is MSBuild. Some large projects can run out of memory when linking if they use the 32-bit hosted tools.
|
||||
See [`vcpkg_build_cmake()`](vcpkg_build_cmake.md).
|
||||
|
||||
## Notes:
|
||||
This command should be preceeded by a call to [`vcpkg_configure_cmake()`](vcpkg_configure_cmake.md).
|
||||
This command transparently forwards to [`vcpkg_build_cmake()`](vcpkg_build_cmake.md), adding a `TARGET install`
|
||||
parameter.
|
||||
|
||||
## Examples:
|
||||
|
||||
|
@ -38,7 +38,7 @@ vcpkg_configure_cmake(
|
||||
# Folly runs built executables during the build, so they need access to the installed DLLs.
|
||||
set(ENV{PATH} "$ENV{PATH};${CURRENT_INSTALLED_DIR}/bin;${CURRENT_INSTALLED_DIR}/debug/bin")
|
||||
|
||||
vcpkg_install_cmake(MSVC_64_TOOLSET)
|
||||
vcpkg_install_cmake()
|
||||
|
||||
vcpkg_copy_pdbs()
|
||||
|
||||
|
@ -58,8 +58,7 @@ vcpkg_configure_cmake(
|
||||
-DCMAKE_INSTALL_CMAKEDIR=share/protobuf
|
||||
)
|
||||
|
||||
# Using 64-bit toolset to avoid occassional Linker Out-of-Memory issues.
|
||||
vcpkg_install_cmake(MSVC_64_TOOLSET)
|
||||
vcpkg_install_cmake()
|
||||
|
||||
# It appears that at this point the build hasn't actually finished. There is probably
|
||||
# a process spawned by the build, therefore we need to wait a bit.
|
||||
|
@ -1,41 +1,76 @@
|
||||
## # vcpkg_build_cmake
|
||||
##
|
||||
## Build a cmake project.
|
||||
##
|
||||
## ## Usage:
|
||||
## ```cmake
|
||||
## vcpkg_build_cmake([DISABLE_PARALLEL] [TARGET <target>])
|
||||
## ```
|
||||
##
|
||||
## ## Parameters:
|
||||
## ### DISABLE_PARALLEL
|
||||
## The underlying buildsystem will be instructed to not parallelize
|
||||
##
|
||||
## ### TARGET
|
||||
## The target passed to the cmake build command (`cmake --build . --target <target>`). If not specified, no target will
|
||||
## be passed.
|
||||
##
|
||||
## ## Notes:
|
||||
## This command should be preceeded by a call to [`vcpkg_configure_cmake()`](vcpkg_configure_cmake.md).
|
||||
## You can use the alias [`vcpkg_install_cmake()`](vcpkg_configure_cmake.md) function if your CMake script supports the
|
||||
## "install" target
|
||||
##
|
||||
## ## Examples:
|
||||
##
|
||||
## * [zlib](https://github.com/Microsoft/vcpkg/blob/master/ports/zlib/portfile.cmake)
|
||||
## * [cpprestsdk](https://github.com/Microsoft/vcpkg/blob/master/ports/cpprestsdk/portfile.cmake)
|
||||
## * [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_build_cmake)
|
||||
cmake_parse_arguments(_bc "MSVC_64_TOOLSET;DISABLE_PARALLEL" "" "" ${ARGN})
|
||||
cmake_parse_arguments(_bc "DISABLE_PARALLEL" "TARGET;LOGFILE_ROOT" "" ${ARGN})
|
||||
|
||||
set(MSVC_EXTRA_ARGS
|
||||
"/p:VCPkgLocalAppDataDisabled=true"
|
||||
"/p:UseIntelMKL=No"
|
||||
)
|
||||
|
||||
# Specifies the architecture of the toolset, NOT the architecture of the produced binary
|
||||
# This can help libraries that cause the linker to run out of memory.
|
||||
# https://support.microsoft.com/en-us/help/2891057/linker-fatal-error-lnk1102-out-of-memory
|
||||
if (_bc_MSVC_64_TOOLSET)
|
||||
list(APPEND MSVC_EXTRA_ARGS "/p:PreferredToolArchitecture=x64")
|
||||
if(NOT _bc_LOGFILE_ROOT)
|
||||
set(_bc_LOGFILE_ROOT "build")
|
||||
endif()
|
||||
|
||||
if (NOT _bc_DISABLE_PARALLEL)
|
||||
list(APPEND MSVC_EXTRA_ARGS "/m")
|
||||
endif()
|
||||
|
||||
if(EXISTS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/build.ninja)
|
||||
set(BUILD_ARGS -v) # verbose output
|
||||
if(_VCPKG_CMAKE_GENERATOR MATCHES "Ninja")
|
||||
set(BUILD_ARGS "-v") # verbose output
|
||||
if (_bc_DISABLE_PARALLEL)
|
||||
list(APPEND BUILD_ARGS "-j1")
|
||||
endif()
|
||||
elseif(_VCPKG_CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
set(BUILD_ARGS
|
||||
"/p:VCPkgLocalAppDataDisabled=true"
|
||||
"/p:UseIntelMKL=No"
|
||||
)
|
||||
if (NOT _bc_DISABLE_PARALLEL)
|
||||
list(APPEND BUILD_ARGS "/m")
|
||||
endif()
|
||||
elseif(_VCPKG_CMAKE_GENERATOR MATCHES "NMake")
|
||||
# No options are currently added for nmake builds
|
||||
else()
|
||||
set(BUILD_ARGS ${MSVC_EXTRA_ARGS})
|
||||
message(FATAL_ERROR "Unrecognized GENERATOR setting from vcpkg_configure_cmake(). Valid generators are: Ninja, Visual Studio, and NMake Makefiles")
|
||||
endif()
|
||||
|
||||
if(_bc_TARGET)
|
||||
set(TARGET_PARAM "--target" ${_bc_TARGET})
|
||||
else()
|
||||
set(TARGET_PARAM)
|
||||
endif()
|
||||
|
||||
message(STATUS "Build ${TARGET_TRIPLET}-rel")
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND ${CMAKE_COMMAND} --build . --config Release -- ${BUILD_ARGS}
|
||||
COMMAND ${CMAKE_COMMAND} --build . --config Release ${TARGET_PARAM} -- ${BUILD_ARGS}
|
||||
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
|
||||
LOGNAME build-${TARGET_TRIPLET}-rel
|
||||
LOGNAME ${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-rel
|
||||
)
|
||||
message(STATUS "Build ${TARGET_TRIPLET}-rel done")
|
||||
|
||||
message(STATUS "Build ${TARGET_TRIPLET}-dbg")
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND ${CMAKE_COMMAND} --build . --config Debug -- ${BUILD_ARGS}
|
||||
COMMAND ${CMAKE_COMMAND} --build . --config Debug ${TARGET_PARAM} -- ${BUILD_ARGS}
|
||||
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
|
||||
LOGNAME build-${TARGET_TRIPLET}-dbg
|
||||
LOGNAME ${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-dbg
|
||||
)
|
||||
message(STATUS "Build ${TARGET_TRIPLET}-dbg done")
|
||||
endfunction()
|
||||
|
@ -188,4 +188,6 @@ function(vcpkg_configure_cmake)
|
||||
LOGNAME config-${TARGET_TRIPLET}-dbg
|
||||
)
|
||||
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg done")
|
||||
|
||||
set(_VCPKG_CMAKE_GENERATOR "${GENERATOR}" PARENT_SCOPE)
|
||||
endfunction()
|
@ -4,15 +4,15 @@
|
||||
##
|
||||
## ## Usage:
|
||||
## ```cmake
|
||||
## vcpkg_install_cmake([MSVC_64_TOOLSET])
|
||||
## vcpkg_install_cmake(...)
|
||||
## ```
|
||||
##
|
||||
## ## Parameters:
|
||||
## ### MSVC_64_TOOLSET
|
||||
## This adds the `/p:PreferredToolArchitecture=x64` switch if the underlying buildsystem is MSBuild. Some large projects can run out of memory when linking if they use the 32-bit hosted tools.
|
||||
## See [`vcpkg_build_cmake()`](vcpkg_build_cmake.md).
|
||||
##
|
||||
## ## Notes:
|
||||
## This command should be preceeded by a call to [`vcpkg_configure_cmake()`](vcpkg_configure_cmake.md).
|
||||
## This command transparently forwards to [`vcpkg_build_cmake()`](vcpkg_build_cmake.md), adding a `TARGET install`
|
||||
## parameter.
|
||||
##
|
||||
## ## Examples:
|
||||
##
|
||||
@ -21,43 +21,5 @@
|
||||
## * [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_install_cmake)
|
||||
cmake_parse_arguments(_bc "MSVC_64_TOOLSET;DISABLE_PARALLEL" "" "" ${ARGN})
|
||||
|
||||
set(MSVC_EXTRA_ARGS
|
||||
"/p:VCPkgLocalAppDataDisabled=true"
|
||||
"/p:UseIntelMKL=No"
|
||||
)
|
||||
|
||||
# Specifies the architecture of the toolset, NOT the architecture of the produced binary
|
||||
# This can help libraries that cause the linker to run out of memory.
|
||||
# https://support.microsoft.com/en-us/help/2891057/linker-fatal-error-lnk1102-out-of-memory
|
||||
if (_bc_MSVC_64_TOOLSET)
|
||||
list(APPEND MSVC_EXTRA_ARGS "/p:PreferredToolArchitecture=x64")
|
||||
endif()
|
||||
|
||||
if (NOT _bc_DISABLE_PARALLEL)
|
||||
list(APPEND MSVC_EXTRA_ARGS "/m")
|
||||
endif()
|
||||
|
||||
if(EXISTS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/build.ninja)
|
||||
set(BUILD_ARGS -v) # verbose output
|
||||
else()
|
||||
set(BUILD_ARGS ${MSVC_EXTRA_ARGS})
|
||||
endif()
|
||||
|
||||
message(STATUS "Package ${TARGET_TRIPLET}-rel")
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND ${CMAKE_COMMAND} --build . --config Release --target install -- ${BUILD_ARGS}
|
||||
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
|
||||
LOGNAME package-${TARGET_TRIPLET}-rel
|
||||
)
|
||||
message(STATUS "Package ${TARGET_TRIPLET}-rel done")
|
||||
|
||||
message(STATUS "Package ${TARGET_TRIPLET}-dbg")
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND ${CMAKE_COMMAND} --build . --config Debug --target install -- ${BUILD_ARGS}
|
||||
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
|
||||
LOGNAME package-${TARGET_TRIPLET}-dbg
|
||||
)
|
||||
message(STATUS "Package ${TARGET_TRIPLET}-dbg done")
|
||||
vcpkg_build_cmake(LOGFILE_ROOT install TARGET install ${ARGN})
|
||||
endfunction()
|
||||
|
Loading…
Reference in New Issue
Block a user