2021-05-10 01:47:21 +08:00
|
|
|
# DEPRECATED BY ports/vcpkg-cmake/vcpkg_cmake_build
|
2020-12-02 05:37:26 +08:00
|
|
|
#[===[.md:
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
### ADD_BIN_TO_PATH
|
|
|
|
Adds the appropriate Release and Debug `bin\` directories to the path during the build such that executables can run against the in-tree DLLs.
|
|
|
|
|
|
|
|
## Notes:
|
2021-05-10 01:48:42 +08:00
|
|
|
This command should be preceded by a call to [`vcpkg_configure_cmake()`](vcpkg_configure_cmake.md).
|
2020-12-02 05:37:26 +08:00
|
|
|
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)
|
|
|
|
#]===]
|
|
|
|
|
2016-09-19 11:50:08 +08:00
|
|
|
function(vcpkg_build_cmake)
|
2021-03-01 05:17:19 +08:00
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 "arg"
|
2021-03-03 09:03:34 +08:00
|
|
|
"DISABLE_PARALLEL;ADD_BIN_TO_PATH"
|
2021-03-01 05:17:19 +08:00
|
|
|
"TARGET;LOGFILE_ROOT"
|
|
|
|
""
|
|
|
|
)
|
|
|
|
|
|
|
|
if(Z_VCPKG_CMAKE_BUILD_GUARD)
|
|
|
|
message(FATAL_ERROR "The ${PORT} port already depends on vcpkg-cmake; using both vcpkg-cmake and vcpkg_build_cmake in the same port is unsupported.")
|
|
|
|
endif()
|
2017-01-14 09:30:48 +08:00
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
if(NOT arg_LOGFILE_ROOT)
|
|
|
|
set(arg_LOGFILE_ROOT "build")
|
2017-01-14 09:30:48 +08:00
|
|
|
endif()
|
|
|
|
|
2017-10-20 08:19:11 +08:00
|
|
|
set(PARALLEL_ARG)
|
|
|
|
set(NO_PARALLEL_ARG)
|
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
if(Z_VCPKG_CMAKE_GENERATOR MATCHES "Ninja")
|
2017-10-06 08:49:28 +08:00
|
|
|
set(BUILD_ARGS "-v") # verbose output
|
2020-09-26 20:17:05 +08:00
|
|
|
set(PARALLEL_ARG "-j${VCPKG_CONCURRENCY}")
|
2018-01-04 12:11:35 +08:00
|
|
|
set(NO_PARALLEL_ARG "-j1")
|
2021-03-01 05:17:19 +08:00
|
|
|
elseif(Z_VCPKG_CMAKE_GENERATOR MATCHES "Visual Studio")
|
2017-10-06 08:49:28 +08:00
|
|
|
set(BUILD_ARGS
|
|
|
|
"/p:VCPkgLocalAppDataDisabled=true"
|
|
|
|
"/p:UseIntelMKL=No"
|
|
|
|
)
|
2018-01-04 12:11:35 +08:00
|
|
|
set(PARALLEL_ARG "/m")
|
2021-03-01 05:17:19 +08:00
|
|
|
elseif(Z_VCPKG_CMAKE_GENERATOR MATCHES "NMake")
|
2017-10-06 08:49:28 +08:00
|
|
|
# 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")
|
2017-01-14 11:09:42 +08:00
|
|
|
endif()
|
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
if(arg_TARGET)
|
|
|
|
set(TARGET_PARAM "--target" ${arg_TARGET})
|
2017-10-06 08:49:28 +08:00
|
|
|
else()
|
|
|
|
set(TARGET_PARAM)
|
2017-02-04 00:16:13 +08:00
|
|
|
endif()
|
|
|
|
|
2018-02-13 16:00:27 +08:00
|
|
|
foreach(BUILDTYPE "debug" "release")
|
2017-10-20 08:19:11 +08:00
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL BUILDTYPE)
|
|
|
|
if(BUILDTYPE STREQUAL "debug")
|
|
|
|
set(SHORT_BUILDTYPE "dbg")
|
2018-03-20 01:30:33 +08:00
|
|
|
set(CONFIG "Debug")
|
2017-10-20 08:19:11 +08:00
|
|
|
else()
|
|
|
|
set(SHORT_BUILDTYPE "rel")
|
2018-03-20 01:30:33 +08:00
|
|
|
set(CONFIG "Release")
|
2017-10-20 08:19:11 +08:00
|
|
|
endif()
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2018-06-27 12:48:29 +08:00
|
|
|
message(STATUS "Building ${TARGET_TRIPLET}-${SHORT_BUILDTYPE}")
|
2017-10-20 08:19:11 +08:00
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
if(arg_ADD_BIN_TO_PATH)
|
2018-03-20 01:30:33 +08:00
|
|
|
set(_BACKUP_ENV_PATH "$ENV{PATH}")
|
|
|
|
if(BUILDTYPE STREQUAL "debug")
|
2020-06-04 10:31:28 +08:00
|
|
|
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/debug/bin")
|
2018-03-20 01:30:33 +08:00
|
|
|
else()
|
2020-06-04 10:31:28 +08:00
|
|
|
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/bin")
|
2018-03-20 01:30:33 +08:00
|
|
|
endif()
|
2017-10-20 08:19:11 +08:00
|
|
|
endif()
|
2018-04-18 07:21:36 +08:00
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
if (arg_DISABLE_PARALLEL)
|
2019-06-13 05:18:43 +08:00
|
|
|
vcpkg_execute_build_process(
|
|
|
|
COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${NO_PARALLEL_ARG}
|
|
|
|
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE}
|
2021-03-01 05:17:19 +08:00
|
|
|
LOGNAME "${arg_LOGFILE_ROOT}-${TARGET_TRIPLET}-${SHORT_BUILDTYPE}"
|
2019-06-13 05:18:43 +08:00
|
|
|
)
|
|
|
|
else()
|
|
|
|
vcpkg_execute_build_process(
|
|
|
|
COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${PARALLEL_ARG}
|
|
|
|
NO_PARALLEL_COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${NO_PARALLEL_ARG}
|
|
|
|
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE}
|
2021-03-01 05:17:19 +08:00
|
|
|
LOGNAME "${arg_LOGFILE_ROOT}-${TARGET_TRIPLET}-${SHORT_BUILDTYPE}"
|
2019-06-13 05:18:43 +08:00
|
|
|
)
|
2017-10-20 08:19:11 +08:00
|
|
|
endif()
|
2019-06-13 05:18:43 +08:00
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
if(arg_ADD_BIN_TO_PATH)
|
2018-03-20 01:30:33 +08:00
|
|
|
set(ENV{PATH} "${_BACKUP_ENV_PATH}")
|
|
|
|
endif()
|
2017-10-20 08:19:11 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2016-09-19 11:50:08 +08:00
|
|
|
endfunction()
|