Просмотр исходного кода

Merge topic 'test-macos-arm64' into release-3.20

1c15eb39d2 Tests: Suppress failures on macOS arm64 due to separate Xcode signing phase
92418ac0ef Tests: Fix CTestTestCrash expected output on macOS arm64
8b22d9b3c3 Tests: Remove explicit no-signing marks from BundleTest
483db3de56 Tests: Clarify internal project name in RunCMake.GoogleTest cases

Acked-by: Kitware Robot <[email protected]>
Merge-request: !5846
Brad King 4 лет назад
Родитель
Сommit
65b70406d9

+ 2 - 2
Tests/BundleTest/BundleLib.cxx

@@ -52,8 +52,8 @@ int foo(char* exec)
   (void)br;
   (void)br;
 
 
   int res1 = findBundleFile(exec, "Resources/randomResourceFile.plist");
   int res1 = findBundleFile(exec, "Resources/randomResourceFile.plist");
-  int res2 = findBundleFile(exec, "MacOS/SomeRandomFile.txt");
-  int res3 = findBundleFile(exec, "MacOS/README.rst");
+  int res2 = findBundleFile(exec, "Other/SomeRandomFile.txt");
+  int res3 = findBundleFile(exec, "Other/README.rst");
   if (!res1 || !res2 || !res3) {
   if (!res1 || !res2 || !res3) {
     return 1;
     return 1;
   }
   }

+ 2 - 6
Tests/BundleTest/BundleSubDir/CMakeLists.txt

