Assembly parameters (for example, MYLIB_WITH_SQLITE ) should be added to the library interface, that is, to the MYLIB_DEFINITIONS variable in the case of the old-school configuration module or to the INTERFACE_COMPILE_DEFINITIONS property if the library creates its own configuration module using the install(EXPORT ...) command:
add_library(mylib ...) if(MYLIB_WITH_SQLITE) target_compile_definitions(mylib PUBLIC MYLIB_WITH_SQLITE) endif() ... install(TARGETS mylib EXPORT mylib-targets ...) install(EXPORT mylib-targets ...)
And in the consumption library or executable you can write simple compile-time checks:
#ifndef MYLIB_WITH_SQLITE #error mylib must be built with sqlite #endif
source share