[CMake] Determining good GCC parameters

Antti S. Lankila alankila at bel.fi
Tue Aug 22 16:41:33 EDT 2006


Philippe Poilbarbe wrote:
> Antti S. Lankila a écrit :
>> ...
>>
>> 1) how would I find out the version of GCC I'm running on?
>>
>> 2) how would I obtain precise knowledge about the host architecture 
>> I'm running on?
>>
>> 3) how would an user best configure the cmake build system to do a 
>> generic instead of native build?
>>
> Since CMake is a multi-platform general tool, we don't have to suppose 
> that GCC is used even with linux.
> It is not the only one compiler (here we also use intel and pgi C and 
> fortran compilers).
> So your question may be written this way:
>
> 1) Which compiler do I use
> 2) How would I find the version of the compiler I use
> 3) how would I obtain precise knowledge about the host architecture 
> I'm running on?
> 4) What are the valid options do generic or fully optimized builds (or 
> more generally
>    how are specific options to do some special trick: warning level, 
> warning is error,
>    source compatibility level...).
> 5) how would an user best configure the cmake build system to do a 
> generic instead of native build?

I agree with your restructuring of my statements from a generic CMake 
point-of-view. However, I suspect that the code I'm working on is 
probably GCC dependant, and there is quite little realistic reason to 
expect it will ever be compiled on another compiler. So from my 
viewpoint, the other compilers are irrelevant and will always be.

But let me drop this argument here, I'm not going to say "GCC is the 
most important compiler ever" although it might be true.

The 1) is presumably answered by examining CMAKE_C_COMPILER.

The 2) was solved by the kind folks of KDE.

The 3) is yet to be solved, I suppose I start playing with reading 
/proc/cpuinfo on Linux and do something else on W32 and something 
different if I manage to port the app to Intel OS X. This is the kind of 
hard work that someone else should do for me. ;-)

For 4,5 ) I imagine I must simply make an user tunable setting in CMake 
options GUI that switches between host detection or some safe static 
option set. My project is quite SSE dependant and I'm rather interested 
in seeing that the SSE instruction set is available, therefore I care 
about specifying architecture correctly. (Just adding -msse will work, 
but it's probably even better to actually specify the architecture.)

-- 
Antti


More information about the CMake mailing list