[CMake] Re-defining CMAKE_CXX_FLAGS with /TP for cl.exe

Bill Hoffman bill.hoffman at kitware.com
Tue Jun 30 09:27:14 EDT 2009


Knox, Kent wrote:
> I've just stumbled across some surprising cl.exe behavior, and I
> would like to see if the collective minds of this dist list has come
> across this before.
> 
> In my c++ project, I override CMAKE_CXX_FLAGS with my own flags,
> including /TP.  Using an nmake based build, this causes the linking
> step to bomb.  Enabling verbose mode for nMake, I saw that /TP was
> actually being defined twice, once by me and I suppose cMake did too
> for good measure.  By eliminating my flags one by one, I found that
> my /TP caused the link problem.
> 
> This is using cmake 2.6.4, 64bit MSVC tools and nmake generator.
> Snippet of error log below.  Does this make sense to anybody?
> 

CMake automatically sets the compiler to pick the correct language, so 
you should not need /TP.  CMake also uses the CXX Flags during the link 
phase, and if you use /TP the compiler treats the .obj file like a c++ 
file.   I guess CMake should filter out the /TP flag for linking, but 
there is no reason for you to add that flag in the first place.

-Bill


More information about the CMake mailing list