summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmMacroCommand.cxx39
-rw-r--r--Source/cmMacroCommand.h4
-rw-r--r--Tests/Complex/CMakeLists.txt15
-rw-r--r--Tests/ComplexOneConfig/CMakeLists.txt15
-rw-r--r--Tests/ComplexRelativePaths/CMakeLists.txt15
5 files changed, 87 insertions, 1 deletions
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 1fd8654..65154fe 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -107,6 +107,45 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf)
}
for (unsigned int j = 1; j < m_Args.size(); ++j)
{
+ variable = "${ARGV}";
+ std::vector<std::string>::iterator eit;
+ std::string var = "";
+ for ( eit = expandedArguments.begin();
+ eit != expandedArguments.end();
+ ++ eit )
+ {
+ if ( var.size() > 0 )
+ {
+ var += ";";
+ }
+ var += *eit;
+ }
+ cmSystemTools::ReplaceString(tmps, variable.c_str(),var.c_str());
+ }
+ for (unsigned int j = 1; j < m_Args.size(); ++j)
+ {
+ variable = "${ARGN}";
+ std::vector<std::string>::iterator eit;
+ std::string var = "";
+ std::vector<std::string>::size_type cnt = 0;
+ for ( eit = expandedArguments.begin();
+ eit != expandedArguments.end();
+ ++ eit )
+ {
+ if ( cnt >= m_Args.size()-1 )
+ {
+ if ( var.size() > 0 )
+ {
+ var += ";";
+ }
+ var += *eit;
+ }
+ cnt ++;
+ }
+ cmSystemTools::ReplaceString(tmps, variable.c_str(),var.c_str());
+ }
+ for (unsigned int j = 1; j < m_Args.size(); ++j)
+ {
// since this could be slow, first check if there is an ARGV
// only then do the inner loop. PS std::string sucks
char argvName[60];
diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h
index c614588..b0848d1 100644
--- a/Source/cmMacroCommand.h
+++ b/Source/cmMacroCommand.h
@@ -106,7 +106,9 @@ public:
"the variable ARGC which will be set to the number of arguments "
"passed into the function as well as ARGV0 ARGV1 ARGV2 ... which "
"will have the actual values of the arguments passed in. This "
- "fascilitates creating macros with optional arguments.";
+ "fascilitates creating macros with optional arguments. Additionally "
+ "ARGV holds the list of all arguments given to the macro and ARGN "
+ "holds the list of argument pass the last expected argument.";
}
cmTypeMacro(cmMacroCommand, cmCommand);
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt
index ef0ff80..c8a0ec3 100644
--- a/Tests/Complex/CMakeLists.txt
+++ b/Tests/Complex/CMakeLists.txt
@@ -29,6 +29,21 @@ ENDMACRO(TEST_ARGC)
# invoke the macro
TEST_ARGC(-DCMAKE_ARGV1 -DCMAKE_ARGV2 -DCMAKE_ARGV3 -DCMAKE_ARGV4)
+MACRO(TEST_VAR_ARG fa)
+ IF("${ARGV}" MATCHES "^1;2;3$")
+ MESSAGE(STATUS "ARGV works")
+ ELSE("${ARGV}" MATCHES "^1;2;3$")
+ MESSAGE(FATAL_ERROR "ARGV does not work; got \"${ARGV}\" instead of \"1;2;3\"")
+ ENDIF("${ARGV}" MATCHES "^1;2;3$")
+ IF("${ARGN}" MATCHES "^2;3$")
+ MESSAGE(STATUS "ARGN works")
+ ELSE("${ARGN}" MATCHES "^2;3$")
+ MESSAGE(FATAL_ERROR "ARGV does not work; got \"${ARGN}\" instead of \"2;3\"")
+ ENDIF("${ARGN}" MATCHES "^2;3$")
+ENDMACRO(TEST_VAR_ARG)
+
+TEST_VAR_ARG(1 2 3)
+
#
# Use the ansi CXX compile flag for building cmake
#
diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt
index ef0ff80..c8a0ec3 100644
--- a/Tests/ComplexOneConfig/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/CMakeLists.txt
@@ -29,6 +29,21 @@ ENDMACRO(TEST_ARGC)
# invoke the macro
TEST_ARGC(-DCMAKE_ARGV1 -DCMAKE_ARGV2 -DCMAKE_ARGV3 -DCMAKE_ARGV4)
+MACRO(TEST_VAR_ARG fa)
+ IF("${ARGV}" MATCHES "^1;2;3$")
+ MESSAGE(STATUS "ARGV works")
+ ELSE("${ARGV}" MATCHES "^1;2;3$")
+ MESSAGE(FATAL_ERROR "ARGV does not work; got \"${ARGV}\" instead of \"1;2;3\"")
+ ENDIF("${ARGV}" MATCHES "^1;2;3$")
+ IF("${ARGN}" MATCHES "^2;3$")
+ MESSAGE(STATUS "ARGN works")
+ ELSE("${ARGN}" MATCHES "^2;3$")
+ MESSAGE(FATAL_ERROR "ARGV does not work; got \"${ARGN}\" instead of \"2;3\"")
+ ENDIF("${ARGN}" MATCHES "^2;3$")
+ENDMACRO(TEST_VAR_ARG)
+
+TEST_VAR_ARG(1 2 3)
+
#
# Use the ansi CXX compile flag for building cmake
#
diff --git a/Tests/ComplexRelativePaths/CMakeLists.txt b/Tests/ComplexRelativePaths/CMakeLists.txt
index ef0ff80..c8a0ec3 100644
--- a/Tests/ComplexRelativePaths/CMakeLists.txt
+++ b/Tests/ComplexRelativePaths/CMakeLists.txt
@@ -29,6 +29,21 @@ ENDMACRO(TEST_ARGC)
# invoke the macro
TEST_ARGC(-DCMAKE_ARGV1 -DCMAKE_ARGV2 -DCMAKE_ARGV3 -DCMAKE_ARGV4)
+MACRO(TEST_VAR_ARG fa)
+ IF("${ARGV}" MATCHES "^1;2;3$")
+ MESSAGE(STATUS "ARGV works")
+ ELSE("${ARGV}" MATCHES "^1;2;3$")
+ MESSAGE(FATAL_ERROR "ARGV does not work; got \"${ARGV}\" instead of \"1;2;3\"")
+ ENDIF("${ARGV}" MATCHES "^1;2;3$")
+ IF("${ARGN}" MATCHES "^2;3$")
+ MESSAGE(STATUS "ARGN works")
+ ELSE("${ARGN}" MATCHES "^2;3$")
+ MESSAGE(FATAL_ERROR "ARGV does not work; got \"${ARGN}\" instead of \"2;3\"")
+ ENDIF("${ARGN}" MATCHES "^2;3$")
+ENDMACRO(TEST_VAR_ARG)
+
+TEST_VAR_ARG(1 2 3)
+
#
# Use the ansi CXX compile flag for building cmake
#