Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query whether a target is an INTERFACE library in CMake

In modern CMake one can specify a library as INTERFACE: it does not produce build output, but it can have properties associated to it, although not all properties can be set (for instance the FOLDER property is not supported). Say I have a generic CMake macro setting properties for a generic library target, is there a way to tell that the input target is an interface library, so that I can skip the unsupported properties only for that target?

like image 665
Paolo Crosetto Avatar asked Oct 27 '25 11:10

Paolo Crosetto


1 Answers

You query the TYPE property of target....

get_target_property(type target TYPE)
if (${type} STREQUAL "INTERFACE_LIBRARY")
like image 140
KamilCuk Avatar answered Oct 30 '25 01:10

KamilCuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!