[CMake] add_definitions affects rc.exe call
Michael Wild
themiwi at gmail.com
Mon Aug 31 07:30:18 EDT 2009
On 31. Aug, 2009, at 13:23, Nicolas Desprès wrote:
> 2009/8/31 Michael Wild <themiwi at gmail.com>:
>>
>> On 31. Aug, 2009, at 11:42, Nicolas Desprès wrote:
>>
>>> Hi all,
>>>
>>> I'm using cmake-2.6.4 to build a project using Visual C++ 2005 and
>>> the
>>> Unix Makefile generator. At the beginning of my main
>>> CMakeLists.txt I
>>> have something like that:
>>>
>>> add_definitions(/Zc:wchar_t- /nologo /wd4996 /wd4290)
>>>
>>> Everything compile fine except the build of the RC object of my
>>> binary. I get this error:
>>>
>>> fatal error RC1212: invalid option - /z argument missing
>>> substitute font
>>> name
>>>
>>> It seems that /Zc:wchar_t- and /nologo are not understood by rc.exe.
>>> So I've fixed the probleme by writting
>>>
>>> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t- /nologo /wd4996
>>> /wd4290")
>>>
>>> I'm not sure if it is the right way to do it but it works.
>>>
>>> Does add_definitions supposed to affects the list of argument
>>> passed to
>>> rc.exe ?
>>>
>>> Cheers,
>>>
>>> --
>>> Nicolas Desprès
>>>
>>
>> AFAIK rc.exe does preprocessing, so you could use include files and
>> do macro
>> expansion, so yes: add_definitions stuff should be passed to rc.exe.
>>
>
> According the rc.exe /help you are right. But rc.exe does not
> understand all flags you can pass to cl.exe through add_definitions.
>
Well, add_definitions is just for that: adding preprocessor
definitions! That means flags, that get passed to the preprocessor
using either -D or /D (or whatever your compiler happens to use).
Nothing else. Although http://cmake.org/cmake/help/cmake2.6docs.html#command
:add_definitions says that it can also be used for "any flags", I
really only would use it for that purpose. Especially as doing it the
way I showed gives the user of your build system a fighting chance,
e.g. when he wants to use a different compiler.
Michael
More information about the CMake
mailing list