<div class="gmail_quote">On Tue, Jan 4, 2011 at 9:59 AM, John Clayton <span dir="ltr"><<a href="mailto:johnc@filewave.com">johnc@filewave.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="word-wrap: break-word;">I have a solution for the problem of creating XCode 3.2.x project on a 10.6 machine that are to target the 10.4u SDK.<div><br></div><div>Here's what I did (thanks to the OGRE and Open Scene Graph projects - which exposed me to this solution). </div>
<div><br></div><div>WARNING: my solution assumes a 32 bit build, so here goes:</div><div><br></div><div>Here's how: put this right at the top of the CMakeLists.txt - in my case, the very top level one. </div><div><div>
<br></div><div>if (APPLE)</div><div> # Force gcc <= 4.0 on Mac OS X because 4.2 is not supported prior to Mac OS X 10.5</div><div> include(CMakeForceCompiler)</div><div> CMAKE_FORCE_C_COMPILER(gcc-4.0 GNU)</div><div>
CMAKE_FORCE_CXX_COMPILER(g++-4.0 GNU)</div><div> SET(CMAKE_SIZEOF_VOID_P 4)</div><div>endif ()</div><div class="im"><div><br></div><div>set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "4.0")</div></div></div><div><br></div>
<div><br></div><div>so, what's it do??</div><div><br></div><div>the FORCE_C_COMPILER stuff is going to ensure that the 4.0 series GCC compiler is picked up, which is really useful when the compiler-test phases of cmake get run. What isn't obvious though is that when this is done, some tests the ptr size are NOT carried out any longer, which impacted our project - so here's the caveat: I'm forcing the CMAKE_SIZEOF_VOID_P to 4, which means the rest of our codebase goes with a 32 bit build. For me, not a problem - for you - good luck :-)</div>
<div><br></div><div>The CMAKE_XCODE_ATTRIBUTE_GCC_VERSION is *also* required. This forces the GCC_VERSION attribute within the xcode configuration to be 4.0 instead of 4.2 (assuming build platform of 10.6). </div><div><br>
</div><div>Take note; if you leave the CMAKE_XCODE_ATTRIBUTE_GCC_VERSION out - then the Xcode GCC version will *still be 4.2* - so you need both of these settings in the CMakeLists.txt file.</div><div><br></div><div>If anyone can improve on this - I'd appreciate it, thanks for all your help and good luck with those 10.4u builds from a 10.6.x machine!</div>
<div><div class="im"><br><div>
<span><img src="https://mail.google.com/a/kitware.com/?ui=2&ik=c3d8d31f4e&view=att&th=12d518b44df42c9c&attid=0.0.1.1&disp=emb&zw" width="137" height="42"></span><span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="font-size: 12px;"><div>
<br><br><br></div><div><span style="font-family: Consolas; font-size: 14px;">John Clayton</span></div><div><font face="Consolas" size="4"><span style="font-size: 14px;"><br></span></font></div><div><span style="font-family: Consolas; font-size: 14px;">---------------------------</span></div>
<div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;"><span style="font-size: 10.5pt; font-family: Consolas;" lang="EN-US">FileWave (Europe) GmbH</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;">
<span style="font-size: 10.5pt; font-family: Consolas;" lang="EN-US">St. Gallerstrasse 1</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;"><span style="font-size: 10.5pt; font-family: Consolas;" lang="EN-US">CH - 9500 Wil</span></div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;"><span style="font-size: 10.5pt; font-family: Consolas;" lang="EN-US"> </span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;">
<span style="font-size: 10.5pt; font-family: Consolas;" lang="EN-US">Phone: +41 71 914 30 80</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;"><span style="font-size: 10.5pt; font-family: Consolas;">Fax: +41 71 914 30 81</span></div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;"><span style="font-size: 10.5pt; font-family: Consolas;">Web: <a style="color: blue; text-decoration: underline;">www.filewave.com</a></span></div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;"><font face="Consolas" size="4"><span style="font-size: 14px;">Skype: johncclayton</span></font></div></div><div><br></div></span></span><br>
<br>
</div>
<br></div><div><div><div></div><div class="h5"><div>On 03.01.2011, at 14:36, John Clayton wrote:</div><br></div></div><blockquote type="cite"><div style="word-wrap: break-word;"><div><div></div><div class="h5">Hi All,<div>
<br></div><div>i'm still having problems getting the CMAKE_XCODE_ATTRIBUTE_GCC_VERSION flag to properly force the compiler version I want to use for my project. </div><div><br></div><div>I'm using XCode 3.2.5, on a Mac 10.6.3 machine - trying to target a Max OS X Tiger 10.4u build. I get compiler errors because the gcc-4.2 compiler is being used in the compiler-test stage of CMake. </div>
<div><br></div><div>I thought CMAKE_XCODE_ATTRIBUTE_GCC_VERSION could be used to force the compiler setting to 4.0?</div><div><br></div><div>My top level CMakeLists.txt file has this as its first few lines - is this the correct way to use this option? </div>
<div><br></div><div><div><span style="white-space: pre-wrap;"> </span>PROJECT( FileWave )</div><div><span style="white-space: pre-wrap;"> </span>cmake_minimum_required(VERSION 2.6)</div><div><span style="white-space: pre-wrap;"> </span>set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "4.0")</div>
<div><br></div></div><div>The error I get after running an XCode based generator is: </div><div><div>-- The C compiler identification is GNU</div><div>-- The CXX compiler identification is GNU</div><div>-- Checking whether C compiler has -isysroot</div>
<div>-- Checking whether C compiler has -isysroot - yes</div><div>-- Checking whether C compiler supports OSX deployment target flag</div><div>-- Checking whether C compiler supports OSX deployment target flag - yes</div>
<div>-- Check for working C compiler using: Xcode</div><div>-- Check for working C compiler using: Xcode -- broken</div><div>CMake Error at /Users/john/CMake/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):</div><div> The C compiler "/usr/bin/gcc-4.0" is not able to compile a simple test</div>
<div> program.</div><div><br></div><div> It fails with the following output:</div><div><br></div><div> Change Dir: /Users/john/src/TRUNK/BuildSystem/Xcode/CMakeFiles/CMakeTmp</div><div><br></div><div> </div><div><br>
</div><div> Run Build Command:/Users/john/CMake/bin/cmakexbuild -project</div><div> CMAKE_TRY_COMPILE.xcodeproj build -target cmTryCompileExec -configuration</div><div> Debug</div><div><br></div><div> </div><div><br></div>
<div> === BUILD NATIVE TARGET cmTryCompileExec OF PROJECT CMAKE_TRY_COMPILE WITH</div><div> CONFIGURATION Debug ===</div><div><br></div><div> Check dependencies</div><div><br></div><div> GCC 4.2 is not compatible with the Mac OS X 10.4 SDK (file testCCompiler.c)</div>
<div><br></div><div> GCC 4.2 is not compatible with the Mac OS X 10.4 SDK (file testCCompiler.c)</div><div><br></div><div> ** BUILD FAILED **</div><div><br></div><div> </div></div><div><br></div></div></div><div><br><div>
<span><span><pastedGraphic.tiff></span></span><div class="im"><span style="font-size: 12px;"><div><br><br><br></div><div><span style="font-family: Consolas; font-size: 14px;">John Clayton</span></div><div><font face="Consolas" size="4"><span style="font-size: 14px;"><br>
</span></font></div><div><span style="font-family: Consolas; font-size: 14px;">---------------------------</span></div><div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;"><span style="font-size: 10.5pt; font-family: Consolas;" lang="EN-US">FileWave (Europe) GmbH</span></div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;"><span style="font-size: 10.5pt; font-family: Consolas;" lang="EN-US">St. Gallerstrasse 1</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;">
<span style="font-size: 10.5pt; font-family: Consolas;" lang="EN-US">CH - 9500 Wil</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;"><span style="font-size: 10.5pt; font-family: Consolas;" lang="EN-US"> </span></div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;"><span style="font-size: 10.5pt; font-family: Consolas;" lang="EN-US">Phone: +41 71 914 30 80</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;">
<span style="font-size: 10.5pt; font-family: Consolas;">Fax: +41 71 914 30 81</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;"><span style="font-size: 10.5pt; font-family: Consolas;">Web: <a style="color: blue; text-decoration: underline;">www.filewave.com</a></span></div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;"><font face="Consolas" size="4"><span style="font-size: 14px;">Skype: johncclayton</span></font></div></div><div><br></div></span><br>
<br>
</div></div>
<br></div></div></blockquote></div><br></div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br></blockquote></div><br><br>The underlying problem here is that my bug fix for <a href="http://public.kitware.com/Bug/view.php?id=9125">http://public.kitware.com/Bug/view.php?id=9125</a> was insufficient. Woefully so for people who rely on try_compile results in their projects.<br>
<br>The real fix would also involve propagating the CMAKE_XCODE_ATTRIBUTE_GCC_VERSION setting to generated projects for try_compile operations. try_compile operations should use the same compiler and flags (and SDKs and ...) as the top level project. Anything else is just "a hack" to get *something* to work with the system as-is.<br>
<br>I would recommend doing your builds with the "Unix Makefiles" generator for the builds where you *have* to specify the gcc 4.0 compiler.<br><br>For Xcode builds, use the 10.6 SDK (so you can use gcc 4.2), but with the 10.4 deployment target. That should work ok. Should be safe, too, as long as you have regular builds with the 10.4 SDK and gcc 4.0 to make sure you don't introduce hard dependencies on stuff introduced in 10.5 and later.<br>
<br>In the meantime, sounds like it's time for a related bug report on this new manifestation of an old issue. :-(<br><br><br>HTH,<br>David<br><br>