C++ with git and CMake: How to build submodules with specific parameters? -
consider c++ project, organized in git repository. assume git repository has submodule library built on (super)project depends. if (super)project depends not on library on library built specific (cmake) parameters, how can ensured submodule built these parameters when (super)project built?
the build options (like mylib_with_sqlite
) must added interface of library, is, mylib_definitions
variable in case of old-school config-module, or interface_compile_definitions
property, if library creates config-module 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 consuming library or executable can write simple compile-time checks:
#ifndef mylib_with_sqlite #error mylib must built sqlite #endif
Comments
Post a Comment