[Cmake-commits] CMake branch, next, updated. v2.8.3-1506-gb706dcf

David Cole david.cole at kitware.com
Thu Jan 27 18:31:34 EST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  b706dcfc2636394bedc768b9ad9114efb78665fc (commit)
       via  008d116b1767cb93c043e399ab607bcc8db5c175 (commit)
      from  570b5d778b9fc620b99b802f10cc06c078ba13cb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b706dcfc2636394bedc768b9ad9114efb78665fc
commit b706dcfc2636394bedc768b9ad9114efb78665fc
Merge: 570b5d7 008d116
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Thu Jan 27 18:31:29 2011 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Jan 27 18:31:29 2011 -0500

    Merge topic 'fix-11695-spaces-in-vs10-rc-defs' into next
    
    008d116 VSResource: Avoid windres /D with quoted spaces (#11695)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=008d116b1767cb93c043e399ab607bcc8db5c175
commit 008d116b1767cb93c043e399ab607bcc8db5c175
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Thu Jan 27 15:45:25 2011 -0500
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Thu Jan 27 18:28:36 2011 -0500

    VSResource: Avoid windres /D with quoted spaces (#11695)
    
    Improve test: print out what's happening along the way.

diff --git a/Tests/VSResource/CMakeLists.txt b/Tests/VSResource/CMakeLists.txt
index 5fbd572..5d7d14e 100644
--- a/Tests/VSResource/CMakeLists.txt
+++ b/Tests/VSResource/CMakeLists.txt
@@ -5,12 +5,31 @@ string(REPLACE "/INCREMENTAL:YES" ""
   CMAKE_EXE_LINKER_FLAGS_DEBUG
   "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
 
-if(MSVC60 OR CYGWIN)
-  # VS6 and Cygwin rc compilers do not deal well with spaces in a "/D" value
+message(STATUS "CMAKE_RC_COMPILER='${CMAKE_RC_COMPILER}'")
+
+# Because of the following avoidance techniques required for windres and VS6,
+# we recommend using a configured header file, and defining preprocessor
+# symbols via #define code and including that header in the rc file. Using
+# add_definitions is fine for simple definitions (with no spaces and no
+# quoting), but requires avoidance or work-arounds beyond that...
+
+if(CMAKE_RC_COMPILER MATCHES windres)
+  # windres rc compiler does not properly define quoted /D values as strings
+  message(STATUS "CMAKE_RC_COMPILER MATCHES windres")
+  add_definitions(/DCMAKE_RCDEFINE=test.txt)
+  add_definitions(/DCMAKE_RCDEFINE_NO_QUOTED_STRINGS)
+elseif(MSVC60)
+  # VS6 rc compiler does not deal well with spaces in a "/D" value, but it can
+  # handle the quoting
+  message(STATUS "MSVC60")
   add_definitions(/DCMAKE_RCDEFINE="test.txt")
 else()
+  # expected case -- rc compiler is "capable enough"
+  message(STATUS
+    "rc compiler handles quoted strings with spaces in values via /D")
+  set(TEXTFILE_FROM_SOURCE_DIR "textfile, spaces in name, from binary dir")
   configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test.txt
-    "${CMAKE_CURRENT_BINARY_DIR}/test with spaces.txt" COPYONLY)
+    "${CMAKE_CURRENT_BINARY_DIR}/test with spaces.txt" @ONLY)
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
   add_definitions(/DCMAKE_RCDEFINE="test with spaces.txt")
 endif()
diff --git a/Tests/VSResource/main.cpp b/Tests/VSResource/main.cpp
index 6f68df3..7ee0c74 100644
--- a/Tests/VSResource/main.cpp
+++ b/Tests/VSResource/main.cpp
@@ -1,10 +1,80 @@
 #include <windows.h>
+#include <stdio.h>
 
-int main(int argc, char** argv) {
-   HRSRC hello = ::FindResource(0, "hello", "TEXT");
-   if(hello) {
-      return 0;
-   } else {
-      return 1;
-   }
+struct x
+{
+  const char *txt;
+};
+
+int main(int argc, char** argv)
+{
+  int ret = 1;
+
+  fprintf(stdout, "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)\n");
+
+#ifdef CMAKE_RCDEFINE
+  fprintf(stdout, "CMAKE_RCDEFINE defined\n");
+#endif
+
+#ifdef CMAKE_RCDEFINE_NO_QUOTED_STRINGS
+  // Expect CMAKE_RCDEFINE to preprocess to exactly test.txt
+  x test;
+  test.txt = "*exactly* test.txt";
+  fprintf(stdout, "CMAKE_RCDEFINE_NO_QUOTED_STRINGS defined\n");
+  fprintf(stdout, "CMAKE_RCDEFINE is %s, and is *not* a string constant\n",
+    CMAKE_RCDEFINE);
+#else
+  // Expect CMAKE_RCDEFINE to be a string:
+  fprintf(stdout, "CMAKE_RCDEFINE='%s', and is a string constant\n",
+    CMAKE_RCDEFINE);
+#endif
+
+  HRSRC hello = ::FindResource(NULL, MAKEINTRESOURCE(1025), "TEXTFILE");
+  if(hello)
+    {
+    fprintf(stdout, "FindResource worked\n");
+    HGLOBAL hgbl = ::LoadResource(NULL, hello);
+    int datasize = (int) ::SizeofResource(NULL, hello);
+    if(hgbl && datasize>0)
+      {
+      fprintf(stdout, "LoadResource worked\n");
+      fprintf(stdout, "SizeofResource returned datasize='%d'\n", datasize);
+      void *data = ::LockResource(hgbl);
+      if (data)
+        {
+        fprintf(stdout, "LockResource worked\n");
+        char *str = (char *) malloc(datasize+4);
+        if (str)
+          {
+          memcpy(str, data, datasize);
+          str[datasize] = 'E';
+          str[datasize+1] = 'O';
+          str[datasize+2] = 'R';
+          str[datasize+3] = 0;
+          fprintf(stdout, "str='%s'\n", str);
+          free(str);
+
+          ret = 0;
+
+#ifdef CMAKE_RCDEFINE_NO_QUOTED_STRINGS
+          fprintf(stdout, "LoadString skipped\n");
+#else
+          char buf[256];
+          if (::LoadString(NULL, 1026, buf, sizeof(buf)) > 0)
+            {
+            fprintf(stdout, "LoadString worked\n");
+            fprintf(stdout, "buf='%s'\n", buf);
+            }
+          else
+            {
+            fprintf(stdout, "LoadString failed\n");
+            ret = 1;
+            }
+#endif
+          }
+        }
+      }
+    }
+
+  return ret;
 }
diff --git a/Tests/VSResource/test.rc b/Tests/VSResource/test.rc
index 2e87a68..4ce4b53 100644
--- a/Tests/VSResource/test.rc
+++ b/Tests/VSResource/test.rc
@@ -1,10 +1,17 @@
 #ifdef CMAKE_RCDEFINE
-hello TEXT DISCARDABLE CMAKE_RCDEFINE
 
+// This line can compile with either an unquoted or a quoted string
+1025 TEXTFILE CMAKE_RCDEFINE
+
+#ifndef CMAKE_RCDEFINE_NO_QUOTED_STRINGS
+// This block can only be compiled if CMAKE_RCDEFINE preprocesses
+// to a double quoted string
 STRINGTABLE
 BEGIN
-  1 CMAKE_RCDEFINE
+  1026 CMAKE_RCDEFINE
 END
+#endif
+
 #else
 #error "resource compiler did not get defines from command line!"
 #endif
diff --git a/Tests/VSResource/test.txt b/Tests/VSResource/test.txt
index 980a0d5..c27c68d 100644
--- a/Tests/VSResource/test.txt
+++ b/Tests/VSResource/test.txt
@@ -1 +1 @@
-Hello World!
+Hello World! (@TEXTFILE_FROM_SOURCE_DIR@)

-----------------------------------------------------------------------

Summary of changes:
 Tests/VSResource/CMakeLists.txt |   25 ++++++++++-
 Tests/VSResource/main.cpp       |   84 +++++++++++++++++++++++++++++++++++---
 Tests/VSResource/test.rc        |   11 ++++-
 Tests/VSResource/test.txt       |    2 +-
 4 files changed, 109 insertions(+), 13 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list