2017-09-26 01:05:32 +08:00
## # vcpkg_build_cmake
##
## Build a cmake project.
##
## ## Usage:
## ```cmake
## vcpkg_build_cmake([MSVC_64_TOOLSET] [DISABLE_PARALLEL])
## ```
##
## ## 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
##
## ## 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
##
## ## 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 )
2017-01-14 11:09:42 +08:00
cmake_parse_arguments ( _bc "MSVC_64_TOOLSET;DISABLE_PARALLEL" "" "" ${ ARGN } )
2017-01-14 09:30:48 +08:00
2017-02-04 09:46:09 +08:00
set ( MSVC_EXTRA_ARGS
" / p : V C P k g L o c a l A p p D a t a D i s a b l e d = t r u e "
" / p : U s e I n t e l M K L = N o "
)
2017-01-14 09:30:48 +08:00
# Specifies the architecture of the toolset, NOT the architecture of the produced binary
2017-02-04 09:46:09 +08:00
# 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
2017-01-14 09:30:48 +08:00
if ( _bc_MSVC_64_TOOLSET )
list ( APPEND MSVC_EXTRA_ARGS "/p:PreferredToolArchitecture=x64" )
endif ( )
2017-01-14 11:09:42 +08:00
if ( NOT _bc_DISABLE_PARALLEL )
list ( APPEND MSVC_EXTRA_ARGS "/m" )
endif ( )
2017-02-04 00:16:13 +08:00
if ( EXISTS ${ CURRENT_BUILDTREES_DIR } / ${ TARGET_TRIPLET } -rel/build.ninja )
set ( BUILD_ARGS -v ) # verbose output
2017-09-26 01:05:32 +08:00
endif ( )
if ( _bc_MSVC_64_TOOLSET )
2017-02-04 00:16:13 +08:00
set ( BUILD_ARGS ${ MSVC_EXTRA_ARGS } )
endif ( )
2016-09-19 11:50:08 +08:00
message ( STATUS "Build ${TARGET_TRIPLET}-rel" )
vcpkg_execute_required_process (
2017-02-04 00:16:13 +08:00
C O M M A N D $ { C M A K E _ C O M M A N D } - - b u i l d . - - c o n f i g R e l e a s e - - $ { B U I L D _ A R G S }
2016-09-19 11:50:08 +08:00
W O R K I N G _ D I R E C T O R Y $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { T A R G E T _ T R I P L E T } - r e l
L O G N A M E b u i l d - $ { T A R G E T _ T R I P L E T } - r e l
)
message ( STATUS "Build ${TARGET_TRIPLET}-rel done" )
message ( STATUS "Build ${TARGET_TRIPLET}-dbg" )
vcpkg_execute_required_process (
2017-02-04 00:16:13 +08:00
C O M M A N D $ { C M A K E _ C O M M A N D } - - b u i l d . - - c o n f i g D e b u g - - $ { B U I L D _ A R G S }
2016-09-19 11:50:08 +08:00
W O R K I N G _ D I R E C T O R Y $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { T A R G E T _ T R I P L E T } - d b g
L O G N A M E b u i l d - $ { T A R G E T _ T R I P L E T } - d b g
)
message ( STATUS "Build ${TARGET_TRIPLET}-dbg done" )
endfunction ( )