MantisBT - CMake
View Issue Details
0007340CMakeCMakepublic2008-07-15 13:182008-07-16 11:06
Yuri 
Brad King 
normalminoralways
closedfixed 
CMake-2-6 
 
0007340: Can't call TRY_COMPILE before PROJECT directive.
To tune compiler and linker options I want to use CMAKE_USER_MAKE_RULES_OVERRIDE variable (in addition to ones provided by CMake). To determine whether compiler supports particular flags I use TRY_COMPILE command.
This works in cmake-2.4.8 but fails in cmake 2.6.0. See examples attached.
I suppose this is caused by splitting EnableLanguage logic in CMake 2.6.

cmGlobalGenerator::EnableLanguage function:

In 2.4 after CMake(LANG)Compiler.cmake processed language becomes enabled and LanguageToOutputExtension map filled before processing CMake(LANG)Information.cmake where custom rules are called from.

In 2.6 after first stage, SetLanguageEnabledFlag called but LanguageToOutputExtension stays clean while CMake(LANG)Information.cmake is being processed, so nested call to ReadListFile() fails to get language by extension.
No tags attached.
zip CompilerTest.zip (507) 2008-07-15 13:18
https://public.kitware.com/Bug/file/1600/CompilerTest.zip
Issue History
2008-07-15 13:18YuriNew Issue
2008-07-15 13:18YuriFile Added: CompilerTest.zip
2008-07-15 13:36Bill HoffmanStatusnew => assigned
2008-07-15 13:36Bill HoffmanAssigned To => Alex Neundorf
2008-07-16 11:03Brad KingAssigned ToAlex Neundorf => Brad King
2008-07-16 11:05Brad KingNote Added: 0012722
2008-07-16 11:06Brad KingStatusassigned => closed
2008-07-16 11:06Brad KingResolutionopen => fixed

Notes
(0012722)
Brad King   
2008-07-16 11:05   
The extension-to-language map must be filled before loading CMake<LANG>Information.cmake since that file includes the user-override files. It must be filled after loading that file since it includes the compiler- and platform-specific settings. The solution is to just fill it both before and after.

Fixed:

/cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v <-- Source/cmGlobalGenerator.cxx
new revision: 1.237; previous revision: 1.236
/cvsroot/CMake/CMake/Source/cmGlobalGenerator.h,v <-- Source/cmGlobalGenerator.h
new revision: 1.113; previous revision: 1.112