From b2f308c8f9b4ded77f0693b39c0288e3bbb00977 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Wed, 22 Dec 2010 15:26:30 -0500 Subject: Add support for windows resources with mingw/msys. --- Modules/CMakeDetermineRCCompiler.cmake | 6 ++++++ Modules/CMakeRCCompiler.cmake.in | 2 +- Modules/Platform/Windows-GNU.cmake | 2 ++ Modules/Platform/Windows-windres.cmake | 1 + Source/cmGlobalMSYSMakefileGenerator.cxx | 7 +++++++ Source/cmGlobalMinGWMakefileGenerator.cxx | 7 +++++++ 6 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Modules/Platform/Windows-windres.cmake diff --git a/Modules/CMakeDetermineRCCompiler.cmake b/Modules/CMakeDetermineRCCompiler.cmake index 094b893..8e085af 100644 --- a/Modules/CMakeDetermineRCCompiler.cmake +++ b/Modules/CMakeDetermineRCCompiler.cmake @@ -54,6 +54,12 @@ ENDIF(NOT CMAKE_RC_COMPILER) MARK_AS_ADVANCED(CMAKE_RC_COMPILER) +GET_FILENAME_COMPONENT(_CMAKE_RC_COMPILER_NAME_WE ${CMAKE_RC_COMPILER} NAME_WE) +IF(_CMAKE_RC_COMPILER_NAME_WE STREQUAL "windres") + SET(CMAKE_RC_OUTPUT_EXTENSION .obj) +ELSE() + SET(CMAKE_RC_OUTPUT_EXTENSION .res) +ENDIF() # configure variables set in this file for fast reload later on CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeRCCompiler.cmake.in diff --git a/Modules/CMakeRCCompiler.cmake.in b/Modules/CMakeRCCompiler.cmake.in index 93bc850..83428e2 100644 --- a/Modules/CMakeRCCompiler.cmake.in +++ b/Modules/CMakeRCCompiler.cmake.in @@ -2,5 +2,5 @@ SET(CMAKE_RC_COMPILER "@CMAKE_RC_COMPILER@") SET(CMAKE_RC_COMPILER_ARG1 "@CMAKE_RC_COMPILER_ARG1@") SET(CMAKE_RC_COMPILER_LOADED 1) SET(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc) -SET(CMAKE_RC_OUTPUT_EXTENSION .res) +SET(CMAKE_RC_OUTPUT_EXTENSION @CMAKE_RC_OUTPUT_EXTENSION@) SET(CMAKE_RC_COMPILER_ENV_VAR "RC") diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index ac635a5..7084b83 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -56,6 +56,8 @@ if("${_help}" MATCHES "GNU ld .* 2\\.1[1-6]") set(__WINDOWS_GNU_LD_RESPONSE 0) endif() +enable_language(RC) + macro(__windows_compiler_gnu lang) if(MSYS OR MINGW) diff --git a/Modules/Platform/Windows-windres.cmake b/Modules/Platform/Windows-windres.cmake new file mode 100644 index 0000000..8bc1b15 --- /dev/null +++ b/Modules/Platform/Windows-windres.cmake @@ -0,0 +1 @@ +SET(CMAKE_RC_COMPILE_OBJECT " -O coff ") diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index d324e59..820e7e6 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -69,9 +69,16 @@ void cmGlobalMSYSMakefileGenerator { gxx = tgxx; } + std::string trc = cmSystemTools::FindProgram("windres", locations); + std::string rc = "windres.exe"; + if(trc.size()) + { + rc = trc; + } mf->AddDefinition("MSYS", "1"); mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str()); mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str()); + mf->AddDefinition("CMAKE_GENERATOR_RC", rc.c_str()); this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); if(!mf->IsSet("CMAKE_AR") && diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx index 9f9d1be..2f558dc 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.cxx +++ b/Source/cmGlobalMinGWMakefileGenerator.cxx @@ -44,8 +44,15 @@ void cmGlobalMinGWMakefileGenerator { gxx = tgxx; } + std::string trc = cmSystemTools::FindProgram("windres", locations); + std::string rc = "windres.exe"; + if(trc.size()) + { + rc = trc; + } mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str()); mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str()); + mf->AddDefinition("CMAKE_GENERATOR_RC", rc.c_str()); this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } -- cgit v0.12