[CMake] XCode 2.1 partial support
William A. Hoffman
billlist at nycap.rr.com
Mon Jul 18 09:25:21 EDT 2005
Perhaps we could just test the version of gcc on the machine.
Xcode 2.x uses a different version of gcc than 1.5, so a gcc -v might
be enough to figure out what version of Xcode is running.
-Bill
At 09:11 AM 7/18/2005, William A. Hoffman wrote:
>OK,
>
>So this patch really is not an Xcode 2.1 generator, but rather it modifies
>the cmake Xcode 1.5 generator to produce files that will be correctly
>translated by Xcode 2.x into the 2.x format. The big difference between
>1.5 and 2.x is that 2.x uses debug/release directories for placing object code
>and libraries. Mathieu with this patch do all the cmake tests pass with 2.x?
>
>-Bill
>
>
>
>At 09:02 PM 7/17/2005, Mathieu Malaterre wrote:
>>Hello,
>>
>> So I had access(*) to a MacOSX with Tiger+Xcode 2.1 this week end. After playing a while with it I was able to hack the current Xcode15 generator to be compatible with Xcode21, see cmake-xcode.patch attached to this email.
>>
>> My first problem is that this patch breaks Xcode15 compatibility since I was not able to find a way to retrieve Xcode version. In Xcode15, xcodebuild -version returns an error and on Xcode21 it returns
>>
>> DevToolsCore-620.0; DevToolsSupport-610.0
>>
>> Which makes it hard to link to a particular Xcode release (1.5, 2.0 or 2.1). Therefore the only safe way I found to find the version is to read the plist from Xcode:
>>
>>$ grep -A 1 ShortVersion /Developer/Applications/Xcode.app/Contents/Info.plist
>> <key>CFBundleShortVersionString</key>
>> <string>2.1</string>
>>
>>I thought then a code like this should work (see patch):
>>
>>std::string cmGlobalXCodeGenerator::GetXCodeVersion()
>>{
>> CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("com.apple.Xcode") );
>> ...
>>}
>>
>> Unfortunately `bundle' is null...
>>
>>Could someone comment on a way to reliably find the Xcode version ?
>>
>>
>> My second problem is a way to tell ctest that Xcode now generate in /Debug or /Deployment subdir (ala Visual Studio). I was not able to make a proper patch to cmCTest.cxx, resulting in a bad hack (that IMHO should break testing with Makefile generator)
>>
>>Comment on the patch are welcome,
>>Mathieu
>>(*) Thanks to Christopher Knox
>>
>>
>>Index: Source/CMakeLists.txt
>>===================================================================
>>RCS file: /cvsroot/CMake/CMake/Source/CMakeLists.txt,v
>>retrieving revision 1.243
>>diff -u -3 -p -r1.243 CMakeLists.txt
>>--- Source/CMakeLists.txt 15 Jul 2005 15:36:22 -0000 1.243
>>+++ Source/CMakeLists.txt 18 Jul 2005 00:31:27 -0000
>>@@ -183,7 +183,7 @@ ENDIF (WIN32)
>>
>> # create a library used by the command line and the GUI
>> ADD_LIBRARY(CMakeLib ${SRCS})
>>-TARGET_LINK_LIBRARIES(CMakeLib cmsys ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES})
>>+TARGET_LINK_LIBRARIES(CMakeLib cmsys ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES} "-framework Carbon")
>> IF (UNIX)
>> TARGET_LINK_LIBRARIES(CMakeLib ${CMAKE_DL_LIBS})
>> ENDIF (UNIX)
>>Index: Source/cmCTest.cxx
>>===================================================================
>>RCS file: /cvsroot/CMake/CMake/Source/cmCTest.cxx,v
>>retrieving revision 1.277
>>diff -u -3 -p -r1.277 cmCTest.cxx
>>--- Source/cmCTest.cxx 14 Jul 2005 18:15:21 -0000 1.277
>>+++ Source/cmCTest.cxx 18 Jul 2005 00:31:27 -0000
>>@@ -1876,7 +1876,8 @@ std::string cmCTest::GetBinaryDir()
>> //----------------------------------------------------------------------
>> std::string cmCTest::GetConfigType()
>> {
>>- return m_ConfigType;
>>+ //return m_ConfigType;
>>+ return "Debug"; // BAD HACK
>> }
>>
>> //----------------------------------------------------------------------
>>Index: Source/cmGlobalXCodeGenerator.cxx
>>===================================================================
>>RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
>>retrieving revision 1.61
>>diff -u -3 -p -r1.61 cmGlobalXCodeGenerator.cxx
>>--- Source/cmGlobalXCodeGenerator.cxx 13 Jul 2005 20:23:32 -0000 1.61
>>+++ Source/cmGlobalXCodeGenerator.cxx 18 Jul 2005 00:31:27 -0000
>>@@ -22,6 +22,7 @@
>> #include "cmGeneratedFileStream.h"
>> #include "cmSourceFile.h"
>> #include "cmOrderLinkDirectories.h"
>>+#include <Carbon/Carbon.h>
>>
>> //TODO
>> // add OSX application stuff
>>@@ -43,7 +44,7 @@ void cmGlobalXCodeGenerator::EnableLangu
>> cmMakefile * mf)
>> {
>> mf->AddDefinition("XCODE","1");
>>- mf->AddDefinition("CMAKE_CFG_INTDIR",".");
>>+ mf->AddDefinition("CMAKE_CFG_INTDIR","Debug");
>> mf->AddDefinition("CMAKE_GENERATOR_CC", "gcc");
>> mf->AddDefinition("CMAKE_GENERATOR_CXX", "g++");
>> mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
>>@@ -97,7 +98,7 @@ std::string cmGlobalXCodeGenerator::Gene
>> {
>> makeCommand += "ALL_BUILD";
>> }
>>- makeCommand += " -buildstyle Development ";
>>+ makeCommand += " -configuration Debug";
>> return makeCommand;
>> }
>>
>>@@ -1155,7 +1156,8 @@ void cmGlobalXCodeGenerator::AddLinkLibr
>> {
>> if(dtarget)
>> {
>>- target->AddDependLibrary(this->GetTargetFullPath(dtarget).c_str());
>>+ const char *path = this->GetTargetFullPath(dtarget).c_str();
>>+ target->AddDependLibrary(path);
>> }
>>
>> // if the library is not a full path then add it with a -l flag
>>@@ -1252,6 +1254,7 @@ void cmGlobalXCodeGenerator::AddDependAn
>> {
>> linkDirs += " ";
>> linkDirs += this->XCodeEscapePath(libDir->c_str());
>>+ linkDirs += "/Debug";
>> }
>> }
>> cmXCodeObject* bset = target->GetObject("buildSettings");
>>@@ -1692,3 +1695,20 @@ std::string cmGlobalXCodeGenerator::XCod
>> }
>> return ret;
>> }
>>+
>>+std::string cmGlobalXCodeGenerator::GetXCodeVersion()
>>+{
>>+ char sz[20];
>>+ CFStringRef versionStr;
>>+ CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("com.apple.Xcode") );
>>+ if ( bundle != NULL )
>>+{
>>+ versionStr = (CFStringRef) CFBundleGetValueForInfoDictionaryKey( bundle, CFSTR("CFBundleShortVersionString") );
>>+ if ( versionStr != NULL
>>+ && CFGetTypeID( versionStr ) == CFStringGetTypeID() )
>>+ {
>>+ CFStringGetCString( versionStr, sz, sizeof( sz ), kCFStringEncodingUTF8 );
>>+ }
>>+}
>>+ return sz;
>>+}
>>Index: Source/cmGlobalXCodeGenerator.h
>>===================================================================
>>RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.h,v
>>retrieving revision 1.25
>>diff -u -3 -p -r1.25 cmGlobalXCodeGenerator.h
>>--- Source/cmGlobalXCodeGenerator.h 15 Jul 2005 19:20:52 -0000 1.25
>>+++ Source/cmGlobalXCodeGenerator.h 18 Jul 2005 00:31:27 -0000
>>@@ -133,6 +133,7 @@ private:
>> cmTarget& cmtarget,
>> const std::vector<cmCustomCommand>&);
>> void CreateReRunCMakeFile(cmLocalGenerator* root);
>>+ std::string GetXCodeVersion();
>> private:
>> std::vector<cmXCodeObject*> m_XCodeObjects;
>> cmXCodeObject* m_RootObject;
>>
>>
>>_______________________________________________
>>CMake mailing list
>>CMake at cmake.org
>>http://www.cmake.org/mailman/listinfo/cmake
>
>_______________________________________________
>CMake mailing list
>CMake at cmake.org
>http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list