Browse Source

Merge topic 'add_preprocessor_def_vs2010_resources'

8c7b19d Only run resource test for MSVC compilers.
753e208 Disable incremental testing for this test, it crashes vs9 linker.
16e7d4b Add flags to resource builds on vs 2010 with a test.
Brad King 15 years ago
parent
commit
f1d7a5600f

+ 4 - 1
Source/cmVisualStudio10TargetGenerator.cxx

@@ -1133,10 +1133,13 @@ OutputIncludes(std::vector<std::string> const & includes)
 
 
 void cmVisualStudio10TargetGenerator::
-WriteRCOptions(std::string const& ,
+WriteRCOptions(std::string const& configName,
                std::vector<std::string> const & includes)
 {
   this->WriteString("<ResourceCompile>\n", 2);
+  Options& clOptions = *(this->ClOptions[configName]);
+  clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, "      ",
+                                          "\n");
   this->OutputIncludes(includes);
   this->WriteString("</ResourceCompile>\n", 2);
 }

+ 3 - 1
Tests/CMakeLists.txt

@@ -131,6 +131,9 @@ IF(BUILD_TESTING)
   ADD_TEST_MACRO(TarTest TarTest)
   ADD_TEST_MACRO(SystemInformation SystemInformation)
   ADD_TEST_MACRO(MathTest MathTest)
+  IF(MSVC)
+    ADD_TEST_MACRO(VSResource VSResource)
+  ENDIF()
   ADD_TEST_MACRO(Simple Simple)
   ADD_TEST_MACRO(PreOrder PreOrder)
   ADD_TEST_MACRO(MissingSourceFile MissingSourceFile)
@@ -246,7 +249,6 @@ IF(BUILD_TESTING)
          --test-command Simple)
       LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_CodeBlocksGenerator")
     ENDIF ("${cmakeOutput}" MATCHES CodeBlocks)
-
     # check for the KDevelop3 generator
     IF ("${cmakeOutput}" MATCHES KDevelop3)
       ADD_TEST(Simple_KDevelop3Generator ${CMAKE_CTEST_COMMAND}

+ 7 - 0
Tests/VSResource/CMakeLists.txt

@@ -0,0 +1,7 @@
+cmake_minimum_required (VERSION 2.6)
+project (VSResource)
+add_definitions(/DCMAKE_RCDEFINE="test.txt")
+string(REPLACE "/INCREMENTAL:YES" ""
+  CMAKE_EXE_LINKER_FLAGS_DEBUG
+  "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
+add_executable(VSResource main.cpp test.rc)

+ 10 - 0
Tests/VSResource/main.cpp

@@ -0,0 +1,10 @@
+#include <windows.h>
+
+int main(int argc, char** argv) {
+   HRSRC hello = ::FindResource(0, "hello", "TEXT");
+   if(hello) {
+      return 0;
+   } else {
+      return 1;
+   }
+}

+ 5 - 0
Tests/VSResource/test.rc

@@ -0,0 +1,5 @@
+#ifdef CMAKE_RCDEFINE
+hello TEXT DISCARDABLE CMAKE_RCDEFINE
+#else
+#error "resource compiler did not get defines from command line!"
+#endif

+ 1 - 0
Tests/VSResource/test.txt

@@ -0,0 +1 @@
+Hello World!