From 3d3caacf9ec9f99cebcfaeb5ab105daa1046f945 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 16 Jul 2002 17:42:56 -0400 Subject: [PATCH] ENH: Added test for IF inside a FOREACH. --- Tests/Complex/CMakeLists.txt | 14 ++++++++++++++ Tests/Complex/Executable/complex.cxx | 12 ++++++++++-- Tests/Complex/cmTestConfigure.h.in | 4 ++++ Tests/ComplexOneConfig/CMakeLists.txt | 14 ++++++++++++++ Tests/ComplexOneConfig/Executable/complex.cxx | 12 ++++++++++-- Tests/ComplexOneConfig/cmTestConfigure.h.in | 4 ++++ Tests/ComplexRelativePaths/CMakeLists.txt | 14 ++++++++++++++ Tests/ComplexRelativePaths/Executable/complex.cxx | 12 ++++++++++-- Tests/ComplexRelativePaths/cmTestConfigure.h.in | 4 ++++ 9 files changed, 84 insertions(+), 6 deletions(-) diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index 0549c6f11..2d6de2035 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -160,6 +160,20 @@ SET(REMOVE_STRING a b c d e f) SET(removeVar1 c e) REMOVE(REMOVE_STRING ${removeVar1} f) +# +# Test an IF inside a FOREACH. +# +FOREACH(x "a") + IF(1) + # Should always execute. + SET(IF_INSIDE_FOREACH_THEN_EXECUTED 1) + ELSE(1) + # Should never execute. + SET(IF_INSIDE_FOREACH_ELSE_EXECUTED 1) + ENDIF(1) +ENDFOREACH(x) + + # # Configure file # (plug vars to #define so that they can be tested) diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index e8885e58a..c5969cb99 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -799,8 +799,16 @@ int main() else { cmFailed("cmSystemTools::UpperCase is working"); - } - + } + + // ---------------------------------------------------------------------- + // Test if IF command inside a FOREACH works. +#if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) && !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED) + cmPassed("IF inside a FOREACH block works"); +#else + cmFailed("IF inside a FOREACH block is broken"); +#endif + // ---------------------------------------------------------------------- // Summary diff --git a/Tests/Complex/cmTestConfigure.h.in b/Tests/Complex/cmTestConfigure.h.in index f89b6153d..350a9c024 100644 --- a/Tests/Complex/cmTestConfigure.h.in +++ b/Tests/Complex/cmTestConfigure.h.in @@ -60,3 +60,7 @@ // Test Remove command #define REMOVE_STRING "${REMOVE_STRING}" + +// Test IF inside FOREACH +#cmakedefine IF_INSIDE_FOREACH_THEN_EXECUTED +#cmakedefine IF_INSIDE_FOREACH_ELSE_EXECUTED diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index 0549c6f11..2d6de2035 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -160,6 +160,20 @@ SET(REMOVE_STRING a b c d e f) SET(removeVar1 c e) REMOVE(REMOVE_STRING ${removeVar1} f) +# +# Test an IF inside a FOREACH. +# +FOREACH(x "a") + IF(1) + # Should always execute. + SET(IF_INSIDE_FOREACH_THEN_EXECUTED 1) + ELSE(1) + # Should never execute. + SET(IF_INSIDE_FOREACH_ELSE_EXECUTED 1) + ENDIF(1) +ENDFOREACH(x) + + # # Configure file # (plug vars to #define so that they can be tested) diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index e8885e58a..c5969cb99 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -799,8 +799,16 @@ int main() else { cmFailed("cmSystemTools::UpperCase is working"); - } - + } + + // ---------------------------------------------------------------------- + // Test if IF command inside a FOREACH works. +#if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) && !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED) + cmPassed("IF inside a FOREACH block works"); +#else + cmFailed("IF inside a FOREACH block is broken"); +#endif + // ---------------------------------------------------------------------- // Summary diff --git a/Tests/ComplexOneConfig/cmTestConfigure.h.in b/Tests/ComplexOneConfig/cmTestConfigure.h.in index f89b6153d..350a9c024 100644 --- a/Tests/ComplexOneConfig/cmTestConfigure.h.in +++ b/Tests/ComplexOneConfig/cmTestConfigure.h.in @@ -60,3 +60,7 @@ // Test Remove command #define REMOVE_STRING "${REMOVE_STRING}" + +// Test IF inside FOREACH +#cmakedefine IF_INSIDE_FOREACH_THEN_EXECUTED +#cmakedefine IF_INSIDE_FOREACH_ELSE_EXECUTED diff --git a/Tests/ComplexRelativePaths/CMakeLists.txt b/Tests/ComplexRelativePaths/CMakeLists.txt index 0549c6f11..2d6de2035 100644 --- a/Tests/ComplexRelativePaths/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/CMakeLists.txt @@ -160,6 +160,20 @@ SET(REMOVE_STRING a b c d e f) SET(removeVar1 c e) REMOVE(REMOVE_STRING ${removeVar1} f) +# +# Test an IF inside a FOREACH. +# +FOREACH(x "a") + IF(1) + # Should always execute. + SET(IF_INSIDE_FOREACH_THEN_EXECUTED 1) + ELSE(1) + # Should never execute. + SET(IF_INSIDE_FOREACH_ELSE_EXECUTED 1) + ENDIF(1) +ENDFOREACH(x) + + # # Configure file # (plug vars to #define so that they can be tested) diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx index e8885e58a..c5969cb99 100644 --- a/Tests/ComplexRelativePaths/Executable/complex.cxx +++ b/Tests/ComplexRelativePaths/Executable/complex.cxx @@ -799,8 +799,16 @@ int main() else { cmFailed("cmSystemTools::UpperCase is working"); - } - + } + + // ---------------------------------------------------------------------- + // Test if IF command inside a FOREACH works. +#if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) && !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED) + cmPassed("IF inside a FOREACH block works"); +#else + cmFailed("IF inside a FOREACH block is broken"); +#endif + // ---------------------------------------------------------------------- // Summary diff --git a/Tests/ComplexRelativePaths/cmTestConfigure.h.in b/Tests/ComplexRelativePaths/cmTestConfigure.h.in index f89b6153d..350a9c024 100644 --- a/Tests/ComplexRelativePaths/cmTestConfigure.h.in +++ b/Tests/ComplexRelativePaths/cmTestConfigure.h.in @@ -60,3 +60,7 @@ // Test Remove command #define REMOVE_STRING "${REMOVE_STRING}" + +// Test IF inside FOREACH +#cmakedefine IF_INSIDE_FOREACH_THEN_EXECUTED +#cmakedefine IF_INSIDE_FOREACH_ELSE_EXECUTED