Discussion:
[CMake] CMAKE_INCLUDE_CURRENT_DIR?
Kishore, Jonnalagadda (IE10)
2007-03-15 13:05:12 UTC
Permalink
Can someone explain to me the use of CMAKE_INCLUDE_CURRENT_DIR?

In the root CMakeLists.txt file of my project I tried setting the
variable to ON (tried 1 as well) with:

SET(CMAKE_INCLUDE_CURRENT_DIR ON)

This seemed to make no difference. My expectation reading
http://www.cmake.org/Wiki/CMake_Useful_Variables was that all the sub
directories included with the command ADD_SUBDIRECTORY() get included as
part of include directories for include files located elsewhere.

Warm regards,
Kishore

Ps. I am making progress with cross-compiling by forcing the TEST
variables as successful. I will write with more details when I am done.
Filipe Sousa
2007-03-15 21:03:18 UTC
Permalink
Post by Kishore, Jonnalagadda (IE10)
Can someone explain to me the use of CMAKE_INCLUDE_CURRENT_DIR?
In the root CMakeLists.txt file of my project I tried setting the
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
This seemed to make no difference. My expectation reading
http://www.cmake.org/Wiki/CMake_Useful_Variables was that all the sub
directories included with the command ADD_SUBDIRECTORY() get included as
part of include directories for include files located elsewhere.
CMAKE_INCLUDE_CURRENT_DIR is the same as
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}) for all targets.

If you have a project that constantly needs to add the current source
directory and the current binary directory to the targets you can set
CMAKE_INCLUDE_CURRENT_DIR.
Post by Kishore, Jonnalagadda (IE10)
Warm regards,
Kishore
Ps. I am making progress with cross-compiling by forcing the TEST
variables as successful. I will write with more details when I am done.
_______________________________________________
CMake mailing list
http://www.cmake.org/mailman/listinfo/cmake
- --
Filipe Sousa
Brandon J. Van Every
2007-03-15 21:28:19 UTC
Permalink
Post by Filipe Sousa
CMAKE_INCLUDE_CURRENT_DIR is the same as
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}) for all targets.
When explaining a variable, it's good to put it on the wiki. I did it
this time.
http://www.cmake.org/Wiki/CMake_Useful_Variables#Environment_Variables


Cheers,
Brandon Van Every
Filipe Sousa
2007-03-15 21:48:21 UTC
Permalink
Post by Brandon J. Van Every
When explaining a variable, it's good to put it on the wiki. I did it
this time.
http://www.cmake.org/Wiki/CMake_Useful_Variables#Environment_Variables
Cheers,
Brandon Van Every
Thanks Brandon!
I'm not good at writing documentation and my poor english is as good as
yours.

--
Filipe Sousa
Filipe Sousa
2007-03-15 22:04:05 UTC
Permalink
Post by Brandon J. Van Every
When explaining a variable, it's good to put it on the wiki. I did it
this time.
http://www.cmake.org/Wiki/CMake_Useful_Variables#Environment_Variables
Cheers,
Brandon Van Every
Thanks Brandon!
I'm not good at writing documentation and my poor english is *not* as
good as yours.

- --
Filipe Sousa
Kishore, Jonnalagadda (IE10)
2007-03-16 13:51:18 UTC
Permalink
-----Original Message-----
Behalf Of Filipe Sousa
Sent: Friday, March 16, 2007 2:33 AM
Subject: Re: [CMake] CMAKE_INCLUDE_CURRENT_DIR?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Post by Kishore, Jonnalagadda (IE10)
Can someone explain to me the use of CMAKE_INCLUDE_CURRENT_DIR?
In the root CMakeLists.txt file of my project I tried setting the
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
This seemed to make no difference. My expectation reading
http://www.cmake.org/Wiki/CMake_Useful_Variables was that all the
sub
Post by Kishore, Jonnalagadda (IE10)
directories included with the command ADD_SUBDIRECTORY() get
included as
Post by Kishore, Jonnalagadda (IE10)
part of include directories for include files located elsewhere.
CMAKE_INCLUDE_CURRENT_DIR is the same as
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}) for all targets.
If you have a project that constantly needs to add the current source
directory and the current binary directory to the targets you can set
CMAKE_INCLUDE_CURRENT_DIR.
Thanks for your reply. I did read the wiki that basically said the same
thing. But then, despite setting the value I had to put in
INCLUDE_DIRECTORIES(.)

