diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/cmake/vcpkg_build_cmake.cmake | 65 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_configure_cmake.cmake | 2 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_install_cmake.cmake | 50 |
3 files changed, 43 insertions, 74 deletions
diff --git a/scripts/cmake/vcpkg_build_cmake.cmake b/scripts/cmake/vcpkg_build_cmake.cmake index 546071a36..5dc81ec09 100644 --- a/scripts/cmake/vcpkg_build_cmake.cmake +++ b/scripts/cmake/vcpkg_build_cmake.cmake @@ -4,19 +4,21 @@ ## ## ## Usage: ## ```cmake -## vcpkg_build_cmake([MSVC_64_TOOLSET] [DISABLE_PARALLEL]) +## vcpkg_build_cmake([DISABLE_PARALLEL] [TARGET <target>]) ## ``` ## ## ## Parameters: -## ### MSVC_64_TOOLSET -## This adds the `/p:PreferredToolArchitecture=x64` switch to the underlying buildsystem parameters. Some large projects can run out of memory when linking if they use the 32-bit hosted tools. -## ## ### DISABLE_PARALLEL -## The /m parameter will not be added to the underlying buildsystem parameters +## 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). -## Use [`vcpkg_install_cmake()`](vcpkg_configure_cmake.md) function if your CMake script supports the "install" target +## You can use the alias [`vcpkg_install_cmake()`](vcpkg_configure_cmake.md) function if your CMake script supports the +## "install" target ## ## ## Examples: ## @@ -25,45 +27,50 @@ ## * [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}) - - set(MSVC_EXTRA_ARGS - "/p:VCPkgLocalAppDataDisabled=true" - "/p:UseIntelMKL=No" - ) + cmake_parse_arguments(_bc "DISABLE_PARALLEL" "TARGET;LOGFILE_ROOT" "" ${ARGN}) - # 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") + 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() + message(FATAL_ERROR "Unrecognized GENERATOR setting from vcpkg_configure_cmake(). Valid generators are: Ninja, Visual Studio, and NMake Makefiles") endif() - if(EXISTS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/build.ninja) - set(BUILD_ARGS -v) # verbose output - endif() - - if(_bc_MSVC_64_TOOLSET) - set(BUILD_ARGS ${MSVC_EXTRA_ARGS}) + 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() diff --git a/scripts/cmake/vcpkg_configure_cmake.cmake b/scripts/cmake/vcpkg_configure_cmake.cmake index fecea8f1c..fe8c97c52 100644 --- a/scripts/cmake/vcpkg_configure_cmake.cmake +++ b/scripts/cmake/vcpkg_configure_cmake.cmake @@ -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()
\ No newline at end of file diff --git a/scripts/cmake/vcpkg_install_cmake.cmake b/scripts/cmake/vcpkg_install_cmake.cmake index 34ac15fe6..ab72d054e 100644 --- a/scripts/cmake/vcpkg_install_cmake.cmake +++ b/scripts/cmake/vcpkg_install_cmake.cmake @@ -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 to the underlying buildsystem parameters. 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,45 +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 - endif() - - if(_bc_MSVC_64_TOOLSET) - 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() |
