2018-08-08 19:15:13 +08:00
function ( vcpkg_install_msbuild )
cmake_parse_arguments (
2020-10-27 10:30:27 +08:00
P A R S E _ A R G V 0
2021-05-18 02:08:42 +08:00
" a r g "
2018-10-26 03:34:45 +08:00
" U S E _ V C P K G _ I N T E G R A T I O N ; A L L O W _ R O O T _ I N C L U D E S ; R E M O V E _ R O O T _ I N C L U D E S ; S K I P _ C L E A N "
2018-08-08 19:15:13 +08:00
" S O U R C E _ P A T H ; P R O J E C T _ S U B P A T H ; I N C L U D E S _ S U B P A T H ; L I C E N S E _ S U B P A T H ; R E L E A S E _ C O N F I G U R A T I O N ; D E B U G _ C O N F I G U R A T I O N ; P L A T F O R M ; P L A T F O R M _ T O O L S E T ; T A R G E T _ P L A T F O R M _ V E R S I O N ; T A R G E T "
" O P T I O N S ; O P T I O N S _ R E L E A S E ; O P T I O N S _ D E B U G "
)
2021-05-18 02:08:42 +08:00
if ( DEFINED arg_UNPARSED_ARGUMENTS )
message ( WARNING "vcpkg_install_msbuild was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}" )
endif ( )
if ( NOT DEFINED arg_RELEASE_CONFIGURATION )
set ( arg_RELEASE_CONFIGURATION Release )
2018-08-08 19:15:13 +08:00
endif ( )
2021-05-18 02:08:42 +08:00
if ( NOT DEFINED arg_DEBUG_CONFIGURATION )
set ( arg_DEBUG_CONFIGURATION Debug )
2018-08-08 19:15:13 +08:00
endif ( )
2021-05-18 02:08:42 +08:00
if ( NOT DEFINED arg_PLATFORM )
if ( VCPKG_TARGET_ARCHITECTURE STREQUAL "x64" )
set ( arg_PLATFORM x64 )
elseif ( VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" )
set ( arg_PLATFORM Win32 )
elseif ( VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" )
set ( arg_PLATFORM ARM )
elseif ( VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" )
set ( arg_PLATFORM arm64 )
2018-08-08 19:15:13 +08:00
else ( )
message ( FATAL_ERROR "Unsupported target architecture" )
endif ( )
endif ( )
2021-05-18 02:08:42 +08:00
if ( NOT DEFINED arg_PLATFORM_TOOLSET )
set ( arg_PLATFORM_TOOLSET "${VCPKG_PLATFORM_TOOLSET}" )
2018-08-08 19:15:13 +08:00
endif ( )
2021-05-18 02:08:42 +08:00
if ( NOT DEFINED arg_TARGET_PLATFORM_VERSION )
vcpkg_get_windows_sdk ( arg_TARGET_PLATFORM_VERSION )
2018-08-08 19:15:13 +08:00
endif ( )
2021-05-18 02:08:42 +08:00
if ( NOT DEFINED arg_TARGET )
set ( arg_TARGET Rebuild )
2018-08-08 19:15:13 +08:00
endif ( )
2021-05-18 02:08:42 +08:00
list ( APPEND arg_OPTIONS
" / t : $ { a r g _ T A R G E T } "
" / p : P l a t f o r m = $ { a r g _ P L A T F O R M } "
" / p : P l a t f o r m T o o l s e t = $ { a r g _ P L A T F O R M _ T O O L S E T } "
" / 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 "
" / p : W i n d o w s T a r g e t P l a t f o r m V e r s i o n = $ { a r g _ T A R G E T _ P L A T F O R M _ V E R S I O N } "
" / p : V c p k g T r i p l e t = $ { T A R G E T _ T R I P L E T } "
2021-02-13 15:42:22 +08:00
" / p : V c p k g I n s t a l l e d D i r = $ { _ V C P K G _ I N S T A L L E D _ D I R } "
2021-05-18 02:08:42 +08:00
" / p : V c p k g M a n i f e s t I n s t a l l = f a l s e "
2021-10-01 07:39:14 +08:00
" / p : U s e M u l t i T o o l T a s k = t r u e "
" / p : M u l t i P r o c M a x C o u n t = $ { V C P K G _ C O N C U R R E N C Y } "
" / p : E n f o r c e P r o c e s s C o u n t A c r o s s B u i l d s = t r u e "
" / m : $ { V C P K G _ C O N C U R R E N C Y } "
2018-08-08 19:15:13 +08:00
)
if ( VCPKG_LIBRARY_LINKAGE STREQUAL "static" )
# Disable LTCG for static libraries because this setting introduces ABI incompatibility between minor compiler versions
# TODO: Add a way for the user to override this if they want to opt-in to incompatibility
2021-05-18 02:08:42 +08:00
list ( APPEND arg_OPTIONS "/p:WholeProgramOptimization=false" )
2018-08-08 19:15:13 +08:00
endif ( )
2021-05-18 02:08:42 +08:00
if ( arg_USE_VCPKG_INTEGRATION )
list ( APPEND arg_OPTIONS
" / p : F o r c e I m p o r t B e f o r e C p p T a r g e t s = $ { S C R I P T S } / b u i l d s y s t e m s / m s b u i l d / v c p k g . t a r g e t s "
" / p : V c p k g A p p l o c a l D e p s = f a l s e "
)
2018-08-08 19:15:13 +08:00
endif ( )
2021-05-18 02:08:42 +08:00
get_filename_component ( source_path_suffix "${arg_SOURCE_PATH}" NAME )
2018-08-08 19:15:13 +08:00
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release" )
2021-05-18 02:08:42 +08:00
message ( STATUS "Building ${arg_PROJECT_SUBPATH} for Release" )
file ( REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" )
file ( MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" )
file ( COPY "${arg_SOURCE_PATH}" DESTINATION "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" )
set ( source_copy_path "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/${source_path_suffix}" )
2018-08-08 19:15:13 +08:00
vcpkg_execute_required_process (
2021-05-18 02:08:42 +08:00
C O M M A N D m s b u i l d " $ { s o u r c e _ c o p y _ p a t h } / $ { a r g _ P R O J E C T _ S U B P A T H } "
" / p : C o n f i g u r a t i o n = $ { a r g _ R E L E A S E _ C O N F I G U R A T I O N } "
$ { a r g _ O P T I O N S }
$ { a r g _ O P T I O N S _ R E L E A S E }
W O R K I N G _ D I R E C T O R Y " $ { s o u r c e _ c o p y _ p a t h } "
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 "
2018-08-08 19:15:13 +08:00
)
2021-05-18 02:08:42 +08:00
file ( GLOB_RECURSE libs "${source_copy_path}/*.lib" )
file ( GLOB_RECURSE dlls "${source_copy_path}/*.dll" )
file ( GLOB_RECURSE exes "${source_copy_path}/*.exe" )
if ( NOT libs STREQUAL "" )
file ( COPY ${ libs } DESTINATION "${CURRENT_PACKAGES_DIR}/lib" )
2018-08-08 19:15:13 +08:00
endif ( )
2021-05-18 02:08:42 +08:00
if ( NOT dlls STREQUAL "" )
file ( COPY ${ dlls } DESTINATION "${CURRENT_PACKAGES_DIR}/bin" )
2018-08-08 19:15:13 +08:00
endif ( )
2021-05-18 02:08:42 +08:00
if ( NOT exes STREQUAL "" )
file ( COPY ${ exes } DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}" )
vcpkg_copy_tool_dependencies ( "${CURRENT_PACKAGES_DIR}/tools/${PORT}" )
2018-08-08 19:15:13 +08:00
endif ( )
endif ( )
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" )
2021-05-18 02:08:42 +08:00
message ( STATUS "Building ${arg_PROJECT_SUBPATH} for Debug" )
file ( REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" )
file ( MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" )
file ( COPY "${arg_SOURCE_PATH}" DESTINATION "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" )
set ( source_copy_path "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/${source_path_suffix}" )
2018-08-08 19:15:13 +08:00
vcpkg_execute_required_process (
2021-05-18 02:08:42 +08:00
C O M M A N D m s b u i l d " $ { s o u r c e _ c o p y _ p a t h } / $ { a r g _ P R O J E C T _ S U B P A T H } "
" / p : C o n f i g u r a t i o n = $ { a r g _ D E B U G _ C O N F I G U R A T I O N } "
$ { a r g _ O P T I O N S }
$ { a r g _ O P T I O N S _ D E B U G }
W O R K I N G _ D I R E C T O R Y " $ { s o u r c e _ c o p y _ p a t h } "
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 "
2018-08-08 19:15:13 +08:00
)
2021-05-18 02:08:42 +08:00
file ( GLOB_RECURSE libs "${source_copy_path}/*.lib" )
file ( GLOB_RECURSE dlls "${source_copy_path}/*.dll" )
if ( NOT libs STREQUAL "" )
file ( COPY ${ libs } DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib" )
2018-08-08 19:15:13 +08:00
endif ( )
2021-05-18 02:08:42 +08:00
if ( NOT dlls STREQUAL "" )
file ( COPY ${ dlls } DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin" )
2018-08-08 19:15:13 +08:00
endif ( )
endif ( )
vcpkg_copy_pdbs ( )
2021-05-18 02:08:42 +08:00
if ( NOT arg_SKIP_CLEAN )
2018-10-26 03:34:45 +08:00
vcpkg_clean_msbuild ( )
endif ( )
2018-08-08 19:15:13 +08:00
2021-05-18 02:08:42 +08:00
if ( DEFINED arg_INCLUDES_SUBPATH )
file ( COPY "${arg_SOURCE_PATH}/${arg_INCLUDES_SUBPATH}/"
D E S T I N A T I O N " $ { C U R R E N T _ P A C K A G E S _ D I R } / i n c l u d e / "
)
2023-01-05 04:11:05 +08:00
file ( GLOB_RECURSE all_am_file "${CURRENT_PACKAGES_DIR}/include/*.am" )
file ( GLOB_RECURSE all_in_file "${CURRENT_PACKAGES_DIR}/include/*.in" )
if ( NOT "${all_am_file}" STREQUAL "" )
file ( REMOVE ${ all_am_file } )
endif ( )
if ( NOT "${all_in_file}" STREQUAL "" )
file ( REMOVE ${ all_in_file } )
endif ( )
2021-05-18 02:08:42 +08:00
file ( GLOB root_includes
L I S T _ D I R E C T O R I E S f a l s e
" $ { C U R R E N T _ P A C K A G E S _ D I R } / i n c l u d e / * " )
if ( NOT root_includes STREQUAL "" )
if ( arg_REMOVE_ROOT_INCLUDES )
file ( REMOVE ${ root_includes } )
elseif ( arg_ALLOW_ROOT_INCLUDES )
2018-08-08 19:15:13 +08:00
else ( )
message ( FATAL_ERROR "Top-level files were found in ${CURRENT_PACKAGES_DIR}/include; this may indicate a problem with the call to `vcpkg_install_msbuild()`.\nTo avoid conflicts with other libraries, it is recommended to not put includes into the root `include/` directory.\nPass either ALLOW_ROOT_INCLUDES or REMOVE_ROOT_INCLUDES to handle these files.\n" )
endif ( )
endif ( )
endif ( )
2021-05-18 02:08:42 +08:00
if ( DEFINED arg_LICENSE_SUBPATH )
file ( INSTALL "${arg_SOURCE_PATH}/${arg_LICENSE_SUBPATH}"
D E S T I N A T I O N " $ { C U R R E N T _ P A C K A G E S _ D I R } / s h a r e / $ { P O R T } "
R E N A M E c o p y r i g h t
)
2018-08-08 19:15:13 +08:00
endif ( )
endfunction ( )