Add support for windows resources with mingw/msys.

This commit is contained in:
Bill Hoffman 2010-12-22 15:26:30 -05:00
parent 8c7b19d35e
commit b2f308c8f9
6 changed files with 24 additions and 1 deletions

View File

@ -54,6 +54,12 @@ ENDIF(NOT CMAKE_RC_COMPILER)
MARK_AS_ADVANCED(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 variables set in this file for fast reload later on
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeRCCompiler.cmake.in CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeRCCompiler.cmake.in

View File

@ -2,5 +2,5 @@ SET(CMAKE_RC_COMPILER "@CMAKE_RC_COMPILER@")
SET(CMAKE_RC_COMPILER_ARG1 "@CMAKE_RC_COMPILER_ARG1@") SET(CMAKE_RC_COMPILER_ARG1 "@CMAKE_RC_COMPILER_ARG1@")
SET(CMAKE_RC_COMPILER_LOADED 1) SET(CMAKE_RC_COMPILER_LOADED 1)
SET(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc) 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") SET(CMAKE_RC_COMPILER_ENV_VAR "RC")

View File

@ -56,6 +56,8 @@ if("${_help}" MATCHES "GNU ld .* 2\\.1[1-6]")
set(__WINDOWS_GNU_LD_RESPONSE 0) set(__WINDOWS_GNU_LD_RESPONSE 0)
endif() endif()
enable_language(RC)
macro(__windows_compiler_gnu lang) macro(__windows_compiler_gnu lang)
if(MSYS OR MINGW) if(MSYS OR MINGW)

View File

@ -0,0 +1 @@
SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff <FLAGS> <DEFINES> <SOURCE> <OBJECT>")

View File

@ -69,9 +69,16 @@ void cmGlobalMSYSMakefileGenerator
{ {
gxx = tgxx; 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("MSYS", "1");
mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str()); mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str());
mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str()); mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
mf->AddDefinition("CMAKE_GENERATOR_RC", rc.c_str());
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
if(!mf->IsSet("CMAKE_AR") && if(!mf->IsSet("CMAKE_AR") &&

View File

@ -44,8 +44,15 @@ void cmGlobalMinGWMakefileGenerator
{ {
gxx = tgxx; 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_CC", gcc.c_str());
mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str()); mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
mf->AddDefinition("CMAKE_GENERATOR_RC", rc.c_str());
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
} }