Is there a way to restrict/indicate a library is for the Mega only?

I've got a library which is quite large and thus only compatible with Mega/Mega 2560. My understanding is that the architecture field of the library descriptor is concerned with CPU architecture and not board architecture i.e. I can't go any more granular than AVR.

I've made it clear in my library description, but is there a way to indicate that the lib is Mega-only in some way that might let an end user know before their compilation fails (at library import time etc.)?


Not exactly what you ask, but to make it very clear (rather than cryptic resources missing messages when you compile) you could just add

#ifndef __AVR_ATmega2560__
#error "please use an Arduino MEGA"

at the beginning of your library. That will stop the compiler if you are not compiling for a MEGA 2560, and the user will get an error message

exit status 1
#error "please use an Arduino MEGA"

I have not tried it yet but a solution can be found based on this post:
(#defines related to the mega CPU type):

and use :
#pragma message "You have the wrong cpu..." if the proper defines are not present.
Best regards,