[CMake] CMAKE_INCLUDE_CURRENT_DIR?
Pascal Fleury
fleury at users.sourceforge.net
Tue Mar 20 03:31:56 EST 2007
On Tuesday 20 March 2007 07:07:35 Kishore, Jonnalagadda (IE10) wrote:
> > Kishore, Jonnalagadda (IE10) wrote:
> This is now a little confusing especially, when the description says "
> automatically add CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR
> to the include directories _in every directory_"
Yes, and I think that the origin of the problem is that this very sentence can
be interpreted in two ways that contradict themselves. Hence the confusion.
Maybe if you can see these two ways, you'll understand :-)
SET(CMAKE_INCLUDE_CURRENT_DIR ON) has only one direct effect at the location
of the CMakeLists.txt it is put in: set a flag to ON. This will then trigger
an automatic INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}) in every CMakeLists.txt it will find when
generating the Makefiles or Studio project files. It's as if you had added
this command in every CMakeLists.txt in your project on the first line, but
it saves you the typing.
Example project tree:
project/CMakeLists.txt
project/src/CMakeLists.txt
project/src/lib/CMakeLists.txt
project/test/CMakeLists.txt
So it you set the flag in 'project/CMakeLists.txt', and run cmake in
$builddir/, then the directories that will be included are as follows:
project/CMakeLists.txt --> 'project/' and '$builddir/'
project/src/CMakeLists.txt --> 'project/src' and '$builddir/src'
project/src/lib/CMakeLists.txt -> 'project/src/lib' and '$builddir/src/lib'
project/test/CMakeLists.txt -> 'project/text' and '$builddir/test'
So it will in effect "automatically add the current source dir and current
binary dir to the include directories in every directory" as the doc says.
However, the *current* directory has a different value when cmake is
processing project/src/CMakeLists.txt than when processing
project/test/CMakeLists.txt. That last part is not clearly stated in the
docs, and may be confusing.
Hope this helps!
(don't blame me for the $builddir path, maybe it is
$builddir/src/lib/cmake.dir/lib/src or some other internal dir, I did not
check the proper dir structure in the builddir)
--paf
More information about the CMake
mailing list