[Cmake] regex error ? in 2.1

Nicolas Belan nbelan at tele2.fr
Mon Jun 7 04:51:24 EDT 2004


Hi all,

i am just starting using cmake, but i can not understand regex arguments
behavior ...
if you write:
SET(A foo)
SET(B bar)
STRING(REGEX REPLACE "foo" "bar" AB ${A} ${B})

for me it is the same as doing:
STRING(REGEX REPLACE "foo" "bar" AB "foo bar")

but if you look code, this is what is happening:
STRING(REGEX REPLACE "foo" "bar" AB "foobar") // notice space deleted

so, why don't you concatenate args with spaces ?

See patch attached with this mail (which fix message error and
modules/CheckIncludes with string regexp)


Thx

--
Nicolas Bélan
mailto: nicolas.belan at free.fr
-------------- next part --------------
Index: Modules/CheckIncludeFiles.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CheckIncludeFiles.cmake,v
retrieving revision 1.7
diff -u -w -r1.7 CheckIncludeFiles.cmake
--- a/Modules/CheckIncludeFiles.cmake	8 Aug 2003 15:59:07 -0000	1.7
+++ b/Modules/CheckIncludeFiles.cmake	4 Jun 2004 16:33:43 -0000
@@ -10,15 +10,11 @@
   IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
     SET(CHECK_INCLUDE_FILES_CONTENT "/* */\n")
     SET(MACRO_CHECK_INCLUDE_FILES_FLAGS ${CMAKE_REQUIRED_FLAGS})
-    FOREACH(FILE ${INCLUDE})
-      SET(CHECK_INCLUDE_FILES_CONTENT
-        "${CHECK_INCLUDE_FILES_CONTENT}#include <${FILE}>\n")
-    ENDFOREACH(FILE)
+    STRING(REGEX REPLACE "([^ ]+)" "#include <\\1>\\n" CHECK_INCLUDE_FILES_CONTENT ${INCLUDE})
     SET(CHECK_INCLUDE_FILES_CONTENT
       "${CHECK_INCLUDE_FILES_CONTENT}\n\nint main(){return 0;}\n")
     FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFiles.c 
       "${CHECK_INCLUDE_FILES_CONTENT}")
-
     MESSAGE(STATUS "Looking for include files ${VARIABLE}")
     TRY_COMPILE(${VARIABLE}
       ${CMAKE_BINARY_DIR}
Index: Source/cmStringCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmStringCommand.cxx,v
retrieving revision 1.12
diff -u -w -r1.12 cmStringCommand.cxx
--- a/Source/cmStringCommand.cxx	4 Mar 2004 15:05:14 -0000	1.12
+++ b/Source/cmStringCommand.cxx	4 Jun 2004 16:33:54 -0000
@@ -198,7 +198,7 @@
     {
     if(args.size() < 6)
       {
-      this->SetError("sub-command REGEX, mode MATCH needs "
+		  this->SetError("sub-command REGEX, mode REPLACE needs "
                      "at least 6 arguments total to command.");
       return false;
       }
@@ -221,6 +221,7 @@
   std::string input = args[4];
   for(unsigned int i=5; i < args.size(); ++i)
     {
+	input += " ";
     input += args[i];
     }
   
@@ -264,6 +265,7 @@
   std::string input = args[4];
   for(unsigned int i=5; i < args.size(); ++i)
     {
+    input += " ";
     input += args[i];
     }
   
@@ -362,6 +365,7 @@
   std::string input = args[5];
   for(unsigned int i=6; i < args.size(); ++i)
     {
+	  input += " ";
     input += args[i];
     }
   


More information about the Cmake mailing list