Hello, 

I would like to let users choose between providing third party libraries or let 
CMake download them. 
To do that, I try to write a simple code like this to manage a third party 
library FOO of an executable MY_EXEC: 
================================================= 
IF(NOT EXISTS FOO_DIR) 
MESSAGE(STATUS "FOO LIBRARY WILL BE DOWNLOADED AND INSTALLED") 
# download and install FOO, define FOO_DIR 
ENDIF() 
INCLUDE_DIRECTORIES(MY_EXEC ${FOO_DIR}/include) 
TARGET_LINK_LIBRARIES(MY_EXEC ${FOO_DIR}/include) 
================================================= 
To do that, I think the user should have the possibility to define FOO_DIR with 
an option. 
So, I put the line 
OPTION(FOO_DIR) 
before the code below. 

However, it doesn't seem to work because FOO_DIR does not seem to be defined. 
The message "FOO LIBRARY WILL BE DOWNLOADED AND INSTALLED" always appears, 
- even if I type "cmake -D FOO_DIR=path", where path is a user-defined path to 
FOO library, 
- even if I put a default value to FOO_DIR with OPTION(FOO_DIR path), where 
path is a hard-coded path to FOO. 

Where does I make a mistake here? 
What is the correct way to manage FOO_DIR when it can be defined by a user? 

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. 

Thank you very much for your help! 

Cédric 

-- 

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:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to