[CMake] Eclipse generator - basic macros
Miguel A. Figueroa-Villanueva
miguelf at ieee.org
Tue Jul 14 19:26:38 EDT 2009
On Tue, Jul 14, 2009 at 7:46 PM, Benjamin Schindler wrote:
> Miguel A. Figueroa-Villanueva wrote:
>> Just to be clear...
>>
>> If you have compiler dependent code:
>>
>> #if defined(_MSC_VER)
>> ...
>> #elif defined(__GNUC__)
>> ...
>> #else
>> ...
>> #endif
>>
>> Then you could do something like the following in CMakeLists.txt:
>>
>> if (CMAKE_COMPILER_IS_GNUC)
>> add_definitions(-DWORKING_WITH_GCC) # or use COMPILE_DEFINITIONS property
>> elseif (MSVC)
>> add_definitions(-DWORKING_WITH_MSVC) # or use COMPILE_DEFINITIONS
>> property
>> endif()
>>
>> and the code above would look like:
>>
>> #if defined(WORKING_WITH_MSVC)
>> ...
>> #elif defined(WORKING_WITH_GCC)
>> ...
>> #else
>> ...
>> #endif
>>
>
> Yes, I could do that. But that's a hack - it should not be needed. All
> compilers have their macros which enables to differentiate between them, so
> why adding a new one?
Right, it is a hack (after all it is a work around) I was just curious
to know where it wouldn't work... and I also wanted to make sure that
the eclipse generator is feeding the manually added definitions
correctly to the IDE.
However, please do add this as a feature request at:
http://public.kitware.com/Bug/my_view_page.php
The following lines seem to dump the needed information:
echo | gcc -v -x c -E -dD -
echo | gcc -v -x c++ -E -dD -
Add any other relevant information; even patches are welcome ;)
--Miguel
More information about the CMake
mailing list