[CMake] namespace support
Michael Jackson
mike.jackson at bluequartz.net
Wed Feb 2 18:56:54 EST 2011
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.
More information about the CMake
mailing list