MantisBT - CMake
View Issue Details
0004772CMakeCMakepublic2007-04-03 11:392008-10-01 13:25
irwin 
Bill Hoffman 
normalmajoralways
closedfixed 
 
 
0004772: CMAKE_BUILD_TYPE does not work correctly for language enabled with ENABLE_LANGUAGE
The combination

PROJECT(free_eos CXX)
ENABLE_LANGUAGE(C)

defines the correct CXX flags, but blanks the C flags in the cache rather than defining them properly, e.g.,

//C compiler.
CMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc

//Flags for C compiler.
CMAKE_C_FLAGS:STRING=' '

//Flags used by the compiler during debug builds.
CMAKE_C_FLAGS_DEBUG:STRING=

//Flags used by the compiler during release minsize builds.
CMAKE_C_FLAGS_MINSIZEREL:STRING=

//Flags used by the compiler during release builds (/MD /Ob1 /Oi
// /Ot /Oy /Gs will produce slightly less optimized but smaller
// files).
CMAKE_C_FLAGS_RELEASE:STRING=

//Flags used by the compiler during Release with Debug Info builds.
//
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=

With these compile flags blanked, it turns, e.g., CMAKE_BUILD_TYPE=Debug into a no-op for the C language.

If I try, instead

PROJECT(free_eos C)
ENABLE_LANGUAGE(CXX)

then the C flags are defined correctly, but the CXX flags are blanked turning, e.g., CMAKE_BUILD_TYPE=Debug into a no-op for the C++ language.

I don't know a fix for this bug in ENABLE_LANGUAGE for Linux, and the only workaround is never to use it, and always specify required languages with the PROJECT command (which is awkward if you want to have language support at the user's option).
No tags attached.
related to 0009656closed Brad King Enabling C adds duplicates in CMAKE_SYSTEM_{PREFIX,INCLUDE}_PATH 
Issue History
2008-08-21 16:01Bill HoffmanStatusassigned => closed
2008-08-21 16:01Bill HoffmanNote Added: 0013144
2008-08-21 16:01Bill HoffmanResolutionopen => fixed
2008-08-21 17:00Bill HoffmanNote Added: 0013145
2008-08-21 17:00Bill HoffmanStatusclosed => assigned
2008-08-21 17:01Bill HoffmanResolutionfixed => reopened
2008-10-01 13:25Bill HoffmanStatusassigned => closed
2008-10-01 13:25Bill HoffmanNote Added: 0013654
2008-10-01 13:25Bill HoffmanResolutionreopened => fixed
2009-10-05 11:22Brad KingRelationship addedrelated to 0009656

Notes
(0013144)
Bill Hoffman   
2008-08-21 16:01   
Seems to be working now.
(0013145)
Bill Hoffman   
2008-08-21 17:00   
Does not work on linux, but works on windows.
(0013654)
Bill Hoffman   
2008-10-01 13:25   
cvs commit -m "BUG: fix for bug 4772, enable_language should now work on linux with correct flags"
cvs commit: Examining .
cvs commit: Examining Platform
Committer: Bill Hoffman <bill.hoffman@kitware.com>
Committer: Bill Hoffman <bill.hoffman@kitware.com>
/cvsroot/CMake/CMake/Modules/CMakeCInformation.cmake,v <-- CMakeCInformation.cmake
new revision: 1.23; previous revision: 1.22
/cvsroot/CMake/CMake/Modules/Platform/Linux.cmake,v <-- Platform/Linux.cmake
new revision: 1.19; previous revision: 1.18