@@ -16,7 +16,7 @@ set_source_files_properties(
   "${BundleTest_SOURCE_DIR}/SomeRandomFile.txt"
   "${BundleTest_SOURCE_DIR}/SomeRandomFile.txt"
   "${BundleTest_SOURCE_DIR}/../../README.rst"
   "${BundleTest_SOURCE_DIR}/../../README.rst"
   PROPERTIES
   PROPERTIES
-  MACOSX_PACKAGE_LOCATION MacOS
+  MACOSX_PACKAGE_LOCATION Other
   )
   )
 
 
 add_executable(SecondBundle
 add_executable(SecondBundle
@@ -35,11 +35,7 @@ install(TARGETS SecondBundle DESTINATION Applications)
 # installed into a location that uses this output name this will fail if the
 # installed into a location that uses this output name this will fail if the
 # bundle does not respect the name.  Also the executable will not be found by
 # bundle does not respect the name.  Also the executable will not be found by
 # the test driver if this does not work.
 # the test driver if this does not work.
-set_target_properties(SecondBundle PROPERTIES
-  OUTPUT_NAME SecondBundleExe
-  XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
-  XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO"
-  )
+set_target_properties(SecondBundle PROPERTIES OUTPUT_NAME SecondBundleExe)
 
 
 # Express one app bundle in terms of another's SOURCES to verify that
 # Express one app bundle in terms of another's SOURCES to verify that
 # the generators do not expose the Info.plist of one to the other.
 # the generators do not expose the Info.plist of one to the other.

+ 11 - 6
Tests/BundleTest/CMakeLists.txt

@@ -3,6 +3,15 @@ project(BundleTest)
 set(MACOSX_BUNDLE_INFO_STRING "bundle_info_string")
 set(MACOSX_BUNDLE_INFO_STRING "bundle_info_string")
 set(CMAKE_MacOSX_Content_COMPILE_OBJECT "\"${CMAKE_COMMAND}\" -E copy_if_different <SOURCE> <OBJECT>")
 set(CMAKE_MacOSX_Content_COMPILE_OBJECT "\"${CMAKE_COMMAND}\" -E copy_if_different <SOURCE> <OBJECT>")
 
 
+if(CMAKE_GENERATOR STREQUAL "Xcode" AND
+   "${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64")
+  # Tell Xcode to pretend the linker signed binaries so that
+  # editing with install_name_tool preserves ad-hoc signatures.
+  # See CMake Issue 21854.
+  # This option is supported by codesign on macOS 11 or higher.
+  set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "-o linker-signed")
+endif()
+
 add_custom_command(
 add_custom_command(
   OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
   OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
   COMMAND /bin/cp
   COMMAND /bin/cp
@@ -19,7 +28,7 @@ set_source_files_properties(
   SomeRandomFile.txt
   SomeRandomFile.txt
   "${BundleTest_SOURCE_DIR}/../../README.rst"
   "${BundleTest_SOURCE_DIR}/../../README.rst"
   PROPERTIES
   PROPERTIES
-  MACOSX_PACKAGE_LOCATION MacOS
+  MACOSX_PACKAGE_LOCATION Other
   )
   )
 
 
 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/foobar")
 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/foobar")
@@ -56,11 +65,7 @@ install(TARGETS BundleTest DESTINATION Applications)
 # installed into a location that uses this output name this will fail if the
 # installed into a location that uses this output name this will fail if the
 # bundle does not respect the name.  Also the executable will not be found by
 # bundle does not respect the name.  Also the executable will not be found by
 # the test driver if this does not work.
 # the test driver if this does not work.
-set_target_properties(BundleTest PROPERTIES
-  OUTPUT_NAME BundleTestExe
-  XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
-  XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO"
-  )
+set_target_properties(BundleTest PROPERTIES OUTPUT_NAME BundleTestExe)
 
 
 # Test executable versioning if it is supported.
 # Test executable versioning if it is supported.
 if(NOT XCODE)
 if(NOT XCODE)

+ 9 - 0
Tests/BundleUtilities/CMakeLists.txt

@@ -1,6 +1,15 @@
 cmake_minimum_required(VERSION 2.8.12)
 cmake_minimum_required(VERSION 2.8.12)
 project(BundleUtilities)
 project(BundleUtilities)
 
 
+if(CMAKE_GENERATOR STREQUAL "Xcode" AND
+   "${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64")
+  # Tell Xcode to pretend the linker signed binaries so that
+  # editing with install_name_tool preserves ad-hoc signatures.
+  # See CMake Issue 21854.
+  # This option is supported by codesign on macOS 11 or higher.
+  set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "-o linker-signed")
+endif()
+
 ###### the various types of dependencies we can have
 ###### the various types of dependencies we can have
 
 
 # a shared library
 # a shared library

+ 1 - 1
Tests/CMakeLists.txt

@@ -2955,7 +2955,7 @@ if(BUILD_TESTING)
       PASS_REGULAR_EXPRESSION "Failed")
       PASS_REGULAR_EXPRESSION "Failed")
   else()
   else()
     set_tests_properties(CTestTestCrash PROPERTIES
     set_tests_properties(CTestTestCrash PROPERTIES
-      PASS_REGULAR_EXPRESSION "(Illegal|SegFault|Subprocess aborted)")
+      PASS_REGULAR_EXPRESSION "(Illegal|SegFault|Subprocess aborted|SIGTRAP)")
   endif()
   endif()
 
 
   configure_file(
   configure_file(

+ 7 - 1
Tests/RunCMake/GoogleTest/GoogleTest.cmake

@@ -1,9 +1,12 @@
-project(test_include_dirs LANGUAGES CXX)
+enable_language(CXX)
 include(GoogleTest)
 include(GoogleTest)
 
 
 enable_testing()
 enable_testing()
 
 
+include(xcode_sign_adhoc.cmake)
+
 add_executable(fake_gtest fake_gtest.cpp)
 add_executable(fake_gtest fake_gtest.cpp)
+xcode_sign_adhoc(fake_gtest)
 
 
 gtest_discover_tests(
 gtest_discover_tests(
   fake_gtest
   fake_gtest
@@ -22,6 +25,7 @@ gtest_discover_tests(
 )
 )
 
 
 add_executable(no_tests_defined no_tests_defined.cpp)
 add_executable(no_tests_defined no_tests_defined.cpp)
+xcode_sign_adhoc(no_tests_defined)
 
 
 gtest_discover_tests(
 gtest_discover_tests(
   no_tests_defined
   no_tests_defined
@@ -33,6 +37,7 @@ gtest_discover_tests(
 # 3.10.3 and later behavior, old behavior added in 3.10.1
 # 3.10.3 and later behavior, old behavior added in 3.10.1
 # is not supported.
 # is not supported.
 add_executable(property_timeout_test timeout_test.cpp)
 add_executable(property_timeout_test timeout_test.cpp)
+xcode_sign_adhoc(property_timeout_test)
 target_compile_definitions(property_timeout_test PRIVATE sleepSec=10)
 target_compile_definitions(property_timeout_test PRIVATE sleepSec=10)
 
 
 gtest_discover_tests(
 gtest_discover_tests(
@@ -50,6 +55,7 @@ gtest_discover_tests(
 )
 )
 
 
 add_executable(skip_test skip_test.cpp)
 add_executable(skip_test skip_test.cpp)
+xcode_sign_adhoc(skip_test)
 
 
 gtest_discover_tests(
 gtest_discover_tests(
   skip_test
   skip_test

+ 4 - 1
Tests/RunCMake/GoogleTest/GoogleTestDiscoveryMultiConfig.cmake

@@ -1,9 +1,12 @@
-project(test_include_dirs LANGUAGES CXX)
+enable_language(CXX)
 include(GoogleTest)
 include(GoogleTest)
 
 
 enable_testing()
 enable_testing()
 
 
+include(xcode_sign_adhoc.cmake)
+
 add_executable(configuration_gtest configuration_gtest.cpp)
 add_executable(configuration_gtest configuration_gtest.cpp)
+xcode_sign_adhoc(configuration_gtest)
 target_compile_definitions(configuration_gtest PRIVATE $<$<CONFIG:Debug>:DEBUG=1>)
 target_compile_definitions(configuration_gtest PRIVATE $<$<CONFIG:Debug>:DEBUG=1>)
 
 
 gtest_discover_tests(
 gtest_discover_tests(

+ 4 - 1
Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTimeout.cmake

@@ -1,9 +1,12 @@
-project(test_include_dirs LANGUAGES CXX)
+enable_language(CXX)
 include(GoogleTest)
 include(GoogleTest)
 
 
 enable_testing()
 enable_testing()
 
 
+include(xcode_sign_adhoc.cmake)
+
 add_executable(discovery_timeout_test timeout_test.cpp)
 add_executable(discovery_timeout_test timeout_test.cpp)
+xcode_sign_adhoc(discovery_timeout_test)
 target_compile_definitions(discovery_timeout_test PRIVATE discoverySleepSec=10)
 target_compile_definitions(discovery_timeout_test PRIVATE discoverySleepSec=10)
 gtest_discover_tests(
 gtest_discover_tests(
   discovery_timeout_test
   discovery_timeout_test

+ 4 - 1
Tests/RunCMake/GoogleTest/GoogleTestXML.cmake

@@ -1,8 +1,10 @@
-project(test_include_dirs LANGUAGES CXX)
+enable_language(CXX)
 include(GoogleTest)
 include(GoogleTest)
 
 
 enable_testing()
 enable_testing()
 
 
+include(xcode_sign_adhoc.cmake)
+
 # This creates the folder structure for the paramterized tests
 # This creates the folder structure for the paramterized tests
 # to avoid handling missing folders in C++
 # to avoid handling missing folders in C++
 #
 #
@@ -15,6 +17,7 @@ enable_testing()
 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/GoogleTestXMLSpecial/cases.case")
 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/GoogleTestXMLSpecial/cases.case")
 
 
 add_executable(xml_output xml_output.cpp)
 add_executable(xml_output xml_output.cpp)
+xcode_sign_adhoc(xml_output)
 gtest_discover_tests(
 gtest_discover_tests(
   xml_output
   xml_output
   XML_OUTPUT_DIR ${CMAKE_BINARY_DIR}
   XML_OUTPUT_DIR ${CMAKE_BINARY_DIR}

+ 8 - 0
Tests/RunCMake/GoogleTest/xcode_sign_adhoc.cmake

@@ -0,0 +1,8 @@
+function(xcode_sign_adhoc target)
+  if(CMAKE_GENERATOR STREQUAL "Xcode" AND
+     "${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64")
+    # Xcode runs POST_BUILD before signing, so let the linker use ad-hoc signing.
+    # See CMake Issue 21845.
+    target_link_options(${target} PRIVATE LINKER:-adhoc_codesign)
+  endif()
+endfunction()

+ 6 - 0
Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake

@@ -12,4 +12,10 @@ add_executable(LinkObjLHSShared LinkObjLHSShared.c)
 target_link_libraries(LinkObjLHSShared AnObjLib)
 target_link_libraries(LinkObjLHSShared AnObjLib)
 
 
 # Verify that our dependency on OtherLib generated its versioning symlinks.
 # Verify that our dependency on OtherLib generated its versioning symlinks.
+if(CMAKE_GENERATOR STREQUAL "Xcode" AND
+   "${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64")
+  # Xcode runs POST_BUILD before signing, so let the linker use ad-hoc signing.
+  # See CMake Issue 21845.
+  target_link_options(LinkObjLHSShared PRIVATE LINKER:-adhoc_codesign)
+endif()
 add_custom_command(TARGET LinkObjLHSShared POST_BUILD COMMAND LinkObjLHSShared)
 add_custom_command(TARGET LinkObjLHSShared POST_BUILD COMMAND LinkObjLHSShared)