<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div><br></div><div>Hello,<br></div><div><br></div><div>I would like to let users choose between providing third party libraries or let CMake download them.<br>To do that, I try to write a simple code like this to manage a third party library FOO of an executable MY_EXEC:<br></div><div>=================================================<br></div><div>IF(NOT EXISTS FOO_DIR)<br></div><div>      MESSAGE(STATUS "FOO LIBRARY WILL BE DOWNLOADED AND INSTALLED")<br></div><div>      # download and install FOO, define FOO_DIR<br></div><div>ENDIF()<br></div><div>INCLUDE_DIRECTORIES(MY_EXEC ${FOO_DIR}/include)<br>TARGET_LINK_LIBRARIES(MY_EXEC ${FOO_DIR}/include)<br></div><div>=================================================</div><div>To do that, I think the user should have the possibility to define FOO_DIR with an option.<br></div><div>So, I put the line<br></div><div>OPTION(FOO_DIR)<br></div><div>before the code below.<br></div><div><br></div><div>However, it doesn't seem to work because FOO_DIR does not seem to be defined.<br></div><div>The message "FOO LIBRARY WILL BE DOWNLOADED AND INSTALLED" always appears, </div><div>- even if I type "cmake -D FOO_DIR=path", where path is a user-defined path to FOO library,<br></div><div>- even if I put a default value to FOO_DIR with OPTION(FOO_DIR path), where path is a hard-coded path to FOO.<br></div><div><br></div><div>Where does I make a mistake here?<br></div><div>What is the correct way to manage FOO_DIR when it can be defined by a user?<br></div><div><br></div><div>Note: the next step is to define FOO_DIR in a FindFoo.cmake file and use find_package(Foo), but it's not my goal yet.<br></div><div><br></div><div>Thank you very much for your help!<br></div><div><br></div><div>Cédric<br></div><div><br></div></div></body></html>