From 923b030ed989472bc421379eecc5f8c979dc6ccb Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 15 Jul 2011 14:51:22 -0400 Subject: [PATCH 1/4] Fix Architecture test to work with Xcode 4 ppc tools are no longer available in the Xcode 4 installation. Eliminate the use of the hard-coded 'ppc' in the test when running on Snow Leopard or later. --- Tests/Architecture/CMakeLists.txt | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/Tests/Architecture/CMakeLists.txt b/Tests/Architecture/CMakeLists.txt index bc767fe3d..db84ea9d8 100644 --- a/Tests/Architecture/CMakeLists.txt +++ b/Tests/Architecture/CMakeLists.txt @@ -1,6 +1,14 @@ cmake_minimum_required(VERSION 2.8) project(Architecture C) +set(archs i386 ppc) + +if(NOT "${DARWIN_MAJOR_VERSION}.${DARWIN_MINOR_VERSION}" VERSION_LESS 10.0) + # Snow Leopard or later, use modern architectures as defaults + # Arch 'ppc' no longer works: tools no longer available starting with Xcode 4 + set(archs i386 x86_64) +endif() + add_library(foo foo.c) if(CMAKE_OSX_ARCHITECTURES) get_property(archs TARGET foo PROPERTY OSX_ARCHITECTURES) @@ -11,11 +19,26 @@ if(CMAKE_OSX_ARCHITECTURES) ) endif() endif() -set_property(TARGET foo PROPERTY OSX_ARCHITECTURES i386) -set_property(TARGET foo PROPERTY OSX_ARCHITECTURES_DEBUG ppc) + +list(LENGTH archs archs_len) +if(archs_len GREATER 1) + list(GET archs 0 arch0) + list(GET archs 1 arch1) +else() + set(arch0 ${archs}) + set(arch1 ${archs}) +endif() + +message("archs='${archs}'") +message("arch0='${arch0}'") +message("arch1='${arch1}'") + +set_property(TARGET foo PROPERTY OSX_ARCHITECTURES ${arch0}) +set_property(TARGET foo PROPERTY OSX_ARCHITECTURES_DEBUG ${arch1}) add_executable(bar bar.c) target_link_libraries(bar foo) + set_property(TARGET bar PROPERTY OUTPUT_NAME Architecture) -set_property(TARGET bar PROPERTY OSX_ARCHITECTURES ppc) -set_property(TARGET bar PROPERTY OSX_ARCHITECTURES_DEBUG i386) +set_property(TARGET bar PROPERTY OSX_ARCHITECTURES ${arch1}) +set_property(TARGET bar PROPERTY OSX_ARCHITECTURES_DEBUG ${arch0}) From c050c592eef00a13bfc1e9bf31e45b2005588ccf Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 15 Jul 2011 15:34:17 -0400 Subject: [PATCH 2/4] Fix BuildDepends test to work with Xcode 4 ppc tools are no longer available in the Xcode 4 installation. Eliminate the use of the hard-coded 'ppc' in the test when running on Snow Leopard or later. --- Tests/BuildDepends/Project/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index 70a2f3701..f03c2387c 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -4,6 +4,11 @@ if(APPLE) # only use multi-arch if the sysroot exists on this machine if(EXISTS "${CMAKE_OSX_SYSROOT}") set(CMAKE_OSX_ARCHITECTURES "ppc;i386") + if(NOT "${DARWIN_MAJOR_VERSION}.${DARWIN_MINOR_VERSION}" VERSION_LESS 10.0) + # Snow Leopard or later, use modern architectures as defaults + # Arch 'ppc' no longer works: tools no longer available starting with Xcode 4 + set(CMAKE_OSX_ARCHITECTURES i386 x86_64) + endif() endif(EXISTS "${CMAKE_OSX_SYSROOT}") endif(APPLE) From 5f7acc8d75d736905d9f54badebc80ad196e8877 Mon Sep 17 00:00:00 2001 From: David Cole Date: Mon, 18 Jul 2011 09:59:58 -0400 Subject: [PATCH 3/4] Base architecture choice logic on Xcode version Not on Darwin version. --- Tests/Architecture/CMakeLists.txt | 24 ++++++++++++++++++----- Tests/BuildDepends/Project/CMakeLists.txt | 20 +++++++++++++++++-- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Tests/Architecture/CMakeLists.txt b/Tests/Architecture/CMakeLists.txt index db84ea9d8..c210727b0 100644 --- a/Tests/Architecture/CMakeLists.txt +++ b/Tests/Architecture/CMakeLists.txt @@ -3,8 +3,24 @@ project(Architecture C) set(archs i386 ppc) -if(NOT "${DARWIN_MAJOR_VERSION}.${DARWIN_MINOR_VERSION}" VERSION_LESS 10.0) - # Snow Leopard or later, use modern architectures as defaults +function(test_for_xcode4 result_var) + set(${result_var} 0 PARENT_SCOPE) + if(APPLE) + execute_process(COMMAND xcodebuild -version + OUTPUT_VARIABLE ov RESULT_VARIABLE rv + ) + if("${rv}" STREQUAL "0") + if(ov MATCHES "^Xcode 4.[0-9].*$") + set(${result_var} 1 PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + +test_for_xcode4(is_xcode4) + +if(is_xcode4) + # Xcode 4, use modern architectures as defaults # Arch 'ppc' no longer works: tools no longer available starting with Xcode 4 set(archs i386 x86_64) endif() @@ -24,11 +40,9 @@ list(LENGTH archs archs_len) if(archs_len GREATER 1) list(GET archs 0 arch0) list(GET archs 1 arch1) -else() - set(arch0 ${archs}) - set(arch1 ${archs}) endif() +message("is_xcode4='${is_xcode4}'") message("archs='${archs}'") message("arch0='${arch0}'") message("arch1='${arch1}'") diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index f03c2387c..a977884c9 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -1,11 +1,27 @@ cmake_minimum_required(VERSION 2.6) project(testRebuild) + +function(test_for_xcode4 result_var) + set(${result_var} 0 PARENT_SCOPE) + if(APPLE) + execute_process(COMMAND xcodebuild -version + OUTPUT_VARIABLE ov RESULT_VARIABLE rv + ) + if("${rv}" STREQUAL "0") + if(ov MATCHES "^Xcode 4.[0-9].*$") + set(${result_var} 1 PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + if(APPLE) # only use multi-arch if the sysroot exists on this machine if(EXISTS "${CMAKE_OSX_SYSROOT}") set(CMAKE_OSX_ARCHITECTURES "ppc;i386") - if(NOT "${DARWIN_MAJOR_VERSION}.${DARWIN_MINOR_VERSION}" VERSION_LESS 10.0) - # Snow Leopard or later, use modern architectures as defaults + test_for_xcode4(is_xcode4) + if(is_xcode4) + # Xcode 4, use modern architectures as defaults # Arch 'ppc' no longer works: tools no longer available starting with Xcode 4 set(CMAKE_OSX_ARCHITECTURES i386 x86_64) endif() From 1a53fb7537c6f37f8ccfa418919b332a4928679a Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 19 Jul 2011 11:53:31 -0400 Subject: [PATCH 4/4] Use correct default multiple architecture values in test Even if CMAKE_OSX_ARCHITECTURES value is a single value... --- Tests/Architecture/CMakeLists.txt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Tests/Architecture/CMakeLists.txt b/Tests/Architecture/CMakeLists.txt index c210727b0..927ce3fed 100644 --- a/Tests/Architecture/CMakeLists.txt +++ b/Tests/Architecture/CMakeLists.txt @@ -1,8 +1,6 @@ cmake_minimum_required(VERSION 2.8) project(Architecture C) -set(archs i386 ppc) - function(test_for_xcode4 result_var) set(${result_var} 0 PARENT_SCOPE) if(APPLE) @@ -19,10 +17,14 @@ endfunction() test_for_xcode4(is_xcode4) +set(arch0 i386) +set(arch1 ppc) + if(is_xcode4) # Xcode 4, use modern architectures as defaults # Arch 'ppc' no longer works: tools no longer available starting with Xcode 4 - set(archs i386 x86_64) + set(arch0 i386) + set(arch1 x86_64) endif() add_library(foo foo.c) @@ -34,12 +36,11 @@ if(CMAKE_OSX_ARCHITECTURES) "Expected [${CMAKE_OSX_ARCHITECTURES}], got [${archs}]." ) endif() -endif() - -list(LENGTH archs archs_len) -if(archs_len GREATER 1) - list(GET archs 0 arch0) - list(GET archs 1 arch1) + list(LENGTH archs archs_len) + if(archs_len GREATER 1) + list(GET archs 0 arch0) + list(GET archs 1 arch1) + endif() endif() message("is_xcode4='${is_xcode4}'")