[CMake] "Treat wchar as built-in type" in Cmake ?

Pau Garcia i Quiles pgquiles at elpauer.org
Sat Feb 9 17:12:39 EST 2008


Quoting Stephen Collyer <scollyer at netspinner.co.uk>:

> Stefan Buschmann wrote:
>> Just add the corresponding command line option for the compiler:
>>
>> ADD_DEFINITIONS(
>>      /Zc:wchar_t-                                # Treat wchar_t as
>> built-in type
>> )
>>
>> BTW: The command line switch for a specific option is usually mentioned
>> in the comments for that option in Visual Studio.
>
> Thanks. However, as far as I can see, ADD_DEFINITIONS adds the
> option globally for all projects. I want to restrict it to
> one only - is that possible ?

Yes, it's possible.

You need to set CMAKE_CXX_FLAGS for that project. I can't remember now  
if that variable is read-only. In case it is read only, use  
SET_TARGET_PROPERTIES for each target you want wchar_t as built-in and  
set the COMPILE_FLAGS property.

You may want to add an IF( MSVC70 OR MSVC71 ), since in Visual Studio  
2005 and 2008 wchar_t is already a built-in type.

-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)



More information about the CMake mailing list