<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri" size="2"><span style="font-size:11pt;">
<div>We are using cmake 2.8.11 for out project. </div>
<div> </div>
<div>Our local compiler is gcc-4.4.3. There is desire to use a newer compiler, but we are not yet ready to commit to anything yet. In the mean time we have installed binaries gcc-4.7 and gcc-4.8. We can specify the alternate compiler with –DCMAKE_C_COMPILER=gcc-4.7,
but we want to go a step farther: one (believed important) advantage of gcc-4.7 is the option -mtune=atom since that is are target system. We want to force this option when using the newer compiler, but the older version of gcc doesn’t accept it.</div>
<div> </div>
<div>Toolchain files are not an option, when you use a toolchain file cmake sets CMAKE_CROSSCOMPILING meaning parts of our system that depend on running on x86 will not run. (it is up to a different team to make a build for other processors – they are nowhere
close to done but that variable is used in a few places to disable things that my team needs). </div>
<div> </div>
<div>Here is what we come up with, which both feels icky, and seems like a bad compromise:</div>
<div> </div>
<div style="margin-bottom:10pt;">IF("4.8.0" STREQUAL ${CMAKE_CXX_COMPILER_VERSION} OR "4.8.1" STREQUAL ${CMAKE_CXX_COMPILER_VERSION} OR "4.8" STREQUAL ${USE_GCC_VERSION})</div>
<div style="margin-bottom:10pt;"> SET(CMAKE_CXX_COMPILER "g++-4.8")</div>
<div style="margin-bottom:10pt;"> SET(CMAKE_C_COMPILER "gcc-4.8")</div>
<div style="margin-bottom:10pt;"> SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++11")</div>
<div style="margin-bottom:10pt;"> SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs" CACHE STRING "" FORCE)</div>
<div style="margin-bottom:10pt;"> ELSEIF("4.7.1" STREQUAL ${CMAKE_CXX_COMPILER_VERSION} OR "4.7.2" STREQUAL ${CMAKE_CXX_COMPILER_VERSION} OR "4.7" STREQUAL ${USE_GCC_VERSION})</div>
<div style="margin-bottom:10pt;"> SET(CMAKE_CXX_COMPILER "g++-4.7")</div>
<div style="margin-bottom:10pt;"> SET(CMAKE_C_COMPILER "gcc-4.7")</div>
<div>ENDIF("4.8.0" STREQUAL ${CMAKE_CXX_COMPILER_VERSION} OR "4.8.1" STREQUAL ${CMAKE_CXX_COMPILER_VERSION} OR "4.8" STREQUAL ${USE_GCC_VERSION})</div>
<div> </div>
<div>The advantage of this is you can’t accidentally use gcc-4.4 and g++-4.8 – we force them in sync. You can also set USE_GCC_VERSION on the command line and it takes both gcc and g++, instead of having to set both CMAKE_C_COMPILER and CMAKE_CXX_COMPILER (and
the line to remember is shorter). If you do this will work (until we upgrade gcc, but I can solve that)</div>
<div> </div>
<div>What is the “right” thing to do – and why is it right?</div>
<div> </div>
<div> </div>
</span></font>
</body>
</html>