summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2011-07-26 18:57:38 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2011-07-26 18:57:38 (GMT)
commit2305b575f11982c190e8c041fb65c05063ebc970 (patch)
treee2aa92dc2a6f6cd03cf65e89cf502dc1b260837e /Tests
parent119dce33d3b51e01507e917ca53f1dd08a7a4c23 (diff)
parent1a53fb7537c6f37f8ccfa418919b332a4928679a (diff)
downloadCMake-2305b575f11982c190e8c041fb65c05063ebc970.zip
CMake-2305b575f11982c190e8c041fb65c05063ebc970.tar.gz
CMake-2305b575f11982c190e8c041fb65c05063ebc970.tar.bz2
Merge topic 'fix-tests-failing-with-Xcode4'
1a53fb7 Use correct default multiple architecture values in test 5f7acc8 Base architecture choice logic on Xcode version c050c59 Fix BuildDepends test to work with Xcode 4 923b030 Fix Architecture test to work with Xcode 4
Diffstat (limited to 'Tests')
-rw-r--r--Tests/Architecture/CMakeLists.txt46
-rw-r--r--Tests/BuildDepends/Project/CMakeLists.txt21
2 files changed, 63 insertions, 4 deletions
diff --git a/Tests/Architecture/CMakeLists.txt b/Tests/Architecture/CMakeLists.txt
index bc767fe..927ce3f 100644
--- a/Tests/Architecture/CMakeLists.txt
+++ b/Tests/Architecture/CMakeLists.txt
@@ -1,6 +1,32 @@
cmake_minimum_required(VERSION 2.8)
project(Architecture C)
+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)
+
+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(arch0 i386)
+ set(arch1 x86_64)
+endif()
+
add_library(foo foo.c)
if(CMAKE_OSX_ARCHITECTURES)
get_property(archs TARGET foo PROPERTY OSX_ARCHITECTURES)
@@ -10,12 +36,24 @@ if(CMAKE_OSX_ARCHITECTURES)
"Expected [${CMAKE_OSX_ARCHITECTURES}], got [${archs}]."
)
endif()
+ list(LENGTH archs archs_len)
+ if(archs_len GREATER 1)
+ list(GET archs 0 arch0)
+ list(GET archs 1 arch1)
+ endif()
endif()
-set_property(TARGET foo PROPERTY OSX_ARCHITECTURES i386)
-set_property(TARGET foo PROPERTY OSX_ARCHITECTURES_DEBUG ppc)
+
+message("is_xcode4='${is_xcode4}'")
+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})
diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt
index 70a2f37..a977884 100644
--- a/Tests/BuildDepends/Project/CMakeLists.txt
+++ b/Tests/BuildDepends/Project/CMakeLists.txt
@@ -1,9 +1,30 @@
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")
+ 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()
endif(EXISTS "${CMAKE_OSX_SYSROOT}")
endif(APPLE)