2021-05-09 19:47:21 +02:00
|
|
|
# DEPRECATED BY ports/vcpkg-cmake/vcpkg_cmake_build
|
2020-12-01 13: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
|
2021-11-05 16:55:14 -07:00
|
|
|
Adds the appropriate Release and Debug `bin` directories to the path during the build such that executables can run against the in-tree DLLs.
|
2020-12-01 13:37:26 -08:00
|
|
|
|
|
|
|
## Notes:
|
2021-05-09 19:48:42 +02:00
|
|
|
This command should be preceded by a call to [`vcpkg_configure_cmake()`](vcpkg_configure_cmake.md).
|
2020-12-01 13: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-18 20:50:08 -07:00
|
|
|
function(vcpkg_build_cmake)
|
2021-02-28 13:17:19 -08:00
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 "arg"
|
2021-03-02 17:03:34 -08:00
|
|
|
"DISABLE_PARALLEL;ADD_BIN_TO_PATH"
|
2021-02-28 13: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-13 17:30:48 -08:00
|
|
|
|
2021-11-05 16:55:14 -07:00
|
|
|
if(NOT DEFINED arg_LOGFILE_ROOT)
|
2021-02-28 13:17:19 -08:00
|
|
|
set(arg_LOGFILE_ROOT "build")
|
2017-01-13 17:30:48 -08:00
|
|
|
endif()
|
|
|
|
|
2021-11-05 16:55:14 -07:00
|
|
|
vcpkg_list(SET build_param)
|
|
|
|
vcpkg_list(SET parallel_param)
|
|
|
|
vcpkg_list(SET no_parallel_param)
|
2017-10-19 17:19:11 -07:00
|
|
|
|
2021-11-05 16:55:14 -07:00
|
|
|
if("${Z_VCPKG_CMAKE_GENERATOR}" STREQUAL "Ninja")
|
|
|
|
vcpkg_list(SET build_param "-v") # verbose output
|
|
|
|
vcpkg_list(SET parallel_param "-j${VCPKG_CONCURRENCY}")
|
|
|
|
vcpkg_list(SET no_parallel_param "-j1")
|
|
|
|
elseif("${Z_VCPKG_CMAKE_GENERATOR}" MATCHES "^Visual Studio")
|
|
|
|
vcpkg_list(SET build_param
|
2017-10-05 17:49:28 -07:00
|
|
|
"/p:VCPkgLocalAppDataDisabled=true"
|
|
|
|
"/p:UseIntelMKL=No"
|
|
|
|
)
|
2021-11-05 16:55:14 -07:00
|
|
|
vcpkg_list(SET parallel_param "/m")
|
|
|
|
elseif("${Z_VCPKG_CMAKE_GENERATOR}" STREQUAL "NMake Makefiles")
|
2017-10-05 17:49:28 -07: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-13 19:09:42 -08:00
|
|
|
endif()
|
|
|
|
|
2021-11-05 16:55:14 -07:00
|
|
|
vcpkg_list(SET target_param)
|
2021-02-28 13:17:19 -08:00
|
|
|
if(arg_TARGET)
|
2021-11-05 16:55:14 -07:00
|
|
|
vcpkg_list(SET target_param "--target" "${arg_TARGET}")
|
2017-02-03 17:16:13 +01:00
|
|
|
endif()
|
|
|
|
|
2021-11-05 16:55:14 -07:00
|
|
|
foreach(build_type IN ITEMS debug release)
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "${build_type}")
|
|
|
|
if("${build_type}" STREQUAL "debug")
|
|
|
|
set(short_build_type "dbg")
|
|
|
|
set(config "Debug")
|
2017-10-19 17:19:11 -07:00
|
|
|
else()
|
2021-11-05 16:55:14 -07:00
|
|
|
set(short_build_type "rel")
|
|
|
|
set(config "Release")
|
2017-10-19 17:19:11 -07:00
|
|
|
endif()
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2021-11-05 16:55:14 -07:00
|
|
|
message(STATUS "Building ${TARGET_TRIPLET}-${short_build_type}")
|
2017-10-19 17:19:11 -07:00
|
|
|
|
2021-02-28 13:17:19 -08:00
|
|
|
if(arg_ADD_BIN_TO_PATH)
|
2021-11-05 16:55:14 -07:00
|
|
|
vcpkg_backup_env_variables(VARS PATH)
|
|
|
|
if("${build_type}" STREQUAL "debug")
|
2020-06-03 19:31:28 -07:00
|
|
|
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/debug/bin")
|
2018-03-19 10:30:33 -07:00
|
|
|
else()
|
2020-06-03 19:31:28 -07:00
|
|
|
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/bin")
|
2018-03-19 10:30:33 -07:00
|
|
|
endif()
|
2017-10-19 17:19:11 -07:00
|
|
|
endif()
|
2018-04-17 16:21:36 -07:00
|
|
|
|
2021-11-05 16:55:14 -07:00
|
|
|
if(arg_DISABLE_PARALLEL)
|
2019-06-12 14:18:43 -07:00
|
|
|
vcpkg_execute_build_process(
|
2021-11-05 16:55:14 -07:00
|
|
|
COMMAND
|
|
|
|
"${CMAKE_COMMAND}" --build . --config "${config}" ${target_param}
|
|
|
|
-- ${build_param} ${no_parallel_param}
|
|
|
|
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_build_type}"
|
|
|
|
LOGNAME "${arg_LOGFILE_ROOT}-${TARGET_TRIPLET}-${short_build_type}"
|
2019-06-12 14:18:43 -07:00
|
|
|
)
|
|
|
|
else()
|
|
|
|
vcpkg_execute_build_process(
|
2021-11-05 16:55:14 -07:00
|
|
|
COMMAND
|
|
|
|
"${CMAKE_COMMAND}" --build . --config "${config}" ${target_param}
|
|
|
|
-- ${build_param} ${parallel_param}
|
|
|
|
NO_PARALLEL_COMMAND
|
|
|
|
"${CMAKE_COMMAND}" --build . --config "${config}" ${target_param}
|
|
|
|
-- ${build_param} ${no_parallel_param}
|
|
|
|
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_build_type}"
|
|
|
|
LOGNAME "${arg_LOGFILE_ROOT}-${TARGET_TRIPLET}-${short_build_type}"
|
2019-06-12 14:18:43 -07:00
|
|
|
)
|
2017-10-19 17:19:11 -07:00
|
|
|
endif()
|
2019-06-12 14:18:43 -07:00
|
|
|
|
2021-02-28 13:17:19 -08:00
|
|
|
if(arg_ADD_BIN_TO_PATH)
|
2021-11-05 16:55:14 -07:00
|
|
|
vcpkg_restore_env_variables(VARS PATH)
|
2018-03-19 10:30:33 -07:00
|
|
|
endif()
|
2017-10-19 17:19:11 -07:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2016-09-18 20:50:08 -07:00
|
|
|
endfunction()
|