Let us say in the root folder I have two files 'config.h' and
'CMakeLists.txt' and a folder called 'src'

CMakeLists.txt contains

ADD_SUBDIRECTORY(src)
PROJECT(test)
ADD_EXECUTABLE(test ${SRCS})

The directory 'src' contains 'CMakeLists.txt' and 'main.c' which contain

CMakeLists.txt:

SET(SRCS ${CMAKE_CURRENT_SOURCE_DIR}/main.c
CACHE
INTERNAL
" source files"
FORCE)

main.c:

include "config.h"
main()
{}
Brandon J. Van Every
2007-03-16 16:56:46 UTC
Permalink
Post by Kishore, Jonnalagadda (IE10)
-----Original Message-----
CMAKE_INCLUDE_CURRENT_DIR is the same as
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}) for all targets.
If you have a project that constantly needs to add the current source
directory and the current binary directory to the targets you can set
CMAKE_INCLUDE_CURRENT_DIR.
Thanks for your reply. I did read the wiki that basically said the same
thing.
That's 'cuz I wrote it after it was posted here. :-)
Post by Kishore, Jonnalagadda (IE10)
But then, despite setting the value I had to put in
INCLUDE_DIRECTORIES(.)
And I was brief because I don't know if there any caveats on how it can
be used. Maybe you found a bug. Maybe the behavior isn't consistent
across generators. Maybe the value isn't propagated to subdirectories.


Cheers,
Brandon Van Every
kitts
2007-03-16 17:33:00 UTC
Permalink
Post by Kishore, Jonnalagadda (IE10)
-----Original Message-----
   
CMAKE_INCLUDE_CURRENT_DIR is the same as
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}) for all targets.
If you have a project that constantly needs to add the current source
directory and the current binary directory to the targets you can set
CMAKE_INCLUDE_CURRENT_DIR.
   
Thanks for your reply. I did read the wiki that basically said the same
thing.
That's 'cuz I wrote it after it was posted here.  :-)
That's funny! I am pretty sure I thought of using it after reading about it
on one of the pages... ;-)
Post by Kishore, Jonnalagadda (IE10)
 But then, despite setting the value I had to put in
INCLUDE_DIRECTORIES(.)
 
And I was brief because I don't know if there any caveats on how it can
be used.  Maybe you found a bug.  Maybe the behavior isn't consistent
across generators.  Maybe the value isn't propagated to subdirectories.
Would you then recommend that i file a bug report? Can any other confirm?
--
Warm regards,
Kishore
Brandon J. Van Every
2007-03-16 18:03:30 UTC
Permalink
Post by kitts
Post by Brandon J. Van Every
Post by Kishore, Jonnalagadda (IE10)
But then, despite setting the value I had to put in
INCLUDE_DIRECTORIES(.)
And I was brief because I don't know if there any caveats on how it can
be used. Maybe you found a bug. Maybe the behavior isn't consistent
across generators. Maybe the value isn't propagated to subdirectories.
Would you then recommend that i file a bug report? Can any other confirm?
If you can reproduce demonstrably wrong behavior with a trivial
CMakeLists.txt, then yes, file a bug report. Writing up trivial
reproducers is how one verifies that something is indeed a bug.

Also, it is perfectly ok to have e-mail discussions occur in the bug
tracker. Even if the final result is "not a bug." A bug tracker is a
database for facilitating the memory of Kitware engineers. They can't
be expected to remember or address everything that comes up on the
mailing list, although history has shown they're awfully effective at
it. We can make their lives easier by using the bug tracker to communicate.

Generally I post a problem on the mailing list when I really have no
idea whether it's a bug or not. In that case, I'm making sure I haven't
missed something.


Thanks,
Brandon Van Every
Pascal Fleury
2007-03-16 19:31:03 UTC
Permalink
Post by Brandon J. Van Every
Post by Kishore, Jonnalagadda (IE10)
But then, despite setting the value I had to put in
INCLUDE_DIRECTORIES(.)
And I was brief because I don't know if there any caveats on how it can
be used. Maybe you found a bug. Maybe the behavior isn't consistent
across generators. Maybe the value isn't propagated to subdirectories.
Hi,
My understanding of your sample is consistent with my reading of the doc and
experience in my own builds: it includes the *current* dir, that is '.' with
respect to the CMakeList.txt file it is currently processing. So
CMAKE_INCLUDE_CURRENT_DIR indicates an additional automatic include for each
CMakeList.txt file it processes. It makes it kind of dynamic, as it has a
different absolute path to include for each CMakeList.txt file.

