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 ( )