I'm using cmake version and have just encountered an issue with my
cmake setup where I was using the [Project name]_SOURCE_DIR variable in an
include_directories command and it was being ignored.  In my top level
CMakeLists.txt I had:



and in the CMakeLists.txt in the foo directory:


The project failed to build because the foo project couldn't find header
files located in the bar project source directory.  The fix was to move the
add_subdirectory(bar) before the add_subdirectory(foo) command.  The
interesting thing is that this setup only caused an error when doing a
clean build from scratch.  It looks like it only fails after a clean start
and a single run of the cmake generator.  If you run cmake-gui and
configure more than once, as you may well do if you need to set some
options, then it appears to get the correct value for ${bar_SOURCE_DIR}.

Are the [Project name]_SOURCE_DIR variables being automatically stored in
the cmake cache, as that would explain what I am seeing ?  I would expect
the above scenario to consistently fail every time due to the missing
header files.  Having it only fail the first time and then work after
subsequent configure/generate steps is confusing.  Is this a bug, or are
there occasions when this is desirable behaviour ?


P.S.  In an ideal world I'd like to see the expansion of the [Project
name]_SOURCE_DIR variables be deferred until after all the CMakeLists.txt
files have been read in so that the order doesn't matter, but I'm guessing
that isn't going to happen :-)

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 

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 

Follow this link to subscribe/unsubscribe:

Reply via email to