[CMake] CMAKE_INCLUDE_CURRENT_DIR?

Kishore, Jonnalagadda (IE10) Kishore.Jonnalagadda at honeywell.com
Tue Mar 20 04:00:58 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.

So by that you mean that every folder where a CMakeLists.txt is
processed, includes itself in the search path but not the other folders
where the other CMakeLists.txt were processed!?

I will need to check this modifying my source files as most of them
include project headers with "" rather than <>. That way local header
files are searched for already rendering this option useless.

Is this what this option is for?

Warm regards,
Kishore


More information about the CMake mailing list