diff options
author | David Cole <david.cole@kitware.com> | 2012-07-24 21:01:57 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-07-24 21:01:57 (GMT) |
commit | 2b3a0dbeffc5368f1be7e425658d5162dbc0af7e (patch) | |
tree | 8614856e1c66251786480b5d8b7f8113ba6cbdd9 | |
parent | 8a0a918fbb62d615dfb839fcb8cd849e5f6165d8 (diff) | |
parent | c8641037487fbce4e3901ad87087181c42b0d356 (diff) | |
download | CMake-2b3a0dbeffc5368f1be7e425658d5162dbc0af7e.zip CMake-2b3a0dbeffc5368f1be7e425658d5162dbc0af7e.tar.gz CMake-2b3a0dbeffc5368f1be7e425658d5162dbc0af7e.tar.bz2 |
Merge topic 'ninja-mingw-windres'
c864103 Ninja: path is already declared
6547f36 Ninja: more searching for windres
78588e0 Ninja: there could be null pointers
0c89c10 Ninja: search for windres with prefix
4654680 Ninja: windres is also used for cross-compiling
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 07cc75f..912e53e 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -474,10 +474,33 @@ void cmGlobalNinjaGenerator if(mf->IsOn("CMAKE_COMPILER_IS_MINGW")) { UsingMinGW = true; - std::string rc = cmSystemTools::FindProgram("windres"); - if(rc.empty()) - rc = "windres.exe";; - mf->AddDefinition("CMAKE_RC_COMPILER", rc.c_str()); + if(!mf->GetDefinition("CMAKE_RC_COMPILER")) + { + std::string windres = cmSystemTools::FindProgram("windres"); + if(windres.empty()) + { + std::string compiler_path; + std::string::size_type prefix = std::string::npos; + if (mf->GetDefinition("CMAKE_C_COMPILER")) + { + compiler_path = mf->GetDefinition("CMAKE_C_COMPILER"); + prefix = compiler_path.rfind("gcc"); + } + else if (mf->GetDefinition("CMAKE_CXX_COMPILER")) + { + compiler_path = mf->GetDefinition("CMAKE_CXX_COMPILER"); + prefix = compiler_path.rfind("++"); + prefix--; + } + if (prefix != std::string::npos) + { + windres = compiler_path.substr(0, prefix) + "windres"; + windres = cmSystemTools::FindProgram(windres.c_str()); + } + } + if(!windres.empty()) + mf->AddDefinition("CMAKE_RC_COMPILER", windres.c_str()); + } } } this->cmGlobalGenerator::EnableLanguage(language, mf, optional); |