summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-10-26 17:12:59 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-10-26 17:12:59 (GMT)
commit4c4da56b2eb22fd902a100b294ff2acb6d77fac3 (patch)
treea7986e6fc8491b28932504bc43a75013f69cf530 /Tests
parent06ee07b854d4a77c4147dadb97f9769b17da832d (diff)
parent601e6e1ad10b83dcb5ad09d061b04e6974cda283 (diff)
downloadCMake-4c4da56b2eb22fd902a100b294ff2acb6d77fac3.zip
CMake-4c4da56b2eb22fd902a100b294ff2acb6d77fac3.tar.gz
CMake-4c4da56b2eb22fd902a100b294ff2acb6d77fac3.tar.bz2
Merge topic 'xcode-optimization-flags'
601e6e1a Xcode: Use regular expression to extract all optimisation flags (#15794)
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/XcodeProject/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeOptimizationFlags-check.cmake7
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake20
-rw-r--r--Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags-check.cmake8
-rw-r--r--Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags.cmake12
-rw-r--r--Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag-check.cmake7
-rw-r--r--Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag.cmake6
7 files changed, 63 insertions, 0 deletions
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
index 8ab618b..7901ec0 100644
--- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -4,6 +4,9 @@ run_cmake(XcodeFileType)
run_cmake(XcodeAttributeGenex)
run_cmake(XcodeAttributeGenexError)
run_cmake(XcodeObjectNeedsQuote)
+run_cmake(XcodeOptimizationFlags)
+run_cmake(XcodePreserveNonOptimizationFlags)
+run_cmake(XcodePreserveObjcFlag)
if (NOT XCODE_VERSION VERSION_LESS 6)
run_cmake(XcodePlatformFrameworks)
endif()
diff --git a/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags-check.cmake b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags-check.cmake
new file mode 100644
index 0000000..f5595b3
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags-check.cmake
@@ -0,0 +1,7 @@
+foreach(level 1 2 3 s fast)
+ file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodeOptimizationFlags.xcodeproj/project.pbxproj actual-${level}
+ REGEX "GCC_OPTIMIZATION_LEVEL = ${level};" LIMIT_COUNT 1)
+ if(NOT actual-${level})
+ message(SEND_ERROR "Optimization level '${level}' not found in Xcode project.")
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake
new file mode 100644
index 0000000..e14bf80
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake
@@ -0,0 +1,20 @@
+set(CMAKE_CONFIGURATION_TYPES "Release" CACHE INTERNAL "Supported configuration types")
+
+set(CMAKE_CXX_FLAGS_RELEASE "")
+
+project(XcodeOptimizationFlags CXX)
+
+add_library(fooO1 STATIC foo.cpp)
+set_target_properties(fooO1 PROPERTIES COMPILE_OPTIONS -O1)
+
+add_library(fooO2 STATIC foo.cpp)
+set_target_properties(fooO2 PROPERTIES COMPILE_OPTIONS -O2)
+
+add_library(fooO3 STATIC foo.cpp)
+set_target_properties(fooO3 PROPERTIES COMPILE_OPTIONS -O3)
+
+add_library(fooOs STATIC foo.cpp)
+set_target_properties(fooOs PROPERTIES COMPILE_OPTIONS -Os)
+
+add_library(fooOfast STATIC foo.cpp)
+set_target_properties(fooOfast PROPERTIES COMPILE_OPTIONS -Ofast)
diff --git a/Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags-check.cmake b/Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags-check.cmake
new file mode 100644
index 0000000..2f6c03d
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags-check.cmake
@@ -0,0 +1,8 @@
+file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodePreserveNonOptimizationFlags.xcodeproj/project.pbxproj actual
+ REGEX "OTHER_CPLUSPLUSFLAGS = [^;]*;")
+foreach(expect "-DA" "-DB +-DC" "-DD")
+ if(NOT "${actual}" MATCHES "${expect}")
+ message(SEND_ERROR "The actual project contains the lines:\n ${actual}\n"
+ "which do not match expected regex:\n ${expect}\n")
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags.cmake b/Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags.cmake
new file mode 100644
index 0000000..16f0381
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags.cmake
@@ -0,0 +1,12 @@
+set(CMAKE_CONFIGURATION_TYPES "Release" CACHE INTERNAL "Supported configuration types")
+
+project(XcodePreserveNonOptimizationFlags CXX)
+
+add_library(preserveStart STATIC foo.cpp)
+set_property(TARGET preserveStart PROPERTY COMPILE_OPTIONS -DA -O1)
+
+add_library(preserveBoth STATIC foo.cpp)
+set_property(TARGET preserveBoth PROPERTY COMPILE_OPTIONS -DB -O1 -DC)
+
+add_library(preserveEnd STATIC foo.cpp)
+set_property(TARGET preserveEnd PROPERTY COMPILE_OPTIONS -O1 -DD)
diff --git a/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag-check.cmake b/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag-check.cmake
new file mode 100644
index 0000000..332906f
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag-check.cmake
@@ -0,0 +1,7 @@
+set(expect "-ObjC")
+file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodePreserveObjcFlag.xcodeproj/project.pbxproj actual
+ REGEX "OTHER_CPLUSPLUSFLAGS = [^;]*;" LIMIT_COUNT 1)
+if(NOT "${actual}" MATCHES "${expect}")
+ message(SEND_ERROR "The actual project contains the line:\n ${actual}\n"
+ "which does not match expected regex:\n ${expect}\n")
+endif()
diff --git a/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag.cmake b/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag.cmake
new file mode 100644
index 0000000..64db633
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag.cmake
@@ -0,0 +1,6 @@
+set(CMAKE_CONFIGURATION_TYPES "Release" CACHE INTERNAL "Supported configuration types")
+
+project(XcodePreserveObjcFlag CXX)
+
+add_library(foo STATIC foo.cpp)
+set_target_properties(foo PROPERTIES COMPILE_OPTIONS -ObjC)