summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/ObjectLibrary
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2021-02-04 09:30:49 (GMT)
committerCraig Scott <craig.scott@crascit.com>2021-02-06 00:34:28 (GMT)
commit4d46b1401f9d1624fa5afc3995844d7aebc7ccf4 (patch)
treee2396c9fab9f6c9e694ae3e281d0d28c8f6a446d /Tests/RunCMake/ObjectLibrary
parent1a915e89531adb426be6db6f648ef496ee8c38e8 (diff)
downloadCMake-4d46b1401f9d1624fa5afc3995844d7aebc7ccf4.zip
CMake-4d46b1401f9d1624fa5afc3995844d7aebc7ccf4.tar.gz
CMake-4d46b1401f9d1624fa5afc3995844d7aebc7ccf4.tar.bz2
add_library(): Allow imported object libraries with multi-arch
Fixes: #21276
Diffstat (limited to 'Tests/RunCMake/ObjectLibrary')
-rw-r--r--Tests/RunCMake/ObjectLibrary/ImportMultiArch-check.cmake15
-rw-r--r--Tests/RunCMake/ObjectLibrary/ImportMultiArch.cmake13
-rw-r--r--Tests/RunCMake/ObjectLibrary/ImportNotSupported-result.txt1
-rw-r--r--Tests/RunCMake/ObjectLibrary/ImportNotSupported-stderr.txt5
-rw-r--r--Tests/RunCMake/ObjectLibrary/ImportNotSupported.cmake1
-rw-r--r--Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake2
6 files changed, 29 insertions, 8 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-result.txt b/Tests/RunCMake/ObjectLibrary/ImportNotSupported-result.txt
deleted file mode 100644
index d00491f..0000000
--- a/Tests/RunCMake/ObjectLibrary/ImportNotSupported-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-1
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)