diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 3c90ca79a..fc5c8c028 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -24,6 +24,7 @@ #include "cmSourceFile.h" #include "cmGeneratedFileStream.h" #include "cmTarget.h" +#include "cmSystemTools.h" #include @@ -131,16 +132,17 @@ void cmExtraCodeBlocksGenerator return; } + // figure out the compiler + std::string compiler = this->GetCBCompilerId(mf); std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); fout<<"\n" "\n" " \n" - " \n"; - - fout<<" \n"; - } + +std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) +{ + // figure out which language to use + // for now care only for C and C++ + std::string compilerIdVar = "CMAKE_CXX_COMPILER_ID"; + cmGlobalGenerator* gg=const_cast(this->GlobalGenerator); + if (gg->GetLanguageEnabled("CXX") == false) + { + compilerIdVar = "CMAKE_C_COMPILER_ID"; + } + + std::string hostSystemName = mf->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME"); + std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME"); + std::string compilerId = mf->GetRequiredDefinition(compilerIdVar.c_str()); + std::string compiler = "gcc"; + if (compilerId == "MSVC") + { + compiler = "msvc"; + } + else if (compilerId == "Borland") + { + compiler = "bcc"; + } + else if (compilerId == "SDCC") + { + compiler = "sdcc"; + } + else if (compilerId == "Intel") + { + compiler = "icc"; + } + else if (compilerId == "Watcom") + { + compiler = "ow"; + } + else if (compilerId == "GNU") + { + if (hostSystemName == "Windows") + { + compiler = "mingw"; + } + else + { + compiler = "gcc"; + } + } + return compiler; +} + + +int cmExtraCodeBlocksGenerator::GetCBTargetType(cmTarget* target) +{ + if ( target->GetType()==cmTarget::EXECUTABLE) + { + if ((target->GetPropertyAsBool("WIN32_EXECUTABLE")) + || (target->GetPropertyAsBool("MACOSX_BUNDLE"))) + { + return 0; + } + else + { + return 1; + } + } + else if ( target->GetType()==cmTarget::STATIC_LIBRARY) + { + return 2; + } + else if ((target->GetType()==cmTarget::SHARED_LIBRARY) + || (target->GetType()==cmTarget::MODULE_LIBRARY)) + { + return 3; + } + return 4; +} + +std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( + const std::string& make, const char* makefile, const char* target) +{ + std::string command = make; + if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0) + { + command += " /NOLOGO /f \\\""; + command += makefile; + command += "\\\" "; + command += target; + } + else + { + command += " -f "; + command += makefile; + command += " "; + command += target; + } + return command; +} diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h index 9d5993616..6daa9763c 100644 --- a/Source/cmExtraCodeBlocksGenerator.h +++ b/Source/cmExtraCodeBlocksGenerator.h @@ -22,6 +22,7 @@ class cmLocalGenerator; class cmMakefile; +class cmTarget; /** \class cmExtraCodeBlocksGenerator * \brief Write CodeBlocks project files for Makefile based projects @@ -50,6 +51,10 @@ private: void CreateNewProjectFile(const std::vector& lgs, const std::string& filename); + std::string GetCBCompilerId(const cmMakefile* mf); + int GetCBTargetType(cmTarget* target); + std::string BuildMakeCommand(const std::string& make, const char* makefile, + const char* target); };