[CMake] How can I automatically optionally build a submodule?

Steve Keller keller.steve at gmx.de
Tue Mar 12 01:37:21 EDT 2019


How can I build a module in a subdirectory automatically if a required
package is available, but not fail if it's not. Say I have a
top-level CMakeLists.txt with

    add_subdirectory(foo)
    add_subdirectory(bar)

and in directory foo I have in CMakeLists.txt

    find_package(yadda, REQUIRED)

I want the submodule foo to be build automatically if the package
yadda is found. Otherwise, foo should be left out and the top-level
build should not fail but continue.

Steve


More information about the CMake mailing list