[CMake] include directories,

Michael Wild themiwi at gmail.com
Wed Aug 10 11:10:50 EDT 2011


On Wed 10 Aug 2011 04:51:36 PM CEST, Łukasz Tasz wrote:
> Hi All,
> 
> Can somebody please advise me with this topic, if it is expected
> behaviour or a bug?
> 
> thanks in advance
> Lukasz
> 
> 2011/8/4 Łukasz Tasz <lukasz at tasz.eu>:
>> Hi All,
>>
>> I have a question according include_directories() function and
>> INCLUDE_DIRECTORIES directory property.
>>
>> Is it possible that I will know set of include directories that will
>> be used by preprocessor when I'm calling add_executable function?
>>
>> I notticed, that order does not matter, for example:
>>
>> add_library(test test.cxx)
>> include_directories("${CMAKE_CURRENT_SOURCE_DIR}libtest")
>> add_library(test1 test1.cxx)
>>
>> both targets will have the same include directories.
>>
>> so from CMake phase I'm not able to check what will be includes
>> configuration, INCLUDE_DIRECTORIES property contain only current one.
>>
>> is this expected behaviour or this can be tuned by setting some policy?
>>
>> thanks in advance
>> Lukasz Tasz

It is expected behaviour. The INCLUDE_DIRECTORIES is a directory
property, and applies to *all* targets defined in that directory. The
targets themselves get generated *after* the processing of the full
CMakeLists.txt file in this directory. However, the get_directory() call
gets evaluated immediately.

I suspect what you want is different include paths for some of the files
or targets, right? Currently the only solution is to put these targets
into different directories. If you need file-level differentiation,
you'll need static libraries in distinct directories.

I know, it is a PITA and has caused much grief for a lot of people on
this list... ;-)


Michael


More information about the CMake mailing list