summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2021-04-11 08:05:14 (GMT)
committerCraig Scott <craig.scott@crascit.com>2021-04-11 08:06:16 (GMT)
commitf62a2bf44f392f6a23836848714ed36cd02975af (patch)
tree704729842548d71750291fb1390e323950b0a6de
parent6e7ff52af74cfbff15ded5c3aba7097499dffd32 (diff)
downloadCMake-f62a2bf44f392f6a23836848714ed36cd02975af.zip
CMake-f62a2bf44f392f6a23836848714ed36cd02975af.tar.gz
CMake-f62a2bf44f392f6a23836848714ed36cd02975af.tar.bz2
Tests: Factor out XcodeProject-Embed check function findAttribute()
-rw-r--r--Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff-check.cmake16
-rw-r--r--Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-check.cmake16
-rw-r--r--Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-check.cmake16
-rw-r--r--Tests/RunCMake/XcodeProject-Embed/findAttribute.cmake19
4 files changed, 28 insertions, 39 deletions
diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff-check.cmake
index 9cc03b9..dbd3e87 100644
--- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff-check.cmake
+++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff-check.cmake
@@ -1,14 +1,4 @@
-function(findAttribute project attr)
- execute_process(
- COMMAND grep ${attr} ${RunCMake_TEST_BINARY_DIR}/${project}.xcodeproj/project.pbxproj
- OUTPUT_VARIABLE output_var
- RESULT_VARIABLE result_var
- )
+include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake)
- if(NOT result_var)
- set(RunCMake_TEST_FAILED "${attr} attribute is set" PARENT_SCOPE)
- endif()
-endfunction()
-
-findAttribute(${test} "RemoveHeadersOnCopy")
-findAttribute(${test} "CodeSignOnCopy")
+findAttribute(${test} "RemoveHeadersOnCopy" FALSE)
+findAttribute(${test} "CodeSignOnCopy" FALSE)
diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-check.cmake
index 3f62640..0f57820 100644
--- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-check.cmake
+++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-check.cmake
@@ -1,14 +1,4 @@
-function(findAttribute project attr)
- execute_process(
- COMMAND grep ${attr} ${RunCMake_TEST_BINARY_DIR}/${project}.xcodeproj/project.pbxproj
- OUTPUT_VARIABLE output_var
- RESULT_VARIABLE result_var
- )
+include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake)
- if(result_var)
- set(RunCMake_TEST_FAILED "${attr} attribute not set" PARENT_SCOPE)
- endif()
-endfunction()
-
-findAttribute(${test} "RemoveHeadersOnCopy")
-findAttribute(${test} "CodeSignOnCopy")
+findAttribute(${test} "RemoveHeadersOnCopy" TRUE)
+findAttribute(${test} "CodeSignOnCopy" TRUE)
diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-check.cmake
index 3f62640..0f57820 100644
--- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-check.cmake
+++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-check.cmake
@@ -1,14 +1,4 @@
-function(findAttribute project attr)
- execute_process(
- COMMAND grep ${attr} ${RunCMake_TEST_BINARY_DIR}/${project}.xcodeproj/project.pbxproj
- OUTPUT_VARIABLE output_var
- RESULT_VARIABLE result_var
- )
+include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake)
- if(result_var)
- set(RunCMake_TEST_FAILED "${attr} attribute not set" PARENT_SCOPE)
- endif()
-endfunction()
-
-findAttribute(${test} "RemoveHeadersOnCopy")
-findAttribute(${test} "CodeSignOnCopy")
+findAttribute(${test} "RemoveHeadersOnCopy" TRUE)
+findAttribute(${test} "CodeSignOnCopy" TRUE)
diff --git a/Tests/RunCMake/XcodeProject-Embed/findAttribute.cmake b/Tests/RunCMake/XcodeProject-Embed/findAttribute.cmake
new file mode 100644
index 0000000..b1963e2
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject-Embed/findAttribute.cmake
@@ -0,0 +1,19 @@
+cmake_policy(VERSION 3.1...3.20)
+
+function(findAttribute project attr expectPresent)
+ execute_process(
+ COMMAND grep ${attr} ${RunCMake_TEST_BINARY_DIR}/${project}.xcodeproj/project.pbxproj
+ OUTPUT_VARIABLE output_var
+ RESULT_VARIABLE result_var
+ )
+
+ if(${expectPresent})
+ if(result_var)
+ set(RunCMake_TEST_FAILED "${attr} attribute is not set" PARENT_SCOPE)
+ endif()
+ else()
+ if(NOT result_var)
+ set(RunCMake_TEST_FAILED "${attr} attribute is set" PARENT_SCOPE)
+ endif()
+ endif()
+endfunction()