So that in your src/CMakeList.txt it will actually include 'src/.' , as would
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}),
but not your root dir './'. The CMAKE_INCLUDE_CURRENT_DIR is a mark for
future behavior, where as INCLUDE_DIRECTORIES is an action to take
immediately.

Hopefully my explanation is clear enough. If somebody can express this more
clearly, it should be put into wiki/docs.

--paf
--
--paf
Kishore, Jonnalagadda (IE10)
2007-03-20 05:19:09 UTC
Permalink
Post by kitts
Post by Kishore, Jonnalagadda (IE10)
Thanks for your reply. I did read the wiki that basically said the
same
Post by Kishore, Jonnalagadda (IE10)
thing.
That's 'cuz I wrote it after it was posted here.  :-)
That's funny! I am pretty sure I thought of using it after reading about
it on one of the pages... ;-)
I just checked again and confirm that the information was already there under the section "Various Options" http://www.cmake.org/Wiki/CMake_Useful_Variables#Various_Options

Now it is also added under "Environment Variables" http://www.cmake.org/Wiki/CMake_Useful_Variables#Environment_Variables

Warm Regards,
Kishore
Brandon J. Van Every
2007-03-20 05:54:10 UTC
Permalink
Post by Kishore, Jonnalagadda (IE10)
I just checked again and confirm that the information was already there under the section "Various Options" http://www.cmake.org/Wiki/CMake_Useful_Variables#Various_Options
Now it is also added under "Environment Variables" http://www.cmake.org/Wiki/CMake_Useful_Variables#Environment_Variables
Good eye. I moved those explanations to Environment Variables as they
are better explanations. I couldn't figure out how to refactor the rest
of the Various Options. It's a horrible name for a category, but
seemingly appropriate for the moment.


Cheers,
Brandon Van Every
Kishore, Jonnalagadda (IE10)
2007-03-20 05:29:46 UTC
Permalink
Post by Pascal Fleury
Post by Brandon J. Van Every
Post by Kishore, Jonnalagadda (IE10)
But then, despite setting the value I had to put in
INCLUDE_DIRECTORIES(.)
And I was brief because I don't know if there any caveats on how it
can
Post by Pascal Fleury
Post by Brandon J. Van Every
be used. Maybe you found a bug. Maybe the behavior isn't
consistent
Post by Pascal Fleury
Post by Brandon J. Van Every
across generators. Maybe the value isn't propagated to
subdirectories.
Post by Pascal Fleury
Hi,
My understanding of your sample is consistent with my reading of the
doc
Post by Pascal Fleury
and
experience in my own builds: it includes the *current* dir, that is
'.'
Post by Pascal Fleury
with
respect to the CMakeList.txt file it is currently processing. So
CMAKE_INCLUDE_CURRENT_DIR indicates an additional automatic include
for
Post by Pascal Fleury
each
CMakeList.txt file it processes. It makes it kind of dynamic, as it
has a
Post by Pascal Fleury
different absolute path to include for each CMakeList.txt file.
So that in your src/CMakeList.txt it will actually include 'src/.' ,
as
Post by Pascal Fleury
would
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}),
but not your root dir './'. The CMAKE_INCLUDE_CURRENT_DIR is a mark
for
Post by Pascal Fleury
future behavior, where as INCLUDE_DIRECTORIES is an action to take
immediately.
Hopefully my explanation is clear enough. If somebody can express this
more
clearly, it should be put into wiki/docs.
Paf,

If I understand you correctly, you mean to say that in the top level
CMakeLists.txt, if I SET(CMAKE_INCLUDE_CURRENT_DIR ON) and
INCLUDE_DIRECTORY(.) then all other subdirectories I add will all
automatically include the other directories?

This however, is not the behavior I am observing. Setting
CMAKE_INCLUDE_CURRENT_DIR does not seem to have any effect.

