[CMake] VS8.0 CompileAs

Philippe Fremy phil at freehackers.org
Tue Apr 15 05:45:01 EDT 2008


	Hi,

For one of my project, I need to compile files with .c extension as C++ 
files. It's an uncommon need but it exists.

In Visual Sturio, there is a compiler option, /TP that does exactly 
this. In Visual Studio  2005 project files, it seems to translate into 
CompileAs property which can be set to 1 (compile as C), 2 (compile as 
C++) or 3 (compile as the project defines it).

I am using CMake 2.4.8

On the project I generated, the general project property correctly 
CompileAs="2". However, each file is marked as CompileAs="1", which 
means that the global option is never applied.

Extract from the .vcproj file (simplified):

			<Tool
				Name="VCCLCompilerTool"
				AdditionalOptions=" /Zm1000"
				AdditionalIncludeDirectories=""							CompileAs="2"
				DebugInformationFormat="3"
				ExceptionHandling="1"
				MinimalRebuild="TRUE"
				Optimization="0"
				RuntimeTypeInfo="TRUE"
				WarningLevel="3"
				PreprocessorDefinitions=""
				AssemblerListingLocation="Debug"
				ObjectFile="$(IntDir)\"
				ProgramDataBaseFileName=""
			/>
	
[...]

			<File	RelativePath="startup.c">
				<FileConfiguration
					Name="Debug|Win32">
					<Tool
					Name="VCCLCompilerTool"
					CompileAs="1"
					/>
				</FileConfiguration>
	

I want the CompileAs of the file to be either "2" (C++) or "3" (inherit 
from project). Is there anything I can do about this ?

	thanks in advance,

	Philippe



More information about the CMake mailing list