[CMake] Toggling a Preprocessor macro for targets within a single project

Christopher Harvey chris at basementcode.com
Fri Feb 20 11:41:27 EST 2009


Michael Jackson wrote:
>
> On Feb 20, 2009, at 8:51 AM, Christian Ehrlicher wrote:
>
>> Michael Jackson schrieb:
>>>
>>> On Feb 20, 2009, at 4:59 AM, Eric Noulard wrote:
>>>
>>>> 2009/2/20 Christian Ehrlicher <Ch.Ehrlicher at gmx.de>:
>>>>>> Von: Andreas Pokorny
>>>>>> Hello,
>>>>>> Wow that was fast. Thanks a lot.
>>>>
>>>> Obviously I was too fast reading the doc :-)
>>>>
>>>>>>> [...]
>>>>>>>
>>>>>>> SET_TARGET_PROPERTIES(PlatformLib PROPERTIES
>>>>>>>                                           DEFINE_SYMBOL USE_TRACER)
>>>>>>>
>>>>>>> Then you shouldn't have to ADD_DEFINITIONS and REMOVE_DEFINITIONS?
>>>>>>
>>>>>>
>>>>>> I do not understand why.. but DEFINE_SYMBOL did not work, but
>>>>>> COMPILE_FLAGS -DUSE_TRACER
>>>>>> did. So SET_TARGET_PROPERTIES is the sledgehammer for getting it
>>>>>> done :)
>>>>>>
>>>>> DEFINE_SYMBOL only works for shared libraries. see cmake
>>>>> documentation: "DEFINE_SYMBOL sets the name of the preprocessor
>>>>> symbol defined when compiling sources in a shared library."
>>>>
>>>> Thank you  Christian
>>>> ...for reading the doc more carefully  than I do :-)
>>>>
>>>>
>>>> -- 
>>>> Erk
>>>>
>>>
>>> and I _think_ that DEFINE_SYMBOL only will work on windows as it is
>>> there to facilitate the dllImport/dllexport functionality used by
>>> windows for exporting/importing symbols from shared libraries.
>>>
>>> I may be wrong on that as I am going on memory at this point.
>>>
>> This is wrong - you've a similar option with gcc - the visibility
>> attribute.
>>
>>
>> Christian
>
> Yep. you are correct. I was away from my machine and so was obviously
> remembering things in-correctly.
>
> Mike
for anybody later googleing this thread with a question about gcc
visibility and msvc  import/export I've managed to implement this
http://gcc.gnu.org/wiki/Visibility
in cmake for windows and gcc on linux. I get the same behavior on both
platforms.
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



More information about the CMake mailing list