On 12.03.2019 06:37 Steve Keller wrote:
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.
If you want yadda to be optional then don't use REQUIRED.
find_package(yadda)
if (yadda_FOUND)
message(STATUS "found yadda, building bar ...")
# add your code to build bar here
endif ()
This should do what you want - unless I misunderstood your question.
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake