summaryrefslogtreecommitdiff
path: root/Tests/Complex
diff options
context:
space:
mode:
authorSylvain Joubert <joubert.sy@gmail.com>2017-07-04 12:00:02 +0200
committerSylvain Joubert <joubert.sy@gmail.com>2017-07-04 12:00:02 +0200
commit58f47448210bf3fd3121bf91f74eb893ba9d034c (patch)
tree9b4a81430dda42f630fb03351332b4551aafde24 /Tests/Complex
parent74112c8da16ea5f2a4940d196d178da684626f92 (diff)
downloadcmake-58f47448210bf3fd3121bf91f74eb893ba9d034c.tar.gz
configure_file: Add support for indented cmakedefine
Optional spaces and/or tabs are now understood between the '#' character and the 'cmakedefine'/'cmakedefine01' words. This indentation is preserved in the output lines. Fixes: #13037
Diffstat (limited to 'Tests/Complex')
-rw-r--r--Tests/Complex/CMakeLists.txt2
-rw-r--r--Tests/Complex/Executable/complex.cxx22
-rw-r--r--Tests/Complex/VarTests.cmake2
-rw-r--r--Tests/Complex/cmTestConfigure.h.in4
4 files changed, 30 insertions, 0 deletions
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt
index 075faa768c..8537cd99af 100644
--- a/Tests/Complex/CMakeLists.txt
+++ b/Tests/Complex/CMakeLists.txt
@@ -356,6 +356,8 @@ endwhile()
set(SHOULD_BE_ZERO )
set(SHOULD_BE_ONE 1)
+set(SHOULD_BE_ZERO_AND_INDENTED )
+set(SHOULD_BE_ONE_AND_INDENTED 1)
# test elseif functionality, the mess below tries to catch problem
# of clauses being executed early or late etc
diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx
index 3b09229ba1..ca39870f23 100644
--- a/Tests/Complex/Executable/complex.cxx
+++ b/Tests/Complex/Executable/complex.cxx
@@ -261,6 +261,12 @@ int main()
cmPassed("ONE_VAR is defined.");
#endif
+#ifndef ONE_VAR_AND_INDENTED
+ cmFailed("cmakedefine is broken, ONE_VAR_AND_INDENTED is not defined.");
+#else
+ cmPassed("ONE_VAR_AND_INDENTED is defined.");
+#endif
+
#ifndef ONE_VAR_IS_DEFINED
cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
"ONE_VAR_IS_DEFINED is not defined.");
@@ -274,6 +280,12 @@ int main()
cmPassed("ZERO_VAR is not defined.");
#endif
+#ifdef ZERO_VAR_AND_INDENTED
+ cmFailed("cmakedefine is broken, ZERO_VAR_AND_INDENTED is defined.");
+#else
+ cmPassed("ZERO_VAR_AND_INDENTED is not defined.");
+#endif
+
#ifndef STRING_VAR
cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
#else
@@ -1030,6 +1042,16 @@ int main()
} else {
cmFailed("cmakedefine01 is not working for 1");
}
+ if (SHOULD_BE_ZERO_AND_INDENTED == 0) {
+ cmPassed("cmakedefine01 is working for 0 and indented");
+ } else {
+ cmFailed("cmakedefine01 is not working for 0 and indented");
+ }
+ if (SHOULD_BE_ONE_AND_INDENTED == 1) {
+ cmPassed("cmakedefine01 is working for 1 and indented");
+ } else {
+ cmFailed("cmakedefine01 is not working for 1 and indented");
+ }
#ifdef FORCE_TEST
cmFailed("CMake SET CACHE FORCE");
#else
diff --git a/Tests/Complex/VarTests.cmake b/Tests/Complex/VarTests.cmake
index 8be59be5ea..9761986ab9 100644
--- a/Tests/Complex/VarTests.cmake
+++ b/Tests/Complex/VarTests.cmake
@@ -2,6 +2,7 @@
# Test SET
#
set (ZERO_VAR 0)
+set (ZERO_VAR_AND_INDENTED 0)
set (ZERO_VAR2 0)
if(ZERO_VAR)
@@ -11,6 +12,7 @@ else()
endif()
set(ONE_VAR 1)
+set(ONE_VAR_AND_INDENTED 1)
set(ONE_VAR2 1)
set(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
diff --git a/Tests/Complex/cmTestConfigure.h.in b/Tests/Complex/cmTestConfigure.h.in
index d7424b1845..72317bcc8f 100644
--- a/Tests/Complex/cmTestConfigure.h.in
+++ b/Tests/Complex/cmTestConfigure.h.in
@@ -1,8 +1,10 @@
// Test SET, VARIABLE_REQUIRES
#cmakedefine ONE_VAR
+# cmakedefine ONE_VAR_AND_INDENTED
#cmakedefine ONE_VAR_IS_DEFINED
#cmakedefine ZERO_VAR
+# cmakedefine ZERO_VAR_AND_INDENTED
#define STRING_VAR "${STRING_VAR}"
@@ -32,6 +34,8 @@
#cmakedefine01 SHOULD_BE_ZERO
#cmakedefine01 SHOULD_BE_ONE
+# cmakedefine01 SHOULD_BE_ZERO_AND_INDENTED
+# cmakedefine01 SHOULD_BE_ONE_AND_INDENTED
// Needed to check for files
#define BINARY_DIR "${Complex_BINARY_DIR}"