From abd1b02dfa6cffef8b6564011353849f20e7dfdc Mon Sep 17 00:00:00 2001 From: Juan Ramos Date: Mon, 29 Apr 2024 11:02:11 -0700 Subject: Tests/Architecture: Have test support Xcode 10+ --- Tests/Architecture/CMakeLists.txt | 36 +++++++++++++----------------------- Tests/CMakeLists.txt | 5 ++++- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/Tests/Architecture/CMakeLists.txt b/Tests/Architecture/CMakeLists.txt index 3d10ee0..8b3d0af 100644 --- a/Tests/Architecture/CMakeLists.txt +++ b/Tests/Architecture/CMakeLists.txt @@ -1,30 +1,21 @@ cmake_minimum_required(VERSION 3.5) 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" AND ov MATCHES "^Xcode ([0-9]+)\\.") - if(NOT CMAKE_MATCH_1 VERSION_LESS 4) - 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 +if (CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 12) + # Since Xcode 12 we have two architectures again: arm64 and x86_64. + set(arch0 x86_64) + set(arch1 arm64) +elseif(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 10) + # Xcode 10 / 11 do not have two supported architectures for the host. + message(STATUS "Skip test x86_64 only") + return() +elseif(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 4) + # Xcode 4 no longer supports ppc, but does support x86_64. set(arch0 i386) set(arch1 x86_64) +else() + set(arch0 i386) + set(arch1 ppc) endif() add_library(foo foo.c) @@ -43,7 +34,6 @@ if(CMAKE_OSX_ARCHITECTURES) endif() endif() -message("is_xcode4='${is_xcode4}'") message("archs='${archs}'") message("arch0='${arch0}'") message("arch1='${arch1}'") diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5d9d193..8f90551 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -578,10 +578,13 @@ if(BUILD_TESTING) if("${CMAKE_GENERATOR}" MATCHES "Make") ADD_TEST_MACRO(Policy0002 Policy0002) endif() - if(CTEST_TEST_OSX_ARCH) + if(CMake_TEST_XCODE_VERSION) + set(Architecture_BUILD_OPTIONS -DCMake_TEST_XCODE_VERSION=${CMake_TEST_XCODE_VERSION}) ADD_TEST_MACRO(Architecture Architecture) set_tests_properties(Architecture PROPERTIES PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked|but attempting to link with file built for)") + set_property(TEST Architecture APPEND PROPERTY + PASS_REGULAR_EXPRESSION "Skip test x86_64 only|found architecture '.*', required architecture '.*'") endif() list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX}) -- cgit v0.12