vcpkg/scripts/cmake/vcpkg_build_ninja.cmake
nicole mazzuca 0e1dc12185
[rollup] Rollup PR 2021-07-16 (#19001)
* [rollup:2021-07-16 1/7] PR #18201 (@JackBoosY)

[vcpkg-cmake] Add check for unused cmake variables

* [rollup:2021-07-16 2/7] PR #18397 (@strega-nil)

[vcpkg_list] add new function

* [rollup:2021-07-16 3/7] PR #18782 (@strega-nil)

[scripts-audit] vcpkg_build_ninja

* [rollup:2021-07-16 4/7] PR #18784 (@strega-nil)

[scripts-audit] vcpkg_minimum_required

* [rollup:2021-07-16 5/7] PR #18785 (@strega-nil)

[scripts-audit] vcpkg_replace_string

* [rollup:2021-07-16 6/7] PR #18786 (@strega-nil)

[scripts-audit] windows scripts

* [rollup:2021-07-16 7/7] PR #18945 (@strega-nil)

[many ports] remove deprecated vcpkg_check_features call [1/5]

Co-authored-by: nicole mazzuca <mazzucan@outlook.com>
Co-authored-by: PhoebeHui <20694052+PhoebeHui@users.noreply.github.com>
2021-07-20 10:24:58 -07:00

48 lines
1.2 KiB
CMake

#[===[.md:
# vcpkg_build_ninja
Build a ninja project
## Usage:
```cmake
vcpkg_build_ninja(
[TARGETS <target>...]
)
```
## Parameters:
### TARGETS
Only build the specified targets.
#]===]
function(z_vcpkg_build_ninja_build config targets)
message(STATUS "Building (${config})...")
vcpkg_execute_build_process(
COMMAND "${NINJA}" -C "${CURRENT_BUILDTREES_DIR}/${config}" ${targets}
WORKING_DIRECTORY "${SOURCE_PATH}"
LOGNAME "build-${config}"
)
endfunction()
function(vcpkg_build_ninja)
cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "TARGETS")
if(DEFINED arg_UNPARSED_ARGUMENTS)
message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()
if(NOT DEFINED arg_TARGETS)
set(arg_TARGETS "")
endif()
vcpkg_find_acquire_program(NINJA)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
z_vcpkg_build_ninja_build("${TARGET_TRIPLET}-dbg" "${arg_TARGETS}")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
z_vcpkg_build_ninja_build("${TARGET_TRIPLET}-rel" "${arg_TARGETS}")
endif()
endfunction()