Hi,
I'm experimenting with the variables available in script mode in the
current master (a3a581f8cd):
CMAKE_SCRIPT_MODE_FILE
CMAKE_ARGC
CMAKE_ARGVx
Apparently they are not available in 2.8.4 yet.
Using this test script:
##################
message("Begin")
message("CMAKE_SCRIPT_MODE_FILE=${CMAKE_SCRIPT_MODE_FILE}")
message("CMAKE_ARGC=${CMAKE_ARGC}")
foreach(i RANGE 0 ${CMAKE_ARGC})
message("CMAKE_ARGV${i}=${CMAKE_ARGV${i}}")
endforeach(i)
message("CMAKE_ARGV=${CMAKE_ARGV}")
message("CMAKE_ARGN=${CMAKE_ARGN}")
message("End")
#################
I have the following behavior:
$ ~/build/cmake/git/_build/bin/cmake -P /tmp/test.cmake a1 a2
Begin
CMAKE_SCRIPT_MODE_FILE=/tmp/test.cmake
CMAKE_ARGC=5
CMAKE_ARGV0=/home/despre_n/build/cmake/git/_build/bin/cmake
CMAKE_ARGV1=-P
CMAKE_ARGV2=/tmp/test.cmake
CMAKE_ARGV3=a1
CMAKE_ARGV4=a2
CMAKE_ARGV5=
CMAKE_ARGV=
CMAKE_ARGN=
End
I think the user does not care about having CMAKE_ARGV1=-P and
CMAKE_ARGV2=/tmp/test.cmake
I have attached a patch that do this behavior:
$ ~/build/cmake/git/_build/bin/cmake -P /tmp/test.cmake a1 a2
Begin
CMAKE_SCRIPT_MODE_FILE=/tmp/test.cmake
CMAKE_ARGC=2
CMAKE_ARGV0=a1
CMAKE_ARGV1=a2
CMAKE_ARGV2=
CMAKE_ARGV=
CMAKE_ARGN=
End
I think having CMAKE_ARGV would be good too but it is another topic.
Cheers,
--
Nicolas Desprès
From a5a7af8b9766ad328c9b58bf94760f4d68f3ed8f Mon Sep 17 00:00:00 2001
From: Nicolas Despres <[email protected]>
Date: Wed, 27 Apr 2011 15:06:32 +0200
Subject: CMAKE_ARGVx does not include -P <pathname>.
The script cares only about the arguments following -P <pathname>. Plus, it
already has CMAKE_SCRIPT_MODE_FILE storing its pathname so CMAKE_ARGV0 can
starts with the first argument after <pathname>.
---
Source/cmake.cxx | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 45927cb..c64de2b 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -478,7 +478,12 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
cmSystemTools::Error("No cmake script provided.");
return false;
}
- this->ReadListFile(args, path.c_str());
+ // Get rid of -P and the path name argument since the script does not
+ // care about it.
+ std::vector<std::string> script_args;
+ for (unsigned int j = i + 1; j < args.size(); ++j)
+ script_args.push_back(args[j]);
+ this->ReadListFile(script_args, path.c_str());
}
}
return true;
--
1.7.4.2
_______________________________________________
cmake-developers mailing list
[email protected]
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers