[CMake] VC7.1 project files and /TP

Bill Hoffman bill.hoffman at kitware.com
Tue Jul 24 09:43:51 EDT 2007


Torsten Martinsen wrote:
> Hi,
>  
> I have a library that contains both C++ and C files. For various
> reasons, the C files must be compiled as C++. In my CMakeLists.txt file
> I have
>
> 	IF(OPT_DEST_VISUALSTUDIO)
> 	   ADD_DEFINITIONS(-TP)
> 	ENDIF(OPT_DEST_VISUALSTUDIO)
>  
> This works fine for "NMake Makefiles" output, but for "Visual Studio 7
> .NET 2003" the C files are always compiled with /TP (and in the project
> file, "Compile As" is set to "Compile as C Code (/TC)". Looking at
> cmLocalVisualStudio7Generator.cxx, it looks as if this is indeed
> hardcoded:
>
>     if(strcmp(linkLanguage, "C") == 0)
>     {
>         flags += " /TC ";
>     }
>     if(strcmp(linkLanguage, "CXX") == 0)
>     {
>         flags += " /TP ";
>     }
>
> I have also tried
>
> 	SET_SOURCE_FILES_PROPERTIES(
> 	   ${C_SOURCE}
> 	   PROPERTIES COMPILE_FLAGS "-TP")
>
> with the same (lack of) result. Any ideas?
>   
Try this:

SET_SOURCE_FILES_PROPERTIES( ${C_SOURCE} PROPERTIES LANGUAGE CXX)

It should work in 2.4.7, but the docs for 2.4.7 have not been updated to include this,
but the code has it.

-Bill
 



More information about the CMake mailing list