[CMake] INCLUDE_DIRECTORIES in sub-directories doesn't work?

Sean Soria sean.soria at gmail.com
Wed Nov 26 15:01:56 EST 2008


Yea, the example was an example.  I changed it to foo/bar.c so no more
multiple main files.

Why is it that source file property COMPILE_FLAGS would work but not
COMPILE_DEFINITIONS?  What is the point of having COMPILE_DEFINITIONS
for source level if it's not obeyed?

On Wed, Nov 26, 2008 at 6:59 AM, Bill Hoffman <bill.hoffman at kitware.com> wrote:
> Bill Hoffman wrote:
>>
>> Sean Soria wrote:
>>>
>>> No, this doesn't work either:
>>> CMakeLists.txt:
>>> ADD_SUBDIRECTORY(foo)
>>> ADD_EXECUTABLE(hello main.c foo/main.c)
>>>
>>> foo/CMakeLists.txt:
>>> SET_PROPERTY(SOURCE main.c PROPERTY INCLUDE_DIRECTORIES
>>> ${CMAKE_CURRENT_SOURCE_DIR})
>>>
>>
>> I might be missing something but why not:
>>
>> INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/foo)
>> ADD_EXECUTABLE(hello main.c foo/main.c)
>>
>
> OK, so I think I just figured out what you are trying to do....
>
> You want two source files in the same target to have different -I flags.
>  There is not really a good way to do that in CMake right now.
>
> You could use the source file property COMPILE_FLAGS, but it might not be
> that portable.   I find it odd that you would need to do something like
> this...   Also, the example seems to have two main.c in one executable which
> is also odd...
>
> -Bill
>


More information about the CMake mailing list