[CMake] add_definitions affects rc.exe call
Michael Wild
themiwi at gmail.com
Mon Aug 31 07:14:22 EDT 2009
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.
If I were you, I would do it like this:
set(CMAKE_EXTRA_CXX_FLAGS "/Zc:wchar_t- /nologo /wd4996 /wd4290" CACHE
STRING "Extra CXX options")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_EXTRA_CXX_FLAGS})
This way the user then has still the option to edit the
CMAKE_EXTRA_CXX_FLAGS variable in the cache if he wants to, without
having to change the CMake code.
HTH
Michael
More information about the CMake
mailing list