2022-02-04 05:04:55 +08:00
# DEPRECATED: in favor of the `supports` field in [`manifest file`](manifest-files.md#supports) et al.
2020-12-02 05:37:26 +08:00
#[===[.md:
# vcpkg_fail_port_install
C h e c k s c o m m o n r e q u i r e m e n t s a n d f a i l s t h e c u r r e n t p o r t f i l e w i t h a ( default ) e r r o r m e s s a g e
## Usage
` ` ` c m a k e
vcpkg_fail_port_install (
[ A L W A Y S ]
[ M E S S A G E < " R e a s o n f o r f a i l u r e " > ]
[ O N _ T A R G E T < W i n d o w s > [ < O S X > . . . ] ]
[ O N _ A R C H < x 6 4 > [ < a r m > . . . ] ]
[ O N _ C R T _ L I N K A G E < s t a t i c > [ < d y n a m i c > . . . ] ] )
[ O N _ L I B R A R Y _ L I N K A G E < s t a t i c > [ < d y n a m i c > . . . ] ]
)
` ` `
## Parameters
### MESSAGE
A d d i t i o n a l f a i l u r e m e s s a g e . I f n o n e i s g i v e n , a d e f a u l t m e s s a g e w i l l b e d i s p l a y e d d e p e n d i n g o n t h e f a i l u r e c o n d i t i o n .
### ALWAYS
W i l l a l w a y s f a i l e a r l y
### ON_TARGET
T a r g e t s f o r w h i c h t h e b u i l d s h o u l d f a i l e a r l y . V a l i d t a r g e t s a r e ` < t a r g e t > ` f r o m ` V C P K G _ I S _ T A R G E T _ < t a r g e t > ` ( s e e ` v c p k g _ c o m m o n _ d e f i n i t i o n s . c m a k e ` ) .
### ON_ARCH
A r c h i t e c t u r e f o r w h i c h t h e b u i l d s h o u l d f a i l e a r l y .
### ON_CRT_LINKAGE
C R T l i n k a g e f o r w h i c h t h e b u i l d s h o u l d f a i l e a r l y .
### ON_LIBRARY_LINKAGE
L i b r a r y l i n k a g e f o r w h i c h t h e b u i l d s h o u l d f a i l e a r l y .
## Examples
* [ a w s - l a m b d a - c p p ] ( h t t p s : / / g i t h u b . c o m / M i c r o s o f t / v c p k g / b l o b / m a s t e r / p o r t s / a w s - l a m b d a - c p p / p o r t f i l e . c m a k e )
#]===]
2019-08-12 14:24:20 +08:00
function ( vcpkg_fail_port_install )
2022-02-04 05:04:55 +08:00
message ( "${Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL}" "vcpkg_fail_port_install has been removed and all values should be moved by adding `supports` field to manifest file or directly adding `${PORT}:${FAILED_TRIPLET}=fail` to _scripts/ci.baseline.txt_.\nPlease remove `vcpkg_fail_port_install(...)`.\n" )
2021-12-29 06:43:05 +08:00
set ( multi_args "ON_TARGET;ON_ARCH;ON_CRT_LINKAGE;ON_LIBRARY_LINKAGE" )
cmake_parse_arguments ( PARSE_ARGV 0 "arg" "ALWAYS" "MESSAGE" "${multi_args}" )
2021-05-27 04:40:48 +08:00
if ( DEFINED arg_UNPARSED_ARGUMENTS )
message ( FATAL_ERROR "vcpkg_fail_port_install was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}" )
2020-02-13 07:58:43 +08:00
endif ( )
2021-12-29 06:43:05 +08:00
if ( arg_ALWAYS )
vcpkg_list ( SET extra_args )
foreach ( arg IN LISTS multi_args )
if ( DEFINED "arg_${arg}" )
vcpkg_list ( APPEND extra_args "${arg}" "${arg_${arg}}" )
endif ( )
endforeach ( )
if ( NOT "${extra_args}" STREQUAL "" )
message ( WARNING "vcpkg_fail_port_install set to fail both unconditionally and conditionally on ${extra_args}. This is likely to be an error." )
endif ( )
if ( NOT DEFINED arg_MESSAGE )
message ( FATAL_ERROR "vcpkg_fail_port_install(ALWAYS) was called without a specific MESSAGE." )
endif ( )
message ( FATAL_ERROR "${arg_MESSAGE}" )
endif ( )
2021-05-27 04:40:48 +08:00
if ( DEFINED arg_MESSAGE )
string ( APPEND arg_MESSAGE "\n" )
2020-02-13 07:58:43 +08:00
else ( )
2021-05-27 04:40:48 +08:00
set ( arg_MESSAGE "" )
2020-02-13 07:58:43 +08:00
endif ( )
2019-08-12 14:24:20 +08:00
2021-12-29 06:43:05 +08:00
set ( fail_port OFF )
2021-05-27 04:40:48 +08:00
# Target fail check
if ( DEFINED arg_ON_TARGET )
foreach ( target IN LISTS arg_ON_TARGET )
string ( TOUPPER "${target}" target_upper )
if ( VCPKG_TARGET_IS_ ${ target_upper } )
2021-12-29 06:43:05 +08:00
set ( fail_port ON )
2021-05-27 04:40:48 +08:00
string ( APPEND arg_MESSAGE "Target '${target}' not supported by ${PORT}!\n" )
2020-02-13 07:58:43 +08:00
endif ( )
endforeach ( )
endif ( )
2021-05-27 04:40:48 +08:00
# Architecture fail check
if ( DEFINED arg_ON_ARCH )
foreach ( arch IN LISTS arg_ON_ARCH )
if ( VCPKG_TARGET_ARCHITECTURE STREQUAL arch )
2021-12-29 06:43:05 +08:00
set ( fail_port ON )
2021-05-27 04:40:48 +08:00
string ( APPEND arg_MESSAGE "Architecture '${arch}' not supported by ${PORT}!\n" )
2020-02-13 07:58:43 +08:00
endif ( )
endforeach ( )
endif ( )
2021-05-27 04:40:48 +08:00
# CRT linkage fail check
if ( DEFINED arg_ON_CRT_LINKAGE )
foreach ( crt_linkage IN LISTS arg_ON_CRT_LINKAGE )
if ( VCPKG_CRT_LINKAGE STREQUAL crt_linkage )
2021-12-29 06:43:05 +08:00
set ( fail_port ON )
2021-05-27 04:40:48 +08:00
string ( APPEND arg_MESSAGE "CRT linkage '${VCPKG_CRT_LINKAGE}' not supported by ${PORT}!\n" )
2020-02-13 07:58:43 +08:00
endif ( )
endforeach ( )
endif ( )
2021-05-27 04:40:48 +08:00
# Library linkage fail check
if ( DEFINED arg_ON_LIBRARY_LINKAGE )
foreach ( library_linkage IN LISTS arg_ON_LIBRARY_LINKAGE )
if ( VCPKG_LIBRARY_LINKAGE STREQUAL library_linkage )
2021-12-29 06:43:05 +08:00
set ( fail_port ON )
2021-05-27 04:40:48 +08:00
string ( APPEND arg_MESSAGE "Library linkage '${VCPKG_LIBRARY_LINKAGE}' not supported by ${PORT}!\n" )
2020-02-13 07:58:43 +08:00
endif ( )
endforeach ( )
endif ( )
2021-12-29 06:43:05 +08:00
if ( fail_port )
message ( FATAL_ERROR "${arg_MESSAGE}" )
2020-02-13 07:58:43 +08:00
endif ( )
endfunction ( )