diff options
Diffstat (limited to 'Source/cmExtraCodeBlocksGenerator.cxx')
-rw-r--r-- | Source/cmExtraCodeBlocksGenerator.cxx | 96 |
1 files changed, 79 insertions, 17 deletions
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 9348ef2..ed0c69c 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -300,6 +300,8 @@ void cmExtraCodeBlocksGenerator // figure out the compiler std::string compiler = this->GetCBCompilerId(mf); std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string makeArgs = mf->GetSafeDefinition( + "CMAKE_CODEBLOCKS_MAKE_ARGUMENTS"); fout<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n" "<CodeBlocks_project_file>\n" @@ -311,7 +313,8 @@ void cmExtraCodeBlocksGenerator " "<<virtualFolders<<"\n" " <Build>\n"; - this->AppendTarget(fout, "all", 0, make.c_str(), lgs[0], compiler.c_str()); + this->AppendTarget(fout, "all", 0, make.c_str(), lgs[0], compiler.c_str(), + makeArgs); // add all executable and library targets and some of the GLOBAL // and UTILITY targets @@ -333,7 +336,8 @@ void cmExtraCodeBlocksGenerator (*lg)->GetBinaryDirectory())==0) { this->AppendTarget(fout, targetName, 0, - make.c_str(), *lg, compiler.c_str()); + make.c_str(), *lg, compiler.c_str(), + makeArgs); } } break; @@ -350,7 +354,7 @@ void cmExtraCodeBlocksGenerator } this->AppendTarget(fout, targetName, 0, - make.c_str(), *lg, compiler.c_str()); + make.c_str(), *lg, compiler.c_str(),makeArgs); break; case cmState::EXECUTABLE: case cmState::STATIC_LIBRARY: @@ -360,11 +364,11 @@ void cmExtraCodeBlocksGenerator { cmGeneratorTarget* gt = *ti; this->AppendTarget(fout, targetName, gt, - make.c_str(), *lg, compiler.c_str()); + make.c_str(), *lg, compiler.c_str(), makeArgs); std::string fastTarget = targetName; fastTarget += "/fast"; this->AppendTarget(fout, fastTarget, gt, - make.c_str(), *lg, compiler.c_str()); + make.c_str(), *lg, compiler.c_str(), makeArgs); } break; default: @@ -555,7 +559,8 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, cmGeneratorTarget* target, const char* make, const cmLocalGenerator* lg, - const char* compiler) + const char* compiler, + const std::string& makeFlags) { cmMakefile const* makefile = lg->GetMakefile(); std::string makefileName = lg->GetCurrentBinaryDirectory(); @@ -663,16 +668,18 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, fout<<" <MakeCommands>\n" " <Build command=\"" - << this->BuildMakeCommand(make, makefileName.c_str(), targetName) + << this->BuildMakeCommand(make, makefileName.c_str(), targetName, + makeFlags) << "\" />\n" " <CompileFile command=\"" - << this->BuildMakeCommand(make, makefileName.c_str(),""$file"") + << this->BuildMakeCommand(make, makefileName.c_str(),""$file"", + makeFlags) << "\" />\n" " <Clean command=\"" - << this->BuildMakeCommand(make, makefileName.c_str(), "clean") + << this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags) << "\" />\n" " <DistClean command=\"" - << this->BuildMakeCommand(make, makefileName.c_str(), "clean") + << this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags) << "\" />\n" " </MakeCommands>\n" " </Target>\n"; @@ -684,18 +691,38 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, 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"; - if (this->GlobalGenerator->GetLanguageEnabled("CXX") == false) + // for now care only for C, C++, and Fortran + + // projects with C/C++ and Fortran are handled as C/C++ projects + bool pureFortran = false; + std::string compilerIdVar; + if (this->GlobalGenerator->GetLanguageEnabled("CXX") == true) + { + compilerIdVar = "CMAKE_CXX_COMPILER_ID"; + } + else if (this->GlobalGenerator->GetLanguageEnabled("C") == true) { compilerIdVar = "CMAKE_C_COMPILER_ID"; } + else if (this->GlobalGenerator->GetLanguageEnabled("Fortran") == true) + { + compilerIdVar = "CMAKE_Fortran_COMPILER_ID"; + pureFortran = true; + } + std::string compilerId = mf->GetSafeDefinition(compilerIdVar); std::string compiler = "gcc"; // default to gcc if (compilerId == "MSVC") { - compiler = "msvc8"; + if( mf->IsDefinitionSet("MSVC10") == true ) + { + compiler = "msvc10"; + } + else + { + compiler = "msvc8"; + } } else if (compilerId == "Borland") { @@ -707,15 +734,44 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) } else if (compilerId == "Intel") { - compiler = "icc"; + if (pureFortran && mf->IsDefinitionSet("WIN32")) + { + compiler = "ifcwin"; // Intel Fortran for Windows (known by cbFortran) + } + else + { + compiler = "icc"; + } } else if (compilerId == "Watcom" || compilerId == "OpenWatcom") { compiler = "ow"; } + else if (compilerId == "Clang") + { + compiler = "clang"; + } + else if (compilerId == "PGI") + { + if (pureFortran) + { + compiler = "pgifortran"; + } + else + { + compiler = "pgi"; // does not exist as default in CodeBlocks 16.01 + } + } else if (compilerId == "GNU") { - compiler = "gcc"; + if (pureFortran) + { + compiler = "gfortran"; + } + else + { + compiler = "gcc"; + } } return compiler; } @@ -753,9 +809,15 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target) // make std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( const std::string& make, const char* makefile, - const std::string& target) + const std::string& target, const std::string& makeFlags) { std::string command = make; + if (makeFlags.size() > 0) + { + command += " "; + command += makeFlags; + } + std::string generator = this->GlobalGenerator->GetName(); if (generator == "NMake Makefiles") { |