2020-12-02 05:37:26 +08:00
|
|
|
#[===[.md:
|
|
|
|
# vcpkg_configure_gn
|
|
|
|
|
|
|
|
Generate Ninja (GN) targets
|
|
|
|
|
|
|
|
## Usage:
|
|
|
|
```cmake
|
|
|
|
vcpkg_configure_gn(
|
|
|
|
SOURCE_PATH <SOURCE_PATH>
|
|
|
|
[OPTIONS <OPTIONS>]
|
|
|
|
[OPTIONS_DEBUG <OPTIONS_DEBUG>]
|
|
|
|
[OPTIONS_RELEASE <OPTIONS_RELEASE>]
|
|
|
|
)
|
|
|
|
```
|
|
|
|
|
|
|
|
## Parameters:
|
|
|
|
### SOURCE_PATH (required)
|
|
|
|
The path to the GN project.
|
|
|
|
|
|
|
|
### OPTIONS
|
|
|
|
Options to be passed to both the debug and release targets.
|
|
|
|
Note: Must be provided as a space-separated string.
|
|
|
|
|
|
|
|
### OPTIONS_DEBUG (space-separated string)
|
|
|
|
Options to be passed to the debug target.
|
|
|
|
|
|
|
|
### OPTIONS_RELEASE (space-separated string)
|
|
|
|
Options to be passed to the release target.
|
|
|
|
#]===]
|
2020-05-12 05:58:12 +08:00
|
|
|
|
2021-05-18 02:08:33 +08:00
|
|
|
function(z_vcpkg_configure_gn_generate)
|
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "SOURCE_PATH;CONFIG;ARGS" "")
|
|
|
|
if(DEFINED arg_UNPARSED_ARGUMENTS)
|
|
|
|
message(FATAL_ERROR "Internal error: generate was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "Generating build (${arg_CONFIG})...")
|
|
|
|
vcpkg_execute_required_process(
|
|
|
|
COMMAND "${GN}" gen "${CURRENT_BUILDTREES_DIR}/${arg_CONFIG}" "${arg_ARGS}"
|
|
|
|
WORKING_DIRECTORY "${arg_SOURCE_PATH}"
|
|
|
|
LOGNAME "generate-${arg_CONFIG}"
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
2020-05-12 05:58:12 +08:00
|
|
|
function(vcpkg_configure_gn)
|
2021-05-18 02:08:33 +08:00
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "SOURCE_PATH;OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" "")
|
2020-05-12 05:58:12 +08:00
|
|
|
|
2021-05-18 02:08:33 +08:00
|
|
|
if(DEFINED arg_UNPARSED_ARGUMENTS)
|
|
|
|
message(WARNING "vcpkg_configure_gn was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
|
|
|
|
endif()
|
|
|
|
if(NOT DEFINED arg_SOURCE_PATH)
|
2020-05-12 05:58:12 +08:00
|
|
|
message(FATAL_ERROR "SOURCE_PATH must be specified.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
vcpkg_find_acquire_program(PYTHON2)
|
|
|
|
get_filename_component(PYTHON2_DIR "${PYTHON2}" DIRECTORY)
|
|
|
|
vcpkg_add_to_path(PREPEND "${PYTHON2_DIR}")
|
|
|
|
|
|
|
|
vcpkg_find_acquire_program(GN)
|
|
|
|
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
2021-05-18 02:08:33 +08:00
|
|
|
z_vcpkg_configure_gn_generate(
|
|
|
|
SOURCE_PATH "${arg_SOURCE_PATH}"
|
|
|
|
CONFIG "${TARGET_TRIPLET}-dbg"
|
|
|
|
ARGS "--args=${arg_OPTIONS} ${arg_OPTIONS_DEBUG}"
|
|
|
|
)
|
2020-05-12 05:58:12 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
2021-05-18 02:08:33 +08:00
|
|
|
z_vcpkg_configure_gn_generate(
|
|
|
|
SOURCE_PATH "${arg_SOURCE_PATH}"
|
|
|
|
CONFIG "${TARGET_TRIPLET}-rel"
|
|
|
|
ARGS "--args=${arg_OPTIONS} ${arg_OPTIONS_RELEASE}"
|
|
|
|
)
|
2020-05-12 05:58:12 +08:00
|
|
|
endif()
|
2020-12-02 05:37:26 +08:00
|
|
|
endfunction()
|