2020-12-02 05:37:26 +08:00
#[===[.md:
# vcpkg_check_linkage
A s s e r t s t h e a v a i l a b l e l i b r a r y a n d C R T l i n k a g e o p t i o n s f o r t h e p o r t .
## Usage
` ` ` c m a k e
vcpkg_check_linkage (
[ O N L Y _ S T A T I C _ L I B R A R Y | O N L Y _ D Y N A M I C _ L I B R A R Y ]
[ O N L Y _ S T A T I C _ C R T | O N L Y _ D Y N A M I C _ C R T ]
)
` ` `
## Parameters
### ONLY_STATIC_LIBRARY
I n d i c a t e s t h a t t h i s p o r t c a n o n l y b e b u i l t w i t h s t a t i c l i b r a r y l i n k a g e .
2021-01-29 11:45:59 +08:00
N o t e : I f t h e u s e r r e q u e s t e d a d y n a m i c b u i l d O N L Y _ S T A T I C _ L I B R A R Y w i l l r e s u l t i n a n o t e b e i n g p r i n t e d , n o t a f a t a l e r r o r .
2020-12-02 05:37:26 +08:00
### ONLY_DYNAMIC_LIBRARY
I n d i c a t e s t h a t t h i s p o r t c a n o n l y b e b u i l t w i t h d y n a m i c / s h a r e d l i b r a r y l i n k a g e .
### ONLY_STATIC_CRT
I n d i c a t e s t h a t t h i s p o r t c a n o n l y b e b u i l t w i t h s t a t i c C R T l i n k a g e .
### ONLY_DYNAMIC_CRT
I n d i c a t e s t h a t t h i s p o r t c a n o n l y b e b u i l t w i t h d y n a m i c / s h a r e d C R T l i n k a g e .
## Notes
T h i s c o m m a n d w i l l e i t h e r a l t e r t h e s e t t i n g s f o r ` V C P K G _ L I B R A R Y _ L I N K A G E ` o r f a i l , d e p e n d i n g o n w h a t w a s r e q u e s t e d b y t h e u s e r v e r s u s w h a t t h e l i b r a r y s u p p o r t s .
## Examples
* [ a b s e i l ] ( 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 b s e i l / p o r t f i l e . c m a k e )
#]===]
2018-08-08 19:15:13 +08:00
function ( vcpkg_check_linkage )
cmake_parse_arguments ( _csc "ONLY_STATIC_LIBRARY;ONLY_DYNAMIC_LIBRARY;ONLY_DYNAMIC_CRT;ONLY_STATIC_CRT" "" "" ${ ARGN } )
if ( _csc_ONLY_STATIC_LIBRARY AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" )
message ( STATUS "Note: ${PORT} only supports static library linkage. Building static library." )
2018-08-08 21:02:30 +08:00
set ( VCPKG_LIBRARY_LINKAGE static PARENT_SCOPE )
2018-08-08 19:15:13 +08:00
endif ( )
if ( _csc_ONLY_DYNAMIC_LIBRARY AND VCPKG_LIBRARY_LINKAGE STREQUAL "static" )
message ( STATUS "Note: ${PORT} only supports dynamic library linkage. Building dynamic library." )
if ( VCPKG_CRT_LINKAGE STREQUAL "static" )
message ( FATAL_ERROR "Refusing to build unexpected dynamic library against the static CRT. If this is desired, please configure your triplet to directly request this configuration." )
endif ( )
2018-08-08 21:02:30 +08:00
set ( VCPKG_LIBRARY_LINKAGE dynamic PARENT_SCOPE )
2018-08-08 19:15:13 +08:00
endif ( )
if ( _csc_ONLY_DYNAMIC_CRT AND VCPKG_CRT_LINKAGE STREQUAL "static" )
message ( FATAL_ERROR "${PORT} only supports dynamic crt linkage" )
endif ( )
if ( _csc_ONLY_STATIC_CRT AND VCPKG_CRT_LINKAGE STREQUAL "dynamic" )
message ( FATAL_ERROR "${PORT} only supports static crt linkage" )
endif ( )
endfunction ( )