[CMake] namespace support

Peter Kümmel syntheticpp at gmx.net
Thu Feb 3 03:59:52 EST 2011


On 03.02.2011 00:56, Michael Jackson wrote:
>
> On Feb 2, 2011, at 6:38 PM, Peter Kümmel wrote:
>
>> On 02.02.2011 16:39, Michael Jackson wrote:
>>>
>>> On Feb 2, 2011, at 10:21 AM, Peter Kümmel wrote:
>>>
>>>> On 02.02.2011 16:17, Michael Wild wrote:
>>>>>> namespace(a)
>>>>>>      include_directories(a)
>>>>>>      add_library(a MODULE a/a.cpp)
>>>>>> endnamespace()
>>>>>>
>>>>> Put a CMakeLists.txt file in a/ and b/ and do the include_directories()
>>>>
>>>> Exactly this is what I don't wanna do and why I've asked ;)
>>>>
>>>> Seems it becomes a feature request.
>>>>
>>>> Peter
>>>>
>>>>> and add_library() calls in there. That's the only way to have separate
>>>>> include directories since there is no corresponding target property
>>>>> (which admittedly would be nice to have).
>>>>>
>>>>> Michael
>>>
>>> Could you create some sort of function call for adding your simple executables?
>>>
>>> function(ADD_MY_LIBRARY path name include_dirs)
>>>    include_directories(${include_dirs})
>>>    add_library(${name} MODULE ${path}
>>> endfunction()
>>>
>>> I _think_ functions have their own scope. I could be wrong.
>>
>> Thanks, I will try it, until now I only used macros.
>>
>> Peter
>>
>
> The subtle difference between a macro and a function is to think of a macro as something like a C/C++ preprocessor #define statement. What ever is in the macro will be substituted at the place in the code where you called it. A function on the other hand really is like a "C" function with its own scope. A "function" is really what you want in this case.
>
> Mike J.
>

I tried it with function and see no difference to the macro approach: each include path is in all projects.
So function does not help.

Pete



More information about the CMake mailing list