diff options
author | Brad King <brad.king@kitware.com> | 2021-02-09 13:21:59 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-02-09 13:22:06 (GMT) |
commit | 40f4147224dd6f3839a224f89dc85f357176fd2f (patch) | |
tree | af6ba66a362f912eecd0f3cf2ec50c115c4b83f0 /Tests | |
parent | 9b9075f7237c92acb70a9495b55f8ca356cf90fa (diff) | |
parent | 4d46b1401f9d1624fa5afc3995844d7aebc7ccf4 (diff) | |
download | CMake-40f4147224dd6f3839a224f89dc85f357176fd2f.zip CMake-40f4147224dd6f3839a224f89dc85f357176fd2f.tar.gz CMake-40f4147224dd6f3839a224f89dc85f357176fd2f.tar.bz2 |
Merge topic 'object-lib-multiarch'
4d46b1401f add_library(): Allow imported object libraries with multi-arch
1a915e8953 Tests: TargetObjects does not need any languages enabled
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5771
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/ObjectLibrary/ImportMultiArch-check.cmake | 15 | ||||
-rw-r--r-- | Tests/RunCMake/ObjectLibrary/ImportMultiArch.cmake | 13 | ||||
-rw-r--r-- | Tests/RunCMake/ObjectLibrary/ImportNotSupported-stderr.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/ObjectLibrary/ImportNotSupported.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/TargetObjects/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/TargetObjects/RunCMakeTest.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/TargetObjects/XcodeVariableNoGenexExpansion-result.txt (renamed from Tests/RunCMake/ObjectLibrary/ImportNotSupported-result.txt) | 0 | ||||
-rw-r--r-- | Tests/RunCMake/TargetObjects/XcodeVariableNoGenexExpansion-stderr.txt | 10 | ||||
-rw-r--r-- | Tests/RunCMake/TargetObjects/XcodeVariableNoGenexExpansion.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/TargetObjects/empty.cpp | 4 |
11 files changed, 56 insertions, 12 deletions
diff --git a/Tests/RunCMake/ObjectLibrary/ImportMultiArch-check.cmake b/Tests/RunCMake/ObjectLibrary/ImportMultiArch-check.cmake new file mode 100644 index 0000000..af1df78 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/ImportMultiArch-check.cmake @@ -0,0 +1,15 @@ +set(xcProjectFile "${RunCMake_TEST_BINARY_DIR}/ImportMultiArch.xcodeproj/project.pbxproj") +if(NOT EXISTS "${xcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${xcProjectFile} does not exist.") + return() +endif() + +file(READ ${xcProjectFile} pbxFileContents) +foreach(config IN ITEMS Debug Release RelWithDebInfo MinSizeRel) + set(regex "--findconfig-${config}[^ +]*\\$\\(CURRENT_ARCH\\)") + if(NOT pbxFileContents MATCHES "${regex}") + set(RunCMake_TEST_FAILED "$(CURRENT_ARCH) not preserved for config ${config}") + return() + endif() +endforeach() diff --git a/Tests/RunCMake/ObjectLibrary/ImportMultiArch.cmake b/Tests/RunCMake/ObjectLibrary/ImportMultiArch.cmake new file mode 100644 index 0000000..64029ee --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/ImportMultiArch.cmake @@ -0,0 +1,13 @@ + +add_library(A OBJECT IMPORTED) + +# We don't actually build this example so just configure dummy +# object files to test. They do not have to exist. +set_target_properties(A PROPERTIES + IMPORTED_OBJECTS "${CMAKE_CURRENT_BINARY_DIR}/$(CURRENT_ARCH)/does_not_exist.o" +) + +add_library(B SHARED $<TARGET_OBJECTS:A> b.c) + +# We use this to find the relevant lines of the project.pbx file +target_link_options(B PRIVATE --findconfig-$<CONFIG>) diff --git a/Tests/RunCMake/ObjectLibrary/ImportNotSupported-stderr.txt b/Tests/RunCMake/ObjectLibrary/ImportNotSupported-stderr.txt deleted file mode 100644 index 0fadac2..0000000 --- a/Tests/RunCMake/ObjectLibrary/ImportNotSupported-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -CMake Error at ImportNotSupported.cmake:[0-9]+ \(add_library\): - The OBJECT library type may not be used for IMPORTED libraries under Xcode - with multiple architectures. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/ImportNotSupported.cmake b/Tests/RunCMake/ObjectLibrary/ImportNotSupported.cmake deleted file mode 100644 index 806b44a..0000000 --- a/Tests/RunCMake/ObjectLibrary/ImportNotSupported.cmake +++ /dev/null @@ -1 +0,0 @@ -add_library(A OBJECT IMPORTED) diff --git a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake index 5ec4018..8515ba5 100644 --- a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake +++ b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake @@ -6,7 +6,7 @@ run_cmake(BadSourceExpression3) run_cmake(BadObjSource1) run_cmake(BadObjSource2) if(RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]") - run_cmake(ImportNotSupported) + run_cmake(ImportMultiArch) run_cmake(InstallNotSupported) else() run_cmake(Import) diff --git a/Tests/RunCMake/TargetObjects/CMakeLists.txt b/Tests/RunCMake/TargetObjects/CMakeLists.txt index 44b5d30..e9a0a3f 100644 --- a/Tests/RunCMake/TargetObjects/CMakeLists.txt +++ b/Tests/RunCMake/TargetObjects/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required(VERSION 3.3) -project(${RunCMake_TEST}) +project(${RunCMake_TEST} LANGUAGES NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake b/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake index 30b9fee..d2b3032 100644 --- a/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake @@ -2,3 +2,7 @@ include(RunCMake) run_cmake(NoTarget) run_cmake(NotObjlibTarget) + +if(RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]") + run_cmake(XcodeVariableNoGenexExpansion) +endif() diff --git a/Tests/RunCMake/ObjectLibrary/ImportNotSupported-result.txt b/Tests/RunCMake/TargetObjects/XcodeVariableNoGenexExpansion-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/ObjectLibrary/ImportNotSupported-result.txt +++ b/Tests/RunCMake/TargetObjects/XcodeVariableNoGenexExpansion-result.txt diff --git a/Tests/RunCMake/TargetObjects/XcodeVariableNoGenexExpansion-stderr.txt b/Tests/RunCMake/TargetObjects/XcodeVariableNoGenexExpansion-stderr.txt new file mode 100644 index 0000000..1360015 --- /dev/null +++ b/Tests/RunCMake/TargetObjects/XcodeVariableNoGenexExpansion-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at XcodeVariableNoGenexExpansion\.cmake:9 \(file\): + Error evaluating generator expression: + + \$\<TARGET_OBJECTS:A\> + + The evaluation of the TARGET_OBJECTS generator expression is only suitable + for consumption by CMake \(limited under Xcode with multiple architectures\)\. + It is not suitable for writing out elsewhere\. +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetObjects/XcodeVariableNoGenexExpansion.cmake b/Tests/RunCMake/TargetObjects/XcodeVariableNoGenexExpansion.cmake new file mode 100644 index 0000000..83d7210 --- /dev/null +++ b/Tests/RunCMake/TargetObjects/XcodeVariableNoGenexExpansion.cmake @@ -0,0 +1,12 @@ +add_library(A OBJECT IMPORTED) + +# We don't actually build this example so just configure a dummy +# object file to test. It does not have to exist. +set_target_properties(A PROPERTIES + IMPORTED_OBJECTS "${CMAKE_CURRENT_BINARY_DIR}/$(CURRENT_ARCH)/does_not_exist.o" +) + +file(GENERATE + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/objects.txt + CONTENT "$<TARGET_OBJECTS:A>" +) diff --git a/Tests/RunCMake/TargetObjects/empty.cpp b/Tests/RunCMake/TargetObjects/empty.cpp deleted file mode 100644 index 4086dcc..0000000 --- a/Tests/RunCMake/TargetObjects/empty.cpp +++ /dev/null @@ -1,4 +0,0 @@ -int empty() -{ - return 0; -} |