diff options
53 files changed, 938 insertions, 114 deletions
diff --git a/Help/generator/CodeLite.rst b/Help/generator/CodeLite.rst new file mode 100644 index 0000000..dbc46d7 --- /dev/null +++ b/Help/generator/CodeLite.rst @@ -0,0 +1,24 @@ +CodeLite +---------- + +Generates CodeLite project files. + +Project files for CodeLite will be created in the top directory and +in every subdirectory which features a CMakeLists.txt file containing +a PROJECT() call. The appropriate make program can build the +project through the default make target. A "make install" target is +also provided. + +This "extra" generator may be specified as: + +``CodeLite - MinGW Makefiles`` + Generate with :generator:`MinGW Makefiles`. + +``CodeLite - NMake Makefiles`` + Generate with :generator:`NMake Makefiles`. + +``CodeLite - Ninja`` + Generate with :generator:`Ninja`. + +``CodeLite - Unix Makefiles`` + Generate with :generator:`Unix Makefiles`. diff --git a/Help/manual/cmake-generators.7.rst b/Help/manual/cmake-generators.7.rst index b72c7ef..8d0c704 100644 --- a/Help/manual/cmake-generators.7.rst +++ b/Help/manual/cmake-generators.7.rst @@ -79,6 +79,7 @@ The following extra generators are known to CMake. :maxdepth: 1 /generator/CodeBlocks + /generator/CodeLite /generator/Eclipse CDT4 /generator/KDevelop3 /generator/Kate diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 4bee05e..891333c 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -97,3 +97,4 @@ All Policies /policy/CMP0043 /policy/CMP0044 /policy/CMP0045 + /policy/CMP0046 diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index d569e31..c0ec0fe 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -247,6 +247,7 @@ Properties on Tests /prop_test/REQUIRED_FILES /prop_test/RESOURCE_LOCK /prop_test/RUN_SERIAL + /prop_test/SKIP_RETURN_CODE /prop_test/TIMEOUT /prop_test/WILL_FAIL /prop_test/WORKING_DIRECTORY diff --git a/Help/policy/CMP0046.rst b/Help/policy/CMP0046.rst new file mode 100644 index 0000000..5192dc7 --- /dev/null +++ b/Help/policy/CMP0046.rst @@ -0,0 +1,17 @@ +CMP0046 +------- + +Error on non-existent dependency in add_dependencies. + +CMake 2.8.12 and lower silently ignored non-existent dependencies +listed in the :command:`add_dependencies` command. + +The OLD behavior for this policy is to silently ignore non-existent +dependencies. The NEW behavior for this policy is to report an error +if non-existent dependencies are listed in the :command:`add_dependencies` +command. + +This policy was introduced in CMake version 3.0.0. +CMake version |release| warns when the policy is not set and uses +OLD behavior. Use the cmake_policy command to set it to OLD or +NEW explicitly. diff --git a/Help/prop_test/SKIP_RETURN_CODE.rst b/Help/prop_test/SKIP_RETURN_CODE.rst new file mode 100644 index 0000000..c61273c --- /dev/null +++ b/Help/prop_test/SKIP_RETURN_CODE.rst @@ -0,0 +1,9 @@ +SKIP_RETURN_CODE +---------------- + +Return code to mark a test as skipped. + +Sometimes only a test itself can determine if all requirements for the +test are met. If such a situation should not be considered a hard failure +a return code of the process can be specified that will mark the test as +"Not Run" if it is encountered. diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 46a893d..9be4270 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -107,11 +107,13 @@ # # :: # -# macro QT4_WRAP_CPP(outfiles inputfile ... OPTIONS ...) +# macro QT4_WRAP_CPP(outfiles inputfile ... [TARGET tgt] OPTIONS ...) # create moc code from a list of files containing Qt class with # the Q_OBJECT declaration. Per-directory preprocessor definitions -# are also added. Options may be given to moc, such as those found -# when executing "moc -help". +# are also added. If the <tgt> is specified, the +# INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from +# the <tgt> are passed to moc. Options may be given to moc, such as +# those found when executing "moc -help". # # # @@ -135,16 +137,19 @@ # # :: # -# macro QT4_GENERATE_MOC(inputfile outputfile ) +# macro QT4_GENERATE_MOC(inputfile outputfile [TARGET tgt]) # creates a rule to run moc on infile and create outfile. # Use this if for some reason QT4_WRAP_CPP() isn't appropriate, e.g. -# because you need a custom filename for the moc file or something similar. +# because you need a custom filename for the moc file or something +# similar. If the <tgt> is specified, the +# INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from +# the <tgt> are passed to moc. # # # # :: # -# macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... ) +# macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... [TARGET tgt]) # The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead. # This macro is still experimental. # It can be used to have moc automatically handled. @@ -157,7 +162,8 @@ # them cause a rule to be generated to run moc at build time on the # accompanying header file foo.h. # If a source file has the SKIP_AUTOMOC property set it will be ignored by this macro. -# +# If the <tgt> is specified, the INTERFACE_INCLUDE_DIRECTORIES and +# INTERFACE_COMPILE_DEFINITIONS from the <tgt> are passed to moc. # # # :: diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index aa036b7..7478310 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -22,13 +22,7 @@ # License text for the above reference.) add_definitions(${QT_DEFINITIONS}) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG QT_DEBUG) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG) -if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) - set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_DEBUG) -endif() +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>) if(QT_INCLUDE_DIRS_NO_SYSTEM) include_directories(${QT_INCLUDE_DIR}) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 3c944fb..dbb922d 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -186,6 +186,8 @@ set(SRCS cmExportSetMap.cxx cmExtraCodeBlocksGenerator.cxx cmExtraCodeBlocksGenerator.h + cmExtraCodeLiteGenerator.cxx + cmExtraCodeLiteGenerator.h cmExtraEclipseCDT4Generator.cxx cmExtraEclipseCDT4Generator.h cmExtraKateGenerator.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 0cdba30..14b0789 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 12) -set(CMake_VERSION_TWEAK 20140113) +set(CMake_VERSION_TWEAK 20140116) #set(CMake_VERSION_RC 1) diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 0e2fa41..cdf90b9 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -206,7 +206,13 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) bool success = !forceFail && (retVal == 0 || this->TestProperties->RequiredRegularExpressions.size()); - if((success && !this->TestProperties->WillFail) + if(this->TestProperties->SkipReturnCode >= 0 + && this->TestProperties->SkipReturnCode == retVal) + { + this->TestResult.Status = cmCTestTestHandler::NOT_RUN; + cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Skipped "); + } + else if((success && !this->TestProperties->WillFail) || (!success && this->TestProperties->WillFail)) { this->TestResult.Status = cmCTestTestHandler::COMPLETED; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 26f8014..3a04b33 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2229,6 +2229,14 @@ bool cmCTestTestHandler::SetTestsProperties( rtit->Processors = 1; } } + if ( key == "SKIP_RETURN_CODE" ) + { + rtit->SkipReturnCode = atoi(val.c_str()); + if(rtit->SkipReturnCode < 0 || rtit->SkipReturnCode > 255) + { + rtit->SkipReturnCode = -1; + } + } if ( key == "DEPENDS" ) { std::vector<std::string> lval; @@ -2364,6 +2372,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args) test.ExplicitTimeout = false; test.Cost = 0; test.Processors = 1; + test.SkipReturnCode = -1; test.PreviousRuns = 0; if (this->UseIncludeRegExpFlag && !this->IncludeTestsRegularExpression.find(testname.c_str())) diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 6dda300..63f9c93 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -109,6 +109,8 @@ public: int Index; //Requested number of process slots int Processors; + // return code of test which will mark test as "not run" + int SkipReturnCode; std::vector<std::string> Environment; std::vector<std::string> Labels; std::set<std::string> LockedResources; diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index 87bfb3c..a7ffded 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -46,7 +46,7 @@ bool cmAddDependenciesCommand ++s; // skip over target_name for (; s != args.end(); ++s) { - target->AddUtility(s->c_str()); + target->AddUtility(s->c_str(), this->Makefile); } } else diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index cf227fb..9776f55 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -63,7 +63,7 @@ private: cmTarget const* HeadTarget; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; - cmGlobalGenerator* GlobalGenerator; + cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; bool DebugMode; diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 73a8e27..a848e4f 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -343,6 +343,45 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, cmTarget const* dependee = depender->GetMakefile()->FindTargetToUse(dependee_name); + if(!dependee && !linking && + (depender->GetType() != cmTarget::GLOBAL_TARGET)) + { + cmMakefile *makefile = depender->GetMakefile(); + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(makefile->GetPolicyStatus(cmPolicies::CMP0046)) + { + case cmPolicies::WARN: + issueMessage = true; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if(issueMessage) + { + cmake* cm = this->GlobalGenerator->GetCMakeInstance(); + cmOStringStream e; + e << (makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0046)) << "\n"; + e << "The dependency target \"" << dependee_name + << "\" of target \"" << depender->GetName() << "\" does not exist."; + + cmListFileBacktrace nullBacktrace; + cmListFileBacktrace const* backtrace = + depender->GetUtilityBacktrace(dependee_name); + if(!backtrace) + { + backtrace = &nullBacktrace; + } + + cm->IssueMessage(messageType, e.str(), *backtrace); + } + } + // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable // within the project. diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index a066153..548c88b 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -761,10 +761,12 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( std::string command = make; if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0) { + // For Windows ConvertToOutputPath already adds quotes when required. + // These need to be escaped, see + // http://public.kitware.com/Bug/view.php?id=13952 std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); - command += " /NOLOGO /f ""; - command += makefileName; - command += "" "; + command += " /NOLOGO /f "; + command += cmXMLSafe(makefileName).str(); command += " VERBOSE=1 "; command += target; } diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx new file mode 100644 index 0000000..b156691 --- /dev/null +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -0,0 +1,487 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2009 Kitware, Inc. + Copyright 2004 Alexander Neundorf (neundorf@kde.org) + Copyright 2013 Eran Ifrah (eran.ifrah@gmail.com) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmExtraCodeLiteGenerator.h" +#include "cmGlobalUnixMakefileGenerator3.h" +#include "cmLocalUnixMakefileGenerator3.h" +#include "cmMakefile.h" +#include "cmake.h" +#include "cmSourceFile.h" +#include "cmGeneratedFileStream.h" +#include "cmSystemTools.h" + +#include <cmsys/SystemTools.hxx> +#include <cmsys/SystemInformation.hxx> +#include <cmsys/Directory.hxx> +#include "cmXMLSafe.h" +#include <sstream> + +//---------------------------------------------------------------------------- +void cmExtraCodeLiteGenerator::GetDocumentation(cmDocumentationEntry& entry, + const char*) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates CodeLite project files."; +} + +cmExtraCodeLiteGenerator::cmExtraCodeLiteGenerator() + : cmExternalMakefileProjectGenerator() + , ConfigName("NoConfig") + , CpuCount(2) +{ +#if defined(_WIN32) + this->SupportedGlobalGenerators.push_back("MinGW Makefiles"); + this->SupportedGlobalGenerators.push_back("NMake Makefiles"); +#endif + this->SupportedGlobalGenerators.push_back("Ninja"); + this->SupportedGlobalGenerators.push_back("Unix Makefiles"); +} + +void cmExtraCodeLiteGenerator::Generate() +{ + // Hold root tree information for creating the workspace + std::string workspaceProjectName; + std::string workspaceOutputDir; + std::string workspaceFileName; + std::string workspaceSourcePath; + std::string lprjdebug; + + cmGeneratedFileStream fout; + + // loop projects and locate the root project. + // and extract the information for creating the worspace + for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + it = this->GlobalGenerator->GetProjectMap().begin(); + it!= this->GlobalGenerator->GetProjectMap().end(); + ++it) + { + const cmMakefile* mf =it->second[0]->GetMakefile(); + this->ConfigName = GetConfigurationName( mf ); + + if (strcmp(mf->GetStartOutputDirectory(), + mf->GetHomeOutputDirectory()) == 0) + { + workspaceOutputDir = mf->GetStartOutputDirectory(); + workspaceProjectName = mf->GetProjectName(); + workspaceSourcePath = mf->GetHomeDirectory(); + workspaceFileName = workspaceOutputDir+"/"; + workspaceFileName += workspaceProjectName + ".workspace"; + this->WorkspacePath = mf->GetStartOutputDirectory();; + + fout.Open(workspaceFileName.c_str(), false, false); + fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<CodeLite_Workspace Name=\"" << workspaceProjectName << "\" >\n"; + } + } + + // for each sub project in the workspace create a codelite project + for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + it = this->GlobalGenerator->GetProjectMap().begin(); + it!= this->GlobalGenerator->GetProjectMap().end(); + ++it) + { + // retrive project information + const cmMakefile* mf = it->second[0]->GetMakefile(); + std::string outputDir = mf->GetStartOutputDirectory(); + std::string projectName = mf->GetProjectName(); + std::string filename = outputDir + "/" + projectName + ".project"; + + // Make the project file relative to the workspace + filename = cmSystemTools::RelativePath(this->WorkspacePath.c_str(), + filename.c_str()); + + // create a project file + this->CreateProjectFile(it->second); + fout << " <Project Name=\"" << projectName << "\" Path=\"" + << filename << "\" Active=\"No\"/>\n"; + lprjdebug += "<Project Name=\"" + projectName + + "\" ConfigName=\"" + this->ConfigName + "\"/>\n"; + } + + fout << " <BuildMatrix>\n" + " <WorkspaceConfiguration Name=\"" + << this->ConfigName << "\" Selected=\"yes\">\n" + " " << lprjdebug << "" + " </WorkspaceConfiguration>\n" + " </BuildMatrix>\n" + "</CodeLite_Workspace>\n"; +} + +/* create the project file */ +void cmExtraCodeLiteGenerator::CreateProjectFile( + const std::vector<cmLocalGenerator*>& lgs) +{ + const cmMakefile* mf = lgs[0]->GetMakefile(); + std::string outputDir = mf->GetStartOutputDirectory(); + std::string projectName = mf->GetProjectName(); + std::string filename = outputDir + "/"; + + filename += projectName + ".project"; + this->CreateNewProjectFile(lgs, filename); +} + +void cmExtraCodeLiteGenerator +::CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs, + const std::string& filename) +{ + const cmMakefile* mf=lgs[0]->GetMakefile(); + cmGeneratedFileStream fout(filename.c_str()); + if(!fout) + { + return; + } + + // figure out the compiler + //std::string compiler = this->GetCBCompilerId(mf); + std::string workspaceSourcePath = mf->GetHomeDirectory(); + std::string workspaceOutputDir = mf->GetHomeOutputDirectory(); + std::vector<std::string> outputFiles = mf->GetOutputFiles(); + std::string projectName = mf->GetProjectName(); + std::string incDirs; + std::vector<cmValueWithOrigin> incDirsVec = + mf->GetIncludeDirectoriesEntries(); + std::vector<cmValueWithOrigin>::const_iterator iterInc = incDirsVec.begin(); + + //std::cout << "GetIncludeDirectories:" << std::endl; + for(; iterInc != incDirsVec.end(); ++iterInc ) + { + //std::cout << (*ItStrVec) << std::endl; + incDirs += iterInc->Value + " "; + } + + //////////////////////////////////// + fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<CodeLite_Project Name=\"" << mf->GetProjectName() + << "\" InternalType=\"\">\n"; + + // Collect all used source files in the project + // Sort them into two containers, one for C/C++ implementation files + // which may have an acompanying header, one for all other files + std::string projectType; + + std::map<std::string, cmSourceFile*> cFiles; + std::set<std::string> otherFiles; + for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin(); + lg!=lgs.end(); lg++) + { + cmMakefile* makefile=(*lg)->GetMakefile(); + cmTargets& targets=makefile->GetTargets(); + for (cmTargets::iterator ti = targets.begin(); + ti != targets.end(); ti++) + { + + switch(ti->second.GetType()) + { + case cmTarget::EXECUTABLE: + { + projectType = "Executable"; + } + break; + case cmTarget::STATIC_LIBRARY: + { + projectType = "Static Library"; + } + break; + case cmTarget::SHARED_LIBRARY: + { + projectType = "Dynamic Library"; + } + break; + case cmTarget::MODULE_LIBRARY: + { + projectType = "Dynamic Library"; + } + break; + default: // intended fallthrough + break; + } + + switch(ti->second.GetType()) + { + case cmTarget::EXECUTABLE: + case cmTarget::STATIC_LIBRARY: + case cmTarget::SHARED_LIBRARY: + case cmTarget::MODULE_LIBRARY: + { + std::vector<cmSourceFile*> sources; + ti->second.GetSourceFiles(sources); + for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); + si!=sources.end(); si++) + { + // check whether it is a C/C++ implementation file + bool isCFile = false; + if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C')) + { + for(std::vector<std::string>::const_iterator + ext = mf->GetSourceExtensions().begin(); + ext != mf->GetSourceExtensions().end(); + ++ext) + { + if ((*si)->GetExtension() == *ext) + { + isCFile = true; + break; + } + } + } + + // then put it accordingly into one of the two containers + if (isCFile) + { + cFiles[(*si)->GetFullPath()] = *si ; + } + else + { + otherFiles.insert((*si)->GetFullPath()); + } + } + } + default: // intended fallthrough + break; + } + } + } + + // The following loop tries to add header files matching to implementation + // files to the project. It does that by iterating over all source files, + // replacing the file name extension with ".h" and checks whether such a + // file exists. If it does, it is inserted into the map of files. + // A very similar version of that code exists also in the kdevelop + // project generator. + for (std::map<std::string, cmSourceFile*>::const_iterator + sit=cFiles.begin(); + sit!=cFiles.end(); + ++sit) + { + std::string headerBasename=cmSystemTools::GetFilenamePath(sit->first); + headerBasename+="/"; + headerBasename+=cmSystemTools::GetFilenameWithoutExtension(sit->first); + + // check if there's a matching header around + for(std::vector<std::string>::const_iterator + ext = mf->GetHeaderExtensions().begin(); + ext != mf->GetHeaderExtensions().end(); + ++ext) + { + std::string hname=headerBasename; + hname += "."; + hname += *ext; + // if it's already in the set, don't check if it exists on disk + std::set<std::string>::const_iterator headerIt=otherFiles.find(hname); + if (headerIt != otherFiles.end()) + { + break; + } + + if(cmSystemTools::FileExists(hname.c_str())) + { + otherFiles.insert(hname); + break; + } + } + } + + // Get the project path ( we need it later to convert files to + // their relative path) + std::string projectPath = cmSystemTools::GetFilenamePath(filename); + + // Create 2 virtual folders: src and include + // and place all the implementation files into the src + // folder, the rest goes to the include folder + fout<< " <VirtualDirectory Name=\"src\">\n"; + + // insert all source files in the codelite project + // first the C/C++ implementation files, then all others + for (std::map<std::string, cmSourceFile*>::const_iterator + sit=cFiles.begin(); + sit!=cFiles.end(); + ++sit) + { + std::string relativePath = + cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str()); + fout<< " <File Name=\"" << relativePath.c_str() << "\"/>\n"; + } + fout<< " </VirtualDirectory>\n"; + fout<< " <VirtualDirectory Name=\"include\">\n"; + for (std::set<std::string>::const_iterator + sit=otherFiles.begin(); + sit!=otherFiles.end(); + ++sit) + { + std::string relativePath = + cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str()); + fout << " <File Name=\"" << relativePath.c_str() << "\"/>\n"; + } + fout << " </VirtualDirectory>\n"; + + // Get the number of CPUs. We use this information for the make -jN + // command + cmsys::SystemInformation info; + info.RunCPUCheck(); + + this->CpuCount = info.GetNumberOfLogicalCPU() * + info.GetNumberOfPhysicalCPU(); + + std::string cleanCommand = GetCleanCommand(mf); + std::string buildCommand = GetBuildCommand(mf); + std::string rebuildCommand = GetRebuildCommand(mf); + std::string singleFileCommand = GetSingleFileBuildCommand(mf); + + std::string codeliteCompilerName = this->GetCodeLiteCompilerName(mf); + + fout << "\n" + " <Settings Type=\"" << projectType << "\">\n" + " <Configuration Name=\"" << this->ConfigName << "\" CompilerType=\"" + << codeliteCompilerName << "\" DebuggerType=\"GNU gdb debugger\" " + "Type=\"" + << projectType << "\" BuildCmpWithGlobalSettings=\"append\" " + "BuildLnkWithGlobalSettings=\"append\" " + "BuildResWithGlobalSettings=\"append\">\n" + " <Compiler Options=\"-g\" " + "Required=\"yes\" PreCompiledHeader=\"\">\n" + " <IncludePath Value=\".\"/>\n" + " </Compiler>\n" + " <Linker Options=\"\" Required=\"yes\"/>\n" + " <ResourceCompiler Options=\"\" Required=\"no\"/>\n" + " <General OutputFile=\"$(IntermediateDirectory)/$(ProjectName)\" " + "IntermediateDirectory=\"./\" Command=\"./$(ProjectName)\" " + "CommandArguments=\"\" WorkingDirectory=\"$(IntermediateDirectory)\" " + "PauseExecWhenProcTerminates=\"yes\"/>\n" + " <Debugger IsRemote=\"no\" RemoteHostName=\"\" " + "RemoteHostPort=\"\" DebuggerPath=\"\">\n" + " <PostConnectCommands/>\n" + " <StartupCommands/>\n" + " </Debugger>\n" + " <PreBuild/>\n" + " <PostBuild/>\n" + " <CustomBuild Enabled=\"yes\">\n" + " <RebuildCommand>" << rebuildCommand << "</RebuildCommand>\n" + " <CleanCommand>" << cleanCommand << "</CleanCommand>\n" + " <BuildCommand>" << buildCommand << "</BuildCommand>\n" + " <SingleFileCommand>" << singleFileCommand + << "</SingleFileCommand>\n" + " <PreprocessFileCommand/>\n" + " <WorkingDirectory>$(WorkspacePath)</WorkingDirectory>\n" + " </CustomBuild>\n" + " <AdditionalRules>\n" + " <CustomPostBuild/>\n" + " <CustomPreBuild/>\n" + " </AdditionalRules>\n" + " </Configuration>\n" + " <GlobalSettings>\n" + " <Compiler Options=\"\">\n" + " <IncludePath Value=\".\"/>\n" + " </Compiler>\n" + " <Linker Options=\"\">\n" + " <LibraryPath Value=\".\"/>\n" + " </Linker>\n" + " <ResourceCompiler Options=\"\"/>\n" + " </GlobalSettings>\n" + " </Settings>\n" + "</CodeLite_Project>\n"; +} + +std::string +cmExtraCodeLiteGenerator::GetCodeLiteCompilerName(const cmMakefile* mf) const +{ + // 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) + { + compilerIdVar = "CMAKE_C_COMPILER_ID"; + } + + std::string compilerId = mf->GetSafeDefinition(compilerIdVar.c_str()); + std::string compiler = "gnu g++"; // default to g++ + + // Since we need the compiler for parsing purposes only + // it does not matter if we use clang or clang++, same as + // "gnu gcc" vs "gnu g++" + if (compilerId == "MSVC") + { + compiler = "VC++"; + } + else if (compilerId == "Clang") + { + compiler = "clang++"; + } + else if (compilerId == "GNU") + { + compiler = "gnu g++"; + } + return compiler; +} + +std::string +cmExtraCodeLiteGenerator::GetConfigurationName(const cmMakefile* mf) const +{ + std::string confName = mf->GetSafeDefinition("CMAKE_BUILD_TYPE"); + // Trim the configuration name from whitespaces (left and right) + confName.erase(0, confName.find_first_not_of(" \t\r\v\n")); + confName.erase(confName.find_last_not_of(" \t\r\v\n")+1); + if ( confName.empty() ) + { + confName = "NoConfig"; + } + return confName; +} + +std::string +cmExtraCodeLiteGenerator::GetBuildCommand(const cmMakefile* mf) const +{ + std::stringstream ss; + std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR"); + std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + std::string buildCommand = make; // Default + if ( generator == "NMake Makefiles" ) + { + buildCommand = make; + } + else if ( generator == "MinGW Makefiles" || + generator == "Unix Makefiles" || + generator == "Ninja" ) + { + ss << make; + buildCommand = ss.str(); + } + return buildCommand; +} + +std::string +cmExtraCodeLiteGenerator::GetCleanCommand(const cmMakefile* mf) const +{ + return GetBuildCommand(mf) + " clean"; +} + +std::string +cmExtraCodeLiteGenerator::GetRebuildCommand(const cmMakefile* mf) const +{ + return GetCleanCommand(mf) + cmXMLSafe(" && ").str() + GetBuildCommand(mf); +} + +std::string +cmExtraCodeLiteGenerator::GetSingleFileBuildCommand +(const cmMakefile* mf) const +{ + std::string buildCommand; + std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR"); + if ( generator == "Unix Makefiles" || generator == "MinGW Makefiles" ) + { + std::stringstream ss; + ss << make << " -f$(ProjectPath)/Makefile $(CurrentFileName).cpp.o"; + buildCommand = ss.str(); + } + return buildCommand; +} diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h new file mode 100644 index 0000000..984313e --- /dev/null +++ b/Source/cmExtraCodeLiteGenerator.h @@ -0,0 +1,54 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2009 Kitware, Inc. + Copyright 2004 Alexander Neundorf (neundorf@kde.org) + Copyright 2013 Eran Ifrah (eran.ifrah@gmail.com) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmGlobalCodeLiteGenerator_h +#define cmGlobalCodeLiteGenerator_h + +#include "cmExternalMakefileProjectGenerator.h" + +class cmLocalGenerator; + +class cmExtraCodeLiteGenerator : public cmExternalMakefileProjectGenerator +{ +protected: + std::string ConfigName; + std::string WorkspacePath; + unsigned int CpuCount; + +protected: + std::string GetCodeLiteCompilerName(const cmMakefile* mf) const; + std::string GetConfigurationName( const cmMakefile* mf ) const; + std::string GetBuildCommand(const cmMakefile* mf) const; + std::string GetCleanCommand(const cmMakefile* mf) const; + std::string GetRebuildCommand(const cmMakefile* mf) const; + std::string GetSingleFileBuildCommand(const cmMakefile* mf) const; +public: + cmExtraCodeLiteGenerator(); + + virtual const char* GetName() const + { return cmExtraCodeLiteGenerator::GetActualName();} + static const char* GetActualName() { return "CodeLite";} + static cmExternalMakefileProjectGenerator* New() + { return new cmExtraCodeLiteGenerator; } + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry, + const char* fullName) const; + + virtual void Generate(); + void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs); + + void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs, + const std::string& filename); +}; + +#endif diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 5cd1f42..0fcee3e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -469,7 +469,7 @@ private: cmTarget* Target; cmGeneratorTarget* GeneratorTarget; cmMakefile* Makefile; - cmGlobalGenerator* GlobalGenerator; + cmGlobalGenerator const* GlobalGenerator; typedef cmGeneratorTarget::SourceEntry SourceEntry; SourceEntry* CurrentEntry; std::queue<cmSourceFile*> SourceQueue; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 17a223a..a4caba1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -50,7 +50,7 @@ public: cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; - cmGlobalGenerator* GlobalGenerator; + cmGlobalGenerator const* GlobalGenerator; std::string ModuleDefinitionFile; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index f883fbe..8a7eee4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -90,7 +90,7 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts) } std::string cmGlobalGenerator::SelectMakeProgram(const char* makeProgram, - std::string makeDefault) + std::string makeDefault) const { if(cmSystemTools::IsOff(makeProgram)) { @@ -111,7 +111,7 @@ std::string cmGlobalGenerator::SelectMakeProgram(const char* makeProgram, void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, cmMakefile *mf, - bool optional) + bool optional) const { std::string langComp = "CMAKE_"; langComp += lang; @@ -723,7 +723,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, //---------------------------------------------------------------------------- void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os, std::string lang, - const char* envVar) + const char* envVar) const { // Subclasses override this method if they do not support this advice. os << @@ -744,7 +744,7 @@ void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os, //---------------------------------------------------------------------------- void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, - std::string lang) + std::string lang) const { std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID"; const char* compilerId = mf->GetDefinition(compilerIdVar.c_str()); @@ -782,13 +782,16 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, //---------------------------------------------------------------------------- const char* -cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) +cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const { if(const char* lang = source.GetLanguage()) { - if(this->LanguageToOutputExtension.count(lang) > 0) + std::map<cmStdString, cmStdString>::const_iterator it = + this->LanguageToOutputExtension.find(lang); + + if(it != this->LanguageToOutputExtension.end()) { - return this->LanguageToOutputExtension[lang].c_str(); + return it->second.c_str(); } } else @@ -809,7 +812,7 @@ cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) } -const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) +const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const { // if there is an extension and it starts with . then move past the // . because the extensions are not stored with a . in the map @@ -817,9 +820,11 @@ const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) { ++ext; } - if(this->ExtensionToLanguage.count(ext) > 0) + std::map<cmStdString, cmStdString>::const_iterator it + = this->ExtensionToLanguage.find(ext); + if(it != this->ExtensionToLanguage.end()) { - return this->ExtensionToLanguage[ext].c_str(); + return it->second.c_str(); } return 0; } @@ -943,7 +948,7 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const char* l, } } -bool cmGlobalGenerator::IgnoreFile(const char* l) +bool cmGlobalGenerator::IgnoreFile(const char* l) const { if(this->GetLanguageFromExtension(l)) { @@ -966,15 +971,22 @@ bool cmGlobalGenerator::IsDependedOn(const char* project, cmTarget const* targetIn) { // Get all local gens for this project - std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project]; + std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator it = + this->ProjectMap.find(project); + if (it == this->ProjectMap.end()) + { + return false; + } + // loop over local gens and get the targets for each one - for(unsigned int i = 0; i < gens->size(); ++i) + for(std::vector<cmLocalGenerator*>::const_iterator geIt = it->second.begin(); + geIt != it->second.end(); ++geIt) { - cmTargets& targets = (*gens)[i]->GetMakefile()->GetTargets(); - for (cmTargets::iterator l = targets.begin(); + cmTargets const& targets = (*geIt)->GetMakefile()->GetTargets(); + for (cmTargets::const_iterator l = targets.begin(); l != targets.end(); l++) { - cmTarget& target = l->second; + cmTarget const& target = l->second; TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(target); if(tgtdeps.count(targetIn)) { @@ -1064,7 +1076,7 @@ void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target) this->CMP0042WarnTargets.insert(target); } -bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() +bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { // If the property is not enabled then okay. if(!this->CMakeInstance @@ -1375,35 +1387,37 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() } //---------------------------------------------------------------------------- +void cmGlobalGenerator::CreateGeneratorTargets(cmMakefile *mf) +{ + cmGeneratorTargetsType generatorTargets; + cmTargets& targets = mf->GetTargets(); + for(cmTargets::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + cmTarget* t = &ti->second; + cmGeneratorTarget* gt = new cmGeneratorTarget(t); + this->GeneratorTargets[t] = gt; + generatorTargets[t] = gt; + } + + for(std::vector<cmTarget*>::const_iterator + j = mf->GetOwnedImportedTargets().begin(); + j != mf->GetOwnedImportedTargets().end(); ++j) + { + cmGeneratorTarget* gt = new cmGeneratorTarget(*j); + this->GeneratorTargets[*j] = gt; + generatorTargets[*j] = gt; + } + mf->SetGeneratorTargets(generatorTargets); +} + +//---------------------------------------------------------------------------- void cmGlobalGenerator::CreateGeneratorTargets() { // Construct per-target generator information. for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) { - cmGeneratorTargetsType generatorTargets; - - cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); - - cmTargets& targets = mf->GetTargets(); - for(cmTargets::iterator ti = targets.begin(); - ti != targets.end(); ++ti) - { - cmTarget* t = &ti->second; - cmGeneratorTarget* gt = new cmGeneratorTarget(t); - this->GeneratorTargets[t] = gt; - generatorTargets[t] = gt; - } - - for(std::vector<cmTarget*>::const_iterator - j = mf->GetOwnedImportedTargets().begin(); - j != mf->GetOwnedImportedTargets().end(); ++j) - { - cmGeneratorTarget* gt = new cmGeneratorTarget(*j); - this->GeneratorTargets[*j] = gt; - generatorTargets[*j] = gt; - } - - mf->SetGeneratorTargets(generatorTargets); + this->CreateGeneratorTargets(this->LocalGenerators[i]->GetMakefile()); } } @@ -1897,7 +1911,7 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmLocalGenerator* gen) + cmLocalGenerator* gen) const { if(!gen || gen == root) { @@ -1917,7 +1931,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget& target) + cmTarget const& target) const { if(target.GetType() == cmTarget::INTERFACE_LIBRARY || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) @@ -1933,16 +1947,17 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } } -void cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) +void +cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const { - for(std::map<cmStdString, bool>::iterator i = + for(std::map<cmStdString, bool>::const_iterator i = this->LanguageEnabled.begin(); i != this->LanguageEnabled.end(); ++i) { lang.push_back(i->first); } } -int cmGlobalGenerator::GetLinkerPreference(const char* lang) +int cmGlobalGenerator::GetLinkerPreference(const char* lang) const { std::map<cmStdString, int>::const_iterator it = this->LanguageToLinkerPreference.find(lang); @@ -1988,10 +2003,10 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmLocalGenerator* lg = *lgi; cmMakefile* mf = lg->GetMakefile(); - cmTargets& targets = mf->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + cmTargets const& targets = mf->GetTargets(); + for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) { - cmTarget& target = t->second; + cmTarget const& target = t->second; // Consider the directory containing the target and all its // parents until something excludes the target. @@ -2020,15 +2035,16 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() ///! Find a local generator by its startdirectory -cmLocalGenerator* cmGlobalGenerator::FindLocalGenerator(const char* start_dir) +cmLocalGenerator* +cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const { - std::vector<cmLocalGenerator*>* gens = &this->LocalGenerators; - for(unsigned int i = 0; i < gens->size(); ++i) + for(std::vector<cmLocalGenerator*>::const_iterator it = + this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it) { - std::string sd = (*gens)[i]->GetMakefile()->GetStartDirectory(); + std::string sd = (*it)->GetMakefile()->GetStartDirectory(); if (sd == start_dir) { - return (*gens)[i]; + return *it; } } return 0; @@ -2511,11 +2527,13 @@ cmGlobalGenerator::GenerateRuleFile(std::string const& output) const //---------------------------------------------------------------------------- std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage( - std::string const& l) + std::string const& l) const { - if(this->LanguageToOriginalSharedLibFlags.count(l) > 0) + std::map<cmStdString, cmStdString>::const_iterator it = + this->LanguageToOriginalSharedLibFlags.find(l); + if(it != this->LanguageToOriginalSharedLibFlags.end()) { - return this->LanguageToOriginalSharedLibFlags[l]; + return it->second; } return ""; } @@ -2646,7 +2664,7 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) +bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const { return (target->GetType() == cmTarget::GLOBAL_TARGET || strcmp(target->GetName(), this->GetAllTargetName()) == 0); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index fc5cab9..ebc2db5 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -80,7 +80,7 @@ public: void SetLanguageEnabled(const char*, cmMakefile* mf); bool GetLanguageEnabled(const char*) const; void ClearEnabledLanguages(); - void GetEnabledLanguages(std::vector<std::string>& lang); + void GetEnabledLanguages(std::vector<std::string>& lang) const; /** * Try to determine system infomation such as shared library * extension, pthreads, byte order etc. @@ -93,7 +93,7 @@ public: * Intended to be called from EnableLanguage. */ void ResolveLanguageCompiler(const std::string &lang, cmMakefile *mf, - bool optional); + bool optional) const; /** * Try to determine system infomation, get it from another generator @@ -182,13 +182,13 @@ public: bool GetToolSupportsColor() const { return this->ToolSupportsColor; } ///! return the language for the given extension - const char* GetLanguageFromExtension(const char* ext); + const char* GetLanguageFromExtension(const char* ext) const; ///! is an extension to be ignored - bool IgnoreFile(const char* ext); + bool IgnoreFile(const char* ext) const; ///! What is the preference for linkers and this language (None or Prefered) - int GetLinkerPreference(const char* lang); + int GetLinkerPreference(const char* lang) const; ///! What is the object file extension for a given source file? - const char* GetLanguageOutputExtension(cmSourceFile const&); + const char* GetLanguageOutputExtension(cmSourceFile const&) const; ///! What is the configurations directory variable called? virtual const char* GetCMakeCFGIntDir() const { return "."; } @@ -220,7 +220,7 @@ public: target in the project */ bool IsDependedOn(const char* project, cmTarget const* target); ///! Find a local generator by its startdirectory - cmLocalGenerator* FindLocalGenerator(const char* start_dir); + cmLocalGenerator* FindLocalGenerator(const char* start_dir) const; /** Append the subdirectory for the given configuration. If anything is appended the given prefix and suffix will be appended around it, which @@ -293,7 +293,7 @@ public: i.e. "Can I build Debug and Release in the same tree?" */ virtual bool IsMultiConfig() { return false; } - std::string GetSharedLibFlagsForLanguage(std::string const& lang); + std::string GetSharedLibFlagsForLanguage(std::string const& lang) const; /** Generate an <output>.rule file path for a given command output. */ virtual std::string GenerateRuleFile(std::string const& output) const; @@ -325,7 +325,7 @@ protected: virtual void GetTargetSets(TargetDependSet& projectTargets, TargetDependSet& originalTargets, cmLocalGenerator* root, GeneratorVector const&); - virtual bool IsRootOnlyTarget(cmTarget* target); + bool IsRootOnlyTarget(cmTarget* target) const; void AddTargetDepends(cmTarget const* target, TargetDependSet& projectTargets); void SetLanguageEnabledFlag(const char* l, cmMakefile* mf); @@ -334,7 +334,7 @@ protected: virtual bool ComputeTargetDepends(); - virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS(); + virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const; bool CheckTargets(); typedef std::vector<std::pair<cmQtAutoGenerators, @@ -342,14 +342,14 @@ protected: void CreateQtAutoGeneratorsTargets(AutogensType& autogens); std::string SelectMakeProgram(const char* makeProgram, - std::string makeDefault = ""); + std::string makeDefault = "") const; // Fill the ProjectMap, this must be called after LocalGenerators // has been populated. void FillProjectMap(); void CheckLocalGenerators(); - bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen); - bool IsExcluded(cmLocalGenerator* root, cmTarget& target); + bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; + bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const char* name, const char* message, @@ -418,8 +418,8 @@ private: void FinalizeTargetCompileInfo(); virtual void PrintCompilerAdvice(std::ostream& os, std::string lang, - const char* envVar); - void CheckCompilerIdCompatibility(cmMakefile* mf, std::string lang); + const char* envVar) const; + void CheckCompilerIdCompatibility(cmMakefile* mf, std::string lang) const; cmExternalMakefileProjectGenerator* ExtraGenerator; @@ -432,6 +432,8 @@ private: // Per-target generator information. cmGeneratorTargetsType GeneratorTargets; + friend class cmake; + void CreateGeneratorTargets(cmMakefile* mf); void CreateGeneratorTargets(); void ComputeGeneratorTargetObjects(); virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index ec91b0f..65b01db 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1107,27 +1107,46 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", - /*restat=*/ false, + /*restat=*/ true, /*generator=*/ true); - cmNinjaDeps implicitDeps; + cmNinjaDeps implicitDeps, outputs, temp; + outputs.push_back(NINJA_BUILD_FILE); for (std::vector<cmLocalGenerator *>::const_iterator i = this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) { const std::vector<std::string>& lf = (*i)->GetMakefile()->GetListFiles(); implicitDeps.insert(implicitDeps.end(), lf.begin(), lf.end()); const std::vector<std::string>& of = (*i)->GetMakefile()->GetOutputFiles(); - implicitDeps.insert(implicitDeps.end(), of.begin(), of.end()); + temp.insert(temp.end(), of.begin(), of.end()); } + + //Add the CMakeCache.txt file to the implicit depends so that we catch + //when somebody manually modifies the file. + implicitDeps.push_back("CMakeCache.txt"); + + //make sure nothing is in implicit depends twice std::sort(implicitDeps.begin(), implicitDeps.end()); implicitDeps.erase(std::unique(implicitDeps.begin(), implicitDeps.end()), implicitDeps.end()); - implicitDeps.push_back("CMakeCache.txt"); + + + //make sure nothing is in outputs depends twice + std::sort(temp.begin(), temp.end()); + temp.erase(std::unique(temp.begin(), temp.end()), + temp.end()); + + //make sure that anything that is in implicitDeps is also NOT in outputs + std::set_difference(temp.begin(), + temp.end(), + implicitDeps.begin(), + implicitDeps.end(), + std::back_inserter(outputs)); this->WriteBuild(os, "Re-run CMake if any of its inputs changed.", "RERUN_CMAKE", - /*outputs=*/ cmNinjaDeps(1, NINJA_BUILD_FILE), + outputs, /*explicitDeps=*/ cmNinjaDeps(), implicitDeps, /*orderOnlyDeps=*/ cmNinjaDeps(), diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index de38923..0d5fb44 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -304,7 +304,7 @@ protected: /// Overloaded methods. /// @see cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() - virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() { return true; } + virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; } private: diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 00a86eb..9173751 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -161,7 +161,7 @@ protected: const char* GetRebuildCacheTargetName() const { return "rebuild_cache"; } const char* GetCleanTargetName() const { return "clean"; } - virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() { return true; } + virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; } // Some make programs (Borland) do not keep a rule if there are no // dependencies or commands. This is a problem for creating rules diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 54e3c28..eab613d 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -110,7 +110,7 @@ protected: private: virtual std::string GetVSMakeProgram() = 0; - void PrintCompilerAdvice(std::ostream&, std::string, const char*) {} + void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; void FollowLinkDepends(cmTarget const* target, diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 6281c3b..ae7f07e 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -212,7 +212,7 @@ protected: std::vector<cmXCodeObject*> XCodeObjects; cmXCodeObject* RootObject; private: - void PrintCompilerAdvice(std::ostream&, std::string, const char*) {} + void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; std::string GetObjectsNormalDirectory( diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 5a189f8..020a782 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -331,6 +331,11 @@ cmPolicies::cmPolicies() CMP0045, "CMP0045", "Error on non-existent target in get_target_property.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0046, "CMP0046", + "Error on non-existent dependency in add_dependencies.", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index b1342bf..38f47f1 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -99,6 +99,7 @@ public: CMP0043, ///< Ignore COMPILE_DEFINITIONS_<Config> properties CMP0044, ///< Case sensitive <LANG>_COMPILER_ID generator expressions CMP0045, ///< Error on non-existent target in get_target_property + CMP0046, ///< Error on non-existent dependency in add_dependencies /** \brief Always the last entry. * diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 4828d20..24fa0c5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -402,6 +402,26 @@ void cmTarget::SetMakefile(cmMakefile* mf) } //---------------------------------------------------------------------------- +void cmTarget::AddUtility(const char *u, cmMakefile *makefile) +{ + this->Utilities.insert(u); + if(makefile) + { + makefile->GetBacktrace(UtilityBacktraces[u]); + } +} + +//---------------------------------------------------------------------------- +cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(const char *u) const +{ + std::map<cmStdString, cmListFileBacktrace>::const_iterator i = + this->UtilityBacktraces.find(u); + if(i == this->UtilityBacktraces.end()) return 0; + + return &i->second; +} + +//---------------------------------------------------------------------------- void cmTarget::FinishConfigure() { // Erase any cached link information that might have been comptued diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 26d391f..ce0d812 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -242,9 +242,10 @@ public: * name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE * commands. It is not a full path nor does it have an extension. */ - void AddUtility(const char* u) { this->Utilities.insert(u);} + void AddUtility(const char* u, cmMakefile *makefile = 0); ///! Get the utilities used by this target std::set<cmStdString>const& GetUtilities() const { return this->Utilities; } + cmListFileBacktrace const* GetUtilityBacktrace(const char* u) const; /** Finalize the target at the end of the Configure step. */ void FinishConfigure(); @@ -691,6 +692,7 @@ private: std::string RuntimeInstallPath; mutable std::string ExportMacro; std::set<cmStdString> Utilities; + std::map<cmStdString, cmListFileBacktrace> UtilityBacktraces; bool RecordDependencies; mutable cmPropertyMap Properties; LinkLibraryVectorType OriginalLinkLibraries; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1dd8a66..33fb0fc 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -69,6 +69,7 @@ #endif #include "cmGlobalUnixMakefileGenerator3.h" #include "cmGlobalNinjaGenerator.h" +#include "cmExtraCodeLiteGenerator.h" #if !defined(CMAKE_BOOT_MINGW) # include "cmExtraCodeBlocksGenerator.h" @@ -593,9 +594,10 @@ bool cmake::FindPackage(const std::vector<std::string>& args) std::string linkPath; std::string flags; std::string linkFlags; - cmGeneratorTarget gtgt(tgt); + gg->CreateGeneratorTargets(mf); + cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt); lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags, - >gt); + gtgt); linkLibs = frameworkPath + linkPath + linkLibs; printf("%s\n", linkLibs.c_str() ); @@ -991,6 +993,8 @@ void cmake::AddDefaultExtraGenerators() this->AddExtraGenerator(cmExtraCodeBlocksGenerator::GetActualName(), &cmExtraCodeBlocksGenerator::New); + this->AddExtraGenerator(cmExtraCodeLiteGenerator::GetActualName(), + &cmExtraCodeLiteGenerator::New); this->AddExtraGenerator(cmExtraSublimeTextGenerator::GetActualName(), &cmExtraSublimeTextGenerator::New); this->AddExtraGenerator(cmExtraKateGenerator::GetActualName(), diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 7969078..a79111a 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2230,6 +2230,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log" ) + configure_file( + "${CMake_SOURCE_DIR}/Tests/CTestTestSkipReturnCode/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/test.cmake" + @ONLY ESCAPE_QUOTES) + add_test(CTestTestSkipReturnCode ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/testOutput.log" + -C \${CTEST_CONFIGURATION_TYPE} + ) + set_tests_properties(CTestTestSkipReturnCode PROPERTIES + PASS_REGULAR_EXPRESSION "CMakeV1 \\.* +Passed.*CMakeV2 \\.+\\*+Skipped") + ADD_TEST_MACRO(CTestTestSerialInDepends ${CMAKE_CTEST_COMMAND} -j 4 --output-on-failure -C "\${CTestTest_CONFIG}") diff --git a/Tests/CTestTestSkipReturnCode/CMakeLists.txt b/Tests/CTestTestSkipReturnCode/CMakeLists.txt new file mode 100644 index 0000000..26c4178 --- /dev/null +++ b/Tests/CTestTestSkipReturnCode/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.8.12) +project(CTestTestSkipReturnCode) +include(CTest) + +add_test (NAME CMakeV1 COMMAND ${CMAKE_COMMAND} "--version") +add_test (NAME CMakeV2 COMMAND ${CMAKE_COMMAND} "--version") + +set_tests_properties(CMakeV2 PROPERTIES SKIP_RETURN_CODE 0) diff --git a/Tests/CTestTestSkipReturnCode/CTestConfig.cmake b/Tests/CTestTestSkipReturnCode/CTestConfig.cmake new file mode 100644 index 0000000..ad8e00e --- /dev/null +++ b/Tests/CTestTestSkipReturnCode/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestSkipReturnCode") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestSkipReturnCode/test.cmake.in b/Tests/CTestTestSkipReturnCode/test.cmake.in new file mode 100644 index 0000000..ebee01b --- /dev/null +++ b/Tests/CTestTestSkipReturnCode/test.cmake.in @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 2.4) + +# Settings: +set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-SkipReturnCode") + +set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestSkipReturnCode") +set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestSkipReturnCode") +set(CTEST_CVS_COMMAND "@CVSCOMMAND@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in index c91d8a0..e4df9d6 100644 --- a/Tests/FindPackageModeMakefileTest/Makefile.in +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -9,9 +9,9 @@ CMAKE_FOO = $(CMAKE) --find-package -DCMAKE_MODULE_PATH=$(CMAKE_CURRENT_BINARY_D tmp = tmp.txt -all: clean pngtest +all: pngtest -main.o: main.cpp +main.o: clean main.cpp @$(CMAKE_FOO) -DMODE=COMPILE >$(tmp) @foo="`cat $(tmp)`"; \ printf '"%s" %s %s -c main.cpp\n' $(CMAKE_CXX_COMPILER) "$(CXXFLAGS)" "$$foo" >$(tmp) diff --git a/Tests/RunCMake/CMP0046/CMP0046-NEW-existing-dependency-stderr.txt b/Tests/RunCMake/CMP0046/CMP0046-NEW-existing-dependency-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0046/CMP0046-NEW-existing-dependency-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0046/CMP0046-NEW-existing-dependency.cmake b/Tests/RunCMake/CMP0046/CMP0046-NEW-existing-dependency.cmake new file mode 100644 index 0000000..0be290a --- /dev/null +++ b/Tests/RunCMake/CMP0046/CMP0046-NEW-existing-dependency.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0046 NEW) + +add_custom_target(foo) +add_custom_target(bar) +add_dependencies(foo bar) diff --git a/Tests/RunCMake/CMP0046/CMP0046-NEW-missing-dependency-result.txt b/Tests/RunCMake/CMP0046/CMP0046-NEW-missing-dependency-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0046/CMP0046-NEW-missing-dependency-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0046/CMP0046-NEW-missing-dependency-stderr.txt b/Tests/RunCMake/CMP0046/CMP0046-NEW-missing-dependency-stderr.txt new file mode 100644 index 0000000..0c23c43 --- /dev/null +++ b/Tests/RunCMake/CMP0046/CMP0046-NEW-missing-dependency-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at CMP0046-NEW-missing-dependency.cmake:4 \(add_dependencies\): + Policy CMP0046 is not set: Error on non-existent dependency in + add_dependencies. Run "cmake --help-policy CMP0046" for policy details. + Use the cmake_policy command to set the policy and suppress this warning. ++ + The dependency target "bar" of target "foo" does not exist. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0046/CMP0046-NEW-missing-dependency.cmake b/Tests/RunCMake/CMP0046/CMP0046-NEW-missing-dependency.cmake new file mode 100644 index 0000000..9bb6b90 --- /dev/null +++ b/Tests/RunCMake/CMP0046/CMP0046-NEW-missing-dependency.cmake @@ -0,0 +1,4 @@ +cmake_policy(SET CMP0046 NEW) + +add_custom_target(foo) +add_dependencies(foo bar) diff --git a/Tests/RunCMake/CMP0046/CMP0046-OLD-existing-dependency-stderr.txt b/Tests/RunCMake/CMP0046/CMP0046-OLD-existing-dependency-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0046/CMP0046-OLD-existing-dependency-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0046/CMP0046-OLD-existing-dependency.cmake b/Tests/RunCMake/CMP0046/CMP0046-OLD-existing-dependency.cmake new file mode 100644 index 0000000..b22ab4f --- /dev/null +++ b/Tests/RunCMake/CMP0046/CMP0046-OLD-existing-dependency.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0046 OLD) + +add_custom_target(foo) +add_custom_target(bar) +add_dependencies(foo bar) diff --git a/Tests/RunCMake/CMP0046/CMP0046-OLD-missing-dependency-stderr.txt b/Tests/RunCMake/CMP0046/CMP0046-OLD-missing-dependency-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0046/CMP0046-OLD-missing-dependency-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0046/CMP0046-OLD-missing-dependency.cmake b/Tests/RunCMake/CMP0046/CMP0046-OLD-missing-dependency.cmake new file mode 100644 index 0000000..5ee3cb7 --- /dev/null +++ b/Tests/RunCMake/CMP0046/CMP0046-OLD-missing-dependency.cmake @@ -0,0 +1,4 @@ +cmake_policy(SET CMP0046 OLD) + +add_custom_target(foo) +add_dependencies(foo bar) diff --git a/Tests/RunCMake/CMP0046/CMP0046-WARN-missing-dependency-stderr.txt b/Tests/RunCMake/CMP0046/CMP0046-WARN-missing-dependency-stderr.txt new file mode 100644 index 0000000..fed36f1 --- /dev/null +++ b/Tests/RunCMake/CMP0046/CMP0046-WARN-missing-dependency-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning \(dev\) at CMP0046-WARN-missing-dependency.cmake:2 \(add_dependencies\): + Policy CMP0046 is not set: Error on non-existent dependency in + add_dependencies. Run "cmake --help-policy CMP0046" for policy details. + Use the cmake_policy command to set the policy and suppress this warning. ++ + The dependency target "bar" of target "foo" does not exist. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0046/CMP0046-WARN-missing-dependency.cmake b/Tests/RunCMake/CMP0046/CMP0046-WARN-missing-dependency.cmake new file mode 100644 index 0000000..896fa40 --- /dev/null +++ b/Tests/RunCMake/CMP0046/CMP0046-WARN-missing-dependency.cmake @@ -0,0 +1,2 @@ +add_custom_target(foo) +add_dependencies(foo bar) diff --git a/Tests/RunCMake/CMP0046/CMakeLists.txt b/Tests/RunCMake/CMP0046/CMakeLists.txt new file mode 100644 index 0000000..2f10cb0 --- /dev/null +++ b/Tests/RunCMake/CMP0046/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0046/RunCMakeTest.cmake b/Tests/RunCMake/CMP0046/RunCMakeTest.cmake new file mode 100644 index 0000000..5131e5b --- /dev/null +++ b/Tests/RunCMake/CMP0046/RunCMakeTest.cmake @@ -0,0 +1,8 @@ +include(RunCMake) + +run_cmake(CMP0046-OLD-missing-dependency) +run_cmake(CMP0046-NEW-missing-dependency) +run_cmake(CMP0046-WARN-missing-dependency) + +run_cmake(CMP0046-OLD-existing-dependency) +run_cmake(CMP0046-NEW-existing-dependency) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 77700d7..1c23bcd 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -66,6 +66,7 @@ if(CMAKE_SYSTEM_NAME MATCHES Darwin AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG) endif() add_RunCMake_test(CMP0043) add_RunCMake_test(CMP0045) +add_RunCMake_test(CMP0046) add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) @@ -739,10 +739,7 @@ if ${cmake_system_linux}; then # avoid binutils problem with large binaries, e.g. when building CMake in debug mode # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50230 if ${cmake_machine_parisc}; then - # if -O[s23] is given the effect is inverted, so do not use the flag then - if [ "`echo "${CXXFLAGS}" | sed -r '/^(.* )?(-O[s234])( .*)?$/s/.*/-Os/'`" != "-Os" ]; then - cmake_ld_flags="${LDFLAGS} -Wl,--unique=.text.*" - fi + cmake_ld_flags="${LDFLAGS} -Wl,--unique=.text._*" fi fi |