In a project, there are many libraries:
- there are dependencies between libraries.
- each library has some features to enable/disable at build time.
- one library feature may depends on another library’s specified feature.
Problem:
- How to use cmake to organize such feature based dependency.
- How to configure different target with different feature list.
Use option() and set() with CACHE keyword commands to define build options.
Use
if(OPTION_NAME)to test for option value. Useadd_dependencies()inside if block to make some of them optional.Use configure_file() to replace template file (config headerm for example) with options’ values.