Warm regards,
Kishore
Brandon J. Van Every
2007-03-20 05:57:52 UTC
Permalink
Post by Kishore, Jonnalagadda (IE10)
If I understand you correctly, you mean to say that in the top level
CMakeLists.txt, if I SET(CMAKE_INCLUDE_CURRENT_DIR ON) and
INCLUDE_DIRECTORY(.) then all other subdirectories I add will all
automatically include the other directories?
This however, is not the behavior I am observing. Setting
CMAKE_INCLUDE_CURRENT_DIR does not seem to have any effect.
It is supposed to include CMAKE_CURRENT_SOURCE_DIR and
CMAKE_CURRENT_BINARY_DIR in the *current* directory only. The current
source and binary directories are different for every subdirectory. It
doesn't pass any values between subdirectories.

Still a bug?


Cheers,
Brandon Van Every
Kishore, Jonnalagadda (IE10)
2007-03-20 06:07:35 UTC
Permalink
Post by Brandon J. Van Every
Post by Kishore, Jonnalagadda (IE10)
If I understand you correctly, you mean to say that in the top level
CMakeLists.txt, if I SET(CMAKE_INCLUDE_CURRENT_DIR ON) and
INCLUDE_DIRECTORY(.) then all other subdirectories I add will all
automatically include the other directories?
This however, is not the behavior I am observing. Setting
CMAKE_INCLUDE_CURRENT_DIR does not seem to have any effect.
It is supposed to include CMAKE_CURRENT_SOURCE_DIR and
CMAKE_CURRENT_BINARY_DIR in the *current* directory only. The current
source and binary directories are different for every subdirectory.
It
Post by Brandon J. Van Every
doesn't pass any values between subdirectories.
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_"
Post by Brandon J. Van Every
Still a bug?
Let me check... OK. I still need to do INCLUDE_DIRECTORIES(.)!

Warm regards,
Kishore
Pascal Fleury
2007-03-20 08:31:56 UTC
Permalink
Post by Kishore, Jonnalagadda (IE10)
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
Brandon J. Van Every
2007-03-20 20:45:15 UTC
Permalink
Post by Pascal Fleury
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.
Feel free to improve the docs if you have better wordsmithing. It is a
wiki, after all. I haven't had time + brain cells, and I'm no more
responsible for the maintenance of the docs than you or anyone else. I
just try to improve what I can, when it's easy enough for me to do.


Cheers,
Brandon Van Every
Pascal Fleury
2007-03-21 09:37:15 UTC
Permalink
Post by Brandon J. Van Every
Feel free to improve the docs if you have better wordsmithing. It is a
wiki, after all. I haven't had time + brain cells, and I'm no more
responsible for the maintenance of the docs than you or anyone else. I
just try to improve what I can, when it's easy enough for me to do.
It's added, but I wanted to put a link to this mail thread, and that needs
approval, apparently.

So please read it and tell me if it's understandable (it's definitely not
Shakespeare...):
http://www.cmake.org/Wiki/CMake_Useful_Variables#Environment_Variables

--paf

Kishore, Jonnalagadda (IE10)
2007-03-20 09:00:58 UTC
Permalink
Post by Pascal Fleury
Post by Kishore, Jonnalagadda (IE10)
This is now a little confusing especially, when the description says
"
Post by Pascal Fleury
Post by Kishore, Jonnalagadda (IE10)
automatically add CMAKE_CURRENT_SOURCE_DIR and
CMAKE_CURRENT_BINARY_DIR
Post by Pascal Fleury
Post by Kishore, Jonnalagadda (IE10)
to the include directories _in every directory_"
Yes, and I think that the origin of the problem is that this very
sentence
Post by Pascal Fleury
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
Post by Pascal Fleury
this command in every CMakeLists.txt in your project on the first
line,
Post by Pascal Fleury
but
it saves you the typing.
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
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
Post by Pascal Fleury
binary dir to the include directories in every directory" as the doc
says.
Post by Pascal Fleury
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
Post by Pascal Fleury
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
Pascal Fleury
2007-03-20 09:16:37 UTC
Permalink
Post by Kishore, Jonnalagadda (IE10)
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!?
That's my understanding, yes.
Post by Kishore, Jonnalagadda (IE10)
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?
It has another use in my case: cmake generated files. They will end up in the
binary folder, which is then also included. If you generate a config.h from
the config.cmake in your src dir, then it is kind of "natural" to include it
as #include "config.h". This would fail if you did not have the binary dir
also pulled in.

--paf
Loading...