[CMake] More control with includes? and non-immediate controls
Bradley Lowekamp
blowekamp at mail.nih.gov
Wed Jun 22 10:51:38 EDT 2005
Hello,
Based on the behavior I have seen, I coded up this example of what I
find to be odd behavior. Consider the following cmake simplified
example:
INCLUDE_DIRECTORIES(foo/include)
ADD_LIBRARY(foo ${FOOS_SRC})
INCLUDE_DIRECTORIES(bar/include)
ADD_LIBRARY(bar ${BARS_SRC})
With these lines I find it interesting that both libraries get compiled
with both include! This is something that is good to know. I guess
there are probably alot of there configuration variables that will fall
into this category of non-immediate effect. The code that I wrote when
I ran into this issue was something like this:
GET_DIRECTORY_PROPERTY(OLD_INCLUDE_DIRS INCLUDE_DIRECTORIES)
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES
"${OLD_INCLUDE_DIRS};${ANOTHER_INCLUDE_DIR}")
ADD_LIBRARY(somelib ${SOME_SRC})
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES
"${OLD_INCLUDE_DIRS};)
I this may be a bigger topic then just the target includes. And
probably comes from the core design of cmake, and could not easily be
done? What are your thoughts on this behavior?
Thanks,
Brad
On Jun 21, 2005, at 4:51 PM, Brad King wrote:
> Bradley Lowekamp wrote:
>> I am needing more control over the include directories. Maybe I am
>> missing some part of CMake or some option some place. I have a
>> directory where I am trying to create a couple of libraries. But they
>> have conflicting include directory requirements. The
>> "INCLUDE_DIRECTORIES" command has no target or file specific effect,
>> so that does not help me with this problem. I tried hacking around
>> with the "SET_DIRECTORY_PROPERTIES" with the "INCLUDE_DIRECTORIES",
>> but the effect of this command seems not to be immediate, and the
>> result at the end of the file is applies to all libraries in the
>> directory.
>> Is there a way to get more control over include directories or an I
>> stuck with just INCLUDE_DIRECTORIES?
>
> You'll have to use separate directories for the two libraries. Using
> LIBRARY_OUTPUT_PATH you can get them to still show up next to each
> other in the build tree. The source files can also stay next to one
> another because you can specify a relative path to them in the
> CMakeLists.txt file.
>
> Per-target include directory (among other) settings would be a good
> feature request for the bug tracker if you want to add it:
>
> http://www.cmake.org/Bug
>
> -Brad
>
>
========================================================
Bradley Lowekamp
Management Systems Designers Contractor for
Office of High Performance Computing and Communications
National Library of Medicine
'blowekamp at mail.nih.gov
More information about the CMake
mailing list