On 2013-03-28 16:02, Chris Stankevitz wrote:
On Tue, Mar 19, 2013 at 3:13 AM, Ansis Māliņš wrote:
Q: Can cmake automatically not build "b" when "a" is not available?
find_package(a)
if(a_FOUND)
ExternalProject_Add(b PREFIX blabla ...)
endif()
Hello,
If I understand correctly, this is what just happened:
Chris: Is there a pretty solution to problem X? An ugly solution is Y.
Ansis: Why don't you try Y?
[snip example]
First, I would suggest putting your dependent components in their own
subdirectories. Then you can at least do:
if(Boost_FOUND)
add_subdirectory(b)
endif()
If even that bothers you, you could wrap the above in a macro like:
macro(optional_add_subdirectory dir)
if(${ARGN})
add_subdirectory(${dir})
endif()
endmacro()
Note the use of ARGN to allow for things like:
optional_add_subdirectory(b Boost_FOUND AND ENABLE_B)
optional_add_subdirectory(c NOT DISABLE_C)
Second:
if(a_FOUND AND b_FOUND AND ...)
I'm not aware of any built-in way of doing this sort of thing
automatically. The best you can do I think is going to be to use
functions and/or macros to make things more convenient.
It's an interesting notion, though...
--
Matthew
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake