summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-01-31 14:04:16 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2017-01-31 14:04:16 (GMT)
commitf012a95836e14e12f5a445abd72fa79599736641 (patch)
tree5df5ea8174a7a1d35b7f383cd641bfb7644c5a7c /Tests
parent8a76536e78e9084fb9636b2f0c57121522cfbbaf (diff)
parent071f8e78dda152d8759539fa390b25c7f58d3cc5 (diff)
downloadCMake-f012a95836e14e12f5a445abd72fa79599736641.zip
CMake-f012a95836e14e12f5a445abd72fa79599736641.tar.gz
CMake-f012a95836e14e12f5a445abd72fa79599736641.tar.bz2
Merge topic '16432-static-frameworks'
071f8e78 Apple: Add support for static frameworks d525754e Xcode: Refactor RunCMake.Framework test to prepare for static frameworks 45405f00 Xcode: Ignore Xcode project warning until issue is fixed 50e1c105 Makefile: For static libraries remove only the "real" lib before creating 8643ca75 Makefile: Re-order list of files to clean
Diffstat (limited to 'Tests')
-rw-r--r--Tests/Framework/CMakeLists.txt47
-rw-r--r--Tests/RunCMake/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/Framework/FrameworkLayout.cmake5
-rw-r--r--Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt1
-rw-r--r--Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt1
-rw-r--r--Tests/RunCMake/Framework/RunCMakeTest.cmake69
-rw-r--r--Tests/RunCMake/RunCMake.cmake2
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeBundles.cmake52
8 files changed, 109 insertions, 71 deletions
diff --git a/Tests/Framework/CMakeLists.txt b/Tests/Framework/CMakeLists.txt
index 271aaf1..a313c2c 100644
--- a/Tests/Framework/CMakeLists.txt
+++ b/Tests/Framework/CMakeLists.txt
@@ -57,29 +57,30 @@ add_custom_target(fooCustom ALL COMMAND ${CMAKE_COMMAND} -E copy foo-post-build
add_dependencies(fooCustom foo)
# Make a static library and apply the framework properties to it to verify
-# that everything still builds correctly, but it will not actually produce
-# a framework... The framework properties only apply when the library type
-# is SHARED.
+# that everything still builds correctly. Xcode prior to version 5 does not
+# support static Frameworks.
#
-add_library(fooStatic STATIC
- foo.cxx
- foo.h
- foo2.h
- fooExtensionlessResource
- fooPublic.h
- fooPublicExtensionlessHeader
- fooPrivate.h
- fooPrivateExtensionlessHeader
- fooNeither.h
- fooBoth.h
- test.lua
- fooDeepPublic.h
-)
-set_target_properties(fooStatic PROPERTIES
- FRAMEWORK TRUE
- FRAMEWORK_VERSION none
-)
-add_executable(barStatic bar.cxx)
-target_link_libraries(barStatic fooStatic)
+if(NOT XCODE OR NOT XCODE_VERSION VERSION_LESS 5)
+ add_library(fooStatic STATIC
+ foo.cxx
+ foo.h
+ foo2.h
+ fooExtensionlessResource
+ fooPublic.h
+ fooPublicExtensionlessHeader
+ fooPrivate.h
+ fooPrivateExtensionlessHeader
+ fooNeither.h
+ fooBoth.h
+ test.lua
+ fooDeepPublic.h
+ )
+ set_target_properties(fooStatic PROPERTIES
+ FRAMEWORK TRUE
+ FRAMEWORK_VERSION none
+ )
+ add_executable(barStatic bar.cxx)
+ target_link_libraries(barStatic fooStatic)
+endif()
include(CPack)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index c2c744f..63016f1 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -276,8 +276,7 @@ if(XCODE_VERSION AND NOT "${XCODE_VERSION}" VERSION_LESS 3)
add_RunCMake_test(XcodeProject -DXCODE_VERSION=${XCODE_VERSION})
endif()
-if(NOT XCODE
- AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang"
+if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang"
AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0)
add_RunCMake_test(Framework)
endif()
diff --git a/Tests/RunCMake/Framework/FrameworkLayout.cmake b/Tests/RunCMake/Framework/FrameworkLayout.cmake
index 5184755..ae32134 100644
--- a/Tests/RunCMake/Framework/FrameworkLayout.cmake
+++ b/Tests/RunCMake/Framework/FrameworkLayout.cmake
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.4)
enable_language(C)
-add_library(Framework SHARED
+add_library(Framework ${FRAMEWORK_TYPE}
foo.c
foo.h
res.txt)
@@ -9,3 +9,6 @@ set_target_properties(Framework PROPERTIES
FRAMEWORK TRUE
PUBLIC_HEADER foo.h
RESOURCE "res.txt")
+
+add_custom_command(TARGET Framework POST_BUILD
+ COMMAND /usr/bin/file $<TARGET_FILE:Framework>)
diff --git a/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt b/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt
new file mode 100644
index 0000000..8d90f5f
--- /dev/null
+++ b/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt
@@ -0,0 +1 @@
+.*/Framework: Mach-O[^\n]* dynamically linked shared library.*
diff --git a/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt
new file mode 100644
index 0000000..c9f50b6
--- /dev/null
+++ b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt
@@ -0,0 +1 @@
+.*/Framework: current ar archive random library.*
diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake
index eeea6f1..e64892d 100644
--- a/Tests/RunCMake/Framework/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake
@@ -1,33 +1,40 @@
include(RunCMake)
-# iOS
-
-set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/iOSFrameworkLayout-build)
-set(RunCMake_TEST_NO_CLEAN 1)
-set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/ios.cmake")
-
-file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
-file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
-
-run_cmake(FrameworkLayout)
-run_cmake_command(iOSFrameworkLayout-build ${CMAKE_COMMAND} --build .)
-
-unset(RunCMake_TEST_BINARY_DIR)
-unset(RunCMake_TEST_NO_CLEAN)
-unset(RunCMake_TEST_OPTIONS)
-
-# OSX
-
-set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/OSXFrameworkLayout-build)
-set(RunCMake_TEST_NO_CLEAN 1)
-set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/osx.cmake")
-
-file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
-file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
-
-run_cmake(FrameworkLayout)
-run_cmake_command(OSXFrameworkLayout-build ${CMAKE_COMMAND} --build .)
-
-unset(RunCMake_TEST_BINARY_DIR)
-unset(RunCMake_TEST_NO_CLEAN)
-unset(RunCMake_TEST_OPTIONS)
+function(framework_layout_test Name Toolchain Type)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${Toolchain}${Type}FrameworkLayout-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${Toolchain}.cmake")
+ list(APPEND RunCMake_TEST_OPTIONS "-DFRAMEWORK_TYPE=${Type}")
+
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake(FrameworkLayout)
+ run_cmake_command(${Name} ${CMAKE_COMMAND} --build .)
+endfunction()
+
+# build check cannot cope with multi-configuration generators directory layout
+if(NOT RunCMake_GENERATOR STREQUAL "Xcode")
+ framework_layout_test(iOSFrameworkLayout-build ios SHARED)
+ framework_layout_test(iOSFrameworkLayout-build ios STATIC)
+ framework_layout_test(OSXFrameworkLayout-build osx SHARED)
+ framework_layout_test(OSXFrameworkLayout-build osx STATIC)
+endif()
+
+function(framework_type_test Toolchain Type)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${Toolchain}${Type}FrameworkType-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${Toolchain}.cmake")
+ list(APPEND RunCMake_TEST_OPTIONS "-DFRAMEWORK_TYPE=${Type}")
+
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake(FrameworkLayout)
+ run_cmake_command(FrameworkType${Type}-build ${CMAKE_COMMAND} --build .)
+endfunction()
+
+framework_type_test(ios SHARED)
+framework_type_test(ios STATIC)
+framework_type_test(osx SHARED)
+framework_type_test(osx STATIC)
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index 6cc3054..5f66da0 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/Tests/RunCMake/RunCMake.cmake
@@ -101,7 +101,7 @@ function(run_cmake test)
endif()
foreach(o out err)
string(REGEX REPLACE "\r\n" "\n" actual_std${o} "${actual_std${o}}")
- string(REGEX REPLACE "(^|\n)((==[0-9]+==|BullseyeCoverage|[a-z]+\\([0-9]+\\) malloc:|Error kstat returned|[^\n]*from Time Machine by path|[^\n]*Bullseye Testing Technology)[^\n]*\n)+" "\\1" actual_std${o} "${actual_std${o}}")
+ string(REGEX REPLACE "(^|\n)((==[0-9]+==|BullseyeCoverage|[a-z]+\\([0-9]+\\) malloc:|Error kstat returned|[^\n]*is a member of multiple groups|[^\n]*from Time Machine by path|[^\n]*Bullseye Testing Technology)[^\n]*\n)+" "\\1" actual_std${o} "${actual_std${o}}")
string(REGEX REPLACE "\n+$" "" actual_std${o} "${actual_std${o}}")
set(expect_${o} "")
if(DEFINED expect_std${o})
diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
index ad4268d..833eb85 100644
--- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
@@ -50,30 +50,56 @@ if (NOT TEST_IOS AND NOT TEST_WATCHOS AND NOT TEST_TVOS)
add_dependencies(AppBundleExtTest AppBundleExt)
endif()
-# Framework (not supported for iOS on Xcode < 6)
+# Shared Framework (not supported for iOS on Xcode < 6)
if(NOT TEST_IOS OR NOT XCODE_VERSION VERSION_LESS 6)
- add_library(Framework SHARED main.c)
- set_target_properties(Framework PROPERTIES FRAMEWORK TRUE)
+ add_library(SharedFramework SHARED main.c)
+ set_target_properties(SharedFramework PROPERTIES FRAMEWORK TRUE)
- add_custom_target(FrameworkTest ALL
+ add_custom_target(SharedFrameworkTest ALL
COMMAND ${CMAKE_COMMAND} -E copy
- "$<TARGET_FILE:Framework>" "$<TARGET_FILE:Framework>.old")
+ "$<TARGET_FILE:SharedFramework>" "$<TARGET_FILE:SharedFramework>.old")
- add_dependencies(FrameworkTest Framework)
+ add_dependencies(SharedFrameworkTest SharedFramework)
# with custom extension
- add_library(FrameworkExt SHARED main.c)
- set_target_properties(FrameworkExt PROPERTIES FRAMEWORK TRUE)
- set_target_properties(FrameworkExt PROPERTIES BUNDLE_EXTENSION "foo")
- install(TARGETS FrameworkExt FRAMEWORK DESTINATION FooExtension)
+ add_library(SharedFrameworkExt SHARED main.c)
+ set_target_properties(SharedFrameworkExt PROPERTIES FRAMEWORK TRUE)
+ set_target_properties(SharedFrameworkExt PROPERTIES BUNDLE_EXTENSION "foo")
+ install(TARGETS SharedFrameworkExt FRAMEWORK DESTINATION FooExtension)
- add_custom_target(FrameworkExtTest ALL
+ add_custom_target(SharedFrameworkExtTest ALL
COMMAND ${CMAKE_COMMAND} -E copy
- "$<TARGET_FILE:FrameworkExt>" "$<TARGET_FILE:FrameworkExt>.old")
+ "$<TARGET_FILE:SharedFrameworkExt>" "$<TARGET_FILE:SharedFrameworkExt>.old")
- add_dependencies(FrameworkExtTest FrameworkExt)
+ add_dependencies(SharedFrameworkExtTest SharedFrameworkExt)
+endif()
+
+# Static Framework (not supported for Xcode < 6)
+
+if(NOT XCODE_VERSION VERSION_LESS 6)
+ add_library(StaticFramework STATIC main.c)
+ set_target_properties(StaticFramework PROPERTIES FRAMEWORK TRUE)
+
+ add_custom_target(StaticFrameworkTest ALL
+ COMMAND ${CMAKE_COMMAND} -E copy
+ "$<TARGET_FILE:StaticFramework>" "$<TARGET_FILE:StaticFramework>.old")
+
+ add_dependencies(StaticFrameworkTest StaticFramework)
+
+ # with custom extension
+
+ add_library(StaticFrameworkExt STATIC main.c)
+ set_target_properties(StaticFrameworkExt PROPERTIES FRAMEWORK TRUE)
+ set_target_properties(StaticFrameworkExt PROPERTIES BUNDLE_EXTENSION "foo")
+ install(TARGETS StaticFrameworkExt FRAMEWORK DESTINATION StaticFooExtension)
+
+ add_custom_target(StaticFrameworkExtTest ALL
+ COMMAND ${CMAKE_COMMAND} -E copy
+ "$<TARGET_FILE:StaticFrameworkExt>" "$<TARGET_FILE:StaticFrameworkExt>.old")
+
+ add_dependencies(StaticFrameworkExtTest StaticFrameworkExt)
endif()
# Bundle