summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuan Ramos <juan.ramos@kitware.com>2024-04-29 18:05:38 (GMT)
committerJuan Ramos <juan.ramos@kitware.com>2024-04-29 21:46:08 (GMT)
commit40fa2c1c90abcfc74e9a2e55001b89c2fa45d6c5 (patch)
treebabfec12c10fe27545c69b60598639f38e36c160
parentabd1b02dfa6cffef8b6564011353849f20e7dfdc (diff)
downloadCMake-40fa2c1c90abcfc74e9a2e55001b89c2fa45d6c5.zip
CMake-40fa2c1c90abcfc74e9a2e55001b89c2fa45d6c5.tar.gz
CMake-40fa2c1c90abcfc74e9a2e55001b89c2fa45d6c5.tar.bz2
Tests: Cleanup CMake_TEST_XCODE_VERSION code
- Consolidate calls to xcodebuild -version - Handles cases where CMake_TEST_XCODE_VERSION is 0 to allow running tests with only command-line tools.
-rw-r--r--Tests/BuildDepends/CMakeLists.txt4
-rw-r--r--Tests/BuildDepends/Project/CMakeLists.txt14
-rw-r--r--Tests/CMakeLists.txt13
3 files changed, 10 insertions, 21 deletions
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt
index 5ddae83..dbafc85 100644
--- a/Tests/BuildDepends/CMakeLists.txt
+++ b/Tests/BuildDepends/CMakeLists.txt
@@ -47,6 +47,10 @@ if(NOT CMAKE_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])")
list(APPEND _cmake_options "-DTEST_MULTI3=1")
endif()
+if (APPLE)
+ list(APPEND _cmake_options "-DCMake_TEST_XCODE_VERSION=${CMake_TEST_XCODE_VERSION}")
+endif()
+
file(MAKE_DIRECTORY ${BuildDepends_BINARY_DIR}/Project)
message("Creating Project/foo.cxx")
write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx
diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt
index a320d53..2abda2e 100644
--- a/Tests/BuildDepends/Project/CMakeLists.txt
+++ b/Tests/BuildDepends/Project/CMakeLists.txt
@@ -1,19 +1,7 @@
cmake_minimum_required(VERSION 2.6)
project(testRebuild)
-if(APPLE)
- set(CMake_TEST_XCODE_VERSION 0)
- if(XCODE_VERSION)
- set(CMake_TEST_XCODE_VERSION "${XCODE_VERSION}")
- else()
- execute_process(
- COMMAND xcodebuild -version
- OUTPUT_VARIABLE _version ERROR_VARIABLE _version_err
- )
- if(_version MATCHES "^Xcode ([0-9]+(\\.[0-9]+)*)")
- set(CMake_TEST_XCODE_VERSION "${CMAKE_MATCH_1}")
- endif()
- endif()
+if(APPLE AND CMake_TEST_XCODE_VERSION)
# only use multi-arch if the sysroot exists on this machine
# Ninja needs -M which could not be used with multiple -arch flags
if(EXISTS "${CMAKE_OSX_SYSROOT}" AND NOT "${CMAKE_GENERATOR}" MATCHES "Ninja")
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 8f90551..a75f6c2 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -299,25 +299,20 @@ if(BUILD_TESTING)
"Should the tests that use '--build-target package' be run?"
ON)
mark_as_advanced(CTEST_TEST_CPACK)
- set(CTEST_TEST_OSX_ARCH 0)
set(CMake_TEST_XCODE_VERSION 0)
if(APPLE)
- set(CTEST_TEST_OSX_ARCH 1)
if(XCODE_VERSION)
set(CMake_TEST_XCODE_VERSION "${XCODE_VERSION}")
else()
execute_process(
COMMAND xcodebuild -version
- OUTPUT_VARIABLE _version ERROR_VARIABLE _version_err
+ OUTPUT_VARIABLE _version
+ RESULT_VARIABLE _failed
)
- if(_version MATCHES "^Xcode ([0-9]+(\\.[0-9]+)*)")
+ if(NOT _failed AND _version MATCHES "^Xcode ([0-9]+(\\.[0-9]+)*)")
set(CMake_TEST_XCODE_VERSION "${CMAKE_MATCH_1}")
endif()
endif()
- if(NOT CMake_TEST_XCODE_VERSION VERSION_LESS 10)
- # Since Xcode 10 we do not have two supported architectures for the host.
- set(CTEST_TEST_OSX_ARCH 0)
- endif()
if(CMAKE_OSX_SYSROOT)
execute_process(
COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version ProductName
@@ -952,6 +947,8 @@ if(BUILD_TESTING)
"${CMake_BINARY_DIR}/Tests/BuildDepends"
${build_generator_args}
--build-project BuildDepends
+ --build-options
+ "-DCMake_TEST_XCODE_VERSION=${CMake_TEST_XCODE_VERSION}"
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BuildDepends")