MantisBT - CMake
View Issue Details
0012639CMakeCMakepublic2011-12-23 17:422011-12-24 14:18
Pau Garcia i Quiles 
Bill Hoffman 
normalblockalways
closedno change required 
MSVC2010SP1Windows7 SP1 64-bit
CMake 2.8.6 
 
0012639: CXX_FLAGS is not set unless a project asks for C++
Visual C++ 2010 does not support C99 yet and it seems it will be a
long time before MSVC supports it. For now, the usual work-around is
to build the project as C++.

I'd like to build as C if using mingw, and as C++ if using MSVC.

As Bill and others suggested, I'm using set_source_files_properties(<SRCS> PROPERTIES LANGUAGE CXX).

Problem is the configure step works fine but the generation step fails because CXX_FLAGS have not been set.

Work-around: include a dummy project that just sets "project(dummy CXX)" so that C++ flags are registered.

See this thread for more details:

http://www.cmake.org/pipermail/cmake/2011-December/048222.html [^]

See attached minimal tests cases:
- fails
- passes (using workaround)
The proper solution is to look for CXX_FLAGS if any source file has a property involving C++ language.
No tags attached.
7z cmakecxx.7z (531) 2011-12-23 17:42
https://public.kitware.com/Bug/file/4150/cmakecxx.7z
Issue History
2011-12-23 17:42Pau Garcia i QuilesNew Issue
2011-12-23 17:42Pau Garcia i QuilesFile Added: cmakecxx.7z
2011-12-24 11:50Pau Garcia i QuilesNote Added: 0028072
2011-12-24 14:18Bill HoffmanStatusnew => closed
2011-12-24 14:18Bill HoffmanAssigned To => Bill Hoffman
2011-12-24 14:18Bill HoffmanResolutionopen => no change required

Notes
(0028072)
Pau Garcia i Quiles   
2011-12-24 11:50   
As Bill pointed in the mailing list, this can be solved by calling "enable_language(CXX)".