summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorYauheni Khnykin <yauheni.khnykin@here.com>2020-11-29 16:54:56 (GMT)
committerBrad King <brad.king@kitware.com>2020-11-30 18:02:51 (GMT)
commit31d3e64080c950b1f201b0fb9040937a8af1cda9 (patch)
tree37ddc0af63e72874fddb67d16932384be77243b5 /Tests
parentf85f86415b1ef628ef5ffc851733927be4098378 (diff)
downloadCMake-31d3e64080c950b1f201b0fb9040937a8af1cda9.zip
CMake-31d3e64080c950b1f201b0fb9040937a8af1cda9.tar.gz
CMake-31d3e64080c950b1f201b0fb9040937a8af1cda9.tar.bz2
Tests: Add Xcode cases fixed by switch to the "new build system"
Support of 'new build system' in Xcode fixes indirectly few issues which were caused by workaround with `XCODE_DEPEND_HELPER.cmake` autogenerated script. This patch adds test which is originated from issue #20260 and reproduces this issue when 'new build system' is disabled. Fixes: #20260
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/XcodeProject/RunCMakeTest.cmake29
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeObjectLibsInTwoProjects.cmake5
-rw-r--r--Tests/RunCMake/XcodeProject/subproject_two_object_libs/CMakeLists.txt31
-rw-r--r--Tests/RunCMake/XcodeProject/subproject_two_object_libs/dummy.cpp5
4 files changed, 70 insertions, 0 deletions
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
index 62163ac..abba741 100644
--- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -51,6 +51,35 @@ run_cmake(PerConfigPerSourceOptions)
run_cmake(PerConfigPerSourceDefinitions)
run_cmake(PerConfigPerSourceIncludeDirs)
+if(XCODE_VERSION VERSION_GREATER_EQUAL 12)
+
+ function(XcodeObjectLibsInTwoProjectsiOS)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeObjectLibsInTwoProjects-build-ios)
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=iOS")
+
+ run_cmake(XcodeObjectLibsInTwoProjects)
+
+ set(RunCMake_TEST_NO_CLEAN 1)
+
+ run_cmake_command(XcodeObjectLibsInTwoProjects-build-ios ${CMAKE_COMMAND} --build . --target shared_lib -- -sdk iphonesimulator)
+ endfunction()
+
+ XcodeObjectLibsInTwoProjectsiOS()
+
+ function(XcodeObjectLibsInTwoProjectsMacOS)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeObjectLibsInTwoProjects-build-macos)
+
+ run_cmake(XcodeObjectLibsInTwoProjects)
+
+ set(RunCMake_TEST_NO_CLEAN 1)
+
+ run_cmake_command(XcodeObjectLibsInTwoProjects-build-macos ${CMAKE_COMMAND} --build . --target shared_lib)
+ endfunction()
+
+ XcodeObjectLibsInTwoProjectsMacOS()
+
+endif()
+
function(XcodeSchemaGeneration)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeSchemaGeneration-build)
set(RunCMake_TEST_NO_CLEAN 1)
diff --git a/Tests/RunCMake/XcodeProject/XcodeObjectLibsInTwoProjects.cmake b/Tests/RunCMake/XcodeProject/XcodeObjectLibsInTwoProjects.cmake
new file mode 100644
index 0000000..3ca24af
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeObjectLibsInTwoProjects.cmake
@@ -0,0 +1,5 @@
+cmake_minimum_required (VERSION 3.19)
+
+project (test_xcode_fail NONE)
+
+add_subdirectory(subproject_two_object_libs)
diff --git a/Tests/RunCMake/XcodeProject/subproject_two_object_libs/CMakeLists.txt b/Tests/RunCMake/XcodeProject/subproject_two_object_libs/CMakeLists.txt
new file mode 100644
index 0000000..e55836d
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/subproject_two_object_libs/CMakeLists.txt
@@ -0,0 +1,31 @@
+cmake_minimum_required (VERSION 3.16)
+
+enable_language(CXX)
+
+project (subproject_two_object_libs)
+
+set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO)
+set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
+
+if(IOS)
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+
+ set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
+endif()
+
+# Hierarchy of libraries looks like:
+#
+# OBJECT-1 ---> STATIC--\
+# |---> SHARED
+# OBJECT-2 -------------/
+
+add_library(object_lib_dependency1 OBJECT dummy.cpp)
+
+add_library(static_lib_dependency STATIC dummy.cpp $<TARGET_OBJECTS:object_lib_dependency1>)
+
+add_library(object_lib_dependency2 OBJECT dummy.cpp)
+target_link_libraries(object_lib_dependency2 PRIVATE static_lib_dependency)
+
+add_library(shared_lib SHARED dummy.cpp)
+target_link_libraries(shared_lib PRIVATE static_lib_dependency)
+target_sources(shared_lib PRIVATE $<TARGET_OBJECTS:object_lib_dependency2>)
diff --git a/Tests/RunCMake/XcodeProject/subproject_two_object_libs/dummy.cpp b/Tests/RunCMake/XcodeProject/subproject_two_object_libs/dummy.cpp
new file mode 100644
index 0000000..8082abc
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/subproject_two_object_libs/dummy.cpp
@@ -0,0 +1,5 @@
+namespace {
+void foo()
+{
+}
+}