diff options
Diffstat (limited to 'Tests/RunCMake')
6 files changed, 33 insertions, 4 deletions
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest.cmake b/Tests/RunCMake/GoogleTest/GoogleTest.cmake index 6aa2658..8efd117 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest.cmake +++ b/Tests/RunCMake/GoogleTest/GoogleTest.cmake @@ -1,9 +1,12 @@ -project(test_include_dirs LANGUAGES CXX) +enable_language(CXX) include(GoogleTest) enable_testing() +include(xcode_sign_adhoc.cmake) + add_executable(fake_gtest fake_gtest.cpp) +xcode_sign_adhoc(fake_gtest) gtest_discover_tests( fake_gtest @@ -22,6 +25,7 @@ gtest_discover_tests( ) add_executable(no_tests_defined no_tests_defined.cpp) +xcode_sign_adhoc(no_tests_defined) gtest_discover_tests( no_tests_defined @@ -33,6 +37,7 @@ gtest_discover_tests( # 3.10.3 and later behavior, old behavior added in 3.10.1 # is not supported. add_executable(property_timeout_test timeout_test.cpp) +xcode_sign_adhoc(property_timeout_test) target_compile_definitions(property_timeout_test PRIVATE sleepSec=10) gtest_discover_tests( @@ -50,6 +55,7 @@ gtest_discover_tests( ) add_executable(skip_test skip_test.cpp) +xcode_sign_adhoc(skip_test) gtest_discover_tests( skip_test diff --git a/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryMultiConfig.cmake b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryMultiConfig.cmake index df784fe..2fae1e2 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryMultiConfig.cmake +++ b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryMultiConfig.cmake @@ -1,9 +1,12 @@ -project(test_include_dirs LANGUAGES CXX) +enable_language(CXX) include(GoogleTest) enable_testing() +include(xcode_sign_adhoc.cmake) + add_executable(configuration_gtest configuration_gtest.cpp) +xcode_sign_adhoc(configuration_gtest) target_compile_definitions(configuration_gtest PRIVATE $<$<CONFIG:Debug>:DEBUG=1>) gtest_discover_tests( diff --git a/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTimeout.cmake b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTimeout.cmake index 20e9d65..5c24d41 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTimeout.cmake +++ b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTimeout.cmake @@ -1,9 +1,12 @@ -project(test_include_dirs LANGUAGES CXX) +enable_language(CXX) include(GoogleTest) enable_testing() +include(xcode_sign_adhoc.cmake) + add_executable(discovery_timeout_test timeout_test.cpp) +xcode_sign_adhoc(discovery_timeout_test) target_compile_definitions(discovery_timeout_test PRIVATE discoverySleepSec=10) gtest_discover_tests( discovery_timeout_test diff --git a/Tests/RunCMake/GoogleTest/GoogleTestXML.cmake b/Tests/RunCMake/GoogleTest/GoogleTestXML.cmake index fb91c0e..53eedc0 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTestXML.cmake +++ b/Tests/RunCMake/GoogleTest/GoogleTestXML.cmake @@ -1,8 +1,10 @@ -project(test_include_dirs LANGUAGES CXX) +enable_language(CXX) include(GoogleTest) enable_testing() +include(xcode_sign_adhoc.cmake) + # This creates the folder structure for the paramterized tests # to avoid handling missing folders in C++ # @@ -15,6 +17,7 @@ enable_testing() file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/GoogleTestXMLSpecial/cases.case") add_executable(xml_output xml_output.cpp) +xcode_sign_adhoc(xml_output) gtest_discover_tests( xml_output XML_OUTPUT_DIR ${CMAKE_BINARY_DIR} diff --git a/Tests/RunCMake/GoogleTest/xcode_sign_adhoc.cmake b/Tests/RunCMake/GoogleTest/xcode_sign_adhoc.cmake new file mode 100644 index 0000000..d2dc530 --- /dev/null +++ b/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() diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake index 0a76932..3d60556 100644 --- a/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake +++ b/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake @@ -12,4 +12,10 @@ add_executable(LinkObjLHSShared LinkObjLHSShared.c) target_link_libraries(LinkObjLHSShared AnObjLib) # 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) |