diff options
Diffstat (limited to 'Source')
233 files changed, 8408 insertions, 7266 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 16b9ea1..fd71b0e 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -299,8 +299,6 @@ set(SRCS cmLocalUnixMakefileGenerator3.cxx cmLocale.h ${MACH_SRCS} - cmMakeDepend.cxx - cmMakeDepend.h cmMakefile.cxx cmMakefile.h cmMakefileTargetGenerator.cxx @@ -327,6 +325,8 @@ set(SRCS cmPropertyDefinitionMap.h cmPropertyMap.cxx cmPropertyMap.h + cmQtAutoGeneratorInitializer.cxx + cmQtAutoGeneratorInitializer.h cmQtAutoGenerators.cxx cmQtAutoGenerators.h cmRST.cxx @@ -502,6 +502,10 @@ if (WIN32) cmGhsMultiGpj.cxx cmGhsMultiGpj.h ) + + # Add a manifest file to executables on Windows to allow for + # GetVersion to work properly on Windows 8 and above. + set(MANIFEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake.version.manifest) endif() endif () @@ -531,7 +535,7 @@ set(SRCS ${SRCS} if(WIN32 AND NOT CYGWIN) set_source_files_properties(cmcldeps.cxx PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0501) - add_executable(cmcldeps cmcldeps.cxx) + add_executable(cmcldeps cmcldeps.cxx ${MANIFEST_FILE}) target_link_libraries(cmcldeps CMakeLib) install(TARGETS cmcldeps DESTINATION bin) endif() @@ -542,6 +546,19 @@ foreach(v CURL_CA_BUNDLE CURL_CA_PATH) endif() endforeach() +foreach(check + STAT_HAS_ST_MTIM + STAT_HAS_ST_MTIMESPEC + ) + if(KWSYS_CXX_${check}_COMPILED) # abuse KWSys check cache entry + set(CMake_${check} 1) + else() + set(CMake_${check} 0) + endif() + set_property(SOURCE cmFileTimeComparison.cxx APPEND PROPERTY + COMPILE_DEFINITIONS CMake_${check}=${CMake_${check}}) +endforeach() + # create a library used by the command line and the GUI add_library(CMakeLib ${SRCS}) target_link_libraries(CMakeLib cmsys @@ -720,15 +737,15 @@ if(APPLE) endif() # Build CMake executable -add_executable(cmake cmakemain.cxx cmcmd.cxx cmcmd.h) +add_executable(cmake cmakemain.cxx cmcmd.cxx cmcmd.h ${MANIFEST_FILE}) target_link_libraries(cmake CMakeLib) # Build CTest executable -add_executable(ctest ctest.cxx) +add_executable(ctest ctest.cxx ${MANIFEST_FILE}) target_link_libraries(ctest CTestLib) # Build CPack executable -add_executable(cpack CPack/cpack.cxx) +add_executable(cpack CPack/cpack.cxx ${MANIFEST_FILE}) target_link_libraries(cpack CPackLib) # Curses GUI diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index de69a15..a5f01d3 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) -set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150911) +set(CMake_VERSION_MINOR 4) +set(CMake_VERSION_PATCH 20151026) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index 43d34ee..4eb23c1 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -24,7 +24,6 @@ #include <cmsys/RegularExpression.hxx> #include <cmGlobalGenerator.h> -#include <cmLocalGenerator.h> #include <cmSystemTools.h> #include <cmMakefile.h> #include <cmGeneratedFileStream.h> diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx index 5a8dc63..471c3a4 100644 --- a/Source/CPack/WiX/cmWIXPatch.cxx +++ b/Source/CPack/WiX/cmWIXPatch.cxx @@ -33,13 +33,30 @@ void cmWIXPatch::ApplyFragment( if(i == Fragments.end()) return; const cmWIXPatchElement& fragment = i->second; + + this->ApplyElementChildren(fragment, writer); + + Fragments.erase(i); +} + +void cmWIXPatch::ApplyElementChildren( + const cmWIXPatchElement& element, cmWIXSourceWriter& writer) +{ for(cmWIXPatchElement::child_list_t::const_iterator - j = fragment.children.begin(); j != fragment.children.end(); ++j) + j = element.children.begin(); j != element.children.end(); ++j) + { + cmWIXPatchNode *node = *j; + + switch(node->type()) { - ApplyElement(**j, writer); + case cmWIXPatchNode::ELEMENT: + ApplyElement(dynamic_cast<const cmWIXPatchElement&>(*node), writer); + break; + case cmWIXPatchNode::TEXT: + writer.AddTextNode(dynamic_cast<const cmWIXPatchText&>(*node).text); + break; } - - Fragments.erase(i); + } } void cmWIXPatch::ApplyElement( @@ -53,16 +70,11 @@ void cmWIXPatch::ApplyElement( writer.AddAttribute(i->first, i->second); } - for(cmWIXPatchElement::child_list_t::const_iterator - i = element.children.begin(); i != element.children.end(); ++i) - { - ApplyElement(**i, writer); - } + this->ApplyElementChildren(element, writer); writer.EndElement(element.name); } - bool cmWIXPatch::CheckForUnappliedFragments() { std::string fragmentList; diff --git a/Source/CPack/WiX/cmWIXPatch.h b/Source/CPack/WiX/cmWIXPatch.h index 7b7b2f1..d53fcb4 100644 --- a/Source/CPack/WiX/cmWIXPatch.h +++ b/Source/CPack/WiX/cmWIXPatch.h @@ -33,6 +33,9 @@ public: bool CheckForUnappliedFragments(); private: + void ApplyElementChildren(const cmWIXPatchElement& element, + cmWIXSourceWriter& writer); + void ApplyElement(const cmWIXPatchElement& element, cmWIXSourceWriter& writer); diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index e066c28..14c5413 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -16,6 +16,21 @@ #include <cm_expat.h> +cmWIXPatchNode::Type cmWIXPatchText::type() +{ + return cmWIXPatchNode::TEXT; +} + +cmWIXPatchNode::Type cmWIXPatchElement::type() +{ + return cmWIXPatchNode::ELEMENT; +} + +cmWIXPatchNode::~cmWIXPatchNode() +{ + +} + cmWIXPatchElement::~cmWIXPatchElement() { for(child_list_t::iterator i = children.begin(); i != children.end(); ++i) @@ -63,20 +78,20 @@ void cmWIXPatchParser::StartElement(const std::string& name, const char **atts) { cmWIXPatchElement &parent = *ElementStack.back(); - parent.children.resize(parent.children.size() + 1); - cmWIXPatchElement*& currentElement = parent.children.back(); - currentElement = new cmWIXPatchElement; - currentElement->name = name; + cmWIXPatchElement *element = new cmWIXPatchElement; + parent.children.push_back(element); + + element->name = name; for(size_t i = 0; atts[i]; i += 2) { std::string key = atts[i]; std::string value = atts[i+1]; - currentElement->attributes[key] = value; + element->attributes[key] = value; } - ElementStack.push_back(currentElement); + ElementStack.push_back(element); } } @@ -117,11 +132,34 @@ void cmWIXPatchParser::EndElement(const std::string& name) } else { - ElementStack.pop_back(); + ElementStack.pop_back(); } } } +void cmWIXPatchParser::CharacterDataHandler(const char* data, int length) +{ + const char* whitespace = "\x20\x09\x0d\x0a"; + + if(State == INSIDE_FRAGMENT) + { + cmWIXPatchElement &parent = *ElementStack.back(); + + std::string text(data, length); + + std::string::size_type first = text.find_first_not_of(whitespace); + std::string::size_type last = text.find_last_not_of(whitespace); + + if(first != std::string::npos && last != std::string::npos) + { + cmWIXPatchText *text_node = new cmWIXPatchText; + text_node->text = text.substr(first, last - first + 1); + + parent.children.push_back(text_node); + } + } +} + void cmWIXPatchParser::ReportError(int line, int column, const char* msg) { cmCPackLogger(cmCPackLog::LOG_ERROR, diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h index acfb4c0..acaeae3 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.h +++ b/Source/CPack/WiX/cmWIXPatchParser.h @@ -20,11 +20,33 @@ #include <map> #include <list> -struct cmWIXPatchElement +struct cmWIXPatchNode { + enum Type + { + TEXT, + ELEMENT + }; + + virtual ~cmWIXPatchNode(); + + virtual Type type() = 0; +}; + +struct cmWIXPatchText : public cmWIXPatchNode +{ + virtual Type type(); + + std::string text; +}; + +struct cmWIXPatchElement : cmWIXPatchNode +{ + virtual Type type(); + ~cmWIXPatchElement(); - typedef std::list<cmWIXPatchElement*> child_list_t; + typedef std::list<cmWIXPatchNode*> child_list_t; typedef std::map<std::string, std::string> attributes_t; std::string name; @@ -48,6 +70,9 @@ private: void StartFragment(const char **attributes); virtual void EndElement(const std::string& name); + + virtual void CharacterDataHandler(const char* data, int length); + virtual void ReportError(int line, int column, const char* msg); void ReportValidationError(std::string const& message); diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index 8d38e9b..63acb27 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -102,6 +102,25 @@ void cmWIXSourceWriter::EndElement(std::string const& name) State = DEFAULT; } +void cmWIXSourceWriter::AddTextNode(std::string const& text) +{ + if(State == BEGIN) + { + File << ">"; + } + + if(Elements.empty()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "can not add text without open WiX element in '" << + SourceFilename << "'" << std::endl); + return; + } + + File << this->EscapeAttributeValue(text); + State = DEFAULT; +} + void cmWIXSourceWriter::AddProcessingInstruction( std::string const& target, std::string const& content) { diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h index 3b9999c..9e303f0 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.h +++ b/Source/CPack/WiX/cmWIXSourceWriter.h @@ -34,6 +34,8 @@ public: void EndElement(std::string const& name); + void AddTextNode(std::string const& text); + void AddProcessingInstruction( std::string const& target, std::string const& content); diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 58bd947..db985db 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -14,7 +14,6 @@ #include "cmake.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmGeneratedFileStream.h" @@ -78,7 +77,7 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive, std::string rp = filePrefix + *fileIt; cmCPackLogger(cmCPackLog::LOG_DEBUG,"Adding file: " << rp << std::endl); - archive.Add(rp); + archive.Add(rp, 0, 0, false); if (!archive) { cmCPackLogger(cmCPackLog::LOG_ERROR, "ERROR while packaging files: " @@ -284,7 +283,7 @@ int cmCPackArchiveGenerator::PackageFiles() // Get the relative path to the file std::string rp = cmSystemTools::RelativePath(toplevel.c_str(), fileIt->c_str()); - archive.Add(rp); + archive.Add(rp, 0, 0, false); if(!archive) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< " diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx index 6605f16..1f905c0 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx @@ -14,7 +14,6 @@ #include "cmake.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmGeneratedFileStream.h" diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.cxx b/Source/CPack/cmCPackCygwinSourceGenerator.cxx index f1e8539..f5cb53c 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.cxx +++ b/Source/CPack/cmCPackCygwinSourceGenerator.cxx @@ -14,7 +14,6 @@ #include "cmake.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmGeneratedFileStream.h" diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index f9dfdf6..04efb71 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -95,6 +95,7 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel, std::string findExpr(this->GetOption("GEN_WDIR")); findExpr += "/*"; gl.RecurseOn(); + gl.SetRecurseListDirs(true); if ( !gl.FindFiles(findExpr) ) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -222,6 +223,7 @@ int cmCPackDebGenerator::PackageComponentsAllInOne() std::string findExpr(this->GetOption("GEN_WDIR")); findExpr += "/*"; gl.RecurseOn(); + gl.SetRecurseListDirs(true); if ( !gl.FindFiles(findExpr) ) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -524,21 +526,24 @@ int cmCPackDebGenerator::createDeb() packageFiles.begin(); fileIt != packageFiles.end(); ++ fileIt ) { - std::string cmd = "\""; - cmd += cmSystemTools::GetCMakeCommand(); - cmd += "\" -E md5sum \""; - cmd += *fileIt; - cmd += "\""; - - std::string output; - int retval = -1; - int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &output, - &retval, toplevel.c_str(), this->GeneratorVerbose, 0); - if ( !res || retval ) + // hash only regular files + if( cmSystemTools::FileIsDirectory(*fileIt) + || cmSystemTools::FileIsSymlink(*fileIt)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running cmake -E md5sum " - << cmd << std::endl); + continue; } + + char md5sum[33]; + if(!cmSystemTools::ComputeFileMD5(*fileIt, md5sum)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem computing the md5 of " + << *fileIt << std::endl); + } + + md5sum[32] = 0; + + std::string output(md5sum); + output += " " + *fileIt + "\n"; // debian md5sums entries are like this: // 014f3604694729f3bf19263bac599765 usr/bin/ccmake // thus strip the full path (with the trailing slash) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 92a4b2b..22d4bf0 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -16,7 +16,6 @@ #include "cmCPackLog.h" #include "cmake.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmGeneratedFileStream.h" #include "cmCPackComponentGroup.h" #include "cmXMLSafe.h" @@ -367,6 +366,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install directory: " << top << std::endl); gl.RecurseOn(); + gl.SetRecurseListDirs(true); if ( !gl.FindFiles(findExpr) ) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -379,7 +379,11 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( for ( gfit = files.begin(); gfit != files.end(); ++ gfit ) { bool skip = false; - std::string &inFile = *gfit; + std::string inFile = *gfit; + if(cmSystemTools::FileIsDirectory(*gfit)) + { + inFile += '/'; + } for ( regIt= ignoreFilesRegex.begin(); regIt!= ignoreFilesRegex.end(); ++ regIt) @@ -713,13 +717,12 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cmake cm; cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); + cm.GetCurrentSnapshot().SetDefaultDefinitions(); cm.AddCMakePaths(); cm.SetProgressCallback(cmCPackGeneratorProgress, this); cmGlobalGenerator gg(&cm); cmsys::auto_ptr<cmMakefile> mf( new cmMakefile(&gg, cm.GetCurrentSnapshot())); - cmsys::auto_ptr<cmLocalGenerator> lg( - gg.CreateLocalGenerator(mf.get())); std::string realInstallDirectory = tempInstallDirectory; if ( !installSubDirectory.empty() && installSubDirectory != "/" ) { @@ -869,6 +872,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cmsys::Glob glB; findExpr += "/*"; glB.RecurseOn(); + glB.SetRecurseListDirs(true); glB.FindFiles(findExpr); filesBefore = glB.GetFiles(); std::sort(filesBefore.begin(),filesBefore.end()); @@ -908,6 +912,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( { cmsys::Glob glA; glA.RecurseOn(); + glA.SetRecurseListDirs(true); glA.FindFiles(findExpr); std::vector<std::string> filesAfter = glA.GetFiles(); std::sort(filesAfter.begin(),filesAfter.end()); @@ -1074,6 +1079,7 @@ int cmCPackGenerator::DoPackage() std::string findExpr = tempDirectory; findExpr += "/*"; gl.RecurseOn(); + gl.SetRecurseListDirs(true); gl.SetRecurseThroughSymlinks(false); if ( !gl.FindFiles(findExpr) ) { diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 6cdda28..5ba639f 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -13,7 +13,6 @@ #include "cmCPackNSISGenerator.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmGeneratedFileStream.h" @@ -158,6 +157,28 @@ int cmCPackNSISGenerator::PackageFiles() installerIconCode.c_str()); } + if (this->IsSet("CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP")) + { + std::string installerBitmapCode = + "!define MUI_WELCOMEFINISHPAGE_BITMAP \""; + installerBitmapCode += + this->GetOption("CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP"); + installerBitmapCode += "\"\n"; + this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_WELCOMEFINISH_CODE", + installerBitmapCode.c_str()); + } + + if (this->IsSet("CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP")) + { + std::string installerBitmapCode = + "!define MUI_UNWELCOMEFINISHPAGE_BITMAP \""; + installerBitmapCode += + this->GetOption("CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP"); + installerBitmapCode += "\"\n"; + this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_UNWELCOMEFINISH_CODE", + installerBitmapCode.c_str()); + } + if(this->IsSet("CPACK_NSIS_MUI_FINISHPAGE_RUN")) { std::string installerRunCode = "!define MUI_FINISHPAGE_RUN \"$INSTDIR\\"; diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index d533af8..8940f54 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -13,7 +13,6 @@ #include "cmake.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmGeneratedFileStream.h" diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 880663f..8fdc036 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -13,7 +13,6 @@ #include "cmake.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmGeneratedFileStream.h" diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 109dcb7..68b893f 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -14,7 +14,6 @@ #include "cmake.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmCPackLog.h" diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index cb9cbc4..c08897f 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -18,7 +18,6 @@ #include "cmCPackGenerator.h" #include "cmake.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmCPackLog.h" @@ -200,12 +199,11 @@ int main (int argc, char const* const* argv) cmake cminst; cminst.SetHomeDirectory(""); cminst.SetHomeOutputDirectory(""); + cminst.GetCurrentSnapshot().SetDefaultDefinitions(); cminst.GetState()->RemoveUnscriptableCommands(); cmGlobalGenerator cmgg(&cminst); cmsys::auto_ptr<cmMakefile> globalMF( new cmMakefile(&cmgg, cminst.GetCurrentSnapshot())); - cmsys::auto_ptr<cmLocalGenerator> cmlg( - cmgg.CreateLocalGenerator(globalMF.get())); #if defined(__CYGWIN__) globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); #endif diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 6dbb245..0d74f48 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -15,7 +15,6 @@ #include "cmCTest.h" #include "cmake.h" #include "cmMakefile.h" -#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmGeneratedFileStream.h" #include "cmXMLWriter.h" diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx index b4c0137..fb6cc00 100644 --- a/Source/CTest/cmCTestCurl.cxx +++ b/Source/CTest/cmCTestCurl.cxx @@ -166,6 +166,10 @@ bool cmCTestCurl::UploadFile(std::string const& local_file, curlWriteMemoryCallback); ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback); + // Be sure to set Content-Type to satisfy fussy modsecurity rules + struct curl_slist *headers = ::curl_slist_append(NULL, + "Content-Type: text/xml"); + ::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers); std::vector<char> responseData; std::vector<char> debugData; ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void *)&responseData); @@ -174,6 +178,8 @@ bool cmCTestCurl::UploadFile(std::string const& local_file, // Now run off and do what you've been told! ::curl_easy_perform(this->Curl); ::fclose(ftpfile); + ::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, NULL); + ::curl_slist_free_all(headers); if ( responseData.size() > 0 ) { diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index fb0cce6..749a5be 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -728,7 +728,6 @@ int cmCTestLaunch::Main(int argc, const char* const argv[]) //---------------------------------------------------------------------------- #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmake.h" #include <cmsys/auto_ptr.hxx> @@ -737,10 +736,9 @@ void cmCTestLaunch::LoadConfig() cmake cm; cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); + cm.GetCurrentSnapshot().SetDefaultDefinitions(); cmGlobalGenerator gg(&cm); cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); - cmsys::auto_ptr<cmLocalGenerator> lg( - gg.CreateLocalGenerator(mf.get())); std::string fname = this->LogDir; fname += "CTestLaunchConfig.cmake"; if(cmSystemTools::FileExists(fname.c_str()) && diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 4832186..7c7f5df 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -198,6 +198,10 @@ void cmCTestMultiProcessHandler::UnlockResources(int index) { this->LockedResources.erase(*i); } + if (this->Properties[index]->RunSerial) + { + this->SerialTestRunning = false; + } } //--------------------------------------------------------- @@ -451,11 +455,6 @@ bool cmCTestMultiProcessHandler::CheckOutput() this->WriteCheckpoint(test); this->UnlockResources(test); this->RunningCount -= GetProcessorsUsed(test); - if (this->Properties[test]->RunSerial) - { - this->SerialTestRunning = false; - } - delete p; } return true; diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index c1ba279..ee15271 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -16,7 +16,6 @@ #include "cmake.h" #include "cmFunctionBlocker.h" #include "cmMakefile.h" -#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmGeneratedFileStream.h" @@ -86,7 +85,6 @@ cmCTestScriptHandler::cmCTestScriptHandler() this->EmptyBinDir = false; this->EmptyBinDirOnce = false; this->Makefile = 0; - this->LocalGenerator = 0; this->CMake = 0; this->GlobalGenerator = 0; @@ -128,9 +126,6 @@ void cmCTestScriptHandler::Initialize() delete this->Makefile; this->Makefile = 0; - delete this->LocalGenerator; - this->LocalGenerator = 0; - delete this->GlobalGenerator; this->GlobalGenerator = 0; @@ -141,7 +136,6 @@ void cmCTestScriptHandler::Initialize() cmCTestScriptHandler::~cmCTestScriptHandler() { delete this->Makefile; - delete this->LocalGenerator; delete this->GlobalGenerator; delete this->CMake; } @@ -179,15 +173,14 @@ int cmCTestScriptHandler::ProcessHandler() void cmCTestScriptHandler::UpdateElapsedTime() { - if (this->LocalGenerator) + if (this->Makefile) { // set the current elapsed time char timeString[20]; int itime = static_cast<unsigned int>(cmSystemTools::GetTime() - this->ScriptStartTime); sprintf(timeString,"%i",itime); - this->LocalGenerator->GetMakefile()->AddDefinition("CTEST_ELAPSED_TIME", - timeString); + this->Makefile->AddDefinition("CTEST_ELAPSED_TIME", timeString); } } @@ -316,28 +309,23 @@ void cmCTestScriptHandler::CreateCMake() { delete this->CMake; delete this->GlobalGenerator; - delete this->LocalGenerator; delete this->Makefile; } this->CMake = new cmake; this->CMake->SetHomeDirectory(""); this->CMake->SetHomeOutputDirectory(""); + this->CMake->GetCurrentSnapshot().SetDefaultDefinitions(); this->CMake->AddCMakePaths(); this->GlobalGenerator = new cmGlobalGenerator(this->CMake); cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot(); + std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); + snapshot.GetDirectory().SetCurrentSource(cwd); + snapshot.GetDirectory().SetCurrentBinary(cwd); this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot); - this->LocalGenerator = - this->GlobalGenerator->CreateLocalGenerator(this->Makefile); this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); - // Set CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR. - // Also, some commands need Makefile->GetCurrentSourceDirectory(). - std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - this->Makefile->SetCurrentSourceDirectory(cwd); - this->Makefile->SetCurrentBinaryDirectory(cwd); - // remove all cmake commands which are not scriptable, since they can't be // used in ctest scripts this->CMake->GetState()->RemoveUnscriptableCommands(); diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index 42c2f20..c9d0b6a 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -18,7 +18,6 @@ #include "cmListFileCache.h" class cmMakefile; -class cmLocalGenerator; class cmGlobalGenerator; class cmake; class cmCTestCommand; @@ -166,7 +165,6 @@ private: double ScriptStartTime; cmMakefile *Makefile; - cmLocalGenerator *LocalGenerator; cmGlobalGenerator *GlobalGenerator; cmake *CMake; }; diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index e19e4f4..36576c5 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -12,7 +12,6 @@ #include "cmCTestStartCommand.h" #include "cmCTest.h" -#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmCTestVC.h" #include "cmGeneratedFileStream.h" diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 1e12f15..833cad6 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -338,6 +338,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, CURLcode res; FILE* ftpfile; char error_buffer[1024]; + struct curl_slist *headers = ::curl_slist_append(NULL, + "Content-Type: text/xml"); /* In windows, this will init the winsock stuff */ ::curl_global_init(CURL_GLOBAL_ALL); @@ -420,6 +422,9 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, ::curl_easy_setopt(curl, CURLOPT_PUT, 1); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + // Be sure to set Content-Type to satisfy fussy modsecurity rules + ::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); + std::string local_file = *file; if ( !cmSystemTools::FileExists(local_file.c_str()) ) { @@ -477,6 +482,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: " << local_file << std::endl); ::curl_easy_cleanup(curl); + ::curl_slist_free_all(headers); ::curl_global_cleanup(); return false; } @@ -621,6 +627,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, << std::endl); } ::curl_easy_cleanup(curl); + ::curl_slist_free_all(headers); ::curl_global_cleanup(); return false; } @@ -630,6 +637,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, " Uploaded: " + local_file << std::endl, this->Quiet); } } + ::curl_slist_free_all(headers); ::curl_global_cleanup(); return true; } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index f9678e7..fa3b416 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -24,7 +24,6 @@ #include <cmsys/FStream.hxx> #include "cmMakefile.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmCommand.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" @@ -1591,10 +1590,9 @@ void cmCTestTestHandler::GetListOfTests() cmake cm; cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); + cm.GetCurrentSnapshot().SetDefaultDefinitions(); cmGlobalGenerator gg(&cm); cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); - cmsys::auto_ptr<cmLocalGenerator> lg( - gg.CreateLocalGenerator(mf.get())); mf->AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType().c_str()); diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 14067d5..c635430 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -65,6 +65,11 @@ public: void SetMaxIndex(int n) {this->MaxIndex = n;} int GetMaxIndex() {return this->MaxIndex;} + void SetTestOutputSizePassed(int n) + { this->CustomMaximumPassedTestOutputSize = n; } + void SetTestOutputSizeFailed(int n) + { this->CustomMaximumFailedTestOutputSize = n; } + ///! pass the -I argument down void SetTestsToRunInformation(const char*); diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 963e501..bf2f34a 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -15,7 +15,6 @@ #include "cmCTest.h" #include "cmake.h" #include "cmMakefile.h" -#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmVersion.h" #include "cmGeneratedFileStream.h" diff --git a/Source/Checks/cm_c11_thread_local.c b/Source/Checks/cm_c11_thread_local.c new file mode 100644 index 0000000..ab780f2 --- /dev/null +++ b/Source/Checks/cm_c11_thread_local.c @@ -0,0 +1,2 @@ +_Thread_local int i = 42; +int main(void) { return 0; } diff --git a/Source/Checks/cm_c11_thread_local.cmake b/Source/Checks/cm_c11_thread_local.cmake new file mode 100644 index 0000000..6b8d10b --- /dev/null +++ b/Source/Checks/cm_c11_thread_local.cmake @@ -0,0 +1,33 @@ +set(CMake_C11_THREAD_LOCAL_BROKEN 0) +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_C11_STANDARD_COMPILE_OPTION) + if(NOT DEFINED CMake_C11_THREAD_LOCAL_WORKS) + message(STATUS "Checking if compiler supports C11 _Thread_local") + try_compile(CMake_C11_THREAD_LOCAL_WORKS + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_LIST_DIR}/cm_c11_thread_local.c + CMAKE_FLAGS -DCMAKE_C_STANDARD=11 + OUTPUT_VARIABLE OUTPUT + ) + if(CMake_C11_THREAD_LOCAL_WORKS AND "${OUTPUT}" MATCHES "error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'") + set_property(CACHE CMake_C11_THREAD_LOCAL_WORKS PROPERTY VALUE 0) + endif() + if(CMake_C11_THREAD_LOCAL_WORKS) + message(STATUS "Checking if compiler supports C11 _Thread_local - yes") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if compiler supports C11 _Thread_local passed with the following output:\n" + "${OUTPUT}\n" + "\n" + ) + else() + message(STATUS "Checking if compiler supports C11 _Thread_local - no") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if compiler supports C11 _Thread_local failed with the following output:\n" + "${OUTPUT}\n" + "\n" + ) + endif() + endif() + if(NOT CMake_C11_THREAD_LOCAL_WORKS) + set(CMake_C11_THREAD_LOCAL_BROKEN 1) + endif() +endif() diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index 67e4aab..6144ddc 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -80,12 +80,13 @@ void cmCursesLongMessageForm::UpdateStatusBar() sprintf(version+sideSpace, "%s", vertmp); version[width] = '\0'; + char fmt_s[] = "%s"; curses_move(y-4,0); attron(A_STANDOUT); - printw(bar); + printw(fmt_s, bar); attroff(A_STANDOUT); curses_move(y-3,0); - printw(version); + printw(fmt_s, version); pos_form_cursor(this->Form); } @@ -101,8 +102,9 @@ void cmCursesLongMessageForm::PrintKeys() char firstLine[512]; sprintf(firstLine, "Press [e] to exit help"); + char fmt_s[] = "%s"; curses_move(y-2,0); - printw(firstLine); + printw(fmt_s, firstLine); pos_form_cursor(this->Form); } diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index be17a9f..a2fc2c0 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -451,24 +451,25 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) } curses_move(y-4,0); + char fmt_s[] = "%s"; char fmt[512] = "Press [enter] to edit option"; if ( process ) { strcpy(fmt, " "); } - printw(fmt); + printw(fmt_s, fmt); curses_move(y-3,0); - printw(firstLine); + printw(fmt_s, firstLine); curses_move(y-2,0); - printw(secondLine); + printw(fmt_s, secondLine); curses_move(y-1,0); - printw(thirdLine); + printw(fmt_s, thirdLine); if (cw) { sprintf(firstLine, "Page %d of %d", cw->GetPage(), this->NumberOfPages); curses_move(0,65-static_cast<unsigned int>(strlen(firstLine))-1); - printw(firstLine); + printw(fmt_s, firstLine); } // } @@ -612,13 +613,13 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) version[width] = '\0'; // Now print both lines + char fmt_s[] = "%s"; curses_move(y-5,0); attron(A_STANDOUT); - char format[] = "%s"; - printw(format, bar); + printw(fmt_s, bar); attroff(A_STANDOUT); curses_move(y-4,0); - printw(version); + printw(fmt_s, version); pos_form_cursor(this->Form); } diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx index acf262f..6eb15c1 100644 --- a/Source/CursesDialog/cmCursesStringWidget.cxx +++ b/Source/CursesDialog/cmCursesStringWidget.cxx @@ -168,17 +168,16 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm, else if ( key == 127 || key == KEY_BACKSPACE ) { - if ( form->curcol > 0 ) - { + FIELD *cur = current_field(form); form_driver(form, REQ_DEL_PREV); - } + if (current_field(form) != cur) + { + set_current_field(form, cur); + } } else if ( key == ctrl('d') ||key == KEY_DC ) { - if ( form->curcol >= 0 ) - { - form_driver(form, REQ_DEL_CHAR); - } + form_driver(form, REQ_DEL_CHAR); } else { @@ -221,6 +220,7 @@ bool cmCursesStringWidget::PrintKeys() } if (this->InEdit) { + char fmt_s[] = "%s"; char firstLine[512]; // Clean the toolbar for(int i=0; i<512; i++) @@ -229,17 +229,16 @@ bool cmCursesStringWidget::PrintKeys() } firstLine[511] = '\0'; curses_move(y-4,0); - printw(firstLine); + printw(fmt_s, firstLine); curses_move(y-3,0); - printw(firstLine); + printw(fmt_s, firstLine); curses_move(y-2,0); - printw(firstLine); + printw(fmt_s, firstLine); curses_move(y-1,0); - printw(firstLine); + printw(fmt_s, firstLine); - sprintf(firstLine, "Editing option, press [enter] to leave edit."); curses_move(y-3,0); - printw(firstLine); + printw(fmt_s, "Editing option, press [enter] to leave edit."); return true; } else diff --git a/Source/CursesDialog/cmCursesWidget.cxx b/Source/CursesDialog/cmCursesWidget.cxx index e5363f4..a12e4c2 100644 --- a/Source/CursesDialog/cmCursesWidget.cxx +++ b/Source/CursesDialog/cmCursesWidget.cxx @@ -49,7 +49,7 @@ void cmCursesWidget::Move(int x, int y, bool isNewPage) void cmCursesWidget::SetValue(const std::string& value) { this->Value = value; - set_field_buffer(this->Field, 0, value.c_str()); + set_field_buffer(this->Field, 0, const_cast<char *>(value.c_str())); } const char* cmCursesWidget::GetValue() diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index ad6a7fb..66fd18b 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -78,9 +78,12 @@ if (Qt5Widgets_FOUND) endif() endif() - if(WIN32 AND TARGET Qt5::Core) + if(TARGET Qt5::Core) get_property(_Qt5_Core_LOCATION TARGET Qt5::Core PROPERTY LOCATION) get_filename_component(Qt_BIN_DIR "${_Qt5_Core_LOCATION}" PATH) + if(APPLE) + get_filename_component(Qt_BIN_DIR "${Qt_BIN_DIR}" PATH) + endif() endif() else() set(QT_MIN_VERSION "4.4.0") @@ -94,12 +97,6 @@ else() set(CMake_QT_LIBRARIES ${QT_LIBRARIES}) - if(WIN32 AND EXISTS "${QT_QMAKE_EXECUTABLE}") - get_filename_component(_Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH) - if(EXISTS "${_Qt_BIN_DIR}/QtCore4.dll") - set(Qt_BIN_DIR ${_Qt_BIN_DIR}) - endif() - endif() endif() set(SRCS @@ -155,11 +152,8 @@ endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) -add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS}) +add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS} ${MANIFEST_FILE}) target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${CMake_QT_LIBRARIES}) -if(Qt_BIN_DIR) - set_property(TARGET cmake-gui PROPERTY Qt_BIN_DIR ${Qt_BIN_DIR}) -endif() if(APPLE) file(STRINGS "${CMake_SOURCE_DIR}/Copyright.txt" copyright_line @@ -223,7 +217,7 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) install(CODE " include(\"${CMake_SOURCE_DIR}/Modules/BundleUtilities.cmake\") set(BU_CHMOD_BUNDLE_ITEMS ON) - fixup_bundle(\"${fixup_exe}\" \"${QT_PLUGINS}\" \"${QT_LIBRARY_DIR};${QT_BINARY_DIR}\") + fixup_bundle(\"${fixup_exe}\" \"${QT_PLUGINS}\" \"${Qt_BIN_DIR};${QT_LIBRARY_DIR};${QT_BINARY_DIR}\") " ${COMPONENT}) endif() diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx index 11e3f34..dc4db63 100644 --- a/Source/bindexplib.cxx +++ b/Source/bindexplib.cxx @@ -173,7 +173,7 @@ public: */ DumpSymbols(ObjectHeaderType* ih, - FILE* fout) { + FILE* fout, bool is64) { this->ObjectImageHeader = ih; this->SymbolTable = (SymbolTableType*) ((DWORD_PTR)this->ObjectImageHeader @@ -183,6 +183,7 @@ public: GetSectionHeaderOffset(this->ObjectImageHeader); this->ImportFlag = true; this->SymbolCount = this->ObjectImageHeader->NumberOfSymbols; + this->Is64Bit = is64; } /* @@ -287,7 +288,14 @@ public: symbol.erase(posAt); } } - if (symbol[0] == '_') symbol.erase(0,1); + // For 64 bit builds we don't need to remove _ + if(!this->Is64Bit) + { + if (symbol[0] == '_') + { + symbol.erase(0,1); + } + } if (this->ImportFlag) { this->ImportFlag = false; fprintf(this->FileOut,"EXPORTS \n"); @@ -355,6 +363,7 @@ private: PIMAGE_SECTION_HEADER SectionHeaders; ObjectHeaderType* ObjectImageHeader; SymbolTableType* SymbolTable; + bool Is64Bit; }; bool @@ -406,7 +415,8 @@ DumpFile(const char* filename, FILE *fout) * and IMAGE_FILE_HEADER.SizeOfOptionalHeader == 0; */ DumpSymbols<IMAGE_FILE_HEADER, IMAGE_SYMBOL> - symbolDumper((PIMAGE_FILE_HEADER) lpFileBase, fout); + symbolDumper((PIMAGE_FILE_HEADER) lpFileBase, fout, + (dosHeader->e_magic == IMAGE_FILE_MACHINE_AMD64)); symbolDumper.DumpObjFile(); } else { // check for /bigobj format @@ -414,7 +424,8 @@ DumpFile(const char* filename, FILE *fout) (cmANON_OBJECT_HEADER_BIGOBJ*) lpFileBase; if(h->Sig1 == 0x0 && h->Sig2 == 0xffff) { DumpSymbols<cmANON_OBJECT_HEADER_BIGOBJ, cmIMAGE_SYMBOL_EX> - symbolDumper((cmANON_OBJECT_HEADER_BIGOBJ*) lpFileBase, fout); + symbolDumper((cmANON_OBJECT_HEADER_BIGOBJ*) lpFileBase, fout, + (dosHeader->e_magic == IMAGE_FILE_MACHINE_AMD64)); symbolDumper.DumpObjFile(); } else { printf("unrecognized file format in '%s'\n", filename); diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index 3a74946..01e5253 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -10,7 +10,6 @@ See the License for more information. ============================================================================*/ #include "cmAddDependenciesCommand.h" -#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" // cmDependenciesCommand diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index d15fc1e..47f6592 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -174,8 +174,8 @@ bool cmAddExecutableCommand this->SetError(e.str()); return false; } - cmTarget::TargetType type = aliasedTarget->GetType(); - if(type != cmTarget::EXECUTABLE) + cmState::TargetType type = aliasedTarget->GetType(); + if(type != cmState::EXECUTABLE) { std::ostringstream e; e << "cannot create ALIAS target \"" << exename @@ -210,7 +210,7 @@ bool cmAddExecutableCommand } // Create the imported target. - this->Makefile->AddImportedTarget(exename, cmTarget::EXECUTABLE, + this->Makefile->AddImportedTarget(exename, cmState::EXECUTABLE, importGlobal); return true; } diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index a844cf1..e0adee3 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -25,10 +25,10 @@ bool cmAddLibraryCommand } // Library type defaults to value of BUILD_SHARED_LIBS, if it exists, // otherwise it defaults to static library. - cmTarget::TargetType type = cmTarget::SHARED_LIBRARY; + cmState::TargetType type = cmState::SHARED_LIBRARY; if (cmSystemTools::IsOff(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { - type = cmTarget::STATIC_LIBRARY; + type = cmState::STATIC_LIBRARY; } bool excludeFromAll = false; bool importTarget = false; @@ -50,7 +50,7 @@ bool cmAddLibraryCommand std::string libType = *s; if(libType == "STATIC") { - if (type == cmTarget::INTERFACE_LIBRARY) + if (type == cmState::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting STATIC type."; @@ -58,12 +58,12 @@ bool cmAddLibraryCommand return false; } ++s; - type = cmTarget::STATIC_LIBRARY; + type = cmState::STATIC_LIBRARY; haveSpecifiedType = true; } else if(libType == "SHARED") { - if (type == cmTarget::INTERFACE_LIBRARY) + if (type == cmState::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting SHARED type."; @@ -71,12 +71,12 @@ bool cmAddLibraryCommand return false; } ++s; - type = cmTarget::SHARED_LIBRARY; + type = cmState::SHARED_LIBRARY; haveSpecifiedType = true; } else if(libType == "MODULE") { - if (type == cmTarget::INTERFACE_LIBRARY) + if (type == cmState::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting MODULE type."; @@ -84,12 +84,12 @@ bool cmAddLibraryCommand return false; } ++s; - type = cmTarget::MODULE_LIBRARY; + type = cmState::MODULE_LIBRARY; haveSpecifiedType = true; } else if(libType == "OBJECT") { - if (type == cmTarget::INTERFACE_LIBRARY) + if (type == cmState::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting OBJECT type."; @@ -97,12 +97,12 @@ bool cmAddLibraryCommand return false; } ++s; - type = cmTarget::OBJECT_LIBRARY; + type = cmState::OBJECT_LIBRARY; haveSpecifiedType = true; } else if(libType == "UNKNOWN") { - if (type == cmTarget::INTERFACE_LIBRARY) + if (type == cmState::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting UNKNOWN type."; @@ -110,12 +110,12 @@ bool cmAddLibraryCommand return false; } ++s; - type = cmTarget::UNKNOWN_LIBRARY; + type = cmState::UNKNOWN_LIBRARY; haveSpecifiedType = true; } else if(libType == "ALIAS") { - if (type == cmTarget::INTERFACE_LIBRARY) + if (type == cmState::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting ALIAS type."; @@ -149,12 +149,12 @@ bool cmAddLibraryCommand return false; } ++s; - type = cmTarget::INTERFACE_LIBRARY; + type = cmState::INTERFACE_LIBRARY; haveSpecifiedType = true; } else if(*s == "EXCLUDE_FROM_ALL") { - if (type == cmTarget::INTERFACE_LIBRARY) + if (type == cmState::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL."; @@ -174,7 +174,7 @@ bool cmAddLibraryCommand ++s; importGlobal = true; } - else if(type == cmTarget::INTERFACE_LIBRARY && *s == "GLOBAL") + else if(type == cmState::INTERFACE_LIBRARY && *s == "GLOBAL") { std::ostringstream e; e << "GLOBAL option may only be used with IMPORTED libraries."; @@ -187,7 +187,7 @@ bool cmAddLibraryCommand } } - if (type == cmTarget::INTERFACE_LIBRARY) + if (type == cmState::INTERFACE_LIBRARY) { if (s != args.end()) { @@ -220,7 +220,7 @@ bool cmAddLibraryCommand switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) { case cmPolicies::WARN: - if(type != cmTarget::INTERFACE_LIBRARY) + if(type != cmState::INTERFACE_LIBRARY) { e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n"; issueMessage = true; @@ -293,12 +293,12 @@ bool cmAddLibraryCommand this->SetError(e.str()); return false; } - cmTarget::TargetType aliasedType = aliasedTarget->GetType(); - if(aliasedType != cmTarget::SHARED_LIBRARY - && aliasedType != cmTarget::STATIC_LIBRARY - && aliasedType != cmTarget::MODULE_LIBRARY - && aliasedType != cmTarget::OBJECT_LIBRARY - && aliasedType != cmTarget::INTERFACE_LIBRARY) + cmState::TargetType aliasedType = aliasedTarget->GetType(); + if(aliasedType != cmState::SHARED_LIBRARY + && aliasedType != cmState::STATIC_LIBRARY + && aliasedType != cmState::MODULE_LIBRARY + && aliasedType != cmState::OBJECT_LIBRARY + && aliasedType != cmState::INTERFACE_LIBRARY) { std::ostringstream e; e << "cannot create ALIAS target \"" << libName @@ -328,19 +328,19 @@ bool cmAddLibraryCommand CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to STATIC. But at this point we know only the name of the target, but not yet its linker language. */ - if ((type == cmTarget::SHARED_LIBRARY || - type == cmTarget::MODULE_LIBRARY) && + if ((type == cmState::SHARED_LIBRARY || + type == cmState::MODULE_LIBRARY) && (this->Makefile->GetState()->GetGlobalPropertyAsBool( "TARGET_SUPPORTS_SHARED_LIBS") == false)) { std::ostringstream w; w << "ADD_LIBRARY called with " << - (type==cmTarget::SHARED_LIBRARY ? "SHARED" : "MODULE") << + (type==cmState::SHARED_LIBRARY ? "SHARED" : "MODULE") << " option but the target platform does not support dynamic linking. " "Building a STATIC library instead. This may lead to problems."; this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - type = cmTarget::STATIC_LIBRARY; + type = cmState::STATIC_LIBRARY; } // Handle imported target creation. @@ -352,7 +352,7 @@ bool cmAddLibraryCommand this->SetError("called with IMPORTED argument but no library type."); return false; } - if(type == cmTarget::OBJECT_LIBRARY) + if(type == cmState::OBJECT_LIBRARY) { this->Makefile->IssueMessage( cmake::FATAL_ERROR, @@ -360,7 +360,7 @@ bool cmAddLibraryCommand ); return true; } - if(type == cmTarget::INTERFACE_LIBRARY) + if(type == cmState::INTERFACE_LIBRARY) { if (!cmGeneratorExpression::IsValidTargetName(libName)) { @@ -387,7 +387,7 @@ bool cmAddLibraryCommand } // A non-imported target may not have UNKNOWN type. - if(type == cmTarget::UNKNOWN_LIBRARY) + if(type == cmState::UNKNOWN_LIBRARY) { this->Makefile->IssueMessage( cmake::FATAL_ERROR, @@ -408,7 +408,7 @@ bool cmAddLibraryCommand std::vector<std::string> srclists; - if(type == cmTarget::INTERFACE_LIBRARY) + if(type == cmState::INTERFACE_LIBRARY) { if (!cmGeneratorExpression::IsValidTargetName(libName) || libName.find("::") != std::string::npos) diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index 62fafa5..64d4fca 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -11,7 +11,6 @@ ============================================================================*/ #include "cmBuildCommand.h" -#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" //---------------------------------------------------------------------- diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h index 8f8038f..47455f8 100644 --- a/Source/cmBuildNameCommand.h +++ b/Source/cmBuildNameCommand.h @@ -23,7 +23,6 @@ public: cmExecutionStatus &status); virtual std::string GetName() const {return "build_name";} virtual bool IsScriptable() const { return true; } - virtual bool IsDiscouraged() const { return true; } }; diff --git a/Source/cmCPackPropertiesGenerator.cxx b/Source/cmCPackPropertiesGenerator.cxx index cbcdd81..35b3d59 100644 --- a/Source/cmCPackPropertiesGenerator.cxx +++ b/Source/cmCPackPropertiesGenerator.cxx @@ -18,7 +18,7 @@ void cmCPackPropertiesGenerator::GenerateScriptForConfig(std::ostream& os, const std::string& config, Indent const& indent) { std::string const& expandedFileName = - this->InstalledFile.GetNameExpression().Evaluate(this->LG->GetMakefile(), + this->InstalledFile.GetNameExpression().Evaluate(this->LG, config); cmInstalledFile::PropertyMapType const& properties = @@ -38,7 +38,7 @@ void cmCPackPropertiesGenerator::GenerateScriptForConfig(std::ostream& os, j = property.ValueExpressions.begin(); j != property.ValueExpressions.end(); ++j) { - std::string value = (*j)->Evaluate(LG->GetMakefile(), config); + std::string value = (*j)->Evaluate(this->LG, config); os << " " << cmOutputConverter::EscapeForCMake(value); } diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 7da334e..fb78446 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -51,14 +51,14 @@ void CCONV cmSetError(void *info, const char *err) unsigned int CCONV cmGetCacheMajorVersion(void *arg) { cmMakefile *mf = static_cast<cmMakefile *>(arg); - cmCacheManager *manager = mf->GetCMakeInstance()->GetCacheManager(); - return manager->GetCacheMajorVersion(); + cmState *state = mf->GetState(); + return state->GetCacheMajorVersion(); } unsigned int CCONV cmGetCacheMinorVersion(void *arg) { cmMakefile *mf = static_cast<cmMakefile *>(arg); - cmCacheManager *manager = mf->GetCMakeInstance()->GetCacheManager(); - return manager->GetCacheMinorVersion(); + cmState *state = mf->GetState(); + return state->GetCacheMinorVersion(); } unsigned int CCONV cmGetMajorVersion(void *) @@ -116,7 +116,7 @@ const char* CCONV cmGetProjectName(void *arg) { cmMakefile *mf = static_cast<cmMakefile *>(arg); static std::string name; - name = mf->GetProjectName(); + name = mf->GetStateSnapshot().GetProjectName(); return name.c_str(); } @@ -373,13 +373,13 @@ void CCONV cmAddLinkLibraryForTarget(void *arg, const char *tgt, switch (libtype) { case CM_LIBRARY_GENERAL: - mf->AddLinkLibraryForTarget(tgt,value, cmTarget::GENERAL); + mf->AddLinkLibraryForTarget(tgt,value, GENERAL_LibraryType); break; case CM_LIBRARY_DEBUG: - mf->AddLinkLibraryForTarget(tgt,value, cmTarget::DEBUG); + mf->AddLinkLibraryForTarget(tgt,value, DEBUG_LibraryType); break; case CM_LIBRARY_OPTIMIZED: - mf->AddLinkLibraryForTarget(tgt,value, cmTarget::OPTIMIZED); + mf->AddLinkLibraryForTarget(tgt,value, OPTIMIZED_LibraryType); break; } } @@ -395,7 +395,7 @@ void CCONV cmAddLibrary(void *arg, const char *libname, int shared, srcs2.push_back(srcs[i]); } mf->AddLibrary(libname, - (shared? cmTarget::SHARED_LIBRARY : cmTarget::STATIC_LIBRARY), + (shared? cmState::SHARED_LIBRARY : cmState::STATIC_LIBRARY), srcs2); } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index b2ad4a8..f3e7121 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -14,7 +14,6 @@ #include "cmCTest.h" #include "cmake.h" #include "cmMakefile.h" -#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include <cmsys/Base64.h> #include <cmsys/Directory.hxx> @@ -518,9 +517,9 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cmake cm; cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); + cm.GetCurrentSnapshot().SetDefaultDefinitions(); cmGlobalGenerator gg(&cm); cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); - cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator(mf.get())); if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf.get()) ) { @@ -2165,7 +2164,46 @@ bool cmCTest::HandleCommandLineArguments(size_t &i, { this->OutputTestOutputOnTestFailure = true; } - + if (this->CheckArgument(arg, "--test-output-size-passed") && + i < args.size() - 1) + { + i++; + long outputSize; + if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize)) + { + if (cmCTestTestHandler *pCTestTestHandler = + static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"])) + { + pCTestTestHandler->SetTestOutputSizePassed(int(outputSize)); + } + } + else + { + cmCTestLog(this, WARNING, + "Invalid value for '--test-output-size-passed': " << + args[i] << "\n"); + } + } + if (this->CheckArgument(arg, "--test-output-size-failed") && + i < args.size() - 1) + { + i++; + long outputSize; + if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize)) + { + if (cmCTestTestHandler *pCTestTestHandler = + static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"])) + { + pCTestTestHandler->SetTestOutputSizeFailed(int(outputSize)); + } + } + else + { + cmCTestLog(this, WARNING, + "Invalid value for '--test-output-size-failed': " << + args[i] << "\n"); + } + } if(this->CheckArgument(arg, "-N", "--show-only")) { this->ShowOnly = true; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 54209c5..ce8af55 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -13,7 +13,6 @@ #include "cmCacheManager.h" #include "cmSystemTools.h" #include "cmGeneratedFileStream.h" -#include "cmMakefile.h" #include "cmake.h" #include "cmVersion.h" @@ -22,101 +21,10 @@ #include <cmsys/FStream.hxx> #include <cmsys/RegularExpression.hxx> -cmCacheManager::cmCacheManager(cmake* cm) +cmCacheManager::cmCacheManager() { this->CacheMajorVersion = 0; this->CacheMinorVersion = 0; - this->CMakeInstance = cm; -} - -bool cmCacheManager::LoadCache(const std::string& path) -{ - std::set<std::string> emptySet; - return this->LoadCache(path, true, emptySet, emptySet); -} - -static bool ParseEntryWithoutType(const std::string& entry, - std::string& var, - std::string& value) -{ - // input line is: key=value - static cmsys::RegularExpression reg( - "^([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); - // input line is: "key"=value - static cmsys::RegularExpression regQuoted( - "^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); - bool flag = false; - if(regQuoted.find(entry)) - { - var = regQuoted.match(1); - value = regQuoted.match(2); - flag = true; - } - else if (reg.find(entry)) - { - var = reg.match(1); - value = reg.match(2); - flag = true; - } - - // if value is enclosed in single quotes ('foo') then remove them - // it is used to enclose trailing space or tab - if (flag && - value.size() >= 2 && - value[0] == '\'' && - value[value.size() - 1] == '\'') - { - value = value.substr(1, - value.size() - 2); - } - - return flag; -} - -bool cmCacheManager::ParseEntry(const std::string& entry, - std::string& var, - std::string& value, - cmState::CacheEntryType& type) -{ - // input line is: key:type=value - static cmsys::RegularExpression reg( - "^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); - // input line is: "key":type=value - static cmsys::RegularExpression regQuoted( - "^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); - bool flag = false; - if(regQuoted.find(entry)) - { - var = regQuoted.match(1); - type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str()); - value = regQuoted.match(3); - flag = true; - } - else if (reg.find(entry)) - { - var = reg.match(1); - type = cmState::StringToCacheEntryType(reg.match(2).c_str()); - value = reg.match(3); - flag = true; - } - - // if value is enclosed in single quotes ('foo') then remove them - // it is used to enclose trailing space or tab - if (flag && - value.size() >= 2 && - value[0] == '\'' && - value[value.size() - 1] == '\'') - { - value = value.substr(1, - value.size() - 2); - } - - if (!flag) - { - return ParseEntryWithoutType(entry, var, value); - } - - return flag; } void cmCacheManager::CleanCMakeFiles(const std::string& path) @@ -195,7 +103,7 @@ bool cmCacheManager::LoadCache(const std::string& path, } } e.SetProperty("HELPSTRING", helpString.c_str()); - if(cmCacheManager::ParseEntry(realbuffer, entryKey, e.Value, e.Type)) + if(cmState::ParseCacheEntry(realbuffer, entryKey, e.Value, e.Type)) { if ( excludes.find(entryKey) == excludes.end() ) { @@ -678,7 +586,6 @@ void cmCacheManager::AddCacheEntry(const std::string& key, } e.SetProperty("HELPSTRING", helpString? helpString : "(This variable does not exist and should not be used)"); - this->CMakeInstance->UnwatchUnusedCli(key); } bool cmCacheManager::CacheIterator::IsAtEnd() const diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 8462259..6f063eb 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -16,9 +16,7 @@ #include "cmPropertyMap.h" #include "cmState.h" -class cmMakefile; class cmMarkAsAdvancedCommand; -class cmake; /** \class cmCacheManager * \brief Control class for cmake's cache @@ -29,7 +27,7 @@ class cmake; class cmCacheManager { public: - cmCacheManager(cmake* cm); + cmCacheManager(); class CacheIterator; friend class cmCacheManager::CacheIterator; @@ -100,7 +98,6 @@ public: } ///! Load a cache for given makefile. Loads from path/CMakeCache.txt. - bool LoadCache(const std::string& path); bool LoadCache(const std::string& path, bool internal, std::set<std::string>& excludes, std::set<std::string>& includes); @@ -124,12 +121,6 @@ public: int GetSize() { return static_cast<int>(this->Cache.size()); } - ///! Break up a line like VAR:type="value" into var, type and value - static bool ParseEntry(const std::string& entry, - std::string& var, - std::string& value, - cmState::CacheEntryType& type); - ///! Get a value from the cache given a key const char* GetInitializedCacheValue(const std::string& key) const; @@ -241,7 +232,7 @@ private: void WritePropertyEntries(std::ostream& os, CacheIterator const& i); CacheEntryMap Cache; - // Only cmake and cmMakefile should be able to add cache values + // Only cmake and cmState should be able to add cache values // the commands should never use the cmCacheManager directly friend class cmState; // allow access to add cache values friend class cmake; // allow access to add cache values diff --git a/Source/cmCommand.h b/Source/cmCommand.h index 0548c6b..59bc396 100644 --- a/Source/cmCommand.h +++ b/Source/cmCommand.h @@ -102,15 +102,6 @@ public: } /** - * This determines if usage of the method is discouraged or not. - * This is currently only used for generating the documentation. - */ - virtual bool IsDiscouraged() const - { - return false; - } - - /** * This is used to avoid including this command * in documentation. This is mainly used by * cmMacroHelperCommand and cmFunctionHelperCommand diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 4840e89..6920faf 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -109,7 +109,7 @@ std::string cmCommonTargetGenerator::ComputeFortranModuleDirectory() const { std::string mod_dir; const char* target_mod_dir = - this->Target->GetProperty("Fortran_MODULE_DIRECTORY"); + this->GeneratorTarget->GetProperty("Fortran_MODULE_DIRECTORY"); const char* moddir_flag = this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG"); if(target_mod_dir && moddir_flag) @@ -214,7 +214,7 @@ cmCommonTargetGenerator this->LocalGenerator->GetFortranFormat(srcfmt); if(format == cmLocalGenerator::FortranFormatNone) { - const char* tgtfmt = this->Target->GetProperty("Fortran_FORMAT"); + const char* tgtfmt = this->GeneratorTarget->GetProperty("Fortran_FORMAT"); format = this->LocalGenerator->GetFortranFormat(tgtfmt); } const char* var = 0; @@ -265,7 +265,7 @@ std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) for(std::vector<std::string>::iterator i = includes.begin(); i != includes.end(); ++i) { - if(this->Target->NameResolvesToFramework(*i)) + if(this->GlobalGenerator->NameResolvesToFramework(*i)) { std::string frameworkDir = *i; frameworkDir += "/../"; @@ -316,10 +316,11 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string &l) this->AddFortranFlags(flags); } - this->LocalGenerator->AddCMP0018Flags(flags, this->Target, + this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, lang, this->ConfigName); - this->LocalGenerator->AddVisibilityPresetFlags(flags, this->Target, + this->LocalGenerator->AddVisibilityPresetFlags(flags, + this->GeneratorTarget, lang); // Append old-style preprocessor definition flags. @@ -331,7 +332,7 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string &l) AppendFlags(flags,this->GetFrameworkFlags(l)); // Add target-specific flags. - this->LocalGenerator->AddCompileOptions(flags, this->Target, + this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, lang, this->ConfigName); ByLanguageMap::value_type entry(l, flags); @@ -348,13 +349,14 @@ std::string cmCommonTargetGenerator::GetDefines(const std::string &l) std::set<std::string> defines; const char *lang = l.c_str(); // Add the export symbol definition for shared library objects. - if(const char* exportMacro = this->Target->GetExportMacro()) + if(const char* exportMacro = + this->GeneratorTarget->GetExportMacro()) { this->LocalGenerator->AppendDefines(defines, exportMacro); } // Add preprocessor definitions for this target and configuration. - this->LocalGenerator->AddCompileDefinitions(defines, this->Target, + this->LocalGenerator->AddCompileDefinitions(defines, this->GeneratorTarget, this->LocalGenerator->GetConfigName(), l); std::string definesString; @@ -383,7 +385,7 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories() const { std::vector<std::string> dirs; - std::set<cmTarget const*> emitted; + std::set<cmGeneratorTarget const*> emitted; if (cmComputeLinkInformation* cli = this->GeneratorTarget->GetLinkInformation(this->ConfigName)) { @@ -391,24 +393,38 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const for(cmComputeLinkInformation::ItemVector::const_iterator i = items.begin(); i != items.end(); ++i) { - cmTarget const* linkee = i->Target; + cmGeneratorTarget const* linkee = i->Target; if(linkee && !linkee->IsImported() // We can ignore the INTERFACE_LIBRARY items because // Target->GetLinkInformation already processed their // link interface and they don't have any output themselves. - && linkee->GetType() != cmTarget::INTERFACE_LIBRARY + && linkee->GetType() != cmState::INTERFACE_LIBRARY && emitted.insert(linkee).second) { - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(linkee); - cmLocalGenerator* lg = gt->GetLocalGenerator(); - cmMakefile* mf = linkee->GetMakefile(); - std::string di = mf->GetCurrentBinaryDirectory(); + cmLocalGenerator* lg = linkee->GetLocalGenerator(); + std::string di = lg->GetCurrentBinaryDirectory(); di += "/"; - di += lg->GetTargetDirectory(*linkee); + di += lg->GetTargetDirectory(linkee); dirs.push_back(di); } } } return dirs; } + +std::string cmCommonTargetGenerator::GetManifests() +{ + std::vector<cmSourceFile const*> manifest_srcs; + this->GeneratorTarget->GetManifests(manifest_srcs, this->ConfigName); + + std::vector<std::string> manifests; + for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin(); + mi != manifest_srcs.end(); ++mi) + { + manifests.push_back(this->Convert((*mi)->GetFullPath(), + this->WorkingDirectory, + cmOutputConverter::SHELL)); + } + + return cmJoin(manifests, " "); +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 0a49e12..a4b2c10 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -88,6 +88,7 @@ protected: ByLanguageMap DefinesByLanguage; std::string GetIncludes(std::string const& l); ByLanguageMap IncludesByLanguage; + std::string GetManifests(); std::vector<std::string> GetLinkedTargetDirectories() const; }; diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 1b5c9f4..13098ad 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -185,7 +185,9 @@ cmComputeLinkDepends // The configuration being linked. this->HasConfig = !config.empty(); this->Config = (this->HasConfig)? config : std::string(); - this->LinkType = this->Target->Target->ComputeLinkType(this->Config); + std::vector<std::string> debugConfigs = + this->Makefile->GetCMakeInstance()->GetDebugConfigs(); + this->LinkType = CMP0003_ComputeLinkType(this->Config, debugConfigs); // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); @@ -268,9 +270,9 @@ cmComputeLinkDepends::Compute() { int i = *li; LinkEntry const& e = this->EntryList[i]; - cmTarget const* t = e.Target; + cmGeneratorTarget const* t = e.Target; // Entries that we know the linker will re-use do not need to be repeated. - bool uniquify = t && t->GetType() == cmTarget::SHARED_LIBRARY; + bool uniquify = t && t->GetType() == cmState::SHARED_LIBRARY; if(!uniquify || emmitted.insert(i).second) { this->FinalLinkEntries.push_back(e); @@ -362,14 +364,12 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) // Follow the item's dependencies. if(entry.Target) { - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(entry.Target); // Follow the target dependencies. if(cmLinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->Target->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target)) { const bool isIface = - entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; + entry.Target->GetType() == cmState::INTERFACE_LIBRARY; // This target provides its own link interface information. this->AddLinkEntries(depender_index, iface->Libraries); @@ -463,10 +463,8 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) // Target items may have their own dependencies. if(entry.Target) { - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(entry.Target); if(cmLinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->Target->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -486,24 +484,24 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, // Look for entries meant for this configuration. std::vector<cmLinkItem> actual_libs; - cmTarget::LinkLibraryType llt = cmTarget::GENERAL; + cmTargetLinkLibraryType llt = GENERAL_LibraryType; bool haveLLT = false; for(std::vector<std::string>::const_iterator di = deplist.begin(); di != deplist.end(); ++di) { if(*di == "debug") { - llt = cmTarget::DEBUG; + llt = DEBUG_LibraryType; haveLLT = true; } else if(*di == "optimized") { - llt = cmTarget::OPTIMIZED; + llt = OPTIMIZED_LibraryType; haveLLT = true; } else if(*di == "general") { - llt = cmTarget::GENERAL; + llt = GENERAL_LibraryType; haveLLT = true; } else if(!di->empty()) @@ -521,17 +519,17 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, { if(strcmp(val, "debug") == 0) { - llt = cmTarget::DEBUG; + llt = DEBUG_LibraryType; } else if(strcmp(val, "optimized") == 0) { - llt = cmTarget::OPTIMIZED; + llt = OPTIMIZED_LibraryType; } } } // If the library is meant for this link type then use it. - if(llt == cmTarget::GENERAL || llt == this->LinkType) + if(llt == GENERAL_LibraryType || llt == this->LinkType) { cmLinkItem item(*di, this->FindTargetToLink(depender_index, *di)); actual_libs.push_back(item); @@ -543,7 +541,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, } // Reset the link type until another explicit type is given. - llt = cmTarget::GENERAL; + llt = GENERAL_LibraryType; haveLLT = false; } } @@ -635,14 +633,16 @@ cmComputeLinkDepends::AddLinkEntries( } //---------------------------------------------------------------------------- -cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, - const std::string& name) +cmGeneratorTarget const* +cmComputeLinkDepends::FindTargetToLink(int depender_index, + const std::string& name) { // Look for a target in the scope of the depender. - cmTarget const* from = this->Target->Target; + cmGeneratorTarget const* from = this->Target; if(depender_index >= 0) { - if(cmTarget const* depender = this->EntryList[depender_index].Target) + if(cmGeneratorTarget const* depender = + this->EntryList[depender_index].Target) { from = depender; } @@ -934,12 +934,10 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) int count = 2; for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - if(cmTarget const* target = this->EntryList[*ni].Target) + if(cmGeneratorTarget const* target = this->EntryList[*ni].Target) { - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(target); if(cmLinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->Target->Target)) + target->GetLinkInterface(this->Config, this->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 2cbb430..889fb08 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -14,6 +14,7 @@ #include "cmStandardIncludes.h" #include "cmTarget.h" +#include "cmLinkItem.h" #include "cmGraphAdjacencyList.h" @@ -23,7 +24,6 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; class cmGeneratorTarget; -class cmTarget; class cmake; /** \class cmComputeLinkDepends @@ -40,7 +40,7 @@ public: struct LinkEntry { std::string Item; - cmTarget const* Target; + cmGeneratorTarget const* Target; bool IsSharedDep; bool IsFlag; LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {} @@ -53,7 +53,7 @@ public: EntryVector const& Compute(); void SetOldLinkDirMode(bool b); - std::set<cmTarget const*> const& GetOldWrongConfigItems() const + std::set<cmGeneratorTarget const*> const& GetOldWrongConfigItems() const { return this->OldWrongConfigItems; } private: @@ -66,8 +66,6 @@ private: std::string Config; EntryVector FinalLinkEntries; - typedef cmTarget::LinkLibraryVectorType LinkLibraryVectorType; - std::map<std::string, int>::iterator AllocateLinkEntry(std::string const& item); int AddLinkEntry(cmLinkItem const& item); @@ -75,8 +73,8 @@ private: void AddDirectLinkEntries(); template <typename T> void AddLinkEntries(int depender_index, std::vector<T> const& libs); - cmTarget const* FindTargetToLink(int depender_index, - const std::string& name); + cmGeneratorTarget const* FindTargetToLink(int depender_index, + const std::string& name); // One entry for each unique item. std::vector<LinkEntry> EntryList; @@ -153,11 +151,11 @@ private: // Record of the original link line. std::vector<int> OriginalEntries; - std::set<cmTarget const*> OldWrongConfigItems; + std::set<cmGeneratorTarget const*> OldWrongConfigItems; void CheckWrongConfigItem(cmLinkItem const& item); int ComponentOrderId; - cmTarget::LinkLibraryType LinkType; + cmTargetLinkLibraryType LinkType; bool HasConfig; bool DebugMode; bool OldLinkDirMode; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index d35b566..a32bb48 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -19,7 +19,6 @@ #include "cmState.h" #include "cmOutputConverter.h" #include "cmMakefile.h" -#include "cmTarget.h" #include "cmGeneratorTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -284,14 +283,14 @@ cmComputeLinkInformation // Check whether we should skip dependencies on shared library files. this->LinkDependsNoShared = - this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. this->LoaderFlag = 0; if(!this->UseImportLibrary && - this->Target->Target->GetType() == cmTarget::MODULE_LIBRARY) + this->Target->GetType() == cmState::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; @@ -309,10 +308,10 @@ cmComputeLinkInformation // Get options needed to specify RPATHs. this->RuntimeUseChrpath = false; - if(this->Target->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Target->GetType() != cmState::STATIC_LIBRARY) { const char* tType = - ((this->Target->Target->GetType() == cmTarget::EXECUTABLE)? + ((this->Target->GetType() == cmState::EXECUTABLE)? "EXECUTABLE" : "SHARED_LIBRARY"); std::string rtVar = "CMAKE_"; rtVar += tType; @@ -408,7 +407,7 @@ cmComputeLinkInformation // order to support such projects we need to add the directories // containing libraries linked with a full path to the -L path. this->OldLinkDirMode = - this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; + this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; if(this->OldLinkDirMode) { // Construct a mask to not bother with this behavior for link @@ -471,7 +470,7 @@ std::vector<std::string> const& cmComputeLinkInformation::GetFrameworkPaths() } //---------------------------------------------------------------------------- -std::set<cmTarget const*> const& +const std::set<const cmGeneratorTarget*>& cmComputeLinkInformation::GetSharedLibrariesLinked() { return this->SharedLibrariesLinked; @@ -481,10 +480,10 @@ cmComputeLinkInformation::GetSharedLibrariesLinked() bool cmComputeLinkInformation::Compute() { // Skip targets that do not link. - if(!(this->Target->GetType() == cmTarget::EXECUTABLE || - this->Target->GetType() == cmTarget::SHARED_LIBRARY || - this->Target->GetType() == cmTarget::MODULE_LIBRARY || - this->Target->GetType() == cmTarget::STATIC_LIBRARY)) + if(!(this->Target->GetType() == cmState::EXECUTABLE || + this->Target->GetType() == cmState::SHARED_LIBRARY || + this->Target->GetType() == cmState::MODULE_LIBRARY || + this->Target->GetType() == cmState::STATIC_LIBRARY)) { return false; } @@ -521,7 +520,7 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. const char* lss = - this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); + this->Target->GetProperty("LINK_SEARCH_END_STATIC"); if(cmSystemTools::IsOn(lss)) { this->SetCurrentLinkType(LinkStatic); @@ -537,16 +536,16 @@ bool cmComputeLinkInformation::Compute() // For CMake 2.4 bug-compatibility we need to consider the output // directories of targets linked in another configuration as link // directories. - std::set<cmTarget const*> const& wrongItems = cld.GetOldWrongConfigItems(); - for(std::set<cmTarget const*>::const_iterator i = wrongItems.begin(); - i != wrongItems.end(); ++i) + std::set<cmGeneratorTarget const*> const& wrongItems = + cld.GetOldWrongConfigItems(); + for(std::set<cmGeneratorTarget const*>::const_iterator i = + wrongItems.begin(); i != wrongItems.end(); ++i) { - cmTarget const* tgt = *i; - cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); + cmGeneratorTarget const* tgt = *i; bool implib = (this->UseImportLibrary && - (tgt->GetType() == cmTarget::SHARED_LIBRARY)); - std::string lib = gtgt->GetFullPath(this->Config , implib, true); + (tgt->GetType() == cmState::SHARED_LIBRARY)); + std::string lib = tgt->GetFullPath(this->Config , implib, true); this->OldLinkDirItems.push_back(lib); } } @@ -572,7 +571,7 @@ bool cmComputeLinkInformation::Compute() "name." ; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } return true; @@ -632,7 +631,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddItem(std::string const& item, - cmTarget const* tgt) + cmGeneratorTarget const* tgt) { // Compute the proper name to use to link this library. const std::string& config = this->Config; @@ -646,7 +645,6 @@ void cmComputeLinkInformation::AddItem(std::string const& item, if(tgt && tgt->IsLinkable()) { - cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); // This is a CMake target. Ask the target for its real name. if(impexe && this->LoaderFlag) { @@ -656,13 +654,13 @@ void cmComputeLinkInformation::AddItem(std::string const& item, std::string linkItem; linkItem = this->LoaderFlag; - std::string exe = gtgt->GetFullPath(config, this->UseImportLibrary, + std::string exe = tgt->GetFullPath(config, this->UseImportLibrary, true); linkItem += exe; this->Items.push_back(Item(linkItem, true, tgt)); this->Depends.push_back(exe); } - else if(tgt->GetType() == cmTarget::INTERFACE_LIBRARY) + else if(tgt->GetType() == cmState::INTERFACE_LIBRARY) { // Add the interface library as an item so it can be considered as part // of COMPATIBLE_INTERFACE_ enforcement. The generators will ignore @@ -674,12 +672,12 @@ void cmComputeLinkInformation::AddItem(std::string const& item, // Decide whether to use an import library. bool implib = (this->UseImportLibrary && - (impexe || tgt->GetType() == cmTarget::SHARED_LIBRARY)); + (impexe || tgt->GetType() == cmState::SHARED_LIBRARY)); // Pass the full path to the target file. - std::string lib = gtgt->GetFullPath(config, implib, true); + std::string lib = tgt->GetFullPath(config, implib, true); if(!this->LinkDependsNoShared || - tgt->GetType() != cmTarget::SHARED_LIBRARY) + tgt->GetType() != cmState::SHARED_LIBRARY) { this->Depends.push_back(lib); } @@ -716,7 +714,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, - cmTarget const* tgt) + const cmGeneratorTarget* tgt) { // If dropping shared library dependencies, ignore them. if(this->SharedDependencyMode == SharedDepModeNone) @@ -730,7 +728,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, { // The target will provide a full path. Make sure it is a shared // library. - if(tgt->GetType() != cmTarget::SHARED_LIBRARY) + if(tgt->GetType() != cmState::SHARED_LIBRARY) { return; } @@ -760,17 +758,13 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } - cmGeneratorTarget *gtgt = 0; - // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being // linked will be able to find it. std::string lib; if(tgt) { - gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); - - lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary); + lib = tgt->GetFullPath(this->Config, this->UseImportLibrary); this->AddLibraryRuntimeInfo(lib, tgt); } else @@ -795,9 +789,9 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, } if(order) { - if(gtgt) + if(tgt) { - std::string soName = gtgt->GetSOName(this->Config); + std::string soName = tgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); order->AddRuntimeLibrary(lib, soname); } @@ -824,9 +818,9 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* target_type_str = 0; switch(this->Target->GetType()) { - case cmTarget::EXECUTABLE: target_type_str = "EXE"; break; - case cmTarget::SHARED_LIBRARY: target_type_str = "SHARED_LIBRARY"; break; - case cmTarget::MODULE_LIBRARY: target_type_str = "SHARED_MODULE"; break; + case cmState::EXECUTABLE: target_type_str = "EXE"; break; + case cmState::SHARED_LIBRARY: target_type_str = "SHARED_LIBRARY"; break; + case cmState::MODULE_LIBRARY: target_type_str = "SHARED_MODULE"; break; default: break; } if(target_type_str) @@ -860,7 +854,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() // Lookup the starting link type from the target (linked statically?). const char* lss = - this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); + this->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } @@ -1082,7 +1076,7 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt) //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddTargetItem(std::string const& item, - cmTarget const* target) + cmGeneratorTarget const* target) { // This is called to handle a link item that is a full path to a target. // If the target is not a static library make sure the link type is @@ -1090,13 +1084,13 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item, // shared and static libraries but static-mode can handle only // static libraries. If a previous user item changed the link type // to static we need to make sure it is back to shared. - if(target->GetType() != cmTarget::STATIC_LIBRARY) + if(target->GetType() != cmState::STATIC_LIBRARY) { this->SetCurrentLinkType(LinkShared); } // Keep track of shared library targets linked. - if(target->GetType() == cmTarget::SHARED_LIBRARY) + if(target->GetType() == cmState::SHARED_LIBRARY) { this->SharedLibrariesLinked.insert(target); } @@ -1146,7 +1140,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. std::string generator = this->GlobalGenerator->GetName(); - if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && (generator.find("Visual Studio") != generator.npos || generator.find("Xcode") != generator.npos)) { @@ -1227,7 +1221,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) } // Check the policy for whether we should use the approach below. - switch (this->Target->Target->GetPolicyStatusCMP0060()) + switch (this->Target->GetPolicyStatusCMP0060()) { case cmPolicies::WARN: if (this->CMP0060Warn) @@ -1537,7 +1531,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, this->OrderLinkerSearchPath->AddLinkLibrary(item); // Produce any needed message. - switch(this->Target->Target->GetPolicyStatusCMP0008()) + switch(this->Target->GetPolicyStatusCMP0008()) { case cmPolicies::WARN: { @@ -1554,7 +1548,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } } case cmPolicies::OLD: @@ -1572,7 +1566,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } break; } @@ -1589,7 +1583,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() } // Enforce policy constraints. - switch(this->Target->Target->GetPolicyStatusCMP0003()) + switch(this->Target->GetPolicyStatusCMP0003()) { case cmPolicies::WARN: if(!this->CMakeInstance->GetState() @@ -1600,7 +1594,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() std::ostringstream w; this->PrintLinkPolicyDiagnosis(w); this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } case cmPolicies::OLD: // OLD behavior is to add the paths containing libraries with @@ -1616,7 +1610,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; this->PrintLinkPolicyDiagnosis(e); this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); return false; } } @@ -1781,7 +1775,7 @@ cmComputeLinkInformation::GetRuntimeSearchPath() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, - cmTarget const* target) + cmGeneratorTarget const* target) { // Ignore targets on Apple where install_name is not @rpath. // The dependenty library can be found with other means such as @@ -1796,22 +1790,21 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, // Libraries with unknown type must be handled using just the file // on disk. - if(target->GetType() == cmTarget::UNKNOWN_LIBRARY) + if(target->GetType() == cmState::UNKNOWN_LIBRARY) { this->AddLibraryRuntimeInfo(fullPath); return; } // Skip targets that are not shared libraries (modules cannot be linked). - if(target->GetType() != cmTarget::SHARED_LIBRARY) + if(target->GetType() != cmState::SHARED_LIBRARY) { return; } // Try to get the soname of the library. Only files with this name // could possibly conflict. - cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(target); - std::string soName = gtgt->GetSOName(this->Config); + std::string soName = target->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); // Include this library in the runtime path ordering. @@ -1918,9 +1911,9 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, // build tree. bool linking_for_install = (for_install || - this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); + this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); bool use_install_rpath = - (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && + (outputRuntime && this->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && @@ -1928,14 +1921,14 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, bool use_link_rpath = outputRuntime && linking_for_install && !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && - this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::set<std::string> emitted; if(use_install_rpath) { const char* install_rpath = - this->Target->Target->GetProperty("INSTALL_RPATH"); + this->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) @@ -1975,8 +1968,9 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, else if(use_link_rpath) { // Do not add any path inside the source or build tree. - const char* topSourceDir = this->Makefile->GetHomeDirectory(); - const char* topBinaryDir = this->Makefile->GetHomeOutputDirectory(); + const char* topSourceDir = this->CMakeInstance->GetHomeDirectory(); + const char* topBinaryDir = + this->CMakeInstance->GetHomeOutputDirectory(); if(!cmSystemTools::ComparePath(*ri, topSourceDir) && !cmSystemTools::ComparePath(*ri, topBinaryDir) && !cmSystemTools::IsSubDirectory(*ri, topSourceDir) && diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 8b83574..5eecf7d 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -19,7 +19,6 @@ class cmake; class cmGlobalGenerator; class cmMakefile; -class cmTarget; class cmGeneratorTarget; class cmOrderDirectories; @@ -39,11 +38,11 @@ public: Item(): Value(), IsPath(true), Target(0) {} Item(Item const& item): Value(item.Value), IsPath(item.IsPath), Target(item.Target) {} - Item(std::string const& v, bool p, cmTarget const* target = 0): + Item(std::string const& v, bool p, cmGeneratorTarget const* target = 0): Value(v), IsPath(p), Target(target) {} std::string Value; bool IsPath; - cmTarget const* Target; + cmGeneratorTarget const* Target; }; typedef std::vector<Item> ItemVector; ItemVector const& GetItems(); @@ -57,13 +56,13 @@ public: void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install); std::string GetRPathString(bool for_install); std::string GetChrpathString(); - std::set<cmTarget const*> const& GetSharedLibrariesLinked(); + std::set<cmGeneratorTarget const*> const& GetSharedLibrariesLinked(); std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; } std::string GetRPathLinkString(); private: - void AddItem(std::string const& item, cmTarget const* tgt); - void AddSharedDepItem(std::string const& item, cmTarget const* tgt); + void AddItem(std::string const& item, const cmGeneratorTarget* tgt); + void AddSharedDepItem(std::string const& item, cmGeneratorTarget const* tgt); // Output information. ItemVector Items; @@ -71,7 +70,7 @@ private: std::vector<std::string> Depends; std::vector<std::string> FrameworkPaths; std::vector<std::string> RuntimeSearchPath; - std::set<cmTarget const*> SharedLibrariesLinked; + std::set<cmGeneratorTarget const*> SharedLibrariesLinked; // Context information. cmGeneratorTarget const* Target; @@ -129,7 +128,7 @@ private: std::string NoCaseExpression(const char* str); // Handling of link items. - void AddTargetItem(std::string const& item, cmTarget const* target); + void AddTargetItem(std::string const& item, const cmGeneratorTarget* target); void AddFullItem(std::string const& item); bool CheckImplicitDirItem(std::string const& item); void AddUserItem(std::string const& item, bool pathNotKnown); @@ -183,7 +182,7 @@ private: bool CMP0060Warn; void AddLibraryRuntimeInfo(std::string const& fullPath, - cmTarget const* target); + const cmGeneratorTarget* target); void AddLibraryRuntimeInfo(std::string const& fullPath); }; diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 9e37c35..03f4fdd 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -207,7 +207,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) { // Get the depender. cmGeneratorTarget const* depender = this->Targets[depender_index]; - if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) + if (depender->GetType() == cmState::INTERFACE_LIBRARY) { return; } @@ -236,16 +236,16 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) std::string objLib = (*oi)->GetObjectLibrary(); if (!objLib.empty() && emitted.insert(objLib).second) { - if(depender->GetType() != cmTarget::EXECUTABLE && - depender->GetType() != cmTarget::STATIC_LIBRARY && - depender->GetType() != cmTarget::SHARED_LIBRARY && - depender->GetType() != cmTarget::MODULE_LIBRARY) + if(depender->GetType() != cmState::EXECUTABLE && + depender->GetType() != cmState::STATIC_LIBRARY && + depender->GetType() != cmState::SHARED_LIBRARY && + depender->GetType() != cmState::MODULE_LIBRARY) { this->GlobalGenerator->GetCMakeInstance() ->IssueMessage(cmake::FATAL_ERROR, "Only executables and non-OBJECT libraries may " "reference target objects.", - depender->Target->GetBacktrace()); + depender->GetBacktrace()); return; } const_cast<cmGeneratorTarget*>(depender)->Target->AddUtility(objLib); @@ -272,7 +272,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Loop over all utility dependencies. { - std::set<cmLinkItem> const& tutils = depender->Target->GetUtilityItems(); + std::set<cmLinkItem> const& tutils = depender->GetUtilityItems(); std::set<std::string> emitted; // A target should not depend on itself. emitted.insert(depender->GetName()); @@ -297,7 +297,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, cmGeneratorTarget const* depender = this->Targets[depender_index]; if(cmLinkInterface const* iface = dependee->GetLinkInterface(config, - depender->Target)) + depender)) { for(std::vector<cmLinkItem>::const_iterator lib = iface->Libraries.begin(); @@ -319,12 +319,12 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, std::set<std::string> &emitted) { cmGeneratorTarget const* depender = this->Targets[depender_index]; - cmTarget const* dependee = dependee_name.Target; + cmGeneratorTarget const* dependee = dependee_name.Target; // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable // within the project. if(dependee && - dependee->GetType() == cmTarget::EXECUTABLE && + dependee->GetType() == cmState::EXECUTABLE && !dependee->IsExecutableWithExports()) { dependee = 0; @@ -332,9 +332,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, if(dependee) { - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(dependee); - this->AddInterfaceDepends(depender_index, gt, "", emitted); + this->AddInterfaceDepends(depender_index, dependee, "", emitted); std::vector<std::string> configs; depender->Makefile->GetConfigurations(configs); for (std::vector<std::string>::const_iterator it = configs.begin(); @@ -342,7 +340,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, { // A target should not depend on itself. emitted.insert(depender->GetName()); - this->AddInterfaceDepends(depender_index, gt, *it, emitted); + this->AddInterfaceDepends(depender_index, dependee, *it, emitted); } } } @@ -356,15 +354,15 @@ void cmComputeTargetDepends::AddTargetDepend( cmGeneratorTarget const* depender = this->Targets[depender_index]; // Check the target's makefile first. - cmTarget const* dependee = dependee_name.Target; + cmGeneratorTarget const* dependee = dependee_name.Target; if(!dependee && !linking && - (depender->GetType() != cmTarget::GLOBAL_TARGET)) + (depender->GetType() != cmState::GLOBAL_TARGET)) { cmake::MessageType messageType = cmake::AUTHOR_WARNING; bool issueMessage = false; std::ostringstream e; - switch(depender->Target->GetPolicyStatusCMP0046()) + switch(depender->GetPolicyStatusCMP0046()) { case cmPolicies::WARN: e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0046) << "\n"; @@ -402,7 +400,7 @@ void cmComputeTargetDepends::AddTargetDepend( // name conflict between an external library and an executable // within the project. if(linking && dependee && - dependee->GetType() == cmTarget::EXECUTABLE && + dependee->GetType() == cmState::EXECUTABLE && !dependee->IsExecutableWithExports()) { dependee = 0; @@ -410,9 +408,7 @@ void cmComputeTargetDepends::AddTargetDepend( if(dependee) { - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(dependee); - this->AddTargetDepend(depender_index, gt, linking); + this->AddTargetDepend(depender_index, dependee, linking); } } @@ -421,20 +417,18 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, const cmGeneratorTarget* dependee, bool linking) { - if(dependee->Target->IsImported() || - dependee->GetType() == cmTarget::INTERFACE_LIBRARY) + if(dependee->IsImported() || + dependee->GetType() == cmState::INTERFACE_LIBRARY) { // Skip IMPORTED and INTERFACE targets but follow their utility // dependencies. - std::set<cmLinkItem> const& utils = dependee->Target->GetUtilityItems(); + std::set<cmLinkItem> const& utils = dependee->GetUtilityItems(); for(std::set<cmLinkItem>::const_iterator i = utils.begin(); i != utils.end(); ++i) { - if(cmTarget const* transitive_dependee = i->Target) + if(cmGeneratorTarget const* transitive_dependee = i->Target) { - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(transitive_dependee); - this->AddTargetDepend(depender_index, gt, false); + this->AddTargetDepend(depender_index, transitive_dependee, false); } } } @@ -529,7 +523,7 @@ cmComputeTargetDepends // Make sure the component is all STATIC_LIBRARY targets. for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - if(this->Targets[*ni]->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Targets[*ni]->GetType() != cmState::STATIC_LIBRARY) { this->ComplainAboutBadComponent(ccg, c); return false; @@ -560,7 +554,7 @@ cmComputeTargetDepends // Describe the depender. e << " \"" << depender->GetName() << "\" of type " - << cmTarget::GetTargetTypeName(depender->Target->GetType()) << "\n"; + << cmState::GetTargetTypeName(depender->GetType()) << "\n"; // List its dependencies that are inside the component. EdgeList const& nl = this->InitialGraph[i]; diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 7874803..5330acd 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -11,9 +11,14 @@ ============================================================================*/ #include "cmConditionEvaluator.h" +#include "cmOutputConverter.h" -cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile): +cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile, + const cmListFileContext &context, + const cmListFileBacktrace& bt): Makefile(makefile), + ExecutionContext(context), + Backtrace(bt), Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012)), Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054)), Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)), @@ -98,6 +103,25 @@ bool cmConditionEvaluator::IsTrue( errorString, status, true); } +cmListFileContext cmConditionEvaluator::GetConditionContext( + cmMakefile* mf, + const cmCommandContext& command, + const std::string& filePath) +{ + cmListFileContext context = + cmListFileContext::FromCommandContext( + command, + filePath); + + if(!mf->GetCMakeInstance()->GetIsInTryCompile()) + { + cmOutputConverter converter(mf->GetStateSnapshot()); + context.FilePath = converter.Convert(context.FilePath, + cmOutputConverter::HOME); + } + return context; +} + //========================================================================= const char* cmConditionEvaluator::GetDefinitionIfUnquoted( cmExpandedCommandArgument const& argument) const @@ -113,7 +137,8 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted( if(def && argument.WasQuoted() && this->Policy54Status == cmPolicies::WARN) { - if(!this->Makefile.HasCMP0054AlreadyBeenReported()) + if(!this->Makefile.HasCMP0054AlreadyBeenReported( + this->ExecutionContext)) { std::ostringstream e; e << (cmPolicies::GetPolicyWarning(cmPolicies::CMP0054)) << "\n"; @@ -122,7 +147,9 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted( "when the policy is set to NEW. " "Since the policy is not set the OLD behavior will be used."; - this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str()); + this->Makefile.GetCMakeInstance() + ->IssueMessage(cmake::AUTHOR_WARNING, e.str(), + this->Backtrace); } } @@ -159,7 +186,8 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword, if(isKeyword && argument.WasQuoted() && this->Policy54Status == cmPolicies::WARN) { - if(!this->Makefile.HasCMP0054AlreadyBeenReported()) + if(!this->Makefile.HasCMP0054AlreadyBeenReported( + this->ExecutionContext)) { std::ostringstream e; e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0054) << "\n"; @@ -168,7 +196,9 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword, "when the policy is set to NEW. " "Since the policy is not set the OLD behavior will be used."; - this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str()); + this->Makefile.GetCMakeInstance() + ->IssueMessage(cmake::AUTHOR_WARNING, e.str(), + this->Backtrace); } } diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h index c4e2d11..8600825 100644 --- a/Source/cmConditionEvaluator.h +++ b/Source/cmConditionEvaluator.h @@ -22,7 +22,9 @@ class cmConditionEvaluator public: typedef std::list<cmExpandedCommandArgument> cmArgumentList; - cmConditionEvaluator(cmMakefile& makefile); + cmConditionEvaluator(cmMakefile& makefile, + cmListFileContext const& context, + cmListFileBacktrace const& bt); // this is a shared function for both If and Else to determine if the // arguments were valid, and if so, was the response true. If there is @@ -31,6 +33,9 @@ public: std::string &errorString, cmake::MessageType &status); + static cmListFileContext GetConditionContext(cmMakefile* mf, + const cmCommandContext& command, std::string const& filePath); + private: // Filter the given variable definition based on policy CMP0054. const char* GetDefinitionIfUnquoted( @@ -91,6 +96,8 @@ private: cmake::MessageType &status); cmMakefile& Makefile; + cmListFileContext ExecutionContext; + cmListFileBacktrace Backtrace; cmPolicies::PolicyStatus Policy12Status; cmPolicies::PolicyStatus Policy54Status; cmPolicies::PolicyStatus Policy57Status; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 9411555..4a1f770 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -29,12 +29,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) const char* sourceDirectory = argv[2].c_str(); const char* projectName = 0; std::string targetName; - std::vector<std::string> cmakeFlags; + std::vector<std::string> cmakeFlags(1, "CMAKE_FLAGS"); // fake argv[0] std::vector<std::string> compileDefs; std::string outputVariable; std::string copyFile; std::string copyFileError; - std::vector<cmTarget const*> targets; + std::vector<std::string> targets; std::string libsToLink = " "; bool useOldLinkLibs = true; char targetNameBuf[64]; @@ -53,10 +53,6 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if(argv[i] == "CMAKE_FLAGS") { doing = DoingCMakeFlags; - // CMAKE_FLAGS is the first argument because we need an argv[0] that - // is not used, so it matches regular command line parsing which has - // the program name as arg 0 - cmakeFlags.push_back(argv[i]); } else if(argv[i] == "COMPILE_DEFINITIONS") { @@ -97,12 +93,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) { switch(tgt->GetType()) { - case cmTarget::SHARED_LIBRARY: - case cmTarget::STATIC_LIBRARY: - case cmTarget::INTERFACE_LIBRARY: - case cmTarget::UNKNOWN_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::STATIC_LIBRARY: + case cmState::INTERFACE_LIBRARY: + case cmState::UNKNOWN_LIBRARY: break; - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: if (tgt->IsExecutableWithExports()) { break; @@ -111,12 +107,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) this->Makefile->IssueMessage(cmake::FATAL_ERROR, "Only libraries may be used as try_compile or try_run IMPORTED " "LINK_LIBRARIES. Got " + std::string(tgt->GetName()) + " of " - "type " + tgt->GetTargetTypeName(tgt->GetType()) + "."); + "type " + cmState::GetTargetTypeName(tgt->GetType()) + "."); return -1; } if (tgt->IsImported()) { - targets.push_back(tgt); + targets.push_back(argv[i]); } } } @@ -379,9 +375,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if (!targets.empty()) { std::string fname = "/" + std::string(targetName) + "Targets.cmake"; - cmExportTryCompileFileGenerator tcfg(gg); + cmExportTryCompileFileGenerator tcfg(gg, targets, this->Makefile); tcfg.SetExportFile((this->BinaryDirectory + fname).c_str()); - tcfg.SetExports(targets); tcfg.SetConfig(this->Makefile->GetSafeDefinition( "CMAKE_TRY_COMPILE_CONFIGURATION")); @@ -481,6 +476,16 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) fprintf(fout, "set(CMAKE_LINK_SEARCH_END_STATIC \"%s\")\n", lssDef); } + /* Set the appropriate policy information for ENABLE_EXPORTS */ + fprintf(fout, "cmake_policy(SET CMP0065 %s)\n", + this->Makefile->GetPolicyStatus(cmPolicies::CMP0065) == + cmPolicies::NEW ? "NEW" : "OLD"); + if(const char *ee = this->Makefile->GetDefinition( + "CMAKE_ENABLE_EXPORTS")) + { + fprintf(fout, "set(CMAKE_ENABLE_EXPORTS %s)\n", ee); + } + /* Put the executable at a known location (for COPY_FILE). */ fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", this->BinaryDirectory.c_str()); diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 7f3b651..dc06678 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -43,15 +43,14 @@ std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const { std::string const& argv0 = this->CC.GetCommandLines()[c][0]; cmGeneratorTarget* target = - this->LG->GetMakefile()->FindGeneratorTargetToUse(argv0); - if(target && target->GetType() == cmTarget::EXECUTABLE && - (target->Target->IsImported() + this->LG->FindGeneratorTargetToUse(argv0); + if(target && target->GetType() == cmState::EXECUTABLE && + (target->IsImported() || !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"))) { return target->GetLocation(this->Config); } - return this->GE->Parse(argv0)->Evaluate(this->LG->GetMakefile(), - this->Config); + return this->GE->Parse(argv0)->Evaluate(this->LG, this->Config); } //---------------------------------------------------------------------------- @@ -92,7 +91,7 @@ cmCustomCommandGenerator for(unsigned int j=1;j < commandLine.size(); ++j) { std::string arg = - this->GE->Parse(commandLine[j])->Evaluate(this->LG->GetMakefile(), + this->GE->Parse(commandLine[j])->Evaluate(this->LG, this->Config); cmd += " "; if(this->OldStyle) @@ -101,7 +100,7 @@ cmCustomCommandGenerator } else { - cmOutputConverter converter(this->LG->GetMakefile()->GetStateSnapshot()); + cmOutputConverter converter(this->LG->GetStateSnapshot()); cmd += converter.EscapeForShell(arg, this->MakeVars); } } @@ -146,7 +145,7 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const = this->GE->Parse(*i); std::vector<std::string> result; cmSystemTools::ExpandListArgument( - cge->Evaluate(this->LG->GetMakefile(), this->Config), result); + cge->Evaluate(this->LG, this->Config), result); for (std::vector<std::string>::iterator it = result.begin(); it != result.end(); ++it) { diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 856dcd4..80f560f 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -160,7 +160,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, if (mod_dir.empty()) { mod_dir = - this->LocalGenerator->GetMakefile()->GetCurrentBinaryDirectory(); + this->LocalGenerator->GetCurrentBinaryDirectory(); } // Actually write dependencies to the streams. diff --git a/Source/cmEnableTestingCommand.cxx b/Source/cmEnableTestingCommand.cxx index aa41ef7..6a7fd46 100644 --- a/Source/cmEnableTestingCommand.cxx +++ b/Source/cmEnableTestingCommand.cxx @@ -10,7 +10,6 @@ See the License for more information. ============================================================================*/ #include "cmEnableTestingCommand.h" -#include "cmLocalGenerator.h" // we do this in the final pass so that we now the subdirs have all // been defined diff --git a/Source/cmExecProgramCommand.h b/Source/cmExecProgramCommand.h index 23d10f9..adefdf9 100644 --- a/Source/cmExecProgramCommand.h +++ b/Source/cmExecProgramCommand.h @@ -50,12 +50,6 @@ public: */ virtual bool IsScriptable() const { return true; } - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - cmTypeMacro(cmExecProgramCommand, cmCommand); private: static bool RunCommand(const char* command, std::string& output, diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index fed0dbc..23c11d7 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -18,13 +18,22 @@ //---------------------------------------------------------------------------- cmExportBuildFileGenerator::cmExportBuildFileGenerator() - : Backtrace() { - this->Makefile = 0; + this->LG = 0; this->ExportSet = 0; } //---------------------------------------------------------------------------- +void cmExportBuildFileGenerator::Compute(cmLocalGenerator* lg) +{ + this->LG = lg; + if (this->ExportSet) + { + this->ExportSet->Compute(lg); + } +} + +//---------------------------------------------------------------------------- bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) { std::vector<cmGeneratorTarget*> allTargets; @@ -37,11 +46,11 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei = targets.begin(); tei != targets.end(); ++tei) { - cmGeneratorTarget *te = this->Makefile + cmGeneratorTarget *te = this->LG ->FindGeneratorTargetToUse(*tei); - expectedTargets += sep + this->Namespace + te->Target->GetExportName(); + expectedTargets += sep + this->Namespace + te->GetExportName(); sep = " "; - if(this->ExportedTargets.insert(te->Target).second) + if(this->ExportedTargets.insert(te).second) { this->Exports.push_back(te); } @@ -49,11 +58,12 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) { std::ostringstream e; e << "given target \"" << te->GetName() << "\" more than once."; - this->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace); + this->LG->GetGlobalGenerator()->GetCMakeInstance() + ->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->LG->GetMakefile()->GetBacktrace()); return false; } - if (te->GetType() == cmTarget::INTERFACE_LIBRARY) + if (te->GetType() == cmState::INTERFACE_LIBRARY) { this->GenerateRequiredCMakeVersion(os, "3.0.0"); } @@ -70,45 +80,44 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei != this->Exports.end(); ++tei) { cmGeneratorTarget* gte = *tei; - cmTarget* te = gte->Target; - this->GenerateImportTargetCode(os, te); + this->GenerateImportTargetCode(os, gte); - te->AppendBuildInterfaceIncludes(); + gte->Target->AppendBuildInterfaceIncludes(); ImportPropertyMap properties; - this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", te, + this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_SOURCES", te, + this->PopulateInterfaceProperty("INTERFACE_SOURCES", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", te, + this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", te, + this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", te, + this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", te, + this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", - te, properties); + gte, properties); const bool newCMP0022Behavior = - te->GetPolicyStatusCMP0022() != cmPolicies::WARN - && te->GetPolicyStatusCMP0022() != cmPolicies::OLD; + gte->GetPolicyStatusCMP0022() != cmPolicies::WARN + && gte->GetPolicyStatusCMP0022() != cmPolicies::OLD; if (newCMP0022Behavior) { - this->PopulateInterfaceLinkLibrariesProperty(te, + this->PopulateInterfaceLinkLibrariesProperty(gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); } this->PopulateCompatibleInterfaceProperties(gte, properties); - this->GenerateInterfaceProperties(te, os, properties); + this->GenerateInterfaceProperties(gte, os, properties); } // Generate import file content for each configuration. @@ -140,14 +149,14 @@ cmExportBuildFileGenerator cmGeneratorTarget* target = *tei; ImportPropertyMap properties; - if (target->GetType() != cmTarget::INTERFACE_LIBRARY) + if (target->GetType() != cmState::INTERFACE_LIBRARY) { this->SetImportLocationProperty(config, suffix, target, properties); } if(!properties.empty()) { // Get the rest of the target details. - if (target->GetType() != cmTarget::INTERFACE_LIBRARY) + if (target->GetType() != cmState::INTERFACE_LIBRARY) { this->SetImportDetailProperties(config, suffix, target, @@ -165,7 +174,7 @@ cmExportBuildFileGenerator // properties); // Generate code in the export file. - this->GenerateImportPropertyCode(os, config, target->Target, + this->GenerateImportPropertyCode(os, config, target, properties); } } @@ -193,7 +202,7 @@ cmExportBuildFileGenerator std::string prop = "IMPORTED_LOCATION"; prop += suffix; std::string value; - if(target->Target->IsAppBundleOnApple()) + if(target->IsAppBundleOnApple()) { value = target->GetFullPath(config, false); } @@ -210,14 +219,14 @@ cmExportBuildFileGenerator // Add the import library for windows DLLs. if(dll_platform && - (target->GetType() == cmTarget::SHARED_LIBRARY || - target->Target->IsExecutableWithExports()) && + (target->GetType() == cmState::SHARED_LIBRARY || + target->IsExecutableWithExports()) && mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { std::string prop = "IMPORTED_IMPLIB"; prop += suffix; std::string value = target->GetFullPath(config, true); - target->Target->GetImplibGNUtoMS(value, value, + target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}"); properties[prop] = value; } @@ -226,14 +235,18 @@ cmExportBuildFileGenerator //---------------------------------------------------------------------------- void cmExportBuildFileGenerator::HandleMissingTarget( - std::string& link_libs, std::vector<std::string>& missingTargets, - cmMakefile* mf, cmTarget* depender, cmTarget* dependee) + std::string& link_libs, + std::vector<std::string>& missingTargets, + cmGeneratorTarget* depender, + cmGeneratorTarget* dependee) { // The target is not in the export. if(!this->AppendMode) { const std::string name = dependee->GetName(); - std::vector<std::string> namespaces = this->FindNamespaces(mf, name); + cmGlobalGenerator* gg = + dependee->GetLocalGenerator()->GetGlobalGenerator(); + std::vector<std::string> namespaces = this->FindNamespaces(gg, name); int targetOccurrences = (int)namespaces.size(); if (targetOccurrences == 1) @@ -268,7 +281,7 @@ void cmExportBuildFileGenerator tei = this->ExportSet->GetTargetExports()->begin(); tei != this->ExportSet->GetTargetExports()->end(); ++tei) { - targets.push_back((*tei)->Target->GetName()); + targets.push_back((*tei)->TargetName); } return; } @@ -278,10 +291,9 @@ void cmExportBuildFileGenerator //---------------------------------------------------------------------------- std::vector<std::string> cmExportBuildFileGenerator -::FindNamespaces(cmMakefile* mf, const std::string& name) +::FindNamespaces(cmGlobalGenerator* gg, const std::string& name) { std::vector<std::string> namespaces; - cmGlobalGenerator* gg = mf->GetGlobalGenerator(); std::map<std::string, cmExportBuildFileGenerator*>& exportSets = gg->GetBuildExportSets(); @@ -304,8 +316,8 @@ cmExportBuildFileGenerator //---------------------------------------------------------------------------- void cmExportBuildFileGenerator -::ComplainAboutMissingTarget(cmTarget* depender, - cmTarget* dependee, +::ComplainAboutMissingTarget(cmGeneratorTarget* depender, + cmGeneratorTarget* dependee, int occurrences) { if(cmSystemTools::GetErrorOccuredFlag()) @@ -328,8 +340,9 @@ cmExportBuildFileGenerator e << "If the required target is not easy to reference in this call, " << "consider using the APPEND option with multiple separate calls."; - this->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace); + this->LG->GetGlobalGenerator()->GetCMakeInstance() + ->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->LG->GetMakefile()->GetBacktrace()); } std::string diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index ff3d2e1..85aae2f 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -43,10 +43,7 @@ public: /** Set whether to append generated code to the output file. */ void SetAppendMode(bool append) { this->AppendMode = append; } - void SetMakefile(cmMakefile *mf) { - this->Makefile = mf; - this->Backtrace = this->Makefile->GetBacktrace(); - } + void Compute(cmLocalGenerator* lg); protected: // Implement virtual methods from the superclass. @@ -57,12 +54,11 @@ protected: std::vector<std::string> &missingTargets); virtual void HandleMissingTarget(std::string& link_libs, std::vector<std::string>& missingTargets, - cmMakefile* mf, - cmTarget* depender, - cmTarget* dependee); + cmGeneratorTarget* depender, + cmGeneratorTarget* dependee); - void ComplainAboutMissingTarget(cmTarget* depender, - cmTarget* dependee, + void ComplainAboutMissingTarget(cmGeneratorTarget* depender, + cmGeneratorTarget* dependee, int occurrences); /** Fill in properties indicating built file locations. */ @@ -75,13 +71,12 @@ protected: const std::string& config); std::vector<std::string> - FindNamespaces(cmMakefile* mf, const std::string& name); + FindNamespaces(cmGlobalGenerator* gg, const std::string& name); std::vector<std::string> Targets; cmExportSet *ExportSet; std::vector<cmGeneratorTarget*> Exports; - cmMakefile* Makefile; - cmListFileBacktrace Backtrace; + cmLocalGenerator* LG; }; #endif diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 96ea77b..4eec66a 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -11,7 +11,6 @@ ============================================================================*/ #include "cmExportCommand.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmGeneratedFileStream.h" #include "cmake.h" @@ -169,7 +168,7 @@ bool cmExportCommand if(cmTarget* target = gg->FindTarget(*currentTarget)) { - if(target->GetType() == cmTarget::OBJECT_LIBRARY) + if(target->GetType() == cmState::OBJECT_LIBRARY) { std::ostringstream e; e << "given OBJECT library \"" << *currentTarget @@ -177,7 +176,7 @@ bool cmExportCommand this->SetError(e.str()); return false; } - if (target->GetType() == cmTarget::UTILITY) + if (target->GetType() == cmState::UTILITY) { this->SetError("given custom target \"" + *currentTarget + "\" which may not be exported."); @@ -222,7 +221,7 @@ bool cmExportCommand { ebfg->SetTargets(targets); } - ebfg->SetMakefile(this->Makefile); + this->Makefile->AddExportBuildFileGenerator(ebfg); ebfg->SetExportOld(this->ExportOld.IsEnabled()); // Compute the set of configurations exported. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 9a7d73f..1a84625 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -18,7 +18,6 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSystemTools.h" -#include "cmTarget.h" #include "cmTargetExport.h" #include "cmVersion.h" #include "cmComputeLinkInformation.h" @@ -155,7 +154,7 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateInterfaceProperty( const std::string& propName, - cmTarget *target, + cmGeneratorTarget *target, ImportPropertyMap &properties) { const char *input = target->GetProperty(propName); @@ -169,7 +168,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty( void cmExportFileGenerator::PopulateInterfaceProperty( const std::string& propName, const std::string& outputName, - cmTarget *target, + cmGeneratorTarget *target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, std::vector<std::string> &missingTargets) @@ -206,7 +205,7 @@ void cmExportFileGenerator::GenerateRequiredCMakeVersion(std::ostream& os, //---------------------------------------------------------------------------- bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty( - cmTarget *target, + cmGeneratorTarget *target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, std::vector<std::string> &missingTargets) @@ -241,12 +240,14 @@ static bool isSubDirectory(const char* a, const char* b) //---------------------------------------------------------------------------- static bool checkInterfaceDirs(const std::string &prepro, - cmTarget *target, const std::string& prop) + cmGeneratorTarget *target, const std::string& prop) { const char* installDir = - target->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); - const char* topSourceDir = target->GetMakefile()->GetHomeDirectory(); - const char* topBinaryDir = target->GetMakefile()->GetHomeOutputDirectory(); + target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); + const char* topSourceDir = + target->GetLocalGenerator()->GetSourceDirectory(); + const char* topBinaryDir = + target->GetLocalGenerator()->GetBinaryDirectory(); std::vector<std::string> parts; cmGeneratorExpression::Split(prepro, parts); @@ -298,7 +299,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " << prop << " property contains relative path:\n" " \"" << *li << "\""; - target->GetMakefile()->IssueMessage(messageType, e.str()); + target->GetLocalGenerator()->IssueMessage(messageType, e.str()); } bool inBinary = isSubDirectory(li->c_str(), topBinaryDir); bool inSource = isSubDirectory(li->c_str(), topSourceDir); @@ -329,7 +330,7 @@ static bool checkInterfaceDirs(const std::string &prepro, "a subdirectory of the " << (inBinary ? "build" : "source") << " tree:\n \"" << (inBinary ? topBinaryDir : topSourceDir) << "\"" << std::endl; - target->GetMakefile()->IssueMessage(cmake::AUTHOR_WARNING, + target->GetLocalGenerator()->IssueMessage(cmake::AUTHOR_WARNING, s.str()); } case cmPolicies::OLD: @@ -352,7 +353,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " << prop << " property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the build directory."; - target->GetMakefile()->IssueMessage(messageType, e.str()); + target->GetLocalGenerator()->IssueMessage(messageType, e.str()); } if (!inSourceBuild) { @@ -361,7 +362,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " << prop << " property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the source directory."; - target->GetMakefile()->IssueMessage(messageType, e.str()); + target->GetLocalGenerator()->IssueMessage(messageType, e.str()); } } } @@ -396,11 +397,11 @@ void cmExportFileGenerator::PopulateSourcesInterface( ImportPropertyMap &properties, std::vector<std::string> &missingTargets) { - cmTarget *target = tei->Target; + cmGeneratorTarget* gt = tei->Target; assert(preprocessRule == cmGeneratorExpression::InstallInterface); const char *propName = "INTERFACE_SOURCES"; - const char *input = target->GetProperty(propName); + const char *input = gt->GetProperty(propName); if (!input) { @@ -418,10 +419,10 @@ void cmExportFileGenerator::PopulateSourcesInterface( true); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target, + this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets); - if (!checkInterfaceDirs(prepro, target, propName)) + if (!checkInterfaceDirs(prepro, gt, propName)) { return; } @@ -436,7 +437,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( ImportPropertyMap &properties, std::vector<std::string> &missingTargets) { - cmTarget *target = tei->Target; + cmGeneratorTarget *target = tei->Target; assert(preprocessRule == cmGeneratorExpression::InstallInterface); const char *propName = "INTERFACE_INCLUDE_DIRECTORIES"; @@ -450,12 +451,12 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( true); this->ReplaceInstallPrefix(dirs); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs); - std::string exportDirs = cge->Evaluate(target->GetMakefile(), "", + std::string exportDirs = cge->Evaluate(target->GetLocalGenerator(), "", false, target); if (cge->GetHadContextSensitiveCondition()) { - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); std::ostringstream e; e << "Target \"" << target->GetName() << "\" is installed with " "INCLUDES DESTINATION set to a context sensitive path. Paths which " @@ -500,7 +501,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateInterfaceProperty( const std::string& propName, - cmTarget *target, + cmGeneratorTarget* target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, std::vector<std::string> &missingTargets) @@ -511,8 +512,9 @@ void cmExportFileGenerator::PopulateInterfaceProperty( //---------------------------------------------------------------------------- -void getPropertyContents(cmTarget const* tgt, const std::string& prop, - std::set<std::string> &ifaceProperties) +void getPropertyContents(cmGeneratorTarget const* tgt, + const std::string& prop, + std::set<std::string> &ifaceProperties) { const char *p = tgt->GetProperty(prop); if (!p) @@ -571,31 +573,30 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( cmGeneratorTarget *gtarget, ImportPropertyMap &properties) { - cmTarget *target = gtarget->Target; this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", - target, properties); + gtarget, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", - target, properties); + gtarget, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN", - target, properties); + gtarget, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX", - target, properties); + gtarget, properties); std::set<std::string> ifaceProperties; - getPropertyContents(target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties); - getPropertyContents(target, "COMPATIBLE_INTERFACE_STRING", ifaceProperties); - getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MIN", + getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties); + getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_STRING", ifaceProperties); + getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_NUMBER_MIN", ifaceProperties); - getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MAX", + getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_NUMBER_MAX", ifaceProperties); - if (target->GetType() != cmTarget::INTERFACE_LIBRARY) + if (gtarget->GetType() != cmState::INTERFACE_LIBRARY) { getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); std::vector<std::string> configNames; - target->GetMakefile()->GetConfigurations(configNames); + gtarget->Target->GetMakefile()->GetConfigurations(configNames); for (std::vector<std::string>::const_iterator ci = configNames.begin(); ci != configNames.end(); ++ci) @@ -608,12 +609,13 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( it != ifaceProperties.end(); ++it) { this->PopulateInterfaceProperty("INTERFACE_" + *it, - target, properties); + gtarget, properties); } } //---------------------------------------------------------------------------- -void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* target, +void cmExportFileGenerator::GenerateInterfaceProperties( + const cmGeneratorTarget* target, std::ostream& os, const ImportPropertyMap &properties) { @@ -635,12 +637,12 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* target, //---------------------------------------------------------------------------- bool cmExportFileGenerator::AddTargetNamespace(std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector<std::string> &missingTargets) { - cmMakefile *mf = target->GetMakefile(); + cmLocalGenerator *lg = target->GetLocalGenerator(); - cmTarget *tgt = mf->FindTargetToUse(input); + cmGeneratorTarget *tgt = lg->FindGeneratorTargetToUse(input); if (!tgt) { return false; @@ -658,7 +660,7 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input, { std::string namespacedTarget; this->HandleMissingTarget(namespacedTarget, missingTargets, - mf, target, tgt); + target, tgt); if (!namespacedTarget.empty()) { input = namespacedTarget; @@ -671,7 +673,7 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input, void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector<std::string> &missingTargets, FreeTargetsReplace replace) { @@ -708,14 +710,12 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( void cmExportFileGenerator::ResolveTargetsInGeneratorExpression( std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector<std::string> &missingTargets) { std::string::size_type pos = 0; std::string::size_type lastPos = pos; - cmMakefile *mf = target->GetMakefile(); - while((pos = input.find("$<TARGET_PROPERTY:", lastPos)) != input.npos) { std::string::size_type nameStartPos = pos + @@ -776,7 +776,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression( if (!errorString.empty()) { - mf->IssueMessage(cmake::FATAL_ERROR, errorString); + target->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, errorString); } } @@ -797,7 +797,7 @@ cmExportFileGenerator { // Add the transitive link dependencies for this configuration. cmLinkInterface const* iface = target->GetLinkInterface(config, - target->Target); + target); if (!iface) { return; @@ -830,10 +830,8 @@ cmExportFileGenerator } const bool newCMP0022Behavior = - target->Target - ->GetPolicyStatusCMP0022() != cmPolicies::WARN - && target->Target - ->GetPolicyStatusCMP0022() != cmPolicies::OLD; + target->GetPolicyStatusCMP0022() != cmPolicies::WARN + && target->GetPolicyStatusCMP0022() != cmPolicies::OLD; if(newCMP0022Behavior && !this->ExportOld) { @@ -857,7 +855,7 @@ cmExportFileGenerator preprocessRule); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target->Target, + this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets, ReplaceFreeTargets); properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro; @@ -878,8 +876,8 @@ cmExportFileGenerator cmMakefile* mf = target->Makefile; // Add the soname for unix shared libraries. - if(target->GetType() == cmTarget::SHARED_LIBRARY || - target->GetType() == cmTarget::MODULE_LIBRARY) + if(target->GetType() == cmState::SHARED_LIBRARY || + target->GetType() == cmState::MODULE_LIBRARY) { // Check whether this is a DLL platform. bool dll_platform = @@ -909,7 +907,7 @@ cmExportFileGenerator // Add the transitive link dependencies for this configuration. if(cmLinkInterface const* iface = - target->GetLinkInterface(config, target->Target)) + target->GetLinkInterface(config, target)) { this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", @@ -959,7 +957,7 @@ cmExportFileGenerator sep = ";"; std::string temp = *li; - this->AddTargetNamespace(temp, target->Target, missingTargets); + this->AddTargetNamespace(temp, target, missingTargets); link_entries += temp; } @@ -1041,7 +1039,7 @@ void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os, //---------------------------------------------------------------------------- void cmExportFileGenerator -::GenerateImportTargetCode(std::ostream& os, cmTarget const* target) +::GenerateImportTargetCode(std::ostream& os, const cmGeneratorTarget* target) { // Construct the imported target name. std::string targetName = this->Namespace; @@ -1052,22 +1050,22 @@ cmExportFileGenerator os << "# Create imported target " << targetName << "\n"; switch(target->GetType()) { - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: os << "add_executable(" << targetName << " IMPORTED)\n"; break; - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: os << "add_library(" << targetName << " STATIC IMPORTED)\n"; break; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: os << "add_library(" << targetName << " SHARED IMPORTED)\n"; break; - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: os << "add_library(" << targetName << " MODULE IMPORTED)\n"; break; - case cmTarget::UNKNOWN_LIBRARY: + case cmState::UNKNOWN_LIBRARY: os << "add_library(" << targetName << " UNKNOWN IMPORTED)\n"; break; - case cmTarget::INTERFACE_LIBRARY: + case cmState::INTERFACE_LIBRARY: os << "add_library(" << targetName << " INTERFACE IMPORTED)\n"; break; default: // should never happen @@ -1107,7 +1105,7 @@ cmExportFileGenerator void cmExportFileGenerator ::GenerateImportPropertyCode(std::ostream& os, const std::string& config, - cmTarget const* target, + cmGeneratorTarget const* target, ImportPropertyMap const& properties) { // Construct the imported target name. @@ -1227,7 +1225,7 @@ cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os) //---------------------------------------------------------------------------- void cmExportFileGenerator -::GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, +::GenerateImportedFileChecksCode(std::ostream& os, cmGeneratorTarget* target, ImportPropertyMap const& properties, const std::set<std::string>& importedLocations) { diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 44f779b..18f0b00 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -75,11 +75,13 @@ protected: const std::string& config = ""); void GenerateImportFooterCode(std::ostream& os); void GenerateImportVersionCode(std::ostream& os); - void GenerateImportTargetCode(std::ostream& os, cmTarget const* target); + void GenerateImportTargetCode(std::ostream& os, + cmGeneratorTarget const* target); void GenerateImportPropertyCode(std::ostream& os, const std::string& config, - cmTarget const* target, + cmGeneratorTarget const* target, ImportPropertyMap const& properties); - void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, + void GenerateImportedFileChecksCode(std::ostream& os, + cmGeneratorTarget* target, ImportPropertyMap const& properties, const std::set<std::string>& importedLocations); void GenerateImportedFileCheckLoop(std::ostream& os); @@ -118,23 +120,24 @@ protected: * export set. */ virtual void HandleMissingTarget(std::string& link_libs, std::vector<std::string>& missingTargets, - cmMakefile* mf, - cmTarget* depender, - cmTarget* dependee) = 0; + cmGeneratorTarget* depender, + cmGeneratorTarget* dependee) = 0; void PopulateInterfaceProperty(const std::string&, - cmTarget *target, + cmGeneratorTarget *target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector<std::string> &missingTargets); - bool PopulateInterfaceLinkLibrariesProperty(cmTarget *target, + bool PopulateInterfaceLinkLibrariesProperty(cmGeneratorTarget* target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector<std::string> &missingTargets); - void PopulateInterfaceProperty(const std::string& propName, cmTarget *target, + void PopulateInterfaceProperty(const std::string& propName, + cmGeneratorTarget* target, ImportPropertyMap &properties); void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target, ImportPropertyMap &properties); - void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, + void GenerateInterfaceProperties(cmGeneratorTarget const* target, + std::ostream& os, const ImportPropertyMap &properties); void PopulateIncludeDirectoriesInterface( cmTargetExport *target, @@ -159,7 +162,7 @@ protected: }; void ResolveTargetsInGeneratorExpressions(std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector<std::string> &missingTargets, FreeTargetsReplace replace = NoReplaceFreeTargets); @@ -182,20 +185,20 @@ protected: bool AppendMode; // The set of targets included in the export. - std::set<cmTarget*> ExportedTargets; + std::set<cmGeneratorTarget*> ExportedTargets; private: void PopulateInterfaceProperty(const std::string&, const std::string&, - cmTarget *target, + cmGeneratorTarget* target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector<std::string> &missingTargets); - bool AddTargetNamespace(std::string &input, cmTarget* target, + bool AddTargetNamespace(std::string &input, cmGeneratorTarget* target, std::vector<std::string> &missingTargets); void ResolveTargetsInGeneratorExpression(std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector<std::string> &missingTargets); virtual void ReplaceInstallPrefix(std::string &input); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 7ffab0c..b695904 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -48,7 +48,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) tei = this->IEGen->GetExportSet()->GetTargetExports()->begin(); tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) { - expectedTargets += sep + this->Namespace + (*tei)->Target->GetExportName(); + expectedTargets += + sep + this->Namespace + (*tei)->Target->GetExportName(); sep = " "; cmTargetExport * te = *tei; if(this->ExportedTargets.insert(te->Target).second) @@ -131,12 +132,12 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) tei = allTargets.begin(); tei != allTargets.end(); ++tei) { - cmTarget* te = (*tei)->Target; + cmGeneratorTarget* gt = (*tei)->Target; requiresConfigFiles = requiresConfigFiles - || te->GetType() != cmTarget::INTERFACE_LIBRARY; + || gt->GetType() != cmState::INTERFACE_LIBRARY; - this->GenerateImportTargetCode(os, te); + this->GenerateImportTargetCode(os, gt); ImportPropertyMap properties; @@ -147,32 +148,32 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); const bool newCMP0022Behavior = - te->GetPolicyStatusCMP0022() != cmPolicies::WARN - && te->GetPolicyStatusCMP0022() != cmPolicies::OLD; + gt->GetPolicyStatusCMP0022() != cmPolicies::WARN + && gt->GetPolicyStatusCMP0022() != cmPolicies::OLD; if (newCMP0022Behavior) { - if (this->PopulateInterfaceLinkLibrariesProperty(te, + if (this->PopulateInterfaceLinkLibrariesProperty(gt, cmGeneratorExpression::InstallInterface, properties, missingTargets) && !this->ExportOld) @@ -180,11 +181,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) require2_8_12 = true; } } - if (te->GetType() == cmTarget::INTERFACE_LIBRARY) + if (gt->GetType() == cmState::INTERFACE_LIBRARY) { require3_0_0 = true; } - if(te->GetProperty("INTERFACE_SOURCES")) + if(gt->GetProperty("INTERFACE_SOURCES")) { // We can only generate INTERFACE_SOURCES in CMake 3.3, but CMake 3.1 // can consume them. @@ -192,14 +193,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) } this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", - te, properties); - cmGeneratorTarget *gtgt = te->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(te); + gt, properties); - this->PopulateCompatibleInterfaceProperties(gtgt, properties); + this->PopulateCompatibleInterfaceProperties(gt, properties); - this->GenerateInterfaceProperties(te, os, properties); + this->GenerateInterfaceProperties(gt, os, properties); } if (require3_1_0) @@ -337,7 +335,7 @@ cmExportInstallFileGenerator { // Collect import properties for this target. cmTargetExport const* te = *tei; - if (te->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + if (te->Target->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -362,8 +360,7 @@ cmExportInstallFileGenerator if(!properties.empty()) { // Get the rest of the target details. - cmGeneratorTarget *gtgt = te->Target->GetMakefile() - ->GetGlobalGenerator()->GetGeneratorTarget(te->Target); + cmGeneratorTarget *gtgt = te->Target; this->SetImportDetailProperties(config, suffix, gtgt, properties, missingTargets); @@ -378,8 +375,8 @@ cmExportInstallFileGenerator // properties); // Generate code in the export file. - this->GenerateImportPropertyCode(os, config, te->Target, properties); - this->GenerateImportedFileChecksCode(os, te->Target, properties, + this->GenerateImportPropertyCode(os, config, gtgt, properties); + this->GenerateImportedFileChecksCode(os, gtgt, properties, importedLocations); } } @@ -402,7 +399,7 @@ cmExportInstallFileGenerator } // Get the target to be installed. - cmTarget* target = itgen->GetTarget()->Target; + cmGeneratorTarget* target = itgen->GetTarget(); // Construct the installed location of the target. std::string dest = itgen->GetDestination(config); @@ -456,12 +453,13 @@ cmExportInstallFileGenerator //---------------------------------------------------------------------------- void -cmExportInstallFileGenerator::HandleMissingTarget( - std::string& link_libs, std::vector<std::string>& missingTargets, - cmMakefile* mf, cmTarget* depender, cmTarget* dependee) +cmExportInstallFileGenerator::HandleMissingTarget(std::string& link_libs, + std::vector<std::string>& missingTargets, + cmGeneratorTarget* depender, cmGeneratorTarget* dependee) { const std::string name = dependee->GetName(); - std::vector<std::string> namespaces = this->FindNamespaces(mf, name); + cmGlobalGenerator* gg = dependee->GetLocalGenerator()->GetGlobalGenerator(); + std::vector<std::string> namespaces = this->FindNamespaces(gg, name); int targetOccurrences = (int)namespaces.size(); if (targetOccurrences == 1) { @@ -482,10 +480,9 @@ cmExportInstallFileGenerator::HandleMissingTarget( //---------------------------------------------------------------------------- std::vector<std::string> cmExportInstallFileGenerator -::FindNamespaces(cmMakefile* mf, const std::string& name) +::FindNamespaces(cmGlobalGenerator* gg, const std::string& name) { std::vector<std::string> namespaces; - cmGlobalGenerator* gg = mf->GetGlobalGenerator(); const cmExportSetMap& exportSets = gg->GetExportSets(); for(cmExportSetMap::const_iterator expIt = exportSets.begin(); @@ -523,8 +520,8 @@ cmExportInstallFileGenerator //---------------------------------------------------------------------------- void cmExportInstallFileGenerator -::ComplainAboutMissingTarget(cmTarget* depender, - cmTarget* dependee, +::ComplainAboutMissingTarget(cmGeneratorTarget* depender, + cmGeneratorTarget* dependee, int occurrences) { std::ostringstream e; diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index b06fee5..13dae89 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -57,17 +57,16 @@ protected: std::vector<std::string> &missingTargets); virtual void HandleMissingTarget(std::string& link_libs, std::vector<std::string>& missingTargets, - cmMakefile* mf, - cmTarget* depender, - cmTarget* dependee); + cmGeneratorTarget* depender, + cmGeneratorTarget* dependee); virtual void ReplaceInstallPrefix(std::string &input); - void ComplainAboutMissingTarget(cmTarget* depender, - cmTarget* dependee, + void ComplainAboutMissingTarget(cmGeneratorTarget* depender, + cmGeneratorTarget* dependee, int occurrences); - std::vector<std::string> FindNamespaces(cmMakefile* mf, + std::vector<std::string> FindNamespaces(cmGlobalGenerator* gg, const std::string& name); diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index fde8fb1..21d961f 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -96,8 +96,8 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const cmTarget const& target = l->second; // Skip non-library targets. - if(target.GetType() < cmTarget::STATIC_LIBRARY - || target.GetType() > cmTarget::MODULE_LIBRARY) + if(target.GetType() < cmState::STATIC_LIBRARY + || target.GetType() > cmState::MODULE_LIBRARY) { continue; } @@ -120,15 +120,15 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const std::string ltValue; switch(li->second) { - case cmTarget::GENERAL: + case GENERAL_LibraryType: valueNew += "general;"; ltValue = "general"; break; - case cmTarget::DEBUG: + case DEBUG_LibraryType: valueNew += "debug;"; ltValue = "debug"; break; - case cmTarget::OPTIMIZED: + case OPTIMIZED_LibraryType: valueNew += "optimized;"; ltValue = "optimized"; break; diff --git a/Source/cmExportLibraryDependenciesCommand.h b/Source/cmExportLibraryDependenciesCommand.h index 2ea4e79..81aa21a 100644 --- a/Source/cmExportLibraryDependenciesCommand.h +++ b/Source/cmExportLibraryDependenciesCommand.h @@ -22,7 +22,6 @@ public: virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); virtual std::string GetName() const { return "export_library_dependencies";} - virtual bool IsDiscouraged() const { return true; } virtual void FinalPass(); virtual bool HasFinalPass() const { return true; } diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx index 4148fb5..0059b64 100644 --- a/Source/cmExportSet.cxx +++ b/Source/cmExportSet.cxx @@ -13,12 +13,22 @@ #include "cmExportSet.h" #include "cmTargetExport.h" #include "cmAlgorithms.h" +#include "cmLocalGenerator.h" cmExportSet::~cmExportSet() { cmDeleteAll(this->TargetExports); } +void cmExportSet::Compute(cmLocalGenerator* lg) +{ + for (std::vector<cmTargetExport*>::iterator it = this->TargetExports.begin(); + it != this->TargetExports.end(); ++it) + { + (*it)->Target = lg->FindGeneratorTargetToUse((*it)->TargetName); + } +} + void cmExportSet::AddTargetExport(cmTargetExport* te) { this->TargetExports.push_back(te); diff --git a/Source/cmExportSet.h b/Source/cmExportSet.h index a57aa12..d780a22 100644 --- a/Source/cmExportSet.h +++ b/Source/cmExportSet.h @@ -15,6 +15,7 @@ #include "cmSystemTools.h" class cmTargetExport; class cmInstallExportGenerator; +class cmLocalGenerator; /// A set of targets that were installed with the same EXPORT parameter. class cmExportSet @@ -25,6 +26,8 @@ public: /// Destructor ~cmExportSet(); + void Compute(cmLocalGenerator* lg); + void AddTargetExport(cmTargetExport* tgt); void AddInstallation(cmInstallExportGenerator const* installation); diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index ba66531..1daa67e 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -14,22 +14,25 @@ #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" +#include "cmLocalGenerator.h" #include "cmGeneratorExpressionDAGChecker.h" //---------------------------------------------------------------------------- cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator( - cmGlobalGenerator* gg) + cmGlobalGenerator* gg, + const std::vector<std::string>& targets, + cmMakefile* mf) { - gg->CreateGenerationObjects(cmGlobalGenerator::ImportedOnly); + gg->CreateImportedGenerationObjects(mf, targets, this->Exports); } bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) { - std::set<cmTarget const*> emitted; - std::set<cmTarget const*> emittedDeps; + std::set<cmGeneratorTarget const*> emitted; + std::set<cmGeneratorTarget const*> emittedDeps; while(!this->Exports.empty()) { - cmTarget const* te = this->Exports.back(); + cmGeneratorTarget const* te = this->Exports.back(); this->Exports.pop_back(); if (emitted.insert(te).second) { @@ -54,9 +57,9 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) } std::string cmExportTryCompileFileGenerator::FindTargets( - const std::string& propName, - cmTarget const* tgt, - std::set<cmTarget const*> &emitted) + const std::string& propName, + cmGeneratorTarget const* tgt, + std::set<cmGeneratorTarget const*> &emitted) { const char *prop = tgt->GetProperty(propName); if(!prop) @@ -73,15 +76,19 @@ std::string cmExportTryCompileFileGenerator::FindTargets( cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop); cmTarget dummyHead; - dummyHead.SetType(cmTarget::EXECUTABLE, "try_compile_dummy_exe"); - dummyHead.SetMakefile(tgt->GetMakefile()); + dummyHead.SetType(cmState::EXECUTABLE, "try_compile_dummy_exe"); + dummyHead.SetMakefile(tgt->Target->GetMakefile()); - std::string result = cge->Evaluate(tgt->GetMakefile(), this->Config, - false, &dummyHead, tgt, &dagChecker); + cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator()); - const std::set<cmTarget const*> &allTargets = cge->GetAllTargetsSeen(); - for(std::set<cmTarget const*>::const_iterator li = allTargets.begin(); - li != allTargets.end(); ++li) + std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config, + false, &gDummyHead, + tgt, &dagChecker); + + const std::set<cmGeneratorTarget const*> &allTargets = + cge->GetAllTargetsSeen(); + for(std::set<cmGeneratorTarget const*>::const_iterator li = + allTargets.begin(); li != allTargets.end(); ++li) { if(emitted.insert(*li).second) { @@ -93,11 +100,12 @@ std::string cmExportTryCompileFileGenerator::FindTargets( //---------------------------------------------------------------------------- void -cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, - ImportPropertyMap& properties, - std::set<cmTarget const*> &emitted) +cmExportTryCompileFileGenerator::PopulateProperties( + const cmGeneratorTarget* target, + ImportPropertyMap& properties, + std::set<cmGeneratorTarget const*> &emitted) { - cmPropertyMap props = target->GetProperties(); + cmPropertyMap props = target->Target->GetProperties(); for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i) { properties[i->first] = i->second.GetValue(); @@ -114,7 +122,8 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, for(std::vector<std::string>::const_iterator li = depends.begin(); li != depends.end(); ++li) { - cmTarget *tgt = target->GetMakefile()->FindTargetToUse(*li); + cmGeneratorTarget *tgt = + target->GetLocalGenerator()->FindGeneratorTargetToUse(*li); if(tgt && emitted.insert(tgt).second) { this->Exports.push_back(tgt); diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 8838eca..fc135a4 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -20,11 +20,11 @@ class cmInstallTargetGenerator; class cmExportTryCompileFileGenerator: public cmExportFileGenerator { public: - cmExportTryCompileFileGenerator(cmGlobalGenerator* gg); + cmExportTryCompileFileGenerator(cmGlobalGenerator* gg, + std::vector<std::string> const& targets, + cmMakefile* mf); /** Set the list of targets to export. */ - void SetExports(const std::vector<cmTarget const*> &exports) - { this->Exports = exports; } void SetConfig(const std::string& config) { this->Config = config; } protected: @@ -37,22 +37,22 @@ protected: std::vector<std::string>&) {} virtual void HandleMissingTarget(std::string&, std::vector<std::string>&, - cmMakefile*, - cmTarget*, - cmTarget*) {} + cmGeneratorTarget*, + cmGeneratorTarget*) {} - void PopulateProperties(cmTarget const* target, + void PopulateProperties(cmGeneratorTarget const* target, ImportPropertyMap& properties, - std::set<cmTarget const*> &emitted); + std::set<const cmGeneratorTarget*>& emitted); std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config); private: - std::string FindTargets(const std::string& prop, cmTarget const* tgt, - std::set<cmTarget const*> &emitted); + std::string FindTargets(const std::string& prop, + const cmGeneratorTarget* tgt, + std::set<const cmGeneratorTarget*>& emitted); - std::vector<cmTarget const*> Exports; + std::vector<cmGeneratorTarget const*> Exports; std::string Config; }; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index dfd51c7..3bc76fa 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -76,9 +76,8 @@ void cmExtraCodeBlocksGenerator::Generate() void cmExtraCodeBlocksGenerator::CreateProjectFile( const std::vector<cmLocalGenerator*>& lgs) { - const cmMakefile* mf=lgs[0]->GetMakefile(); - std::string outputDir=mf->GetCurrentBinaryDirectory(); - std::string projectName=mf->GetProjectName(); + std::string outputDir=lgs[0]->GetCurrentBinaryDirectory(); + std::string projectName=lgs[0]->GetProjectName(); std::string filename=outputDir+"/"; filename+=projectName+".cbp"; @@ -273,7 +272,7 @@ void cmExtraCodeBlocksGenerator } const std::string &relative = cmSystemTools::RelativePath( - it->second[0]->GetMakefile()->GetHomeDirectory(), + it->second[0]->GetSourceDirectory(), jt->c_str()); std::vector<std::string> splitted; cmSystemTools::SplitPath(relative, splitted, false); @@ -297,7 +296,7 @@ void cmExtraCodeBlocksGenerator tree.BuildVirtualFolder(virtualFolders); // And one for <Unit> std::string unitFiles; - tree.BuildUnit(unitFiles, std::string(mf->GetHomeDirectory()) + "/"); + tree.BuildUnit(unitFiles, std::string(lgs[0]->GetSourceDirectory()) + "/"); // figure out the compiler std::string compiler = this->GetCBCompilerId(mf); @@ -307,7 +306,7 @@ void cmExtraCodeBlocksGenerator "<CodeBlocks_project_file>\n" " <FileVersion major=\"1\" minor=\"6\" />\n" " <Project>\n" - " <Option title=\"" << mf->GetProjectName()<<"\" />\n" + " <Option title=\"" << lgs[0]->GetProjectName()<<"\" />\n" " <Option makefile_is_custom=\"1\" />\n" " <Option compiler=\"" << compiler << "\" />\n" " "<<virtualFolders<<"\n" @@ -327,19 +326,19 @@ void cmExtraCodeBlocksGenerator { switch(ti->second.GetType()) { - case cmTarget::GLOBAL_TARGET: + case cmState::GLOBAL_TARGET: { // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs - if (strcmp(makefile->GetCurrentBinaryDirectory(), - makefile->GetHomeOutputDirectory())==0) + if (strcmp((*lg)->GetCurrentBinaryDirectory(), + (*lg)->GetBinaryDirectory())==0) { this->AppendTarget(fout, ti->first, 0, make.c_str(), *lg, compiler.c_str()); } } break; - case cmTarget::UTILITY: + case cmState::UTILITY: // Add all utility targets, except the Nightly/Continuous/ // Experimental-"sub"targets as e.g. NightlyStart if (((ti->first.find("Nightly")==0) &&(ti->first!="Nightly")) @@ -353,17 +352,19 @@ void cmExtraCodeBlocksGenerator this->AppendTarget(fout, ti->first, 0, make.c_str(), *lg, compiler.c_str()); break; - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - case cmTarget::OBJECT_LIBRARY: + case cmState::EXECUTABLE: + case cmState::STATIC_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: + case cmState::OBJECT_LIBRARY: { - this->AppendTarget(fout, ti->first, &ti->second, + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&ti->second); + this->AppendTarget(fout, ti->first, gt, make.c_str(), *lg, compiler.c_str()); std::string fastTarget = ti->first; fastTarget += "/fast"; - this->AppendTarget(fout, fastTarget, &ti->second, + this->AppendTarget(fout, fastTarget, gt, make.c_str(), *lg, compiler.c_str()); } break; @@ -393,15 +394,17 @@ void cmExtraCodeBlocksGenerator { switch(ti->second.GetType()) { - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - case cmTarget::OBJECT_LIBRARY: - case cmTarget::UTILITY: // can have sources since 2.6.3 + case cmState::EXECUTABLE: + case cmState::STATIC_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: + case cmState::OBJECT_LIBRARY: + case cmState::UTILITY: // can have sources since 2.6.3 { std::vector<cmSourceFile*> sources; - ti->second.GetSourceFiles(sources, + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&ti->second); + gt->GetSourceFiles(sources, makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); si!=sources.end(); si++) @@ -520,15 +523,14 @@ void cmExtraCodeBlocksGenerator // Write a dummy file for OBJECT libraries, so C::B can reference some file std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile( cmLocalGenerator* lg, - cmTarget* target) const + cmGeneratorTarget* target) const { - cmMakefile *mf = lg->GetMakefile(); // this file doesn't seem to be used by C::B in custom makefile mode, // but we generate a unique file for each OBJECT library so in case // C::B uses it in some way, the targets don't interfere with each other. - std::string filename = mf->GetCurrentBinaryDirectory(); + std::string filename = lg->GetCurrentBinaryDirectory(); filename += "/"; - filename += lg->GetTargetDirectory(*target); + filename += lg->GetTargetDirectory(target); filename += "/"; filename += target->GetName(); filename += ".objlib"; @@ -547,21 +549,21 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile( // Generate the xml code for one target. void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, const std::string& targetName, - cmTarget* target, + cmGeneratorTarget* target, const char* make, const cmLocalGenerator* lg, const char* compiler) { cmMakefile const* makefile = lg->GetMakefile(); - std::string makefileName = makefile->GetCurrentBinaryDirectory(); + std::string makefileName = lg->GetCurrentBinaryDirectory(); makefileName += "/Makefile"; fout<<" <Target title=\"" << targetName << "\">\n"; if (target!=0) { - int cbTargetType = this->GetCBTargetType(target); - std::string workingDir = makefile->GetCurrentBinaryDirectory(); - if ( target->GetType()==cmTarget::EXECUTABLE) + int cbTargetType = this->GetCBTargetType(target->Target); + std::string workingDir = lg->GetCurrentBinaryDirectory(); + if ( target->GetType()==cmState::EXECUTABLE) { // Determine the directory where the executable target is created, and // set the working directory to this dir. @@ -584,16 +586,14 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, std::string buildType = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); std::string location; - if ( target->GetType()==cmTarget::OBJECT_LIBRARY) + if ( target->GetType()==cmState::OBJECT_LIBRARY) { location = this->CreateDummyTargetFile(const_cast<cmLocalGenerator*>(lg), target); } else { - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(target); - location = gt->GetLocation(buildType); + location = target->GetLocation(buildType); } fout<<" <Option output=\"" << location @@ -604,12 +604,9 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, " <Option compiler=\"" << compiler << "\" />\n" " <Compiler>\n"; - cmGeneratorTarget *gtgt = this->GlobalGenerator - ->GetGeneratorTarget(target); - // the compilerdefines for this target std::vector<std::string> cdefs; - gtgt->GetCompileDefinitions(cdefs, buildType, "C"); + target->GetCompileDefinitions(cdefs, buildType, "C"); // Expand the list. for(std::vector<std::string>::const_iterator di = cdefs.begin(); @@ -623,7 +620,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, std::set<std::string> uniqIncludeDirs; std::vector<std::string> includes; - lg->GetIncludeDirectories(includes, gtgt, "C", buildType); + lg->GetIncludeDirectories(includes, target, "C", buildType); uniqIncludeDirs.insert(includes.begin(), includes.end()); @@ -657,7 +654,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, else // e.g. all and the GLOBAL and UTILITY targets { fout<<" <Option working_dir=\"" - << makefile->GetCurrentBinaryDirectory() << "\" />\n" + << lg->GetCurrentBinaryDirectory() << "\" />\n" <<" <Option type=\"" << 4 << "\" />\n"; } @@ -691,8 +688,6 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) 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->GetSafeDefinition(compilerIdVar); std::string compiler = "gcc"; // default to gcc if (compilerId == "MSVC") @@ -726,7 +721,7 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) // Translate the cmake target type into the CodeBlocks target type id int cmExtraCodeBlocksGenerator::GetCBTargetType(cmTarget* target) { - if ( target->GetType()==cmTarget::EXECUTABLE) + if ( target->GetType()==cmState::EXECUTABLE) { if ((target->GetPropertyAsBool("WIN32_EXECUTABLE")) || (target->GetPropertyAsBool("MACOSX_BUNDLE"))) @@ -738,13 +733,13 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmTarget* target) return 1; } } - else if (( target->GetType()==cmTarget::STATIC_LIBRARY) - || (target->GetType()==cmTarget::OBJECT_LIBRARY)) + else if (( target->GetType()==cmState::STATIC_LIBRARY) + || (target->GetType()==cmState::OBJECT_LIBRARY)) { return 2; } - else if ((target->GetType()==cmTarget::SHARED_LIBRARY) - || (target->GetType()==cmTarget::MODULE_LIBRARY)) + else if ((target->GetType()==cmState::SHARED_LIBRARY) + || (target->GetType()==cmState::MODULE_LIBRARY)) { return 3; } diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h index e5ede9a..f28809a 100644 --- a/Source/cmExtraCodeBlocksGenerator.h +++ b/Source/cmExtraCodeBlocksGenerator.h @@ -17,6 +17,7 @@ class cmLocalGenerator; class cmMakefile; +class cmGeneratorTarget; class cmTarget; class cmGeneratedFileStream; @@ -49,7 +50,7 @@ private: void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs, const std::string& filename); std::string CreateDummyTargetFile(cmLocalGenerator* lg, - cmTarget* target) const; + cmGeneratorTarget* target) const; std::string GetCBCompilerId(const cmMakefile* mf); int GetCBTargetType(cmTarget* target); @@ -57,7 +58,7 @@ private: const std::string& target); void AppendTarget(cmGeneratedFileStream& fout, const std::string& targetName, - cmTarget* target, + cmGeneratorTarget* target, const char* make, const cmLocalGenerator* lg, const char* compiler); diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index c2cff14..10f33be 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -68,15 +68,15 @@ void cmExtraCodeLiteGenerator::Generate() const cmMakefile* mf =it->second[0]->GetMakefile(); this->ConfigName = GetConfigurationName( mf ); - if (strcmp(mf->GetCurrentBinaryDirectory(), - mf->GetHomeOutputDirectory()) == 0) + if (strcmp(it->second[0]->GetCurrentBinaryDirectory(), + it->second[0]->GetBinaryDirectory()) == 0) { - workspaceOutputDir = mf->GetCurrentBinaryDirectory(); - workspaceProjectName = mf->GetProjectName(); - workspaceSourcePath = mf->GetHomeDirectory(); + workspaceOutputDir = it->second[0]->GetCurrentBinaryDirectory(); + workspaceProjectName = it->second[0]->GetProjectName(); + workspaceSourcePath = it->second[0]->GetSourceDirectory(); workspaceFileName = workspaceOutputDir+"/"; workspaceFileName += workspaceProjectName + ".workspace"; - this->WorkspacePath = mf->GetCurrentBinaryDirectory();; + this->WorkspacePath = it->second[0]->GetCurrentBinaryDirectory();; fout.Open(workspaceFileName.c_str(), false, false); fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" @@ -91,9 +91,8 @@ void cmExtraCodeLiteGenerator::Generate() ++it) { // retrive project information - const cmMakefile* mf = it->second[0]->GetMakefile(); - std::string outputDir = mf->GetCurrentBinaryDirectory(); - std::string projectName = mf->GetProjectName(); + std::string outputDir = it->second[0]->GetCurrentBinaryDirectory(); + std::string projectName = it->second[0]->GetProjectName(); std::string filename = outputDir + "/" + projectName + ".project"; // Make the project file relative to the workspace @@ -121,9 +120,8 @@ void cmExtraCodeLiteGenerator::Generate() void cmExtraCodeLiteGenerator::CreateProjectFile( const std::vector<cmLocalGenerator*>& lgs) { - const cmMakefile* mf = lgs[0]->GetMakefile(); - std::string outputDir = mf->GetCurrentBinaryDirectory(); - std::string projectName = mf->GetProjectName(); + std::string outputDir = lgs[0]->GetCurrentBinaryDirectory(); + std::string projectName = lgs[0]->GetProjectName(); std::string filename = outputDir + "/"; filename += projectName + ".project"; @@ -143,7 +141,7 @@ void cmExtraCodeLiteGenerator //////////////////////////////////// fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" - "<CodeLite_Project Name=\"" << mf->GetProjectName() + "<CodeLite_Project Name=\"" << lgs[0]->GetProjectName() << "\" InternalType=\"\">\n"; // Collect all used source files in the project @@ -164,22 +162,22 @@ void cmExtraCodeLiteGenerator switch(ti->second.GetType()) { - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: { projectType = "Executable"; } break; - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: { projectType = "Static Library"; } break; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: { projectType = "Dynamic Library"; } break; - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: { projectType = "Dynamic Library"; } @@ -190,13 +188,15 @@ void cmExtraCodeLiteGenerator switch(ti->second.GetType()) { - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: + case cmState::EXECUTABLE: + case cmState::STATIC_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: { std::vector<cmSourceFile*> sources; - ti->second.GetSourceFiles(sources, + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&ti->second); + gt->GetSourceFiles(sources, makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); si!=sources.end(); si++) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 44bf586..31c05fd 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -79,8 +79,8 @@ void cmExtraEclipseCDT4Generator //---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator::Generate() { - const cmMakefile* mf - = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); + cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0]; + const cmMakefile* mf = lg->GetMakefile(); std::string eclipseVersion = mf->GetSafeDefinition("CMAKE_ECLIPSE_VERSION"); cmsys::RegularExpression regex(".*([0-9]+\\.[0-9]+).*"); @@ -106,8 +106,8 @@ void cmExtraEclipseCDT4Generator::Generate() } // TODO: Decide if these are local or member variables - this->HomeDirectory = mf->GetHomeDirectory(); - this->HomeOutputDirectory = mf->GetHomeOutputDirectory(); + this->HomeDirectory = lg->GetSourceDirectory(); + this->HomeOutputDirectory = lg->GetBinaryDirectory(); this->GenerateLinkedResources = mf->IsOn( "CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES"); @@ -157,9 +157,8 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() assert(this->HomeDirectory != this->HomeOutputDirectory); // set up the project name: <project>-Source@<baseSourcePathName> - const cmMakefile* mf - = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); - std::string name = this->GenerateProjectName(mf->GetProjectName(), "Source", + cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0]; + std::string name = this->GenerateProjectName(lg->GetProjectName(), "Source", this->GetPathBasename(this->HomeDirectory)); const std::string filename = this->HomeDirectory + "/.project"; @@ -197,8 +196,11 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() //---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, - const char* envVar, cmMakefile* mf) + const char* envVar, + cmLocalGenerator* lg) { + cmMakefile* mf = lg->GetMakefile(); + // get the variables from the environment and from the cache and then // figure out which one to use: @@ -206,7 +208,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_"; cacheEntryName += envVar; - const char* cacheValue = mf->GetState()->GetInitializedCacheValue( + const char* cacheValue = lg->GetState()->GetInitializedCacheValue( cacheEntryName); // now we have both, decide which one to use @@ -224,7 +226,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), cacheEntryName.c_str(), cmState::STRING, true); - mf->GetCMakeInstance()->SaveCache(mf->GetHomeOutputDirectory()); + mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory()); } else if (envVarValue==0 && cacheValue!=0) { @@ -245,7 +247,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), cacheEntryName.c_str(), cmState::STRING, true); - mf->GetCMakeInstance()->SaveCache(mf->GetHomeOutputDirectory()); + mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory()); } } @@ -259,8 +261,8 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, //---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator::CreateProjectFile() { - cmMakefile* mf - = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); + cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0]; + cmMakefile* mf = lg->GetMakefile(); const std::string filename = this->HomeOutputDirectory + "/.project"; @@ -280,7 +282,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<projectDescription>\n" "\t<name>" << - this->GenerateProjectName(mf->GetProjectName(), + this->GenerateProjectName(lg->GetProjectName(), mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), this->GetPathBasename(this->HomeOutputDirectory)) << "</name>\n" @@ -361,17 +363,17 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() // but not necessarily when eclipse is open if (compilerId == "MSVC") { - AddEnvVar(fout, "PATH", mf); - AddEnvVar(fout, "INCLUDE", mf); - AddEnvVar(fout, "LIB", mf); - AddEnvVar(fout, "LIBPATH", mf); + AddEnvVar(fout, "PATH", lg); + AddEnvVar(fout, "INCLUDE", lg); + AddEnvVar(fout, "LIB", lg); + AddEnvVar(fout, "LIBPATH", lg); } else if (compilerId == "Intel") { // if the env.var is set, use this one and put it in the cache // if the env.var is not set, but the value is in the cache, // use it from the cache: - AddEnvVar(fout, "INTEL_LICENSE_FILE", mf); + AddEnvVar(fout, "INTEL_LICENSE_FILE", lg); } fout << "</value>\n" @@ -495,7 +497,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() std::string sourceLinkedResourceName = "[Source directory]"; std::string linkSourceDirectory = this->GetEclipsePath( - mf->GetCurrentSourceDirectory()); + lg->GetCurrentSourceDirectory()); // .project dir can't be subdir of a linked resource dir if (!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory, linkSourceDirectory)) @@ -542,13 +544,13 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( linkName2 += "/"; switch(ti->second.GetType()) { - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - case cmTarget::OBJECT_LIBRARY: + case cmState::EXECUTABLE: + case cmState::STATIC_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: + case cmState::OBJECT_LIBRARY: { - const char* prefix = (ti->second.GetType()==cmTarget::EXECUTABLE ? + const char* prefix = (ti->second.GetType()==cmState::EXECUTABLE ? "[exe] " : "[lib] "); linkName2 += prefix; linkName2 += ti->first; @@ -562,7 +564,9 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( // get the files from the source lists then add them to the groups cmTarget* tgt = const_cast<cmTarget*>(&ti->second); std::vector<cmSourceFile*> files; - tgt->GetSourceFiles(files, + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(tgt); + gt->GetSourceFiles(files, makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::vector<cmSourceFile*>::const_iterator sfIt = files.begin(); sfIt != files.end(); @@ -634,7 +638,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( ++it) { std::string linkSourceDirectory = this->GetEclipsePath( - it->second[0]->GetMakefile()->GetCurrentSourceDirectory()); + it->second[0]->GetCurrentSourceDirectory()); // a linked resource must not point to a parent directory of .project or // .project itself if ((baseDir != linkSourceDirectory) && @@ -694,8 +698,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const { std::set<std::string> emmited; - const cmMakefile* mf - = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); + cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0]; + const cmMakefile* mf = lg->GetMakefile(); const std::string filename = this->HomeOutputDirectory + "/.cproject"; @@ -961,15 +965,10 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - cmGeneratorTargetsType targets = (*it)->GetMakefile() - ->GetGeneratorTargets(); + cmGeneratorTargetsType targets = (*it)->GetGeneratorTargets(); for (cmGeneratorTargetsType::iterator l = targets.begin(); l != targets.end(); ++l) { - if (l->first->IsImported()) - { - continue; - } std::vector<std::string> includeDirs; std::string config = mf->GetSafeDefinition("CMAKE_BUILD_TYPE"); (*it)->GetIncludeDirectories(includeDirs, l->second, "C", config); @@ -1032,8 +1031,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const ++it) { const cmTargets& targets = (*it)->GetMakefile()->GetTargets(); - cmMakefile* makefile=(*it)->GetMakefile(); - std::string subdir = (*it)->Convert(makefile->GetCurrentBinaryDirectory(), + std::string subdir = (*it)->Convert((*it)->GetCurrentBinaryDirectory(), cmLocalGenerator::HOME_OUTPUT); if (subdir == ".") { @@ -1044,7 +1042,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const { switch(ti->second.GetType()) { - case cmTarget::GLOBAL_TARGET: + case cmState::GLOBAL_TARGET: { // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs @@ -1054,7 +1052,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const } } break; - case cmTarget::UTILITY: + case cmState::UTILITY: // Add all utility targets, except the Nightly/Continuous/ // Experimental-"sub"targets as e.g. NightlyStart if (((ti->first.find("Nightly")==0) &&(ti->first!="Nightly")) @@ -1067,13 +1065,13 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const this->AppendTarget(fout, ti->first, make, makeArgs, subdir, ": "); break; - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - case cmTarget::OBJECT_LIBRARY: + case cmState::EXECUTABLE: + case cmState::STATIC_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: + case cmState::OBJECT_LIBRARY: { - const char* prefix = (ti->second.GetType()==cmTarget::EXECUTABLE ? + const char* prefix = (ti->second.GetType()==cmState::EXECUTABLE ? "[exe] " : "[lib] "); this->AppendTarget(fout, ti->first, make, makeArgs, subdir, prefix); std::string fastTarget = ti->first; @@ -1087,18 +1085,20 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const virtDir += prefix; virtDir += ti->first; std::string buildArgs = "-C \""; - buildArgs += makefile->GetHomeOutputDirectory(); + buildArgs += (*it)->GetBinaryDirectory(); buildArgs += "\" "; buildArgs += makeArgs; this->AppendTarget(fout, "Build", make, buildArgs, virtDir, "", ti->first.c_str()); std::string cleanArgs = "-E chdir \""; - cleanArgs += makefile->GetCurrentBinaryDirectory(); + cleanArgs += (*it)->GetCurrentBinaryDirectory(); cleanArgs += "\" \""; cleanArgs += cmSystemTools::GetCMakeCommand(); cleanArgs += "\" -P \""; - cleanArgs += (*it)->GetTargetDirectory(ti->second); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&ti->second); + cleanArgs += (*it)->GetTargetDirectory(gt); cleanArgs += "/cmake_clean.cmake\""; this->AppendTarget(fout, "Clean", cmSystemTools::GetCMakeCommand(), cleanArgs, virtDir, "", ""); @@ -1149,8 +1149,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const fout << "</cconfiguration>\n" "</storageModule>\n" "<storageModule moduleId=\"cdtBuildSystem\" version=\"4.0.0\">\n" - "<project id=\"" << this->EscapeForXML(mf->GetProjectName()) - << ".null.1\" name=\"" << this->EscapeForXML(mf->GetProjectName()) + "<project id=\"" << this->EscapeForXML(lg->GetProjectName()) + << ".null.1\" name=\"" << this->EscapeForXML(lg->GetProjectName()) << "\"/>\n" "</storageModule>\n" "</cproject>\n" diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index ef99760..16675f2 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -100,7 +100,7 @@ private: std::set<std::string>& emittedDirs); static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar, - cmMakefile* mf); + cmLocalGenerator* lg); void CreateLinksToSubprojects(cmGeneratedFileStream& fout, const std::string& baseDir); diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index f83b5cf..dc6421b 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -46,21 +46,22 @@ cmExtraKateGenerator::cmExtraKateGenerator() void cmExtraKateGenerator::Generate() { - const cmMakefile* mf - = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); - this->ProjectName = this->GenerateProjectName(mf->GetProjectName(), + cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0]; + const cmMakefile* mf = lg->GetMakefile(); + this->ProjectName = this->GenerateProjectName(lg->GetProjectName(), mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), - this->GetPathBasename(mf->GetHomeOutputDirectory())); + this->GetPathBasename(lg->GetBinaryDirectory())); this->UseNinja = (this->GlobalGenerator->GetName() == "Ninja"); - this->CreateKateProjectFile(mf); - this->CreateDummyKateProjectFile(mf); + this->CreateKateProjectFile(lg); + this->CreateDummyKateProjectFile(lg); } -void cmExtraKateGenerator::CreateKateProjectFile(const cmMakefile* mf) const +void cmExtraKateGenerator::CreateKateProjectFile( + const cmLocalGenerator* lg) const { - std::string filename = mf->GetHomeOutputDirectory(); + std::string filename = lg->GetBinaryDirectory(); filename += "/.kateproject"; cmGeneratedFileStream fout(filename.c_str()); if (!fout) @@ -68,31 +69,29 @@ void cmExtraKateGenerator::CreateKateProjectFile(const cmMakefile* mf) const return; } - std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); - std::string args = mf->GetSafeDefinition("CMAKE_KATE_MAKE_ARGUMENTS"); - fout << "{\n" "\t\"name\": \"" << this->ProjectName << "\",\n" - "\t\"directory\": \"" << mf->GetHomeDirectory() << "\",\n" - "\t\"files\": [ { " << this->GenerateFilesString(mf) << "} ],\n"; - this->WriteTargets(mf, fout); + "\t\"directory\": \"" << lg->GetSourceDirectory() << "\",\n" + "\t\"files\": [ { " << this->GenerateFilesString(lg) << "} ],\n"; + this->WriteTargets(lg, fout); fout << "}\n"; } void -cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, +cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, cmGeneratedFileStream& fout) const { + cmMakefile const* mf = lg->GetMakefile(); const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); const std::string makeArgs = mf->GetSafeDefinition( "CMAKE_KATE_MAKE_ARGUMENTS"); - const char* homeOutputDir = mf->GetHomeOutputDirectory(); + const char* homeOutputDir = lg->GetBinaryDirectory(); fout << "\t\"build\": {\n" - "\t\t\"directory\": \"" << mf->GetHomeOutputDirectory() << "\",\n" + "\t\t\"directory\": \"" << lg->GetBinaryDirectory() << "\",\n" "\t\t\"default_target\": \"all\",\n" "\t\t\"clean_target\": \"clean\",\n"; @@ -122,14 +121,14 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, { const cmTargets& targets = (*it)->GetMakefile()->GetTargets(); cmMakefile* makefile=(*it)->GetMakefile(); - std::string currentDir = makefile->GetCurrentBinaryDirectory(); - bool topLevel = (currentDir == makefile->GetHomeOutputDirectory()); + std::string currentDir = (*it)->GetCurrentBinaryDirectory(); + bool topLevel = (currentDir == (*it)->GetBinaryDirectory()); for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end(); ++ti) { switch(ti->second.GetType()) { - case cmTarget::GLOBAL_TARGET: + case cmState::GLOBAL_TARGET: { bool insertTarget = false; // Only add the global targets from CMAKE_BINARY_DIR, @@ -160,7 +159,7 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, } } break; - case cmTarget::UTILITY: + case cmState::UTILITY: // Add all utility targets, except the Nightly/Continuous/ // Experimental-"sub"targets as e.g. NightlyStart if (((ti->first.find("Nightly")==0) &&(ti->first!="Nightly")) @@ -174,11 +173,11 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, this->AppendTarget(fout, ti->first, make, makeArgs, currentDir, homeOutputDir); break; - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - case cmTarget::OBJECT_LIBRARY: + case cmState::EXECUTABLE: + case cmState::STATIC_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: + case cmState::OBJECT_LIBRARY: { this->AppendTarget(fout, ti->first, make, makeArgs, currentDir, homeOutputDir); @@ -234,9 +233,10 @@ cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout, void -cmExtraKateGenerator::CreateDummyKateProjectFile(const cmMakefile* mf) const +cmExtraKateGenerator::CreateDummyKateProjectFile( + const cmLocalGenerator* lg) const { - std::string filename = mf->GetHomeOutputDirectory(); + std::string filename = lg->GetBinaryDirectory(); filename += "/"; filename += this->ProjectName; filename += ".kateproject"; @@ -252,23 +252,23 @@ cmExtraKateGenerator::CreateDummyKateProjectFile(const cmMakefile* mf) const std::string -cmExtraKateGenerator::GenerateFilesString(const cmMakefile* mf) const +cmExtraKateGenerator::GenerateFilesString(const cmLocalGenerator* lg) const { - std::string s = mf->GetHomeDirectory(); + std::string s = lg->GetSourceDirectory(); s += "/.git"; if(cmSystemTools::FileExists(s.c_str())) { return std::string("\"git\": 1 "); } - s = mf->GetHomeDirectory(); + s = lg->GetSourceDirectory(); s += "/.svn"; if(cmSystemTools::FileExists(s.c_str())) { return std::string("\"svn\": 1 "); } - s = mf->GetHomeDirectory(); + s = lg->GetSourceDirectory(); s += "/"; std::set<std::string> files; diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h index f800feb..b20d0a7 100644 --- a/Source/cmExtraKateGenerator.h +++ b/Source/cmExtraKateGenerator.h @@ -39,9 +39,10 @@ public: virtual void Generate(); private: - void CreateKateProjectFile(const cmMakefile* mf) const; - void CreateDummyKateProjectFile(const cmMakefile* mf) const; - void WriteTargets(const cmMakefile* mf, cmGeneratedFileStream& fout) const; + void CreateKateProjectFile(const cmLocalGenerator* lg) const; + void CreateDummyKateProjectFile(const cmLocalGenerator* lg) const; + void WriteTargets(const cmLocalGenerator* lg, + cmGeneratedFileStream& fout) const; void AppendTarget(cmGeneratedFileStream& fout, const std::string& target, const std::string& make, @@ -49,7 +50,7 @@ private: const std::string& path, const char* homeOutputDir) const; - std::string GenerateFilesString(const cmMakefile* mf) const; + std::string GenerateFilesString(const cmLocalGenerator* lg) const; std::string GetPathBasename(const std::string& path) const; std::string GenerateProjectName(const std::string& name, const std::string& type, diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 163a75b..ac0202b 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -77,9 +77,8 @@ void cmExtraSublimeTextGenerator::Generate() void cmExtraSublimeTextGenerator::CreateProjectFile( const std::vector<cmLocalGenerator*>& lgs) { - const cmMakefile* mf=lgs[0]->GetMakefile(); - std::string outputDir=mf->GetCurrentBinaryDirectory(); - std::string projectName=mf->GetProjectName(); + std::string outputDir=lgs[0]->GetCurrentBinaryDirectory(); + std::string projectName=lgs[0]->GetProjectName(); const std::string filename = outputDir + "/" + projectName + ".sublime-project"; @@ -99,8 +98,8 @@ void cmExtraSublimeTextGenerator } const std::string &sourceRootRelativeToOutput = cmSystemTools::RelativePath( - mf->GetHomeOutputDirectory(), - mf->GetHomeDirectory()); + lgs[0]->GetBinaryDirectory(), + lgs[0]->GetSourceDirectory()); // Write the folder entries to the project file fout << "{\n"; fout << "\t\"folders\":\n\t[\n\t"; @@ -108,8 +107,8 @@ void cmExtraSublimeTextGenerator { fout << "\t{\n\t\t\t\"path\": \"" << sourceRootRelativeToOutput << "\""; const std::string &outputRelativeToSourceRoot = - cmSystemTools::RelativePath(mf->GetHomeDirectory(), - mf->GetHomeOutputDirectory()); + cmSystemTools::RelativePath(lgs[0]->GetSourceDirectory(), + lgs[0]->GetBinaryDirectory()); if ((!outputRelativeToSourceRoot.empty()) && ((outputRelativeToSourceRoot.length() < 3) || (outputRelativeToSourceRoot.substr(0, 3) != "../"))) @@ -169,12 +168,12 @@ void cmExtraSublimeTextGenerator:: { switch(ti->second.GetType()) { - case cmTarget::GLOBAL_TARGET: + case cmState::GLOBAL_TARGET: { // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs - if (strcmp(makefile->GetCurrentBinaryDirectory(), - makefile->GetHomeOutputDirectory())==0) + if (strcmp((*lg)->GetCurrentBinaryDirectory(), + (*lg)->GetBinaryDirectory())==0) { this->AppendTarget(fout, ti->first, *lg, 0, make.c_str(), makefile, compiler.c_str(), @@ -182,7 +181,7 @@ void cmExtraSublimeTextGenerator:: } } break; - case cmTarget::UTILITY: + case cmState::UTILITY: // Add all utility targets, except the Nightly/Continuous/ // Experimental-"sub"targets as e.g. NightlyStart if (((ti->first.find("Nightly")==0) &&(ti->first!="Nightly")) @@ -197,11 +196,11 @@ void cmExtraSublimeTextGenerator:: make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); break; - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - case cmTarget::OBJECT_LIBRARY: + case cmState::EXECUTABLE: + case cmState::STATIC_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: + case cmState::OBJECT_LIBRARY: { this->AppendTarget(fout, ti->first, *lg, &ti->second, make.c_str(), makefile, compiler.c_str(), @@ -237,7 +236,7 @@ void cmExtraSublimeTextGenerator:: cmGeneratorTarget *gtgt = this->GlobalGenerator ->GetGeneratorTarget(target); std::vector<cmSourceFile*> sourceFiles; - target->GetSourceFiles(sourceFiles, + gtgt->GetSourceFiles(sourceFiles, makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); std::vector<cmSourceFile*>::const_iterator sourceFilesEnd = sourceFiles.end(); @@ -255,9 +254,9 @@ void cmExtraSublimeTextGenerator:: } std::vector<std::string>& flags = sourceFileFlagsIter->second; std::string flagsString = - this->ComputeFlagsForObject(*iter, lg, target, gtgt); + this->ComputeFlagsForObject(*iter, lg, gtgt); std::string definesString = - this->ComputeDefines(*iter, lg, target, gtgt); + this->ComputeDefines(*iter, lg, gtgt); flags.clear(); cmsys::RegularExpression flagRegex; // Regular expression to extract compiler flags from a string @@ -302,7 +301,7 @@ void cmExtraSublimeTextGenerator:: { fout << ",\n\t"; } - fout << "\t{\n\t\t\t\"name\": \"" << makefile->GetProjectName() << " - " << + fout << "\t{\n\t\t\t\"name\": \"" << lg->GetProjectName() << " - " << targetName << "\",\n"; fout << "\t\t\t\"cmd\": [" << this->BuildMakeCommand(make, makefileName.c_str(), targetName) << @@ -365,7 +364,6 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand( std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, cmLocalGenerator* lg, - cmTarget *target, cmGeneratorTarget* gtgt) { std::string flags; @@ -390,7 +388,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, // } // Add shared-library flags if needed. - lg->AddCMP0018Flags(flags, target, language, config); + lg->AddCMP0018Flags(flags, gtgt, language, config); // Add include directory flags. { @@ -405,7 +403,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, lg->AppendFlags(flags, makefile->GetDefineFlags()); // Add target-specific flags. - lg->AddCompileOptions(flags, target, language, config); + lg->AddCompileOptions(flags, gtgt, language, config); // Add source file specific flags. lg->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS")); @@ -419,8 +417,8 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, // void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). std::string cmExtraSublimeTextGenerator:: -ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target, - cmGeneratorTarget*) +ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, + cmGeneratorTarget* target) { std::set<std::string> defines; diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h index 4173b7d..5dd1140 100644 --- a/Source/cmExtraSublimeTextGenerator.h +++ b/Source/cmExtraSublimeTextGenerator.h @@ -79,11 +79,10 @@ private: */ std::string ComputeFlagsForObject(cmSourceFile *source, cmLocalGenerator* lg, - cmTarget *target, cmGeneratorTarget* gtgt); std::string ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, - cmTarget *target, cmGeneratorTarget* gtgt); + cmGeneratorTarget* gtgt); }; #endif diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index 12adfd9..d17d664 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -129,45 +129,6 @@ void cmFLTKWrapUICommand::FinalPass() cmSystemTools::Message(msg.c_str(),"Warning"); return; } - std::vector<cmSourceFile*> srcs; - target->GetSourceFiles(srcs, ""); - bool found = false; - for (unsigned int i = 0; i < srcs.size(); ++i) - { - if (srcs[i]->GetFullPath() == - this->GeneratedSourcesClasses[0]->GetFullPath()) - { - found = true; - break; - } - } - if (!found) - { - std::string msg = - "In CMake 2.2 the FLTK_WRAP_UI command sets a variable to the list of " - "source files that should be added to your executable or library. It " - "appears that you have not added these source files to your target. " - "You should change your CMakeLists.txt file to " - "directly add the generated files to the target. " - "For example FTLK_WRAP_UI(foo src1 src2 src3) " - "will create a variable named foo_FLTK_UI_SRCS that contains the list " - "of sources to add to your target when you call ADD_LIBRARY or " - "ADD_EXECUTABLE. For now CMake will add the sources to your target " - "for you as was done in CMake 2.0 and earlier. In the future this may " - "become an error."; - msg +="The problem was found while processing the source directory: "; - msg += this->Makefile->GetCurrentSourceDirectory(); - cmSystemTools::Message(msg.c_str(),"Warning"); - // first we add the rules for all the .fl to .h and .cxx files - size_t lastHeadersClass = this->GeneratedSourcesClasses.size(); - - // Generate code for all the .fl files - for(size_t classNum = 0; classNum < lastHeadersClass; classNum++) - { - this->Makefile->GetTargets()[this->Target] - .AddSource(this->GeneratedSourcesClasses[classNum]->GetFullPath()); - } - } } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 87faf84..df95d9d 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -15,7 +15,6 @@ #include "cmHexFileConverter.h" #include "cmInstallType.h" #include "cmFileTimeComparison.h" -#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmCryptoHash.h" #include "cmAlgorithms.h" diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx index 13e2a66..279b61d 100644 --- a/Source/cmFileTimeComparison.cxx +++ b/Source/cmFileTimeComparison.cxx @@ -148,7 +148,7 @@ int cmFileTimeComparisonInternal::Compare(cmFileTimeComparison_Type* s1, cmFileTimeComparison_Type* s2) { #if !defined(_WIN32) || defined(__CYGWIN__) -# if cmsys_STAT_HAS_ST_MTIM +# if CMake_STAT_HAS_ST_MTIM // Compare using nanosecond resolution. if(s1->st_mtim.tv_sec < s2->st_mtim.tv_sec) { @@ -166,6 +166,24 @@ int cmFileTimeComparisonInternal::Compare(cmFileTimeComparison_Type* s1, { return 1; } +# elif CMake_STAT_HAS_ST_MTIMESPEC + // Compare using nanosecond resolution. + if(s1->st_mtimespec.tv_sec < s2->st_mtimespec.tv_sec) + { + return -1; + } + else if(s1->st_mtimespec.tv_sec > s2->st_mtimespec.tv_sec) + { + return 1; + } + else if(s1->st_mtimespec.tv_nsec < s2->st_mtimespec.tv_nsec) + { + return -1; + } + else if(s1->st_mtimespec.tv_nsec > s2->st_mtimespec.tv_nsec) + { + return 1; + } # else // Compare using 1 second resolution. if(s1->st_mtime < s2->st_mtime) @@ -190,7 +208,7 @@ bool cmFileTimeComparisonInternal::TimesDiffer(cmFileTimeComparison_Type* s1, cmFileTimeComparison_Type* s2) { #if !defined(_WIN32) || defined(__CYGWIN__) -# if cmsys_STAT_HAS_ST_MTIM +# if CMake_STAT_HAS_ST_MTIM // Times are integers in units of 1ns. long long bil = 1000000000; long long t1 = s1->st_mtim.tv_sec * bil + s1->st_mtim.tv_nsec; @@ -207,6 +225,23 @@ bool cmFileTimeComparisonInternal::TimesDiffer(cmFileTimeComparison_Type* s1, { return false; } +# elif CMake_STAT_HAS_ST_MTIMESPEC + // Times are integers in units of 1ns. + long long bil = 1000000000; + long long t1 = s1->st_mtimespec.tv_sec * bil + s1->st_mtimespec.tv_nsec; + long long t2 = s2->st_mtimespec.tv_sec * bil + s2->st_mtimespec.tv_nsec; + if(t1 < t2) + { + return (t2 - t1) >= bil; + } + else if(t2 < t1) + { + return (t1 - t2) >= bil; + } + else + { + return false; + } # else // Times are integers in units of 1s. if(s1->st_mtime < s2->st_mtime) diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index 7959ffe..fa9b381 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -207,6 +207,10 @@ void cmFindBase::ExpandPaths() { this->FillCMakeEnvironmentPath(); } + } + this->FillUserHintsPath(); + if(!this->NoDefaultPath) + { if(!this->NoSystemEnvironmentPath) { this->FillSystemEnvironmentPath(); @@ -216,8 +220,6 @@ void cmFindBase::ExpandPaths() this->FillCMakeSystemVariablePath(); } } - - this->FillUserHintsPath(); this->FillUserGuessPath(); } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 9b9071d..64176e7 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1133,6 +1133,10 @@ void cmFindPackageCommand::ComputePrefixes() { this->FillPrefixesCMakeEnvironment(); } + } + this->FillPrefixesUserHints(); + if(!this->NoDefaultPath) + { if(!this->NoSystemEnvironmentPath) { this->FillPrefixesSystemEnvironment(); @@ -1150,7 +1154,6 @@ void cmFindPackageCommand::ComputePrefixes() this->FillPrefixesSystemRegistry(); } } - this->FillPrefixesUserHints(); this->FillPrefixesUserGuess(); this->ComputeFinalPaths(); diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 80a4f81..6796a01 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -11,10 +11,9 @@ ============================================================================*/ #include "cmGeneratorExpression.h" -#include "cmMakefile.h" -#include "cmTarget.h" #include "assert.h" #include "cmAlgorithms.h" +#include "cmSystemTools.h" #include "cmGeneratorExpressionEvaluator.h" #include "cmGeneratorExpressionLexer.h" @@ -48,13 +47,13 @@ cmGeneratorExpression::~cmGeneratorExpression() } //---------------------------------------------------------------------------- -const char *cmCompiledGeneratorExpression::Evaluate( - cmMakefile* mf, const std::string& config, bool quiet, - cmTarget const* headTarget, +const char *cmCompiledGeneratorExpression::Evaluate(cmLocalGenerator* lg, + const std::string& config, bool quiet, + const cmGeneratorTarget* headTarget, cmGeneratorExpressionDAGChecker *dagChecker, std::string const& language) const { - return this->Evaluate(mf, + return this->Evaluate(lg, config, quiet, headTarget, @@ -65,13 +64,13 @@ const char *cmCompiledGeneratorExpression::Evaluate( //---------------------------------------------------------------------------- const char *cmCompiledGeneratorExpression::Evaluate( - cmMakefile* mf, const std::string& config, bool quiet, - cmTarget const* headTarget, - cmTarget const* currentTarget, + cmLocalGenerator* lg, const std::string& config, bool quiet, + const cmGeneratorTarget* headTarget, + const cmGeneratorTarget* currentTarget, cmGeneratorExpressionDAGChecker *dagChecker, std::string const& language) const { - cmGeneratorExpressionContext context(mf, config, quiet, headTarget, + cmGeneratorExpressionContext context(lg, config, quiet, headTarget, currentTarget ? currentTarget : headTarget, this->EvaluateForBuildsystem, this->Backtrace, language); @@ -463,10 +462,11 @@ bool cmGeneratorExpression::IsValidTargetName(const std::string &input) //---------------------------------------------------------------------------- void -cmCompiledGeneratorExpression::GetMaxLanguageStandard(cmTarget const* tgt, +cmCompiledGeneratorExpression::GetMaxLanguageStandard( + const cmGeneratorTarget* tgt, std::map<std::string, std::string>& mapping) { - typedef std::map<cmTarget const*, + typedef std::map<cmGeneratorTarget const*, std::map<std::string, std::string> > MapType; MapType::const_iterator it = this->MaxLanguageStandard.find(tgt); if (it != this->MaxLanguageStandard.end()) diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index cd19bc0..efd381b 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -19,8 +19,8 @@ #include <cmsys/RegularExpression.hxx> #include <cmsys/auto_ptr.hxx> -class cmTarget; -class cmMakefile; +class cmGeneratorTarget; +class cmLocalGenerator; class cmListFileBacktrace; struct cmGeneratorExpressionEvaluator; @@ -78,26 +78,26 @@ private: class cmCompiledGeneratorExpression { public: - const char* Evaluate(cmMakefile* mf, const std::string& config, + const char* Evaluate(cmLocalGenerator* lg, const std::string& config, bool quiet = false, - cmTarget const* headTarget = 0, - cmTarget const* currentTarget = 0, + cmGeneratorTarget const* headTarget = 0, + cmGeneratorTarget const* currentTarget = 0, cmGeneratorExpressionDAGChecker *dagChecker = 0, std::string const& language = std::string()) const; - const char* Evaluate(cmMakefile* mf, const std::string& config, + const char* Evaluate(cmLocalGenerator* lg, const std::string& config, bool quiet, - cmTarget const* headTarget, + cmGeneratorTarget const* headTarget, cmGeneratorExpressionDAGChecker *dagChecker, std::string const& language = std::string()) const; /** Get set of targets found during evaluations. */ - std::set<cmTarget*> const& GetTargets() const + std::set<cmGeneratorTarget*> const& GetTargets() const { return this->DependTargets; } std::set<std::string> const& GetSeenTargetProperties() const { return this->SeenTargetProperties; } - std::set<cmTarget const*> const& GetAllTargetsSeen() const + std::set<cmGeneratorTarget const*> const& GetAllTargetsSeen() const { return this->AllTargetsSeen; } ~cmCompiledGeneratorExpression(); @@ -119,7 +119,7 @@ public: { return this->HadHeadSensitiveCondition; } - std::set<cmTarget const*> GetSourceSensitiveTargets() const + std::set<cmGeneratorTarget const*> GetSourceSensitiveTargets() const { return this->SourceSensitiveTargets; } @@ -129,7 +129,7 @@ public: this->EvaluateForBuildsystem = eval; } - void GetMaxLanguageStandard(cmTarget const* tgt, + void GetMaxLanguageStandard(cmGeneratorTarget const* tgt, std::map<std::string, std::string>& mapping); private: @@ -149,15 +149,15 @@ private: const std::string Input; bool NeedsEvaluation; - mutable std::set<cmTarget*> DependTargets; - mutable std::set<cmTarget const*> AllTargetsSeen; + mutable std::set<cmGeneratorTarget*> DependTargets; + mutable std::set<cmGeneratorTarget const*> AllTargetsSeen; mutable std::set<std::string> SeenTargetProperties; - mutable std::map<cmTarget const*, std::map<std::string, std::string> > - MaxLanguageStandard; + mutable std::map<cmGeneratorTarget const*, + std::map<std::string, std::string> > MaxLanguageStandard; mutable std::string Output; mutable bool HadContextSensitiveCondition; mutable bool HadHeadSensitiveCondition; - mutable std::set<cmTarget const*> SourceSensitiveTargets; + mutable std::set<cmGeneratorTarget const*> SourceSensitiveTargets; bool EvaluateForBuildsystem; }; diff --git a/Source/cmGeneratorExpressionContext.cxx b/Source/cmGeneratorExpressionContext.cxx index 947015e..5c9462f 100644 --- a/Source/cmGeneratorExpressionContext.cxx +++ b/Source/cmGeneratorExpressionContext.cxx @@ -11,16 +11,17 @@ ============================================================================*/ #include "cmGeneratorExpressionContext.h" +#include "cmGeneratorTarget.h" cmGeneratorExpressionContext::cmGeneratorExpressionContext( - cmMakefile* mf, std::string const& config, - bool quiet, cmTarget const* headTarget, - cmTarget const* currentTarget, + cmLocalGenerator* lg, std::string const& config, + bool quiet, cmGeneratorTarget const* headTarget, + const cmGeneratorTarget* currentTarget, bool evaluateForBuildsystem, cmListFileBacktrace const& backtrace, std::string const& language) : Backtrace(backtrace), - Makefile(mf), + LG(lg), Config(config), Language(language), HeadTarget(headTarget), diff --git a/Source/cmGeneratorExpressionContext.h b/Source/cmGeneratorExpressionContext.h index ed83509..e802138 100644 --- a/Source/cmGeneratorExpressionContext.h +++ b/Source/cmGeneratorExpressionContext.h @@ -18,32 +18,35 @@ #include <map> #include <string> -class cmTarget; +class cmGeneratorTarget; +class cmLocalGenerator; //---------------------------------------------------------------------------- struct cmGeneratorExpressionContext { - cmGeneratorExpressionContext(cmMakefile* mf, std::string const& config, - bool quiet, cmTarget const* headTarget, - cmTarget const* currentTarget, + cmGeneratorExpressionContext(cmLocalGenerator* lg, std::string const& config, + bool quiet, const cmGeneratorTarget* headTarget, + cmGeneratorTarget const* currentTarget, bool evaluateForBuildsystem, cmListFileBacktrace const& backtrace, std::string const& language); cmListFileBacktrace Backtrace; - std::set<cmTarget*> DependTargets; - std::set<cmTarget const*> AllTargets; + std::set<cmGeneratorTarget*> DependTargets; + std::set<cmGeneratorTarget const*> AllTargets; std::set<std::string> SeenTargetProperties; - std::set<cmTarget const*> SourceSensitiveTargets; - std::map<cmTarget const*, std::map<std::string, std::string> > + std::set<cmGeneratorTarget const*> SourceSensitiveTargets; + std::map<cmGeneratorTarget const*, std::map<std::string, std::string> > MaxLanguageStandard; - cmMakefile *Makefile; + cmLocalGenerator *LG; std::string Config; std::string Language; - cmTarget const* HeadTarget; // The target whose property is being evaluated. - cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears - // directly or indirectly in the property. + // The target whose property is being evaluated. + cmGeneratorTarget const* HeadTarget; + // The dependent of HeadTarget which appears + // directly or indirectly in the property. + cmGeneratorTarget const* CurrentTarget; bool Quiet; bool HadError; bool HadContextSensitiveCondition; diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 851aacd..5eed89d 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -13,6 +13,7 @@ #include "cmGeneratorExpressionDAGChecker.h" #include "cmMakefile.h" +#include "cmLocalGenerator.h" #include "cmAlgorithms.h" //---------------------------------------------------------------------------- @@ -110,7 +111,7 @@ void cmGeneratorExpressionDAGChecker::ReportError( << " " << expr << "\n" << "Self reference on target \"" << context->HeadTarget->GetName() << "\".\n"; - context->Makefile->GetCMakeInstance() + context->LG->GetCMakeInstance() ->IssueMessage(cmake::FATAL_ERROR, e.str(), parent->Backtrace); return; @@ -121,7 +122,7 @@ void cmGeneratorExpressionDAGChecker::ReportError( e << "Error evaluating generator expression:\n" << " " << expr << "\n" << "Dependency loop found."; - context->Makefile->GetCMakeInstance() + context->LG->GetCMakeInstance() ->IssueMessage(cmake::FATAL_ERROR, e.str(), context->Backtrace); } @@ -134,7 +135,7 @@ void cmGeneratorExpressionDAGChecker::ReportError( << " " << (parent->Content ? parent->Content->GetOriginalExpression() : expr) << "\n"; - context->Makefile->GetCMakeInstance() + context->LG->GetCMakeInstance() ->IssueMessage(cmake::FATAL_ERROR, e.str(), parent->Backtrace); parent = parent->Parent; diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index e4d9f10..4ac2a0d 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -44,7 +44,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg, std::string rawCondition = this->Condition->GetInput(); if (!rawCondition.empty()) { - std::string condResult = this->Condition->Evaluate(lg->GetMakefile(), + std::string condResult = this->Condition->Evaluate(lg, config, false, 0, 0, 0, lang); if (condResult == "0") @@ -62,10 +62,10 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg, } const std::string outputFileName - = this->OutputFileExpr->Evaluate(lg->GetMakefile(), config, + = this->OutputFileExpr->Evaluate(lg, config, false, 0, 0, 0, lang); const std::string outputContent - = inputExpression->Evaluate(lg->GetMakefile(), + = inputExpression->Evaluate(lg, config, false, 0, 0, 0, lang); @@ -110,7 +110,7 @@ void cmGeneratorExpressionEvaluationFile::CreateOutputFile( for(std::vector<std::string>::const_iterator le = enabledLanguages.begin(); le != enabledLanguages.end(); ++le) { - std::string name = this->OutputFileExpr->Evaluate(lg->GetMakefile(), + std::string name = this->OutputFileExpr->Evaluate(lg, config, false, 0, 0, 0, *le); cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource(name); @@ -139,7 +139,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator *lg) { std::ostringstream e; e << "Evaluation file \"" << this->Input << "\" cannot be read."; - lg->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 31b6766..7a7e4ff 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -13,18 +13,20 @@ #include "cmGeneratorExpressionNode.h" #include "cmGlobalGenerator.h" #include "cmAlgorithms.h" +#include "cmOutputConverter.h" //---------------------------------------------------------------------------- std::string cmGeneratorExpressionNode::EvaluateDependentExpression( - std::string const& prop, cmMakefile *makefile, + std::string const& prop, cmLocalGenerator *lg, cmGeneratorExpressionContext *context, - cmTarget const* headTarget, cmTarget const* currentTarget, + cmGeneratorTarget const* headTarget, + cmGeneratorTarget const* currentTarget, cmGeneratorExpressionDAGChecker *dagChecker) { cmGeneratorExpression ge(context->Backtrace); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop); cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem); - std::string result = cge->Evaluate(makefile, + std::string result = cge->Evaluate(lg, context->Config, context->Quiet, headTarget, @@ -366,7 +368,8 @@ struct CompilerIdNode : public cmGeneratorExpressionNode const std::string &lang) const { const char *compilerId = - context->Makefile->GetSafeDefinition("CMAKE_" + lang + "_COMPILER_ID"); + context->LG->GetMakefile() + ->GetSafeDefinition("CMAKE_" + lang + "_COMPILER_ID"); if (parameters.empty()) { return compilerId ? compilerId : ""; @@ -390,13 +393,13 @@ struct CompilerIdNode : public cmGeneratorExpressionNode if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0) { - switch(context->Makefile->GetPolicyStatus(cmPolicies::CMP0044)) + switch(context->LG->GetMakefile()->GetPolicyStatus(cmPolicies::CMP0044)) { case cmPolicies::WARN: { std::ostringstream e; e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0044); - context->Makefile->GetCMakeInstance() + context->LG->GetCMakeInstance() ->IssueMessage(cmake::AUTHOR_WARNING, e.str(), context->Backtrace); } @@ -469,8 +472,9 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode cmGeneratorExpressionDAGChecker *, const std::string &lang) const { - const char *compilerVersion = context->Makefile->GetSafeDefinition( - "CMAKE_" + lang + "_COMPILER_VERSION"); + const char *compilerVersion = + context->LG->GetMakefile()->GetSafeDefinition( + "CMAKE_" + lang + "_COMPILER_VERSION"); if (parameters.empty()) { return compilerVersion ? compilerVersion : ""; @@ -552,7 +556,7 @@ struct PlatformIdNode : public cmGeneratorExpressionNode cmGeneratorExpressionDAGChecker *) const { const char *platformId = - context->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME"); + context->LG->GetMakefile()->GetSafeDefinition("CMAKE_SYSTEM_NAME"); if (parameters.empty()) { return platformId ? platformId : ""; @@ -701,7 +705,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode const char* loc = 0; const char* imp = 0; std::string suffix; - if (context->CurrentTarget->GetMappedConfig(context->Config, + if (context->CurrentTarget->Target->GetMappedConfig(context->Config, &loc, &imp, suffix)) @@ -767,7 +771,7 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode } std::vector<std::string> enabledLanguages; - cmGlobalGenerator* gg = context->Makefile->GetGlobalGenerator(); + cmGlobalGenerator* gg = context->LG->GetGlobalGenerator(); gg->GetEnabledLanguages(enabledLanguages); if (!parameters.empty() && std::find(enabledLanguages.begin(), enabledLanguages.end(), @@ -830,8 +834,8 @@ template <typename T> std::string getLinkedTargetsContent( std::vector<T> const &libraries, - cmTarget const* target, - cmTarget const* headTarget, + cmGeneratorTarget const* target, + cmGeneratorTarget const* headTarget, cmGeneratorExpressionContext *context, cmGeneratorExpressionDAGChecker *dagChecker, const std::string &interfacePropertyName) @@ -857,8 +861,10 @@ getLinkedTargetsContent( { linkedTargetsContent = cmGeneratorExpressionNode::EvaluateDependentExpression(depString, - target->GetMakefile(), context, - headTarget, target, dagChecker); + target->GetLocalGenerator(), + context, + headTarget, + target, dagChecker); } linkedTargetsContent = cmGeneratorExpression::StripEmptyListElements(linkedTargetsContent); @@ -887,7 +893,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$"); - cmTarget const* target = context->HeadTarget; + cmGeneratorTarget const* target = context->HeadTarget; std::string propertyName = *parameters.begin(); if (parameters.size() == 1) @@ -937,16 +943,17 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } if(propertyName == "ALIASED_TARGET") { - if(context->Makefile->IsAlias(targetName)) + if(context->LG->GetMakefile()->IsAlias(targetName)) { - if(cmTarget* tgt = context->Makefile->FindTargetToUse(targetName)) + if(cmGeneratorTarget* tgt = + context->LG->FindGeneratorTargetToUse(targetName)) { return tgt->GetName(); } } return ""; } - target = context->Makefile->FindTargetToUse(targetName); + target = context->LG->FindGeneratorTargetToUse(targetName); if (!target) { @@ -990,12 +997,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode assert(target); - cmGeneratorTarget* gtgt = - context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); - if (propertyName == "LINKER_LANGUAGE") { - if (target->LinkLanguagePropagatesToDependents() && + if (target->Target->LinkLanguagePropagatesToDependents() && dagCheckerParent && (dagCheckerParent->EvaluatingLinkLibraries() || dagCheckerParent->EvaluatingSources())) { @@ -1004,7 +1008,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - return gtgt->GetLinkerLanguage(context->Config); + return target->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1096,20 +1100,21 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "COMPILE_DEFINITIONS_")) { cmPolicies::PolicyStatus polSt = - context->Makefile->GetPolicyStatus(cmPolicies::CMP0043); + context->LG->GetMakefile()->GetPolicyStatus(cmPolicies::CMP0043); if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) { interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS"; } } #undef POPULATE_INTERFACE_PROPERTY_NAME - cmTarget const* headTarget = context->HeadTarget && isInterfaceProperty + cmGeneratorTarget const* headTarget = + context->HeadTarget && isInterfaceProperty ? context->HeadTarget : target; if(isInterfaceProperty) { if(cmLinkInterfaceLibraries const* iface = - gtgt->GetLinkInterfaceLibraries(context->Config, headTarget, true)) + target->GetLinkInterfaceLibraries(context->Config, headTarget, true)) { linkedTargetsContent = getLinkedTargetsContent(iface->Libraries, target, @@ -1134,44 +1139,44 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!prop) { if (target->IsImported() - || target->GetType() == cmTarget::INTERFACE_LIBRARY) + || target->GetType() == cmState::INTERFACE_LIBRARY) { return linkedTargetsContent; } - if (gtgt->IsLinkInterfaceDependentBoolProperty(propertyName, + if (target->IsLinkInterfaceDependentBoolProperty(propertyName, context->Config)) { context->HadContextSensitiveCondition = true; - return gtgt->GetLinkInterfaceDependentBoolProperty( + return target->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } - if (gtgt->IsLinkInterfaceDependentStringProperty(propertyName, + if (target->IsLinkInterfaceDependentStringProperty(propertyName, context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = - gtgt->GetLinkInterfaceDependentStringProperty( + target->GetLinkInterfaceDependentStringProperty( propertyName, context->Config); return propContent ? propContent : ""; } - if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = - gtgt->GetLinkInterfaceDependentNumberMinProperty( + target->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; } - if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = - gtgt->GetLinkInterfaceDependentNumberMaxProperty( + target->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1183,22 +1188,22 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!target->IsImported() && dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries()) { - if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = - gtgt->GetLinkInterfaceDependentNumberMinProperty( + target->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; } - if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = - gtgt->GetLinkInterfaceDependentNumberMaxProperty( + target->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1207,7 +1212,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if(!interfacePropertyName.empty()) { std::string result = this->EvaluateDependentExpression(prop, - context->Makefile, context, + context->LG, context, headTarget, target, &dagChecker); if (!linkedTargetsContent.empty()) { @@ -1263,7 +1268,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode std::string tgtName = parameters.front(); cmGeneratorTarget* gt = - context->Makefile->FindGeneratorTargetToUse(tgtName); + context->LG->FindGeneratorTargetToUse(tgtName); if (!gt) { std::ostringstream e; @@ -1272,7 +1277,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode reportError(context, content->GetOriginalExpression(), e.str()); return std::string(); } - if (gt->GetType() != cmTarget::OBJECT_LIBRARY) + if (gt->GetType() != cmState::OBJECT_LIBRARY) { std::ostringstream e; e << "Objects of target \"" << tgtName @@ -1306,7 +1311,8 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode assert(!map_it->second.empty()); result += sep; std::string objFile = obj_dir + map_it->second; - cmSourceFile* sf = context->Makefile->GetOrCreateSource(objFile, true); + cmSourceFile* sf = + context->LG->GetMakefile()->GetOrCreateSource(objFile, true); sf->SetObjectLibrary(tgtName); sf->SetProperty("EXTERNAL_OBJECT", "1"); result += objFile; @@ -1328,7 +1334,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode const GeneratorExpressionContent *content, cmGeneratorExpressionDAGChecker *dagChecker) const { - cmTarget const* target = context->HeadTarget; + cmGeneratorTarget const* target = context->HeadTarget; if (!target) { reportError(context, content->GetOriginalExpression(), @@ -1348,7 +1354,8 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode { std::string error; std::string lang; - if (!context->Makefile->CompileFeatureKnown(context->HeadTarget, + if (!context->LG->GetMakefile()->CompileFeatureKnown( + context->HeadTarget->Target, *it, lang, &error)) { reportError(context, content->GetOriginalExpression(), error); @@ -1359,7 +1366,8 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode if (availableFeatures.find(lang) == availableFeatures.end()) { const char* featuresKnown - = context->Makefile->CompileFeaturesAvailable(lang, &error); + = context->LG->GetMakefile()->CompileFeaturesAvailable(lang, + &error); if (!featuresKnown) { reportError(context, content->GetOriginalExpression(), error); @@ -1377,7 +1385,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode { std::vector<std::string> const& langAvailable = availableFeatures[lit->first]; - const char* standardDefault = context->Makefile + const char* standardDefault = context->LG->GetMakefile() ->GetDefinition("CMAKE_" + lit->first + "_STANDARD_DEFAULT"); for (std::vector<std::string>::const_iterator it = lit->second.begin(); it != lit->second.end(); ++it) @@ -1393,7 +1401,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode // All features known for the language are always available. continue; } - if (!context->Makefile->HaveStandardAvailable(target, + if (!context->LG->GetMakefile()->HaveStandardAvailable(target->Target, lit->first, *it)) { if (evalLL) @@ -1428,13 +1436,13 @@ static const char* targetPolicyWhitelist[] = { #undef TARGET_POLICY_STRING }; -cmPolicies::PolicyStatus statusForTarget(cmTarget const* tgt, +cmPolicies::PolicyStatus statusForTarget(cmGeneratorTarget const* tgt, const char *policy) { #define RETURN_POLICY(POLICY) \ if (strcmp(policy, #POLICY) == 0) \ { \ - return tgt->GetPolicyStatus ## POLICY (); \ + return tgt->Target->GetPolicyStatus ## POLICY (); \ } \ CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY) @@ -1489,11 +1497,11 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode const char *policy = targetPolicyWhitelist[i]; if (parameters.front() == policy) { - cmMakefile *mf = context->HeadTarget->GetMakefile(); + cmLocalGenerator* lg = context->HeadTarget->GetLocalGenerator(); switch(statusForTarget(context->HeadTarget, policy)) { case cmPolicies::WARN: - mf->IssueMessage(cmake::AUTHOR_WARNING, + lg->IssueMessage(cmake::AUTHOR_WARNING, cmPolicies::GetPolicyWarning(policyForString(policy))); case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: @@ -1571,21 +1579,21 @@ struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag> const GeneratorExpressionContent *content) { // The target soname file (.so.1). - if(target->Target->IsDLLPlatform()) + if(target->IsDLLPlatform()) { ::reportError(context, content->GetOriginalExpression(), "TARGET_SONAME_FILE is not allowed " "for DLL target platforms."); return std::string(); } - if(target->GetType() != cmTarget::SHARED_LIBRARY) + if(target->GetType() != cmState::SHARED_LIBRARY) { ::reportError(context, content->GetOriginalExpression(), "TARGET_SONAME_FILE is allowed only for " "SHARED libraries."); return std::string(); } - std::string result = target->Target->GetDirectory(context->Config); + std::string result = target->GetDirectory(context->Config); result += "/"; result += target->GetSOName(context->Config); return result; @@ -1611,18 +1619,18 @@ struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag> std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; - if(!context->Makefile->IsOn(pdbSupportVar)) + if(!context->LG->GetMakefile()->IsOn(pdbSupportVar)) { ::reportError(context, content->GetOriginalExpression(), "TARGET_PDB_FILE is not supported by the target linker."); return std::string(); } - cmTarget::TargetType targetType = target->Target->GetType(); + cmState::TargetType targetType = target->GetType(); - if(targetType != cmTarget::SHARED_LIBRARY && - targetType != cmTarget::MODULE_LIBRARY && - targetType != cmTarget::EXECUTABLE) + if(targetType != cmState::SHARED_LIBRARY && + targetType != cmState::MODULE_LIBRARY && + targetType != cmState::EXECUTABLE) { ::reportError(context, content->GetOriginalExpression(), "TARGET_PDB_FILE is allowed only for " @@ -1630,7 +1638,7 @@ struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag> return std::string(); } - std::string result = target->Target->GetPDBDirectory(context->Config); + std::string result = target->GetPDBDirectory(context->Config); result += "/"; result += target->GetPDBName(context->Config); return result; @@ -1646,7 +1654,7 @@ struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag> const GeneratorExpressionContent *content) { // The file used to link to the target (.so, .lib, .a). - if(!target->Target->IsLinkable()) + if(!target->IsLinkable()) { ::reportError(context, content->GetOriginalExpression(), "TARGET_LINKER_FILE is allowed only for libraries and " @@ -1654,7 +1662,7 @@ struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag> return std::string(); } return target->GetFullPath(context->Config, - target->Target->HasImportLibrary()); + target->HasImportLibrary()); } }; @@ -1725,15 +1733,15 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode return std::string(); } cmGeneratorTarget* target = - context->Makefile->FindGeneratorTargetToUse(name); + context->LG->FindGeneratorTargetToUse(name); if(!target) { ::reportError(context, content->GetOriginalExpression(), "No target \"" + name + "\""); return std::string(); } - if(target->GetType() >= cmTarget::OBJECT_LIBRARY && - target->GetType() != cmTarget::UNKNOWN_LIBRARY) + if(target->GetType() >= cmState::OBJECT_LIBRARY && + target->GetType() != cmState::UNKNOWN_LIBRARY) { ::reportError(context, content->GetOriginalExpression(), "Target \"" + name + "\" is not an executable or library."); @@ -1748,8 +1756,8 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode "be used while evaluating link libraries"); return std::string(); } - context->DependTargets.insert(target->Target); - context->AllTargets.insert(target->Target); + context->DependTargets.insert(target); + context->AllTargets.insert(target); std::string result = TargetFilesystemArtifactResultCreator<ArtifactT>::Create( @@ -1792,6 +1800,27 @@ static const TargetFilesystemArtifactNodeGroup<ArtifactPdbTag> targetPdbNodeGroup; //---------------------------------------------------------------------------- +static const struct ShellPathNode : public cmGeneratorExpressionNode +{ + ShellPathNode() {} + + std::string Evaluate(const std::vector<std::string> ¶meters, + cmGeneratorExpressionContext *context, + const GeneratorExpressionContent *content, + cmGeneratorExpressionDAGChecker *) const + { + if (!cmSystemTools::FileIsFullPath(parameters.front())) + { + reportError(context, content->GetOriginalExpression(), + "\"" + parameters.front() + "\" is not an absolute path."); + return std::string(); + } + cmOutputConverter converter(context->LG->GetStateSnapshot()); + return converter.ConvertDirectorySeparatorsForShell(parameters.front()); + } +} shellPathNode; + +//---------------------------------------------------------------------------- const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(const std::string &identifier) { @@ -1846,6 +1875,7 @@ cmGeneratorExpressionNode::GetNode(const std::string &identifier) nodeMap["JOIN"] = &joinNode; nodeMap["LINK_ONLY"] = &linkOnlyNode; nodeMap["COMPILE_LANGUAGE"] = &languageNode; + nodeMap["SHELL_PATH"] = &shellPathNode; } NodeMap::const_iterator i = nodeMap.find(identifier); if (i == nodeMap.end()) @@ -1869,7 +1899,7 @@ void reportError(cmGeneratorExpressionContext *context, e << "Error evaluating generator expression:\n" << " " << expr << "\n" << result; - context->Makefile->GetCMakeInstance() + context->LG->GetCMakeInstance() ->IssueMessage(cmake::FATAL_ERROR, e.str(), context->Backtrace); } diff --git a/Source/cmGeneratorExpressionNode.h b/Source/cmGeneratorExpressionNode.h index 847a00a..db65db1 100644 --- a/Source/cmGeneratorExpressionNode.h +++ b/Source/cmGeneratorExpressionNode.h @@ -54,9 +54,10 @@ struct cmGeneratorExpressionNode ) const = 0; static std::string EvaluateDependentExpression( - std::string const& prop, cmMakefile *makefile, + std::string const& prop, cmLocalGenerator *lg, cmGeneratorExpressionContext *context, - cmTarget const* headTarget, cmTarget const* currentTarget, + const cmGeneratorTarget* headTarget, + const cmGeneratorTarget* currentTarget, cmGeneratorExpressionDAGChecker *dagChecker); static const cmGeneratorExpressionNode* GetNode( diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 09387b7..713ab6a 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -62,7 +62,7 @@ void reportBadObjLib(std::vector<cmSourceFile*> const& badObjLib, e << "but may contain only sources that compile, header files, and " "other files that would not affect linking of a normal library."; cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - target->Target->GetBacktrace()); + target->GetBacktrace()); } } @@ -75,6 +75,7 @@ struct IDLSourcesTag {}; struct ResxTag {}; struct ModuleDefinitionFileTag {}; struct AppManifestTag{}; +struct ManifestsTag{}; struct CertificatesTag{}; struct XamlTag{}; @@ -154,7 +155,7 @@ struct TagVisitor : Data(data), Target(target), GlobalGenerator(target->GetLocalGenerator()->GetGlobalGenerator()), Header(CM_HEADER_REGEX), - IsObjLib(target->GetType() == cmTarget::OBJECT_LIBRARY) + IsObjLib(target->GetType() == cmState::OBJECT_LIBRARY) { } @@ -171,7 +172,7 @@ struct TagVisitor { DoAccept<IsSameTag<Tag, CustomCommandsTag>::Result>::Do(this->Data, sf); } - else if(this->Target->GetType() == cmTarget::UTILITY) + else if(this->Target->GetType() == cmState::UTILITY) { DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf); } @@ -216,6 +217,10 @@ struct TagVisitor { DoAccept<IsSameTag<Tag, AppManifestTag>::Result>::Do(this->Data, sf); } + else if (ext == "manifest") + { + DoAccept<IsSameTag<Tag, ManifestsTag>::Result>::Do(this->Data, sf); + } else if (ext == "pfx") { DoAccept<IsSameTag<Tag, CertificatesTag>::Result>::Do(this->Data, sf); @@ -264,12 +269,17 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) DebugIncludesDone(false), DebugCompileOptionsDone(false), DebugCompileFeaturesDone(false), - DebugCompileDefinitionsDone(false) + DebugCompileDefinitionsDone(false), + DebugSourcesDone(false), + LinkImplementationLanguageIsContextDependent(true), + UtilityItemsDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); + this->GlobalGenerator->ComputeTargetObjectDirectory(this); + CreatePropertyGeneratorExpressions( t->GetIncludeDirectoriesEntries(), t->GetIncludeDirectoriesBacktraces(), @@ -289,6 +299,17 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetCompileDefinitionsEntries(), t->GetCompileDefinitionsBacktraces(), this->CompileDefinitionsEntries); + + CreatePropertyGeneratorExpressions( + t->GetSourceEntries(), + t->GetSourceBacktraces(), + this->SourceEntries, true); + + this->DLLPlatform = (this->Makefile->IsOn("WIN32") || + this->Makefile->IsOn("CYGWIN") || + this->Makefile->IsOn("MINGW")); + + this->PolicyMap = t->PolicyMap; } cmGeneratorTarget::~cmGeneratorTarget() @@ -297,6 +318,7 @@ cmGeneratorTarget::~cmGeneratorTarget() cmDeleteAll(this->CompileOptionsEntries); cmDeleteAll(this->CompileFeaturesEntries); cmDeleteAll(this->CompileDefinitionsEntries); + cmDeleteAll(this->SourceEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -307,7 +329,7 @@ cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const } //---------------------------------------------------------------------------- -int cmGeneratorTarget::GetType() const +cmState::TargetType cmGeneratorTarget::GetType() const { return this->Target->GetType(); } @@ -319,12 +341,88 @@ std::string cmGeneratorTarget::GetName() const } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetExportName() const +{ + const char *exportName = this->GetProperty("EXPORT_NAME"); + + if (exportName && *exportName) + { + if (!cmGeneratorExpression::IsValidTargetName(exportName)) + { + std::ostringstream e; + e << "EXPORT_NAME property \"" << exportName << "\" for \"" + << this->GetName() << "\": is not valid."; + cmSystemTools::Error(e.str().c_str()); + return ""; + } + return exportName; + } + return this->GetName(); +} + +//---------------------------------------------------------------------------- const char *cmGeneratorTarget::GetProperty(const std::string& prop) const { return this->Target->GetProperty(prop); } //---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const +{ + switch(this->GetType()) + { + case cmState::SHARED_LIBRARY: + if(this->IsDLLPlatform()) + { + if(implib) + { + // A DLL import library is treated as an archive target. + return "ARCHIVE"; + } + else + { + // A DLL shared library is treated as a runtime target. + return "RUNTIME"; + } + } + else + { + // For non-DLL platforms shared libraries are treated as + // library targets. + return "LIBRARY"; + } + case cmState::STATIC_LIBRARY: + // Static libraries are always treated as archive targets. + return "ARCHIVE"; + case cmState::MODULE_LIBRARY: + if(implib) + { + // Module libraries are always treated as library targets. + return "ARCHIVE"; + } + else + { + // Module import libraries are treated as archive targets. + return "LIBRARY"; + } + case cmState::EXECUTABLE: + if(implib) + { + // Executable import libraries are treated as archive targets. + return "ARCHIVE"; + } + else + { + // Executables are always treated as runtime targets. + return "RUNTIME"; + } + default: + break; + } + return ""; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetOutputName(const std::string& config, bool implib) const { @@ -340,7 +438,7 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, // Compute output name. std::vector<std::string> props; - std::string type = this->Target->GetOutputTargetType(implib); + std::string type = this->GetOutputTargetType(implib); std::string configUpper = cmSystemTools::UpperCase(config); if(!type.empty() && !configUpper.empty()) { @@ -366,7 +464,7 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, for(std::vector<std::string>::const_iterator it = props.begin(); it != props.end(); ++it) { - if (const char* outNameProp = this->Target->GetProperty(*it)) + if (const char* outNameProp = this->GetProperty(*it)) { outName = outNameProp; break; @@ -381,35 +479,67 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, // Now evaluate genex and update the previously-prepared map entry. cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(outName); - i->second = cge->Evaluate(this->Makefile, config); + i->second = cge->Evaluate(this->LocalGenerator, config); } else if(i->second.empty()) { // An empty map entry indicates we have been called recursively // from the above block. - this->Makefile->GetCMakeInstance()->IssueMessage( + this->LocalGenerator->GetCMakeInstance() + ->IssueMessage( cmake::FATAL_ERROR, "Target '" + this->GetName() + "' OUTPUT_NAME depends on itself.", - this->Target->GetBacktrace()); + this->GetBacktrace()); } return i->second; } +void cmGeneratorTarget::AddSource(const std::string& src) +{ + this->Target->AddSource(src); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src); + cge->SetEvaluateForBuildsystem(true); + this->SourceEntries.push_back( + new TargetPropertyEntry(cge)); + this->SourceFilesMap.clear(); + this->LinkImplementationLanguageIsContextDependent = true; +} + +void cmGeneratorTarget::AddTracedSources(std::vector<std::string> const& srcs) +{ + this->Target->AddTracedSources(srcs); + if (!srcs.empty()) + { + std::string srcFiles = cmJoin(srcs, ";"); + this->SourceFilesMap.clear(); + this->LinkImplementationLanguageIsContextDependent = true; + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles); + cge->SetEvaluateForBuildsystem(true); + this->SourceEntries.push_back( + new cmGeneratorTarget::TargetPropertyEntry(cge)); + } +} + //---------------------------------------------------------------------------- std::vector<cmSourceFile*> const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { - SourceEntriesType::const_iterator i = this->SourceEntries.find(sf); - if(i != this->SourceEntries.end()) + SourceEntriesType::const_iterator i = this->SourceDepends.find(sf); + if(i != this->SourceDepends.end()) { return &i->second.Depends; } return 0; } -static void handleSystemIncludesDep(cmMakefile *mf, cmTarget const* depTgt, +static void handleSystemIncludesDep(cmLocalGenerator *lg, + cmGeneratorTarget const* depTgt, const std::string& config, - cmTarget *headTarget, + cmGeneratorTarget const* headTarget, cmGeneratorExpressionDAGChecker *dagChecker, std::vector<std::string>& result, bool excludeImported) @@ -419,7 +549,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget const* depTgt, { cmGeneratorExpression ge; cmSystemTools::ExpandListArgument(ge.Parse(dirs) - ->Evaluate(mf, + ->Evaluate(lg, config, false, headTarget, depTgt, dagChecker), result); } @@ -433,7 +563,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget const* depTgt, { cmGeneratorExpression ge; cmSystemTools::ExpandListArgument(ge.Parse(dirs) - ->Evaluate(mf, + ->Evaluate(lg, config, false, headTarget, depTgt, dagChecker), result); } @@ -442,7 +572,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget const* depTgt, #define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE) \ { \ std::vector<cmSourceFile*> sourceFiles; \ - this->Target->GetSourceFiles(sourceFiles, config); \ + this->GetSourceFiles(sourceFiles, config); \ TagVisitor<DATA ## Tag DATATYPE> visitor(this, data); \ for(std::vector<cmSourceFile*>::const_iterator si = sourceFiles.begin(); \ si != sourceFiles.end(); ++si) \ @@ -510,12 +640,12 @@ const char* cmGeneratorTarget::GetFeature(const std::string& feature, std::string featureConfig = feature; featureConfig += "_"; featureConfig += cmSystemTools::UpperCase(config); - if(const char* value = this->Target->GetProperty(featureConfig)) + if(const char* value = this->GetProperty(featureConfig)) { return value; } } - if(const char* value = this->Target->GetProperty(feature)) + if(const char* value = this->GetProperty(feature)) { return value; } @@ -626,6 +756,15 @@ cmGeneratorTarget //---------------------------------------------------------------------------- void cmGeneratorTarget +::GetManifests(std::vector<cmSourceFile const*>& data, + const std::string& config) const +{ + IMPLEMENT_VISIT(Manifests); +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget ::GetCertificates(std::vector<cmSourceFile const*>& data, const std::string& config) const { @@ -649,7 +788,24 @@ cmGeneratorTarget::GetExpectedXamlSources(std::set<std::string>& srcs, { XamlData data; IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData) - srcs = data.ExpectedXamlSources; + srcs = data.ExpectedXamlSources; +} + +std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const +{ + if(!this->UtilityItemsDone) + { + this->UtilityItemsDone = true; + std::set<std::string> const& utilities = this->Target->GetUtilities(); + for(std::set<std::string>::const_iterator i = utilities.begin(); + i != utilities.end(); ++i) + { + cmGeneratorTarget* gt = + this->LocalGenerator->FindGeneratorTargetToUse(*i); + this->UtilityItems.insert(cmLinkItem(*i, gt)); + } + } + return this->UtilityItems; } //---------------------------------------------------------------------------- @@ -666,7 +822,7 @@ void cmGeneratorTarget const char* cmGeneratorTarget::GetLocation(const std::string& config) const { static std::string location; - if (this->Target->IsImported()) + if (this->IsImported()) { location = this->Target->ImportedGetFullPath(config, false); } @@ -693,7 +849,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } // Now handle the deprecated build-time configuration location. - location = this->Target->GetDirectory(); + location = this->GetDirectory(); const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR"); if(cfgid && strcmp(cfgid, ".") != 0) { @@ -701,7 +857,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const location += cfgid; } - if(this->Target->IsAppBundleOnApple()) + if(this->IsAppBundleOnApple()) { std::string macdir = this->BuildMacContentDirectory("", "", false); @@ -721,7 +877,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const { - assert(this->GetType() != cmTarget::INTERFACE_LIBRARY); + assert(this->GetType() != cmState::INTERFACE_LIBRARY); std::string config_upper; if(!config.empty()) { @@ -739,7 +895,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, "SYSTEM_INCLUDE_DIRECTORIES", 0, 0); bool excludeImported - = this->Target->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED"); + = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED"); std::vector<std::string> result; for (std::set<std::string>::const_iterator @@ -748,17 +904,17 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, { cmGeneratorExpression ge; cmSystemTools::ExpandListArgument(ge.Parse(*it) - ->Evaluate(this->Makefile, - config, false, this->Target, + ->Evaluate(this->LocalGenerator, + config, false, this, &dagChecker), result); } - std::vector<cmTarget const*> const& deps = + std::vector<cmGeneratorTarget const*> const& deps = this->GetLinkImplementationClosure(config); - for(std::vector<cmTarget const*>::const_iterator + for(std::vector<cmGeneratorTarget const*>::const_iterator li = deps.begin(), le = deps.end(); li != le; ++li) { - handleSystemIncludesDep(this->Makefile, *li, config, this->Target, + handleSystemIncludesDep(this->LocalGenerator, *li, config, this, &dagChecker, result, excludeImported); } @@ -786,10 +942,258 @@ bool cmGeneratorTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- +static void AddInterfaceEntries( + cmGeneratorTarget const* thisTarget, std::string const& config, + std::string const& prop, + std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries) +{ + if(cmLinkImplementationLibraries const* impl = + thisTarget->GetLinkImplementationLibraries(config)) + { + for (std::vector<cmLinkImplItem>::const_iterator + it = impl->Libraries.begin(), end = impl->Libraries.end(); + it != end; ++it) + { + if(it->Target) + { + std::string genex = + "$<TARGET_PROPERTY:" + *it + "," + prop + ">"; + cmGeneratorExpression ge(it->Backtrace); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex); + cge->SetEvaluateForBuildsystem(true); + entries.push_back( + new cmGeneratorTarget::TargetPropertyEntry(cge, *it)); + } + } + } +} + +//---------------------------------------------------------------------------- +static bool processSources(cmGeneratorTarget const* tgt, + const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries, + std::vector<std::string> &srcs, + UNORDERED_SET<std::string> &uniqueSrcs, + cmGeneratorExpressionDAGChecker *dagChecker, + std::string const& config, bool debugSources) +{ + cmMakefile *mf = tgt->Target->GetMakefile(); + + bool contextDependent = false; + + for (std::vector<cmGeneratorTarget::TargetPropertyEntry*>::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) + { + cmLinkImplItem const& item = (*it)->LinkImplItem; + std::string const& targetName = item; + std::vector<std::string> entrySources; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate( + tgt->GetLocalGenerator(), + config, + false, + tgt, + tgt, + dagChecker), + entrySources); + + if ((*it)->ge->GetHadContextSensitiveCondition()) + { + contextDependent = true; + } + + for(std::vector<std::string>::iterator i = entrySources.begin(); + i != entrySources.end(); ++i) + { + std::string& src = *i; + cmSourceFile* sf = mf->GetOrCreateSource(src); + std::string e; + std::string fullPath = sf->GetFullPath(&e); + if(fullPath.empty()) + { + if(!e.empty()) + { + cmake* cm = tgt->GetLocalGenerator()->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e, + tgt->GetBacktrace()); + } + return contextDependent; + } + + if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src.c_str())) + { + std::ostringstream err; + if (!targetName.empty()) + { + err << "Target \"" << targetName << "\" contains relative " + "path in its INTERFACE_SOURCES:\n" + " \"" << src << "\""; + } + else + { + err << "Found relative path while evaluating sources of " + "\"" << tgt->GetName() << "\":\n \"" << src << "\"\n"; + } + tgt->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, err.str()); + return contextDependent; + } + src = fullPath; + } + std::string usedSources; + for(std::vector<std::string>::iterator + li = entrySources.begin(); li != entrySources.end(); ++li) + { + std::string src = *li; + + if(uniqueSrcs.insert(src).second) + { + srcs.push_back(src); + if (debugSources) + { + usedSources += " * " + src + "\n"; + } + } + } + if (!usedSources.empty()) + { + tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used sources for target ") + + tgt->GetName() + ":\n" + + usedSources, (*it)->ge->GetBacktrace()); + } + } + return contextDependent; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetSourceFiles(std::vector<std::string> &files, + const std::string& config) const +{ + assert(this->GetType() != cmState::INTERFACE_LIBRARY); + + if (!this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) + { + // At configure-time, this method can be called as part of getting the + // LOCATION property or to export() a file to be include()d. However + // there is no cmGeneratorTarget at configure-time, so search the SOURCES + // for TARGET_OBJECTS instead for backwards compatibility with OLD + // behavior of CMP0024 and CMP0026 only. + + cmStringRange sourceEntries = this->Target->GetSourceEntries(); + for(cmStringRange::const_iterator + i = sourceEntries.begin(); + i != sourceEntries.end(); ++i) + { + std::string const& entry = *i; + + std::vector<std::string> items; + cmSystemTools::ExpandListArgument(entry, items); + for (std::vector<std::string>::const_iterator + li = items.begin(); li != items.end(); ++li) + { + if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") && + (*li)[li->size() - 1] == '>') + { + continue; + } + files.push_back(*li); + } + } + return; + } + + std::vector<std::string> debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugSources = !this->DebugSourcesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "SOURCES") + != debugProperties.end(); + + if (this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) + { + this->DebugSourcesDone = true; + } + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "SOURCES", 0, 0); + + UNORDERED_SET<std::string> uniqueSrcs; + bool contextDependentDirectSources = processSources(this, + this->SourceEntries, + files, + uniqueSrcs, + &dagChecker, + config, + debugSources); + + std::vector<cmGeneratorTarget::TargetPropertyEntry*> + linkInterfaceSourcesEntries; + + AddInterfaceEntries( + this, config, "INTERFACE_SOURCES", + linkInterfaceSourcesEntries); + + std::vector<std::string>::size_type numFilesBefore = files.size(); + bool contextDependentInterfaceSources = processSources(this, + linkInterfaceSourcesEntries, + files, + uniqueSrcs, + &dagChecker, + config, + debugSources); + + if (!contextDependentDirectSources + && !(contextDependentInterfaceSources && numFilesBefore < files.size())) + { + this->LinkImplementationLanguageIsContextDependent = false; + } + + cmDeleteAll(linkInterfaceSourcesEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files, const std::string& config) const { - this->Target->GetSourceFiles(files, config); + + // Lookup any existing link implementation for this configuration. + std::string key = cmSystemTools::UpperCase(config); + + if(!this->LinkImplementationLanguageIsContextDependent) + { + files = this->SourceFilesMap.begin()->second; + return; + } + + SourceFilesMapType::iterator + it = this->SourceFilesMap.find(key); + if(it != this->SourceFilesMap.end()) + { + files = it->second; + } + else + { + std::vector<std::string> srcs; + this->GetSourceFiles(srcs, config); + + std::set<cmSourceFile*> emitted; + + for(std::vector<std::string>::const_iterator i = srcs.begin(); + i != srcs.end(); ++i) + { + cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i); + if (emitted.insert(sf).second) + { + files.push_back(sf); + } + } + this->SourceFilesMap[key] = files; + } } //---------------------------------------------------------------------------- @@ -805,13 +1209,13 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string configUpper = cmSystemTools::UpperCase(config); std::string configProp = "COMPILE_PDB_NAME_"; configProp += configUpper; - const char* config_name = this->Target->GetProperty(configProp); + const char* config_name = this->GetProperty(configProp); if(config_name && *config_name) { return prefix + config_name + ".pdb"; } - const char* name = this->Target->GetProperty("COMPILE_PDB_NAME"); + const char* name = this->GetProperty("COMPILE_PDB_NAME"); if(name && *name) { return prefix + name + ".pdb"; @@ -828,7 +1232,7 @@ cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const std::string name = this->GetCompilePDBName(config); if(dir.empty() && !name.empty()) { - dir = this->Target->GetPDBDirectory(config); + dir = this->GetPDBDirectory(config); } if(!dir.empty()) { @@ -842,7 +1246,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, // and then only when the platform supports an soname flag. - return ((this->GetType() == cmTarget::SHARED_LIBRARY) && + return ((this->GetType() == cmState::SHARED_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } @@ -853,9 +1257,9 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const { // Only executables and shared libraries can have an rpath and may // need relinking. - if(this->GetType() != cmTarget::EXECUTABLE && - this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY) + if(this->GetType() != cmState::EXECUTABLE && + this->GetType() != cmState::SHARED_LIBRARY && + this->GetType() != cmState::MODULE_LIBRARY) { return false; } @@ -910,16 +1314,16 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const // will likely change between the build tree and install tree and // this target must be relinked. return this->HaveBuildTreeRPATH(config) - || this->Target->HaveInstallTreeRPATH(); + || this->HaveInstallTreeRPATH(); } //---------------------------------------------------------------------------- bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const { // Only certain target types have an rpath. - if(!(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || - this->GetType() == cmTarget::EXECUTABLE)) + if(!(this->GetType() == cmState::SHARED_LIBRARY || + this->GetType() == cmState::MODULE_LIBRARY || + this->GetType() == cmState::EXECUTABLE)) { return false; } @@ -980,14 +1384,144 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const return false; } +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsImportedSharedLibWithoutSOName( + const std::string& config) const +{ + if(this->IsImported() && this->GetType() == cmState::SHARED_LIBRARY) + { + if(cmGeneratorTarget::ImportInfo const* info = + this->GetImportInfo(config)) + { + return info->NoSOName; + } + } + return false; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir( + const std::string& config) const +{ + bool install_name_is_rpath = false; + bool macosx_rpath = false; + + if(!this->IsImported()) + { + if(this->GetType() != cmState::SHARED_LIBRARY) + { + return false; + } + const char* install_name = this->GetProperty("INSTALL_NAME_DIR"); + bool use_install_name = + this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"); + if(install_name && use_install_name && + std::string(install_name) == "@rpath") + { + install_name_is_rpath = true; + } + else if(install_name && use_install_name) + { + return false; + } + if(!install_name_is_rpath) + { + macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); + } + } + else + { + // Lookup the imported soname. + if(cmGeneratorTarget::ImportInfo const* info = + this->GetImportInfo(config)) + { + if(!info->NoSOName && !info->SOName.empty()) + { + if(info->SOName.find("@rpath/") == 0) + { + install_name_is_rpath = true; + } + } + else + { + std::string install_name; + cmSystemTools::GuessLibraryInstallName(info->Location, install_name); + if(install_name.find("@rpath") != std::string::npos) + { + install_name_is_rpath = true; + } + } + } + } + + if(!install_name_is_rpath && !macosx_rpath) + { + return false; + } + + if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG")) + { + std::ostringstream w; + w << "Attempting to use"; + if(macosx_rpath) + { + w << " MACOSX_RPATH"; + } + else + { + w << " @rpath"; + } + w << " without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being set."; + w << " This could be because you are using a Mac OS X version"; + w << " less than 10.5 or because CMake's platform configuration is"; + w << " corrupt."; + cmake* cm = this->LocalGenerator->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, w.str(), + this->GetBacktrace()); + } + + return true; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const +{ + // we can't do rpaths when unsupported + if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG")) + { + return false; + } + + const char* macosx_rpath_str = this->GetProperty("MACOSX_RPATH"); + if(macosx_rpath_str) + { + return this->GetPropertyAsBool("MACOSX_RPATH"); + } + + cmPolicies::PolicyStatus cmp0042 = this->GetPolicyStatusCMP0042(); + + if(cmp0042 == cmPolicies::WARN) + { + this->LocalGenerator->GetGlobalGenerator()-> + AddCMP0042WarnTarget(this->GetName()); + } + + if(cmp0042 == cmPolicies::NEW) + { + return true; + } + + return false; +} //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { - if(this->Target->IsImported()) + if(this->IsImported()) { // Lookup the imported soname. - if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + if(cmGeneratorTarget::ImportInfo const* info = + this->GetImportInfo(config)) { if(info->NoSOName) { @@ -1044,9 +1578,9 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, //---------------------------------------------------------------------------- bool cmGeneratorTarget::IsBundleOnApple() const { - return this->Target->IsFrameworkOnApple() - || this->Target->IsAppBundleOnApple() - || this->Target->IsCFBundleOnApple(); + return this->IsFrameworkOnApple() + || this->IsAppBundleOnApple() + || this->IsCFBundleOnApple(); } //---------------------------------------------------------------------------- @@ -1056,10 +1590,10 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, std::string fpath; fpath += this->GetOutputName(config, false); fpath += "."; - const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + const char *ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { - if (this->Target->IsXCTestOnApple()) + if (this->IsXCTestOnApple()) { ext = "xctest"; } @@ -1098,9 +1632,9 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, std::string cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const { - if(this->Target->IsImported()) + if(this->IsImported()) { - return this->Target->GetFullNameImported(config, implib); + return this->GetFullNameImported(config, implib); } else { @@ -1126,13 +1660,13 @@ cmGeneratorTarget::GetInstallNameDirForBuildTree( !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) { std::string dir; - if(this->Target->MacOSXRpathInstallNameDirDefault()) + if(this->MacOSXRpathInstallNameDirDefault()) { dir = "@rpath"; } else { - dir = this->Target->GetDirectory(config); + dir = this->GetDirectory(config); } dir += "/"; return dir; @@ -1162,7 +1696,7 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } if(!install_name_dir) { - if(this->Target->MacOSXRpathInstallNameDirDefault()) + if(this->MacOSXRpathInstallNameDirDefault()) { dir = "@rpath/"; } @@ -1175,6 +1709,47 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } } +cmListFileBacktrace cmGeneratorTarget::GetBacktrace() const +{ + return this->Target->GetBacktrace(); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HaveWellDefinedOutputFiles() const +{ + return + this->GetType() == cmState::STATIC_LIBRARY || + this->GetType() == cmState::SHARED_LIBRARY || + this->GetType() == cmState::MODULE_LIBRARY || + this->GetType() == cmState::EXECUTABLE; +} + +//---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetExportMacro() const +{ + // Define the symbol for targets that export symbols. + if(this->GetType() == cmState::SHARED_LIBRARY || + this->GetType() == cmState::MODULE_LIBRARY || + this->IsExecutableWithExports()) + { + if(const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL")) + { + this->ExportMacro = custom_export_name; + } + else + { + std::string in = this->GetName(); + in += "_EXPORTS"; + this->ExportMacro = cmSystemTools::MakeCidentifier(in); + } + return this->ExportMacro.c_str(); + } + else + { + return 0; + } +} + //---------------------------------------------------------------------------- class cmTargetCollectLinkLanguages { @@ -1182,10 +1757,10 @@ public: cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, const std::string& config, UNORDERED_SET<std::string>& languages, - cmTarget const* head): + cmGeneratorTarget const* head): Config(config), Languages(languages), HeadTarget(head), Makefile(target->Target->GetMakefile()), Target(target) - { this->Visited.insert(target->Target); } + { this->Visited.insert(target); } void Visit(cmLinkItem const& item) { @@ -1220,8 +1795,8 @@ public: << "\" but the target was not found. Perhaps a find_package() " "call is missing for an IMPORTED target, or an ALIAS target is " "missing?"; - this->Makefile->GetCMakeInstance()->IssueMessage( - messageType, e.str(), this->Target->Target->GetBacktrace()); + this->Target->GetLocalGenerator()->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->Target->GetBacktrace()); } } return; @@ -1230,11 +1805,8 @@ public: { return; } - cmGeneratorTarget* gtgt = - this->Target->GetLocalGenerator()->GetGlobalGenerator() - ->GetGeneratorTarget(item.Target); cmLinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->HeadTarget); + item.Target->GetLinkInterface(this->Config, this->HeadTarget); if(!iface) { return; } for(std::vector<std::string>::const_iterator @@ -1252,10 +1824,10 @@ public: private: std::string Config; UNORDERED_SET<std::string>& Languages; - cmTarget const* HeadTarget; + cmGeneratorTarget const* HeadTarget; cmMakefile* Makefile; const cmGeneratorTarget* Target; - std::set<cmTarget const*> Visited; + std::set<cmGeneratorTarget const*> Visited; }; //---------------------------------------------------------------------------- @@ -1280,14 +1852,12 @@ class cmTargetSelectLinker { int Preference; cmGeneratorTarget const* Target; - cmMakefile* Makefile; cmGlobalGenerator* GG; std::set<std::string> Preferred; public: cmTargetSelectLinker(cmGeneratorTarget const* target) : Preference(0), Target(target) { - this->Makefile = this->Target->Makefile; this->GG = this->Target->GetLocalGenerator()->GetGlobalGenerator(); } void Consider(const char* lang) @@ -1321,9 +1891,9 @@ public: e << " " << *li << "\n"; } e << "Set the LINKER_LANGUAGE property for this target."; - cmake* cm = this->Makefile->GetCMakeInstance(); + cmake* cm = this->Target->GetLocalGenerator()->GetCMakeInstance(); cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } return *this->Preferred.begin(); } @@ -1345,7 +1915,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, } // Add interface languages from linked targets. - cmTargetCollectLinkLanguages cll(this, config, languages, this->Target); + cmTargetCollectLinkLanguages cll(this, config, languages, this); for(std::vector<cmLinkImplItem>::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { @@ -1412,15 +1982,15 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, bool contentOnly) const { std::string fpath = base; - if(this->Target->IsAppBundleOnApple()) + if(this->IsAppBundleOnApple()) { fpath += this->GetAppBundleDirectory(config, contentOnly); } - if(this->Target->IsFrameworkOnApple()) + if(this->IsFrameworkOnApple()) { fpath += this->GetFrameworkDirectory(config, contentOnly); } - if(this->Target->IsCFBundleOnApple()) + if(this->IsCFBundleOnApple()) { fpath += this->GetCFBundleDirectory(config, contentOnly); } @@ -1433,10 +2003,10 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config, bool implib) const { // Start with the output directory for the target. - std::string fpath = this->Target->GetDirectory(config, implib); + std::string fpath = this->GetDirectory(config, implib); fpath += "/"; bool contentOnly = true; - if(this->Target->IsFrameworkOnApple()) + if(this->IsFrameworkOnApple()) { // additional files with a framework go into the version specific // directory @@ -1457,12 +2027,12 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( return 0; } - if(this->GetType() > cmTarget::OBJECT_LIBRARY) + if(this->GetType() > cmState::OBJECT_LIBRARY) { std::string msg = "cmTarget::GetCompileInfo called for "; msg += this->GetName(); msg += " which has type "; - msg += cmTarget::GetTargetTypeName(this->Target->GetType()); + msg += cmState::GetTargetTypeName(this->GetType()); this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); return 0; } @@ -1478,8 +2048,7 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( if(i == this->CompileInfoMap.end()) { CompileInfo info; - this->Target - ->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); + this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); CompileInfoMapType::value_type entry(config_upper, info); i = this->CompileInfoMap.insert(entry).first; } @@ -1495,6 +2064,11 @@ cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const return data; } +bool cmGeneratorTarget::IsDLLPlatform() const +{ + return this->DLLPlatform; +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs, @@ -1502,27 +2076,26 @@ cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs, { std::vector<cmSourceFile const*> objectFiles; this->GetExternalObjects(objectFiles, config); - std::vector<cmTarget*> objectLibraries; + std::vector<cmGeneratorTarget*> objectLibraries; for(std::vector<cmSourceFile const*>::const_iterator it = objectFiles.begin(); it != objectFiles.end(); ++it) { std::string objLib = (*it)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + if (cmGeneratorTarget* tgt = + this->LocalGenerator->FindGeneratorTargetToUse(objLib)) { objectLibraries.push_back(tgt); } } - std::vector<cmTarget*>::const_iterator end + std::vector<cmGeneratorTarget*>::const_iterator end = cmRemoveDuplicates(objectLibraries); - for(std::vector<cmTarget*>::const_iterator + for(std::vector<cmGeneratorTarget*>::const_iterator ti = objectLibraries.begin(); ti != end; ++ti) { - cmTarget* objLib = *ti; - cmGeneratorTarget* ogt = - this->GlobalGenerator->GetGeneratorTarget(objLib); + cmGeneratorTarget* ogt = *ti; std::vector<cmSourceFile const*> objectSources; ogt->GetObjectSources(objectSources, config); for(std::vector<cmSourceFile const*>::const_iterator @@ -1553,28 +2126,27 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string> &result, this->GetName(), "AUTOUIC_OPTIONS", 0, 0); cmSystemTools::ExpandListArgument(ge.Parse(prop) - ->Evaluate(this->Makefile, + ->Evaluate(this->LocalGenerator, config, false, - this->Target, + this, &dagChecker), result); } //---------------------------------------------------------------------------- void processILibs(const std::string& config, - cmTarget const* headTarget, + cmGeneratorTarget const* headTarget, cmLinkItem const& item, cmGlobalGenerator* gg, - std::vector<cmTarget const*>& tgts, - std::set<cmTarget const*>& emitted) + std::vector<cmGeneratorTarget const*>& tgts, + std::set<cmGeneratorTarget const*>& emitted) { if (item.Target && emitted.insert(item.Target).second) { tgts.push_back(item.Target); - cmGeneratorTarget* gt = gg->GetGeneratorTarget(item.Target); if(cmLinkInterfaceLibraries const* iface = - gt->GetLinkInterfaceLibraries(config, headTarget, true)) + item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) { for(std::vector<cmLinkItem>::const_iterator it = iface->Libraries.begin(); @@ -1587,7 +2159,7 @@ void processILibs(const std::string& config, } //---------------------------------------------------------------------------- -const std::vector<const cmTarget*>& +const std::vector<const cmGeneratorTarget*>& cmGeneratorTarget::GetLinkImplementationClosure( const std::string& config) const { @@ -1596,16 +2168,16 @@ cmGeneratorTarget::GetLinkImplementationClosure( if(!tgts.Done) { tgts.Done = true; - std::set<cmTarget const*> emitted; + std::set<cmGeneratorTarget const*> emitted; cmLinkImplementationLibraries const* impl - = this->Target->GetLinkImplementationLibraries(config); + = this->GetLinkImplementationLibraries(config); for(std::vector<cmLinkImplItem>::const_iterator it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) { - processILibs(config, this->Target, *it, + processILibs(config, this, *it, this->LocalGenerator->GetGlobalGenerator(), tgts , emitted); } @@ -1620,9 +2192,9 @@ public: cmTargetTraceDependencies(cmGeneratorTarget* target); void Trace(); private: - cmTarget* Target; cmGeneratorTarget* GeneratorTarget; cmMakefile* Makefile; + cmLocalGenerator* LocalGenerator; cmGlobalGenerator const* GlobalGenerator; typedef cmGeneratorTarget::SourceEntry SourceEntry; SourceEntry* CurrentEntry; @@ -1646,15 +2218,16 @@ private: //---------------------------------------------------------------------------- cmTargetTraceDependencies ::cmTargetTraceDependencies(cmGeneratorTarget* target): - Target(target->Target), GeneratorTarget(target) + GeneratorTarget(target) { // Convenience. - this->Makefile = this->Target->GetMakefile(); - this->GlobalGenerator = target->GetLocalGenerator()->GetGlobalGenerator(); + this->Makefile = target->Target->GetMakefile(); + this->LocalGenerator = target->GetLocalGenerator(); + this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); this->CurrentEntry = 0; // Queue all the source files already specified for the target. - if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) + if (target->GetType() != cmState::INTERFACE_LIBRARY) { std::vector<std::string> configs; this->Makefile->GetConfigurations(configs); @@ -1667,14 +2240,14 @@ cmTargetTraceDependencies ci != configs.end(); ++ci) { std::vector<cmSourceFile*> sources; - this->Target->GetSourceFiles(sources, *ci); + this->GeneratorTarget->GetSourceFiles(sources, *ci); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); si != sources.end(); ++si) { cmSourceFile* sf = *si; - const std::set<cmTarget const*> tgts = + const std::set<cmGeneratorTarget const*> tgts = this->GlobalGenerator->GetFilenameTargetDepends(sf); - if (tgts.find(this->Target) != tgts.end()) + if (tgts.find(this->GeneratorTarget) != tgts.end()) { std::ostringstream e; e << "Evaluation output file\n \"" << sf->GetFullPath() @@ -1693,9 +2266,12 @@ cmTargetTraceDependencies } // Queue pre-build, pre-link, and post-build rule dependencies. - this->CheckCustomCommands(this->Target->GetPreBuildCommands()); - this->CheckCustomCommands(this->Target->GetPreLinkCommands()); - this->CheckCustomCommands(this->Target->GetPostBuildCommands()); + this->CheckCustomCommands( + this->GeneratorTarget->Target->GetPreBuildCommands()); + this->CheckCustomCommands( + this->GeneratorTarget->Target->GetPreLinkCommands()); + this->CheckCustomCommands( + this->GeneratorTarget->Target->GetPostBuildCommands()); } //---------------------------------------------------------------------------- @@ -1707,7 +2283,7 @@ void cmTargetTraceDependencies::Trace() // Get the next source from the queue. cmSourceFile* sf = this->SourceQueue.front(); this->SourceQueue.pop(); - this->CurrentEntry = &this->GeneratorTarget->SourceEntries[sf]; + this->CurrentEntry = &this->GeneratorTarget->SourceDepends[sf]; // Queue dependencies added explicitly by the user. if(const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) @@ -1739,7 +2315,7 @@ void cmTargetTraceDependencies::Trace() } this->CurrentEntry = 0; - this->Target->AddTracedSources(this->NewSources); + this->GeneratorTarget->AddTracedSources(this->NewSources); } //---------------------------------------------------------------------------- @@ -1804,15 +2380,16 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) // Check for a target with this name. if(cmGeneratorTarget* t - = this->Makefile->FindGeneratorTargetToUse(util)) + = this->GeneratorTarget-> + GetLocalGenerator()->FindGeneratorTargetToUse(util)) { // If we find the target and the dep was given as a full path, // then make sure it was not a full path to something else, and // the fact that the name matched a target was just a coincidence. if(cmSystemTools::FileIsFullPath(dep.c_str())) { - if(t->GetType() >= cmTarget::EXECUTABLE && - t->GetType() <= cmTarget::MODULE_LIBRARY) + if(t->GetType() >= cmState::EXECUTABLE && + t->GetType() <= cmState::MODULE_LIBRARY) { // This is really only for compatibility so we do not need to // worry about configuration names and output names. @@ -1823,7 +2400,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) tLocation = cmSystemTools::CollapseFullPath(tLocation); if(depLocation == tLocation) { - this->Target->AddUtility(util); + this->GeneratorTarget->Target->AddUtility(util); return true; } } @@ -1832,7 +2409,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) { // The original name of the dependency was not a full path. It // must name a target, so add the target-level dependency. - this->Target->AddUtility(util); + this->GeneratorTarget->Target->AddUtility(util); return true; } } @@ -1851,22 +2428,23 @@ cmTargetTraceDependencies cmGeneratorExpression ge(cc.GetBacktrace()); // Add target-level dependencies referenced by generator expressions. - std::set<cmTarget*> targets; + std::set<cmGeneratorTarget*> targets; for(cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin(); cit != cc.GetCommandLines().end(); ++cit) { std::string const& command = *cit->begin(); // Check for a target with this name. - if(cmTarget* t = this->Makefile->FindTargetToUse(command)) + if(cmGeneratorTarget* t = + this->LocalGenerator->FindGeneratorTargetToUse(command)) { - if(t->GetType() == cmTarget::EXECUTABLE) + if(t->GetType() == cmState::EXECUTABLE) { // The command refers to an executable target built in // this project. Add the target-level dependency to make // sure the executable is up to date before this custom // command possibly runs. - this->Target->AddUtility(command); + this->GeneratorTarget->Target->AddUtility(command); } } @@ -1876,16 +2454,16 @@ cmTargetTraceDependencies { const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*cli); - cge->Evaluate(this->Makefile, "", true); - std::set<cmTarget*> geTargets = cge->GetTargets(); + cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "", true); + std::set<cmGeneratorTarget*> geTargets = cge->GetTargets(); targets.insert(geTargets.begin(), geTargets.end()); } } - for(std::set<cmTarget*>::iterator ti = targets.begin(); + for(std::set<cmGeneratorTarget*>::iterator ti = targets.begin(); ti != targets.end(); ++ti) { - this->Target->AddUtility((*ti)->GetName()); + this->GeneratorTarget->Target->AddUtility((*ti)->GetName()); } // Queue the custom command dependencies. @@ -1948,7 +2526,7 @@ void cmGeneratorTarget::TraceDependencies() // would find nothing anyway, but when building CMake itself the "install" // target command ends up referencing the "cmake" target but we do not // really want the dependency because "install" depend on "all" anyway. - if(this->GetType() == cmTarget::GLOBAL_TARGET) + if(this->GetType() == cmState::GLOBAL_TARGET) { return; } @@ -1977,11 +2555,11 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config, { std::string defVarName = "OSX_ARCHITECTURES_"; defVarName += cmSystemTools::UpperCase(config); - archs = this->Target->GetProperty(defVarName); + archs = this->GetProperty(defVarName); } if(!archs) { - archs = this->Target->GetProperty("OSX_ARCHITECTURES"); + archs = this->GetProperty("OSX_ARCHITECTURES"); } if(archs) { @@ -1996,7 +2574,7 @@ cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang, { switch(this->GetType()) { - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: { std::string var = "CMAKE_" + lang + "_CREATE_STATIC_LIBRARY"; if(this->GetFeatureAsBool( @@ -2010,11 +2588,11 @@ cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang, } return var; } - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: return "CMAKE_" + lang + "_CREATE_SHARED_LIBRARY"; - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: return "CMAKE_" + lang + "_CREATE_SHARED_MODULE"; - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: return "CMAKE_" + lang + "_LINK_EXECUTABLE"; default: break; @@ -2030,8 +2608,6 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt, const std::string& config, bool debugIncludes, const std::string& language) { - cmMakefile *mf = tgt->Target->GetMakefile(); - for (std::vector<cmGeneratorTarget::TargetPropertyEntry*>::const_iterator it = entries.begin(), end = entries.end(); it != end; ++it) { @@ -2040,10 +2616,11 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt, bool const fromImported = item.Target && item.Target->IsImported(); bool const checkCMP0027 = item.FromGenex; std::vector<std::string> entryIncludes; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate( + tgt->GetLocalGenerator(), config, false, - tgt->Target, + tgt, dagChecker, language), entryIncludes); @@ -2058,7 +2635,7 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt, cmake::MessageType messageType = cmake::FATAL_ERROR; if (checkCMP0027) { - switch(tgt->Target->GetPolicyStatusCMP0027()) + switch(tgt->GetPolicyStatusCMP0027()) { case cmPolicies::WARN: e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; @@ -2097,7 +2674,7 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt, } else { - switch(tgt->Target->GetPolicyStatusCMP0021()) + switch(tgt->GetPolicyStatusCMP0021()) { case cmPolicies::WARN: { @@ -2143,7 +2720,7 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt, } if (!usedIncludes.empty()) { - mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(cmake::LOG, std::string("Used includes for target ") + tgt->GetName() + ":\n" + usedIncludes, (*it)->ge->GetBacktrace()); @@ -2151,34 +2728,6 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt, } } - -//---------------------------------------------------------------------------- -static void AddInterfaceEntries( - cmGeneratorTarget const* thisTarget, std::string const& config, - std::string const& prop, - std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries) -{ - if(cmLinkImplementationLibraries const* impl = - thisTarget->Target->GetLinkImplementationLibraries(config)) - { - for (std::vector<cmLinkImplItem>::const_iterator - it = impl->Libraries.begin(), end = impl->Libraries.end(); - it != end; ++it) - { - if(it->Target) - { - std::string genex = - "$<TARGET_PROPERTY:" + *it + "," + prop + ">"; - cmGeneratorExpression ge(it->Backtrace); - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex); - cge->SetEvaluateForBuildsystem(true); - entries.push_back( - new cmGeneratorTarget::TargetPropertyEntry(cge, *it)); - } - } - } -} - //---------------------------------------------------------------------------- std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(const std::string& config, @@ -2204,7 +2753,7 @@ cmGeneratorTarget::GetIncludeDirectories(const std::string& config, "INCLUDE_DIRECTORIES") != debugProperties.end(); - if (this->Makefile->IsConfigured()) + if (this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->DebugIncludesDone = true; } @@ -2227,7 +2776,7 @@ cmGeneratorTarget::GetIncludeDirectories(const std::string& config, if(this->Makefile->IsOn("APPLE")) { cmLinkImplementationLibraries const* impl = - this->Target->GetLinkImplementationLibraries(config); + this->GetLinkImplementationLibraries(config); for(std::vector<cmLinkImplItem>::const_iterator it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) @@ -2274,16 +2823,15 @@ static void processCompileOptionsInternal(cmGeneratorTarget const* tgt, const std::string& config, bool debugOptions, const char *logName, std::string const& language) { - cmMakefile *mf = tgt->Target->GetMakefile(); - for (std::vector<cmGeneratorTarget::TargetPropertyEntry*>::const_iterator it = entries.begin(), end = entries.end(); it != end; ++it) { std::vector<std::string> entryOptions; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate( + tgt->GetLocalGenerator(), config, false, - tgt->Target, + tgt, dagChecker, language), entryOptions); @@ -2304,7 +2852,7 @@ static void processCompileOptionsInternal(cmGeneratorTarget const* tgt, } if (!usedOptions.empty()) { - mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(cmake::LOG, std::string("Used compile ") + logName + std::string(" for target ") + tgt->GetName() + ":\n" @@ -2351,7 +2899,7 @@ void cmGeneratorTarget::GetCompileOptions(std::vector<std::string> &result, "COMPILE_OPTIONS") != debugProperties.end(); - if (this->Makefile->IsConfigured()) + if (this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->DebugCompileOptionsDone = true; } @@ -2421,7 +2969,7 @@ void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string> &result, "COMPILE_FEATURES") != debugProperties.end(); - if (this->Makefile->IsConfigured()) + if (this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->DebugCompileFeaturesDone = true; } @@ -2489,7 +3037,7 @@ void cmGeneratorTarget::GetCompileDefinitions(std::vector<std::string> &list, "COMPILE_DEFINITIONS") != debugProperties.end(); - if (this->Makefile->IsConfigured()) + if (this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->DebugCompileDefinitionsDone = true; } @@ -2512,7 +3060,7 @@ void cmGeneratorTarget::GetCompileDefinitions(std::vector<std::string> &list, { std::string configPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config); - const char *configProp = this->Target->GetProperty(configPropName); + const char *configProp = this->GetProperty(configPropName); if (configProp) { switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) @@ -2557,7 +3105,7 @@ void cmGeneratorTarget::GetCompileDefinitions(std::vector<std::string> &list, void cmGeneratorTarget::ComputeTargetManifest( const std::string& config) const { - if (this->Target->IsImported()) + if (this->IsImported()) { return; } @@ -2569,13 +3117,13 @@ void cmGeneratorTarget::ComputeTargetManifest( std::string realName; std::string impName; std::string pdbName; - if(this->GetType() == cmTarget::EXECUTABLE) + if(this->GetType() == cmState::EXECUTABLE) { this->GetExecutableNames(name, realName, impName, pdbName, config); } - else if(this->GetType() == cmTarget::STATIC_LIBRARY || - this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) + else if(this->GetType() == cmState::STATIC_LIBRARY || + this->GetType() == cmState::SHARED_LIBRARY || + this->GetType() == cmState::MODULE_LIBRARY) { this->GetLibraryNames(name, soName, realName, impName, pdbName, config); @@ -2586,7 +3134,7 @@ void cmGeneratorTarget::ComputeTargetManifest( } // Get the directory. - std::string dir = this->Target->GetDirectory(config, false); + std::string dir = this->GetDirectory(config, false); // Add each name. std::string f; @@ -2620,7 +3168,7 @@ void cmGeneratorTarget::ComputeTargetManifest( } if(!impName.empty()) { - f = this->Target->GetDirectory(config, true); + f = this->GetDirectory(config, true); f += "/"; f += impName; gg->AddToManifest(f); @@ -2631,7 +3179,7 @@ void cmGeneratorTarget::ComputeTargetManifest( std::string cmGeneratorTarget::GetFullPath(const std::string& config, bool implib, bool realname) const { - if(this->Target->IsImported()) + if(this->IsImported()) { return this->Target->ImportedGetFullPath(config, implib); } @@ -2645,9 +3193,9 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, bool implib, bool realname) const { - std::string fpath = this->Target->GetDirectory(config, implib); + std::string fpath = this->GetDirectory(config, implib); fpath += "/"; - if(this->Target->IsAppBundleOnApple()) + if(this->IsAppBundleOnApple()) { fpath = this->BuildMacContentDirectory(fpath, config, false); fpath += "/"; @@ -2676,14 +3224,14 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time // enforcement of the limited imported target API. - if(this->Target->IsImported()) + if(this->IsImported()) { std::string msg = "NormalGetRealName called on imported target: "; msg += this->GetName(); this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); } - if(this->GetType() == cmTarget::EXECUTABLE) + if(this->GetType() == cmState::EXECUTABLE) { // Compute the real name that will be built. std::string name; @@ -2718,7 +3266,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time // enforcement of the limited imported target API. - if(this->Target->IsImported()) + if(this->IsImported()) { std::string msg = "GetLibraryNames called on imported target: "; msg += this->GetName(); @@ -2731,7 +3279,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, const char* version = this->GetProperty("VERSION"); const char* soversion = this->GetProperty("SOVERSION"); if(!this->HasSOName(config) || - this->Target->IsFrameworkOnApple()) + this->IsFrameworkOnApple()) { // Versioning is supported only for shared libraries and modules, // and then only when the platform supports an soname flag. @@ -2759,7 +3307,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, // The library name. name = prefix+base+suffix; - if(this->Target->IsFrameworkOnApple()) + if(this->IsFrameworkOnApple()) { realName = prefix; if(!this->Makefile->PlatformIsAppleIos()) @@ -2774,17 +3322,17 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, else { // The library's soname. - this->Target->ComputeVersionedName(soName, prefix, base, suffix, + this->ComputeVersionedName(soName, prefix, base, suffix, name, soversion); // The library's real name on disk. - this->Target->ComputeVersionedName(realName, prefix, base, suffix, + this->ComputeVersionedName(realName, prefix, base, suffix, name, version); } // The import library name. - if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) + if(this->GetType() == cmState::SHARED_LIBRARY || + this->GetType() == cmState::MODULE_LIBRARY) { impName = this->GetFullNameInternal(config, true); } @@ -2807,7 +3355,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time // enforcement of the limited imported target API. - if(this->Target->IsImported()) + if(this->IsImported()) { std::string msg = "GetExecutableNames called on imported target: "; @@ -2822,7 +3370,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #else // Check for executable version properties. const char* version = this->GetProperty("VERSION"); - if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) + if(this->GetType() != cmState::EXECUTABLE || this->Makefile->IsOn("XCODE")) { version = 0; } @@ -2871,6 +3419,24 @@ std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, } //---------------------------------------------------------------------------- +const char* +cmGeneratorTarget::ImportedGetLocation(const std::string& config) const +{ + static std::string location; + assert(this->IsImported()); + location = this->Target->ImportedGetFullPath(config, false); + return location.c_str(); +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullNameImported(const std::string& config, + bool implib) const +{ + return cmSystemTools::GetFilenameName( + this->Target->ImportedGetFullPath(config, implib)); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameInternal(const std::string& config, bool implib, std::string& outPrefix, @@ -2878,10 +3444,10 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string& outSuffix) const { // Use just the target name for non-main target types. - if(this->GetType() != cmTarget::STATIC_LIBRARY && - this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) + if(this->GetType() != cmState::STATIC_LIBRARY && + this->GetType() != cmState::SHARED_LIBRARY && + this->GetType() != cmState::MODULE_LIBRARY && + this->GetType() != cmState::EXECUTABLE) { outPrefix = ""; outBase = this->GetName(); @@ -2902,9 +3468,9 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, // The implib option is only allowed for shared libraries, module // libraries, and executables. - if(this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) + if(this->GetType() != cmState::SHARED_LIBRARY && + this->GetType() != cmState::MODULE_LIBRARY && + this->GetType() != cmState::EXECUTABLE) { implib = false; } @@ -2924,8 +3490,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, configPostfix = this->GetProperty(configProp); // Mac application bundles and frameworks have no postfix. if(configPostfix && - (this->Target->IsAppBundleOnApple() - || this->Target->IsFrameworkOnApple())) + (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) { configPostfix = 0; } @@ -2962,7 +3527,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, // frameworks have directory prefix but no suffix std::string fw_prefix; - if(this->Target->IsFrameworkOnApple()) + if(this->IsFrameworkOnApple()) { fw_prefix = this->GetOutputName(config, false); fw_prefix += ".framework/"; @@ -2970,7 +3535,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, targetSuffix = 0; } - if(this->Target->IsCFBundleOnApple()) + if(this->IsCFBundleOnApple()) { fw_prefix = this->GetCFBundleDirectory(config, false); fw_prefix += "/"; @@ -2990,7 +3555,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, // Name shared libraries with their version number on some platforms. if(const char* soversion = this->GetProperty("SOVERSION")) { - if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && + if(this->GetType() == cmState::SHARED_LIBRARY && !implib && this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) { outBase += "-"; @@ -3096,7 +3661,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const this->SourceFileFlagsConstructed = true; // Process public headers to mark the source files. - if(const char* files = this->Target->GetProperty("PUBLIC_HEADER")) + if(const char* files = this->GetProperty("PUBLIC_HEADER")) { std::vector<std::string> relFiles; cmSystemTools::ExpandListArgument(files, relFiles); @@ -3114,7 +3679,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const // Process private headers after public headers so that they take // precedence if a file is listed in both. - if(const char* files = this->Target->GetProperty("PRIVATE_HEADER")) + if(const char* files = this->GetProperty("PRIVATE_HEADER")) { std::vector<std::string> relFiles; cmSystemTools::ExpandListArgument(files, relFiles); @@ -3131,7 +3696,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const } // Mark sources listed as resources. - if(const char* files = this->Target->GetProperty("RESOURCE")) + if(const char* files = this->GetProperty("RESOURCE")) { std::vector<std::string> relFiles; cmSystemTools::ExpandListArgument(files, relFiles); @@ -3159,10 +3724,10 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const compat.Done = true; compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); compat.PropsString.insert("AUTOUIC_OPTIONS"); - std::vector<cmTarget const*> const& deps = + std::vector<cmGeneratorTarget const*> const& deps = this->GetLinkImplementationClosure(config); - for(std::vector<cmTarget const*>::const_iterator li = deps.begin(); - li != deps.end(); ++li) + for(std::vector<cmGeneratorTarget const*>::const_iterator li = + deps.begin(); li != deps.end(); ++li) { #define CM_READ_COMPATIBLE_INTERFACE(X, x) \ if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ @@ -3185,8 +3750,8 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty( const std::string &p, const std::string& config) const { - if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY - || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + if (this->GetType() == cmState::OBJECT_LIBRARY + || this->GetType() == cmState::INTERFACE_LIBRARY) { return false; } @@ -3197,8 +3762,8 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty( bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty( const std::string &p, const std::string& config) const { - if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY - || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + if (this->GetType() == cmState::OBJECT_LIBRARY + || this->GetType() == cmState::INTERFACE_LIBRARY) { return false; } @@ -3209,8 +3774,8 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty( bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty( const std::string &p, const std::string& config) const { - if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY - || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + if (this->GetType() == cmState::OBJECT_LIBRARY + || this->GetType() == cmState::INTERFACE_LIBRARY) { return false; } @@ -3221,8 +3786,8 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty( bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( const std::string &p, const std::string& config) const { - if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY - || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + if (this->GetType() == cmState::OBJECT_LIBRARY + || this->GetType() == cmState::INTERFACE_LIBRARY) { return false; } @@ -3279,7 +3844,7 @@ const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, //---------------------------------------------------------------------------- template<typename PropertyType> void checkPropertyConsistency(cmGeneratorTarget const* depender, - cmTarget const* dependee, + cmGeneratorTarget const* dependee, const std::string& propName, std::set<std::string> &emitted, const std::string& config, @@ -3295,7 +3860,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender, std::vector<std::string> props; cmSystemTools::ExpandListArgument(prop, props); std::string pdir = - dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); + dependee->Target->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); pdir += "/Help/prop_tgt/"; for(std::vector<std::string>::iterator pi = props.begin(); @@ -3508,18 +4073,20 @@ std::string compatibilityAgree(CompatibleType t, bool dominant) //---------------------------------------------------------------------------- template<typename PropertyType> -PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); +PropertyType getTypedProperty(cmGeneratorTarget const* tgt, + const std::string& prop); //---------------------------------------------------------------------------- template<> -bool getTypedProperty<bool>(cmTarget const* tgt, const std::string& prop) +bool getTypedProperty<bool>(cmGeneratorTarget const* tgt, + const std::string& prop) { return tgt->GetPropertyAsBool(prop); } //---------------------------------------------------------------------------- template<> -const char *getTypedProperty<const char *>(cmTarget const* tgt, +const char *getTypedProperty<const char *>(cmGeneratorTarget const* tgt, const std::string& prop) { return tgt->GetProperty(prop); @@ -3649,16 +4216,16 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, CompatibleType t, PropertyType *) { - PropertyType propContent = getTypedProperty<PropertyType>(tgt->Target, p); + PropertyType propContent = getTypedProperty<PropertyType>(tgt, p); const bool explicitlySet = tgt->Target->GetProperties() .find(p) != tgt->Target->GetProperties().end(); const bool impliedByUse = - tgt->Target->IsNullImpliedByLinkLibraries(p); + tgt->IsNullImpliedByLinkLibraries(p); assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); - std::vector<cmTarget const*> const& deps = + std::vector<cmGeneratorTarget const*> const& deps = tgt->GetLinkImplementationClosure(config); if(deps.empty()) @@ -3685,7 +4252,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, } std::string interfaceProperty = "INTERFACE_" + p; - for(std::vector<cmTarget const*>::const_iterator li = + for(std::vector<cmGeneratorTarget const*>::const_iterator li = deps.begin(); li != deps.end(); ++li) { @@ -3695,11 +4262,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, // target itself has a POSITION_INDEPENDENT_CODE which disagrees // with a dependency. - cmTarget const* theTarget = *li; + cmGeneratorTarget const* theTarget = *li; - const bool ifaceIsSet = theTarget->GetProperties() + const bool ifaceIsSet = theTarget->Target->GetProperties() .find(interfaceProperty) - != theTarget->GetProperties().end(); + != theTarget->Target->GetProperties().end(); PropertyType ifacePropContent = getTypedProperty<PropertyType>(theTarget, interfaceProperty); @@ -3903,6 +4470,61 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetTargetVersion(int& major, int& minor) const +{ + int patch; + this->GetTargetVersion(false, major, minor, patch); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetTargetVersion(bool soversion, + int& major, int& minor, int& patch) const +{ + // Set the default values. + major = 0; + minor = 0; + patch = 0; + + assert(this->GetType() != cmState::INTERFACE_LIBRARY); + + // Look for a VERSION or SOVERSION property. + const char* prop = soversion? "SOVERSION" : "VERSION"; + if(const char* version = this->GetProperty(prop)) + { + // Try to parse the version number and store the results that were + // successfully parsed. + int parsed_major; + int parsed_minor; + int parsed_patch; + switch(sscanf(version, "%d.%d.%d", + &parsed_major, &parsed_minor, &parsed_patch)) + { + case 3: patch = parsed_patch; // no break! + case 2: minor = parsed_minor; // no break! + case 1: major = parsed_major; // no break! + default: break; + } + } +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeVersionedName(std::string& vName, + std::string const& prefix, + std::string const& base, + std::string const& suffix, + std::string const& name, + const char* version) const +{ + vName = this->Makefile->IsOn("APPLE") ? (prefix+base) : name; + if(version) + { + vName += "."; + vName += version; + } + vName += this->Makefile->IsOn("APPLE") ? suffix : std::string(); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, const std::string &result, @@ -3923,7 +4545,7 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, p) != debugProperties.end(); - if (this->Target->GetMakefile()->IsConfigured()) + if (this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->DebugCompatiblePropertiesDone[p] = true; } @@ -3939,7 +4561,7 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, areport += result; areport += "\"):\n" + report; - this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); + this->LocalGenerator->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); } //---------------------------------------------------------------------------- @@ -3949,12 +4571,12 @@ void cmGeneratorTarget::LookupLinkItems(std::vector<std::string> const& names, for(std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) { - std::string name = this->Target->CheckCMP0004(*i); + std::string name = this->CheckCMP0004(*i); if(name == this->GetName() || name.empty()) { continue; } - items.push_back(cmLinkItem(name, this->Target->FindTargetToLink(name))); + items.push_back(cmLinkItem(name, this->FindTargetToLink(name))); } } @@ -3962,7 +4584,7 @@ void cmGeneratorTarget::LookupLinkItems(std::vector<std::string> const& names, void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, - cmTarget const* headTarget, + cmGeneratorTarget const* headTarget, bool usage_requirements_only, std::vector<cmLinkItem>& items, bool& hadHeadSensitiveCondition) const @@ -3978,11 +4600,11 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, std::vector<std::string> libs; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); cmSystemTools::ExpandListArgument(cge->Evaluate( - this->Makefile, + this->LocalGenerator, config, false, headTarget, - this->Target, &dagChecker), libs); + this, &dagChecker), libs); this->LookupLinkItems(libs, items); hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); } @@ -3990,7 +4612,7 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, //---------------------------------------------------------------------------- cmLinkInterface const* cmGeneratorTarget::GetLinkInterface(const std::string& config, - cmTarget const* head) const + cmGeneratorTarget const* head) const { // Imported targets have their own link interface. if(this->IsImported()) @@ -4000,8 +4622,8 @@ cmGeneratorTarget::GetLinkInterface(const std::string& config, // Link interfaces are not supported for executables that do not // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->Target->IsExecutableWithExports()) + if(this->GetType() == cmState::EXECUTABLE && + !this->IsExecutableWithExports()) { return 0; } @@ -4039,13 +4661,13 @@ cmGeneratorTarget::GetLinkInterface(const std::string& config, //---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, cmOptionalLinkInterface &iface, - cmTarget const* headTarget) const + cmGeneratorTarget const* headTarget) const { if(iface.ExplicitLibraries) { - if(this->GetType() == cmTarget::SHARED_LIBRARY - || this->GetType() == cmTarget::STATIC_LIBRARY - || this->GetType() == cmTarget::INTERFACE_LIBRARY) + if(this->GetType() == cmState::SHARED_LIBRARY + || this->GetType() == cmState::STATIC_LIBRARY + || this->GetType() == cmState::INTERFACE_LIBRARY) { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. @@ -4055,7 +4677,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, { emitted.insert(*li); } - if (this->GetType() != cmTarget::INTERFACE_LIBRARY) + if (this->GetType() != cmState::INTERFACE_LIBRARY) { cmLinkImplementation const* impl = this->GetLinkImplementation(config); @@ -4067,7 +4689,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, if(li->Target) { // This is a runtime dependency on another shared library. - if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) + if(li->Target->GetType() == cmState::SHARED_LIBRARY) { iface.SharedDeps.push_back(*li); } @@ -4084,13 +4706,13 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, } } } - else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) { // The link implementation is the default link interface. cmLinkImplementationLibraries const* - impl = this->Target->GetLinkImplementationLibrariesInternal(config, - headTarget); + impl = this->GetLinkImplementationLibrariesInternal(config, + headTarget); iface.ImplementationIsInterface = true; iface.WrongConfigLibraries = impl->WrongConfigLibraries; } @@ -4105,7 +4727,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, } } - if(this->GetType() == cmTarget::STATIC_LIBRARY) + if(this->GetType() == cmState::STATIC_LIBRARY) { // Construct the property name suffix for this configuration. std::string suffix = "_"; @@ -4137,7 +4759,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, //---------------------------------------------------------------------------- const cmLinkInterfaceLibraries * cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* head, + cmGeneratorTarget const* head, bool usage_requirements_only) const { // Imported targets have their own link interface. @@ -4149,8 +4771,8 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, // Link interfaces are not supported for executables that do not // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->Target->IsExecutableWithExports()) + if(this->GetType() == cmState::EXECUTABLE && + !this->IsExecutableWithExports()) { return 0; } @@ -4181,11 +4803,261 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetDirectory(const std::string& config, + bool implib) const +{ + if (this->IsImported()) + { + // Return the directory from which the target is imported. + return + cmSystemTools::GetFilenamePath( + this->Target->ImportedGetFullPath(config, implib)); + } + else if(OutputInfo const* info = this->GetOutputInfo(config)) + { + // Return the directory in which the target will be built. + return implib? info->ImpDir : info->OutDir; + } + return ""; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::UsesDefaultOutputDir(const std::string& config, + bool implib) const +{ + std::string dir; + return this->ComputeOutputDir(config, implib, dir); +} + +//---------------------------------------------------------------------------- +cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( + const std::string& config) const +{ + // There is no output information for imported targets. + if(this->IsImported()) + { + return 0; + } + + // Only libraries and executables have well-defined output files. + if(!this->HaveWellDefinedOutputFiles()) + { + std::string msg = "cmGeneratorTarget::GetOutputInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmState::GetTargetTypeName(this->GetType()); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); + return 0; + } + + // Lookup/compute/cache the output information for this configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + OutputInfoMapType::iterator i = + this->OutputInfoMap.find(config_upper); + if(i == this->OutputInfoMap.end()) + { + // Add empty info in map to detect potential recursion. + OutputInfo info; + OutputInfoMapType::value_type entry(config_upper, info); + i = this->OutputInfoMap.insert(entry).first; + + // Compute output directories. + this->ComputeOutputDir(config, false, info.OutDir); + this->ComputeOutputDir(config, true, info.ImpDir); + if(!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) + { + info.PdbDir = info.OutDir; + } + + // Now update the previously-prepared map entry. + i->second = info; + } + else if(i->second.empty()) + { + // An empty map entry indicates we have been called recursively + // from the above block. + this->LocalGenerator->GetCMakeInstance()->IssueMessage( + cmake::FATAL_ERROR, + "Target '" + this->GetName() + "' OUTPUT_DIRECTORY depends on itself.", + this->GetBacktrace()); + return 0; + } + return &i->second; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::ComputeOutputDir(const std::string& config, + bool implib, std::string& out) const +{ + bool usesDefaultOutputDir = false; + std::string conf = config; + + // Look for a target property defining the target output directory + // based on the target type. + std::string targetTypeName = this->GetOutputTargetType(implib); + const char* propertyName = 0; + std::string propertyNameStr = targetTypeName; + if(!propertyNameStr.empty()) + { + propertyNameStr += "_OUTPUT_DIRECTORY"; + propertyName = propertyNameStr.c_str(); + } + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(conf); + const char* configProp = 0; + std::string configPropStr = targetTypeName; + if(!configPropStr.empty()) + { + configPropStr += "_OUTPUT_DIRECTORY_"; + configPropStr += configUpper; + configProp = configPropStr.c_str(); + } + + // Select an output directory. + if(const char* config_outdir = this->GetProperty(configProp)) + { + // Use the user-specified per-configuration output directory. + cmGeneratorExpression ge; + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(config_outdir); + out = cge->Evaluate(this->LocalGenerator, config); + + // Skip per-configuration subdirectory. + conf = ""; + } + else if(const char* outdir = this->GetProperty(propertyName)) + { + // Use the user-specified output directory. + cmGeneratorExpression ge; + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(outdir); + out = cge->Evaluate(this->LocalGenerator, config); + + // Skip per-configuration subdirectory if the value contained a + // generator expression. + if (out != outdir) + { + conf = ""; + } + } + else if(this->GetType() == cmState::EXECUTABLE) + { + // Lookup the output path for executables. + out = this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); + } + else if(this->GetType() == cmState::STATIC_LIBRARY || + this->GetType() == cmState::SHARED_LIBRARY || + this->GetType() == cmState::MODULE_LIBRARY) + { + // Lookup the output path for libraries. + out = this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH"); + } + if(out.empty()) + { + // Default to the current output directory. + usesDefaultOutputDir = true; + out = "."; + } + + // Convert the output path to a full path in case it is + // specified as a relative path. Treat a relative path as + // relative to the current output directory for this makefile. + out = (cmSystemTools::CollapseFullPath + (out, this->LocalGenerator->GetCurrentBinaryDirectory())); + + // The generator may add the configuration's subdirectory. + if(!conf.empty()) + { + bool iosPlatform = this->Makefile->PlatformIsAppleIos(); + std::string suffix = + usesDefaultOutputDir && iosPlatform ? "${EFFECTIVE_PLATFORM_NAME}" : ""; + this->LocalGenerator->GetGlobalGenerator()-> + AppendDirectoryForConfig("/", conf, suffix, out); + } + + return usesDefaultOutputDir; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind, + const std::string& config, + std::string& out) const +{ + // Look for a target property defining the target output directory + // based on the target type. + const char* propertyName = 0; + std::string propertyNameStr = kind; + if(!propertyNameStr.empty()) + { + propertyNameStr += "_OUTPUT_DIRECTORY"; + propertyName = propertyNameStr.c_str(); + } + std::string conf = config; + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(conf); + const char* configProp = 0; + std::string configPropStr = kind; + if(!configPropStr.empty()) + { + configPropStr += "_OUTPUT_DIRECTORY_"; + configPropStr += configUpper; + configProp = configPropStr.c_str(); + } + + // Select an output directory. + if(const char* config_outdir = this->GetProperty(configProp)) + { + // Use the user-specified per-configuration output directory. + out = config_outdir; + + // Skip per-configuration subdirectory. + conf = ""; + } + else if(const char* outdir = this->GetProperty(propertyName)) + { + // Use the user-specified output directory. + out = outdir; + } + if(out.empty()) + { + return false; + } + + // Convert the output path to a full path in case it is + // specified as a relative path. Treat a relative path as + // relative to the current output directory for this makefile. + out = (cmSystemTools::CollapseFullPath + (out, this->LocalGenerator->GetCurrentBinaryDirectory())); + + // The generator may add the configuration's subdirectory. + if(!conf.empty()) + { + this->LocalGenerator->GetGlobalGenerator()-> + AppendDirectoryForConfig("/", conf, "", out); + } + return true; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HaveInstallTreeRPATH() const +{ + const char* install_rpath = this->GetProperty("INSTALL_RPATH"); + return (install_rpath && *install_rpath) && + !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH"); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkInterfaceLibraries( const std::string& config, cmOptionalLinkInterface& iface, - cmTarget const* headTarget, + cmGeneratorTarget const* headTarget, bool usage_requirements_only) const { // Construct the property name suffix for this configuration. @@ -4203,15 +5075,15 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // libraries and executables that export symbols. const char* explicitLibraries = 0; std::string linkIfaceProp; - if(this->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD && - this->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN) + if(this->GetPolicyStatusCMP0022() != cmPolicies::OLD && + this->GetPolicyStatusCMP0022() != cmPolicies::WARN) { // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; explicitLibraries = this->GetProperty(linkIfaceProp); } - else if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->Target->IsExecutableWithExports()) + else if(this->GetType() == cmState::SHARED_LIBRARY || + this->IsExecutableWithExports()) { // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a // shared lib or executable. @@ -4230,7 +5102,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( } if(explicitLibraries && - this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && + this->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022) { // Compare the explicitly set old link interface properties to the @@ -4258,8 +5130,8 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // There is no implicit link interface for executables or modules // so if none was explicitly set then there is no link interface. if(!explicitLibraries && - (this->GetType() == cmTarget::EXECUTABLE || - (this->GetType() == cmTarget::MODULE_LIBRARY))) + (this->GetType() == cmState::EXECUTABLE || + (this->GetType() == cmState::MODULE_LIBRARY))) { return; } @@ -4275,8 +5147,8 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( iface.Libraries, iface.HadHeadSensitiveCondition); } - else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) // If CMP0022 is NEW then the plain tll signature sets the // INTERFACE_LINK_LIBRARIES, so if we get here then the project // cleared the property explicitly and we should not fall back @@ -4284,11 +5156,10 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( { // The link implementation is the default link interface. cmLinkImplementationLibraries const* impl = - this->Target->GetLinkImplementationLibrariesInternal(config, - headTarget); + this->GetLinkImplementationLibrariesInternal(config, headTarget); iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(), impl->Libraries.end()); - if(this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && + if(this->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022 && !usage_requirements_only) { // Compare the link implementation fallback link interface to the @@ -4299,8 +5170,9 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( { bool hadHeadSensitiveConditionDummy = false; this->ExpandLinkItems(newProp, newExplicitLibraries, config, - headTarget, usage_requirements_only, - ifaceLibs, hadHeadSensitiveConditionDummy); + headTarget, + usage_requirements_only, + ifaceLibs, hadHeadSensitiveConditionDummy); } if (ifaceLibs != iface.Libraries) { @@ -4334,10 +5206,10 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( //---------------------------------------------------------------------------- const cmLinkInterface * cmGeneratorTarget::GetImportLinkInterface(const std::string& config, - cmTarget const* headTarget, + cmGeneratorTarget const* headTarget, bool usage_requirements_only) const { - cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config); + cmGeneratorTarget::ImportInfo const* info = this->GetImportInfo(config); if(!info) { return 0; @@ -4375,6 +5247,223 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, return &iface; } +//---------------------------------------------------------------------------- +cmGeneratorTarget::ImportInfo const* +cmGeneratorTarget::GetImportInfo(const std::string& config) const +{ + // There is no imported information for non-imported targets. + if(!this->IsImported()) + { + return 0; + } + + // Lookup/compute/cache the import information for this + // configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + else + { + config_upper = "NOCONFIG"; + } + + ImportInfoMapType::const_iterator i = + this->ImportInfoMap.find(config_upper); + if(i == this->ImportInfoMap.end()) + { + ImportInfo info; + this->ComputeImportInfo(config_upper, info); + ImportInfoMapType::value_type entry(config_upper, info); + i = this->ImportInfoMap.insert(entry).first; + } + + if(this->GetType() == cmState::INTERFACE_LIBRARY) + { + return &i->second; + } + // If the location is empty then the target is not available for + // this configuration. + if(i->second.Location.empty() && i->second.ImportLibrary.empty()) + { + return 0; + } + + // Return the import information. + return &i->second; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config, + ImportInfo& info) const +{ + // This method finds information about an imported target from its + // properties. The "IMPORTED_" namespace is reserved for properties + // defined by the project exporting the target. + + // Initialize members. + info.NoSOName = false; + + const char* loc = 0; + const char* imp = 0; + std::string suffix; + if (!this->Target->GetMappedConfig(desired_config, &loc, &imp, suffix)) + { + return; + } + + // Get the link interface. + { + std::string linkProp = "INTERFACE_LINK_LIBRARIES"; + const char *propertyLibs = this->GetProperty(linkProp); + + if (this->GetType() != cmState::INTERFACE_LIBRARY) + { + if(!propertyLibs) + { + linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; + linkProp += suffix; + propertyLibs = this->GetProperty(linkProp); + } + + if(!propertyLibs) + { + linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; + propertyLibs = this->GetProperty(linkProp); + } + } + if(propertyLibs) + { + info.LibrariesProp = linkProp; + info.Libraries = propertyLibs; + } + } + if(this->GetType() == cmState::INTERFACE_LIBRARY) + { + return; + } + + // A provided configuration has been chosen. Load the + // configuration's properties. + + // Get the location. + if(loc) + { + info.Location = loc; + } + else + { + std::string impProp = "IMPORTED_LOCATION"; + impProp += suffix; + if(const char* config_location = this->GetProperty(impProp)) + { + info.Location = config_location; + } + else if(const char* location = this->GetProperty("IMPORTED_LOCATION")) + { + info.Location = location; + } + } + + // Get the soname. + if(this->GetType() == cmState::SHARED_LIBRARY) + { + std::string soProp = "IMPORTED_SONAME"; + soProp += suffix; + if(const char* config_soname = this->GetProperty(soProp)) + { + info.SOName = config_soname; + } + else if(const char* soname = this->GetProperty("IMPORTED_SONAME")) + { + info.SOName = soname; + } + } + + // Get the "no-soname" mark. + if(this->GetType() == cmState::SHARED_LIBRARY) + { + std::string soProp = "IMPORTED_NO_SONAME"; + soProp += suffix; + if(const char* config_no_soname = this->GetProperty(soProp)) + { + info.NoSOName = cmSystemTools::IsOn(config_no_soname); + } + else if(const char* no_soname = this->GetProperty("IMPORTED_NO_SONAME")) + { + info.NoSOName = cmSystemTools::IsOn(no_soname); + } + } + + // Get the import library. + if(imp) + { + info.ImportLibrary = imp; + } + else if(this->GetType() == cmState::SHARED_LIBRARY || + this->IsExecutableWithExports()) + { + std::string impProp = "IMPORTED_IMPLIB"; + impProp += suffix; + if(const char* config_implib = this->GetProperty(impProp)) + { + info.ImportLibrary = config_implib; + } + else if(const char* implib = this->GetProperty("IMPORTED_IMPLIB")) + { + info.ImportLibrary = implib; + } + } + + // Get the link dependencies. + { + std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES"; + linkProp += suffix; + if(const char* config_libs = this->GetProperty(linkProp)) + { + info.SharedDeps = config_libs; + } + else if(const char* libs = + this->GetProperty("IMPORTED_LINK_DEPENDENT_LIBRARIES")) + { + info.SharedDeps = libs; + } + } + + // Get the link languages. + if(this->Target->LinkLanguagePropagatesToDependents()) + { + std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES"; + linkProp += suffix; + if(const char* config_libs = this->GetProperty(linkProp)) + { + info.Languages = config_libs; + } + else if(const char* libs = + this->GetProperty("IMPORTED_LINK_INTERFACE_LANGUAGES")) + { + info.Languages = libs; + } + } + + // Get the cyclic repetition count. + if(this->GetType() == cmState::STATIC_LIBRARY) + { + std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY"; + linkProp += suffix; + if(const char* config_reps = this->GetProperty(linkProp)) + { + sscanf(config_reps, "%u", &info.Multiplicity); + } + else if(const char* reps = + this->GetProperty("IMPORTED_LINK_INTERFACE_MULTIPLICITY")) + { + sscanf(reps, "%u", &info.Multiplicity); + } + } +} + cmHeadToLinkInterfaceMap& cmGeneratorTarget::GetHeadToLinkInterfaceMap(const std::string &config) const { @@ -4395,17 +5484,17 @@ const cmLinkImplementation * cmGeneratorTarget::GetLinkImplementation(const std::string& config) const { // There is no link implementation for imported targets. - if(this->Target->IsImported()) + if(this->IsImported()) { return 0; } - cmOptionalLinkImplementation& impl = this->Target->GetLinkImplMap(config); + std::string CONFIG = cmSystemTools::UpperCase(config); + cmOptionalLinkImplementation& impl = this->LinkImplMap[CONFIG][this->Target]; if(!impl.LibrariesDone) { impl.LibrariesDone = true; - this->Target->ComputeLinkImplementationLibraries(config, impl, - this->Target); + this->ComputeLinkImplementationLibraries(config, impl, this); } if(!impl.LanguagesDone) { @@ -4428,12 +5517,12 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles( std::vector<std::string>::const_iterator it = configs.begin(); const std::string& firstConfig = *it; - this->Target->GetSourceFiles(files, firstConfig); + this->GetSourceFiles(files, firstConfig); for ( ; it != configs.end(); ++it) { std::vector<cmSourceFile*> configFiles; - this->Target->GetSourceFiles(configFiles, *it); + this->GetSourceFiles(configFiles, *it); if (configFiles != files) { std::string firstConfigFiles; @@ -4473,6 +5562,105 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles( } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetObjectLibrariesCMP0026( + std::vector<cmGeneratorTarget*>& objlibs) const +{ + // At configure-time, this method can be called as part of getting the + // LOCATION property or to export() a file to be include()d. However + // there is no cmGeneratorTarget at configure-time, so search the SOURCES + // for TARGET_OBJECTS instead for backwards compatibility with OLD + // behavior of CMP0024 and CMP0026 only. + cmStringRange rng = this->Target->GetSourceEntries(); + for(std::vector<std::string>::const_iterator + i = rng.begin(); i != rng.end(); ++i) + { + std::string const& entry = *i; + + std::vector<std::string> files; + cmSystemTools::ExpandListArgument(entry, files); + for (std::vector<std::string>::const_iterator + li = files.begin(); li != files.end(); ++li) + { + if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") && + (*li)[li->size() - 1] == '>') + { + std::string objLibName = li->substr(17, li->size()-18); + + if (cmGeneratorExpression::Find(objLibName) != std::string::npos) + { + continue; + } + cmGeneratorTarget *objLib = + this->LocalGenerator->FindGeneratorTargetToUse(objLibName); + if(objLib) + { + objlibs.push_back(objLib); + } + } + } + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const +{ + // Strip whitespace off the library names because we used to do this + // in case variables were expanded at generate time. We no longer + // do the expansion but users link to libraries like " ${VAR} ". + std::string lib = item; + std::string::size_type pos = lib.find_first_not_of(" \t\r\n"); + if(pos != lib.npos) + { + lib = lib.substr(pos, lib.npos); + } + pos = lib.find_last_not_of(" \t\r\n"); + if(pos != lib.npos) + { + lib = lib.substr(0, pos+1); + } + if(lib != item) + { + cmake* cm = this->LocalGenerator->GetCMakeInstance(); + switch(this->GetPolicyStatusCMP0004()) + { + case cmPolicies::WARN: + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0004) << "\n" + << "Target \"" << this->GetName() << "\" links to item \"" + << item << "\" which has leading or trailing whitespace."; + cm->IssueMessage(cmake::AUTHOR_WARNING, w.str(), + this->GetBacktrace()); + } + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + { + std::ostringstream e; + e << "Target \"" << this->GetName() << "\" links to item \"" + << item << "\" which has leading or trailing whitespace. " + << "This is now an error according to policy CMP0004."; + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->GetBacktrace()); + } + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + { + std::ostringstream e; + e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0004) << "\n" + << "Target \"" << this->GetName() << "\" links to item \"" + << item << "\" which has leading or trailing whitespace."; + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->GetBacktrace()); + } + break; + } + } + return lib; +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages, const std::string& config) const { @@ -4490,16 +5678,15 @@ void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages, std::vector<cmGeneratorTarget*> objectLibraries; std::vector<cmSourceFile const*> externalObjects; - if (!this->Makefile->IsConfigured()) + if (!this->GlobalGenerator->GetConfigureDoneCMP0026()) { - std::vector<cmTarget*> objectTargets; - this->Target->GetObjectLibrariesCMP0026(objectTargets); + std::vector<cmGeneratorTarget*> objectTargets; + this->GetObjectLibrariesCMP0026(objectTargets); objectLibraries.reserve(objectTargets.size()); - for (std::vector<cmTarget*>::const_iterator it = objectTargets.begin(); - it != objectTargets.end(); ++it) + for (std::vector<cmGeneratorTarget*>::const_iterator it = + objectTargets.begin(); it != objectTargets.end(); ++it) { - objectLibraries.push_back(this->GlobalGenerator - ->GetGeneratorTarget(*it)); + objectLibraries.push_back(*it); } } else @@ -4509,10 +5696,10 @@ void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages, i = externalObjects.begin(); i != externalObjects.end(); ++i) { std::string objLib = (*i)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + if (cmGeneratorTarget* tgt = + this->LocalGenerator->FindGeneratorTargetToUse(objLib)) { - objectLibraries.push_back(this->GlobalGenerator - ->GetGeneratorTarget(tgt)); + objectLibraries.push_back(tgt); } } } @@ -4540,14 +5727,317 @@ void cmGeneratorTarget::ComputeLinkImplementationLanguages( //---------------------------------------------------------------------------- bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const { - if (this->Target->GetPropertyAsBool("SKIP_BUILD_RPATH")) + if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) { return false; } if(cmLinkImplementationLibraries const* impl = - this->Target->GetLinkImplementationLibraries(config)) + this->GetLinkImplementationLibraries(config)) { return !impl->Libraries.empty(); } return false; } + +//---------------------------------------------------------------------------- +cmLinkImplementationLibraries const* +cmGeneratorTarget::GetLinkImplementationLibraries( + const std::string& config) const +{ + return this->GetLinkImplementationLibrariesInternal(config, this); +} + +//---------------------------------------------------------------------------- +cmLinkImplementationLibraries const* +cmGeneratorTarget::GetLinkImplementationLibrariesInternal( + const std::string& config, cmGeneratorTarget const* head) const +{ + // There is no link implementation for imported targets. + if(this->IsImported()) + { + return 0; + } + + // Populate the link implementation libraries for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + HeadToLinkImplementationMap& hm = + this->LinkImplMap[CONFIG]; + + // If the link implementation does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + cmOptionalLinkImplementation& impl = hm[head->Target]; + if(!impl.LibrariesDone) + { + impl.LibrariesDone = true; + this->ComputeLinkImplementationLibraries(config, impl, head); + } + return &impl; +} + +//---------------------------------------------------------------------------- +bool +cmGeneratorTarget::IsNullImpliedByLinkLibraries(const std::string &p) const +{ + return this->LinkImplicitNullProperties.find(p) + != this->LinkImplicitNullProperties.end(); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkImplementationLibraries( + const std::string& config, + cmOptionalLinkImplementation& impl, + cmGeneratorTarget const* head) const +{ + cmStringRange entryRange = + this->Target->GetLinkImplementationEntries(); + cmBacktraceRange btRange = + this->Target->GetLinkImplementationBacktraces(); + cmBacktraceRange::const_iterator btIt = btRange.begin(); + // Collect libraries directly linked in this configuration. + for (cmStringRange::const_iterator le = entryRange.begin(), + end = entryRange.end(); le != end; ++le, ++btIt) + { + std::vector<std::string> llibs; + cmGeneratorExpressionDAGChecker dagChecker( + this->GetName(), + "LINK_LIBRARIES", 0, 0); + cmGeneratorExpression ge(*btIt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> const cge = + ge.Parse(*le); + std::string const evaluated = + cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker); + cmSystemTools::ExpandListArgument(evaluated, llibs); + if(cge->GetHadHeadSensitiveCondition()) + { + impl.HadHeadSensitiveCondition = true; + } + + for(std::vector<std::string>::const_iterator li = llibs.begin(); + li != llibs.end(); ++li) + { + // Skip entries that resolve to the target itself or are empty. + std::string name = this->CheckCMP0004(*li); + if(name == this->GetName() || name.empty()) + { + if(name == this->GetName()) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + std::ostringstream e; + switch(this->GetPolicyStatusCMP0038()) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0038) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->GetName() << "\" links to itself."; + this->LocalGenerator->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->GetBacktrace()); + if (messageType == cmake::FATAL_ERROR) + { + return; + } + } + } + continue; + } + + // The entry is meant for this configuration. + impl.Libraries.push_back( + cmLinkImplItem(name, this->FindTargetToLink(name), + *btIt, evaluated != *le)); + } + + std::set<std::string> const& seenProps = cge->GetSeenTargetProperties(); + for (std::set<std::string>::const_iterator it = seenProps.begin(); + it != seenProps.end(); ++it) + { + if (!this->GetProperty(*it)) + { + this->LinkImplicitNullProperties.insert(*it); + } + } + cge->GetMaxLanguageStandard(this, + this->MaxLanguageStandards); + } + + // Get the list of configurations considered to be DEBUG. + std::vector<std::string> debugConfigs = + this->Makefile->GetCMakeInstance()->GetDebugConfigs(); + + cmTargetLinkLibraryType linkType = + CMP0003_ComputeLinkType(config, debugConfigs); + cmTarget::LinkLibraryVectorType const& oldllibs = + this->Target->GetOriginalLinkLibraries(); + for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin(); + li != oldllibs.end(); ++li) + { + if(li->second != GENERAL_LibraryType && li->second != linkType) + { + std::string name = this->CheckCMP0004(li->first); + if(name == this->GetName() || name.empty()) + { + continue; + } + // Support OLD behavior for CMP0003. + impl.WrongConfigLibraries.push_back( + cmLinkItem(name, this->FindTargetToLink(name))); + } + } +} + +//---------------------------------------------------------------------------- +cmGeneratorTarget* +cmGeneratorTarget::FindTargetToLink(std::string const& name) const +{ + cmGeneratorTarget* tgt = + this->LocalGenerator->FindGeneratorTargetToUse(name); + + // Skip targets that will not really be linked. This is probably a + // name conflict between an external library and an executable + // within the project. + if(tgt && tgt->GetType() == cmState::EXECUTABLE && + !tgt->IsExecutableWithExports()) + { + tgt = 0; + } + + if(tgt && tgt->GetType() == cmState::OBJECT_LIBRARY) + { + std::ostringstream e; + e << "Target \"" << this->GetName() << "\" links to " + "OBJECT library \"" << tgt->GetName() << "\" but this is not " + "allowed. " + "One may link only to STATIC or SHARED libraries, or to executables " + "with the ENABLE_EXPORTS property set."; + cmake* cm = this->LocalGenerator->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->GetBacktrace()); + tgt = 0; + } + + return tgt; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetPDBDirectory(const std::string& config) const +{ + if(OutputInfo const* info = this->GetOutputInfo(config)) + { + // Return the directory in which the target will be built. + return info->PdbDir; + } + return ""; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasImplibGNUtoMS() const +{ + return this->HasImportLibrary() + && this->GetPropertyAsBool("GNUtoMS"); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& gnuName, + std::string& out, const char* newExt) const +{ + if(this->HasImplibGNUtoMS() && + gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a") + { + out = gnuName.substr(0, gnuName.size()-6); + out += newExt? newExt : ".lib"; + return true; + } + return false; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsExecutableWithExports() const +{ + return (this->GetType() == cmState::EXECUTABLE && + this->GetPropertyAsBool("ENABLE_EXPORTS")); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasImportLibrary() const +{ + return (this->IsDLLPlatform() && + (this->GetType() == cmState::SHARED_LIBRARY || + this->IsExecutableWithExports())); +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetSupportDirectory() const +{ + std::string dir = this->LocalGenerator->GetCurrentBinaryDirectory(); + dir += cmake::GetCMakeFilesDirectory(); + dir += "/"; + dir += this->GetName(); +#if defined(__VMS) + dir += "_dir"; +#else + dir += ".dir"; +#endif + return dir; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkable() const +{ + return (this->GetType() == cmState::STATIC_LIBRARY || + this->GetType() == cmState::SHARED_LIBRARY || + this->GetType() == cmState::MODULE_LIBRARY || + this->GetType() == cmState::UNKNOWN_LIBRARY || + this->GetType() == cmState::INTERFACE_LIBRARY || + this->IsExecutableWithExports()); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsFrameworkOnApple() const +{ + return (this->GetType() == cmState::SHARED_LIBRARY && + this->Makefile->IsOn("APPLE") && + this->GetPropertyAsBool("FRAMEWORK")); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsAppBundleOnApple() const +{ + return (this->GetType() == cmState::EXECUTABLE && + this->Makefile->IsOn("APPLE") && + this->GetPropertyAsBool("MACOSX_BUNDLE")); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsXCTestOnApple() const +{ + return (this->IsCFBundleOnApple() && + this->GetPropertyAsBool("XCTEST")); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsCFBundleOnApple() const +{ + return (this->GetType() == cmState::MODULE_LIBRARY && + this->Makefile->IsOn("APPLE") && + this->GetPropertyAsBool("BUNDLE")); +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 06d9a1f..2dc3a6f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -33,6 +33,14 @@ public: bool IsImported() const; const char *GetLocation(const std::string& config) const; +#define DECLARE_TARGET_POLICY(POLICY) \ + cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \ + { return this->PolicyMap.Get(cmPolicies::POLICY); } + + CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY) + +#undef DECLARE_TARGET_POLICY + /** Get the location of the target in the build tree with a placeholder referencing the configuration in the native build system. This location is suitable for use as the LOCATION target property. */ @@ -41,8 +49,10 @@ public: cmComputeLinkInformation* GetLinkInformation(const std::string& config) const; - int GetType() const; + cmState::TargetType GetType() const; std::string GetName() const; + std::string GetExportName() const; + const char *GetProperty(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector<cmSourceFile*>& files, @@ -71,6 +81,8 @@ public: const std::string& config) const; void GetAppManifest(std::vector<cmSourceFile const*>&, const std::string& config) const; + void GetManifests(std::vector<cmSourceFile const*>&, + const std::string& config) const; void GetCertificates(std::vector<cmSourceFile const*>&, const std::string& config) const; void GetXamlSources(std::vector<cmSourceFile const*>&, @@ -80,6 +92,8 @@ public: void GetExpectedXamlSources(std::set<std::string>&, const std::string& config) const; + std::set<cmLinkItem>const& GetUtilityItems() const; + void ComputeObjectMapping(); const char* GetFeature(const std::string& feature, @@ -107,19 +121,19 @@ public: const std::string& config) const; cmLinkInterface const* GetLinkInterface(const std::string& config, - cmTarget const* headTarget) const; + const cmGeneratorTarget* headTarget) const; void ComputeLinkInterface(const std::string& config, cmOptionalLinkInterface& iface, - cmTarget const* head) const; + const cmGeneratorTarget* head) const; cmLinkInterfaceLibraries const* GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* headTarget, + const cmGeneratorTarget* headTarget, bool usage_requirements_only) const; void ComputeLinkInterfaceLibraries(const std::string& config, cmOptionalLinkInterface &iface, - cmTarget const* head, + const cmGeneratorTarget* head, bool usage_requirements_only) const; /** Get the full path to the target according to the settings in its @@ -160,6 +174,12 @@ public: * install tree. For example: "\@rpath/" or "\@loader_path/". */ std::string GetInstallNameDirForInstallTree() const; + cmListFileBacktrace GetBacktrace() const; + + /** Get the macro to define when building sources in this target. + If no macro should be defined null is returned. */ + const char* GetExportMacro() const; + /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; @@ -184,6 +204,12 @@ public: std::string GetModuleDefinitionFile(const std::string& config) const; + /** Return whether or not the target is for a DLL platform. */ + bool IsDLLPlatform() const; + + /** @return whether this target have a well defined output file name. */ + bool HaveWellDefinedOutputFiles() const; + /** Link information from the transitive closure of the link implementation and the interfaces of its dependencies. */ struct LinkClosure @@ -205,6 +231,15 @@ public: cmOptionalLinkImplementation& impl ) const; + cmLinkImplementationLibraries const* + GetLinkImplementationLibraries(const std::string& config) const; + + void ComputeLinkImplementationLibraries(const std::string& config, + cmOptionalLinkImplementation& impl, + const cmGeneratorTarget* head) const; + + cmGeneratorTarget* FindTargetToLink(std::string const& name) const; + // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change // when source file properties are changed and we do not have enough @@ -213,6 +248,12 @@ public: void GetLanguages(std::set<std::string>& languages, std::string const& config) const; + void + GetObjectLibrariesCMP0026(std::vector<cmGeneratorTarget*>& objlibs) const; + + std::string GetFullNameImported(const std::string& config, + bool implib) const; + bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const; bool HaveBuildTreeRPATH(const std::string& config) const; @@ -259,6 +300,13 @@ public: */ void TraceDependencies(); + /** Get the directory in which this target will be built. If the + configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + output directory is given. */ + std::string GetDirectory(const std::string& config = "", + bool implib = false) const; + /** Get the directory in which to place the target compiler .pdb file. If the configuration name is given then the generator will add its subdirectory for that configuration. Otherwise just the canonical @@ -269,6 +317,22 @@ public: std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile const* sf) const; + /** Return whether this target uses the default value for its output + directory. */ + bool UsesDefaultOutputDir(const std::string& config, bool implib) const; + + // Cache target output paths for each configuration. + struct OutputInfo + { + std::string OutDir; + std::string ImpDir; + std::string PdbDir; + bool empty() const + { return OutDir.empty() && ImpDir.empty() && PdbDir.empty(); } + }; + + OutputInfo const* GetOutputInfo(const std::string& config) const; + /** Get the name of the pdb file for the target. */ std::string GetPDBName(const std::string& config="") const; @@ -285,6 +349,8 @@ public: typedef std::map<std::string, CompileInfo> CompileInfoMapType; mutable CompileInfoMapType CompileInfoMap; + bool IsNullImpliedByLinkLibraries(const std::string &p) const; + /** Get the name of the compiler pdb file for the target. */ std::string GetCompilePDBName(const std::string& config="") const; @@ -294,6 +360,9 @@ public: // Get the target base name. std::string GetOutputName(const std::string& config, bool implib) const; + void AddSource(const std::string& src); + void AddTracedSources(std::vector<std::string> const& srcs); + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. @@ -340,9 +409,47 @@ public: /** Return true if builtin chrpath will work for this target */ bool IsChrpathUsed(const std::string& config) const; + /** Get the directory in which this targets .pdb files will be placed. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + pdb output directory is given. */ + std::string GetPDBDirectory(const std::string& config) const; + ///! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config = "") const; + /** Does this target have a GNU implib to convert to MS format? */ + bool HasImplibGNUtoMS() const; + + /** Convert the given GNU import library name (.dll.a) to a name with a new + extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */ + bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, + const char* newExt = 0) const; + + bool IsExecutableWithExports() const; + + /** Return whether or not the target has a DLL import library. */ + bool HasImportLibrary() const; + + /** Get a build-tree directory in which to place target support files. */ + std::string GetSupportDirectory() const; + + /** Return whether this target may be used to link another target. */ + bool IsLinkable() const; + + /** Return whether this target is a shared library Framework on + Apple. */ + bool IsFrameworkOnApple() const; + + /** Return whether this target is an executable Bundle on Apple. */ + bool IsAppBundleOnApple() const; + + /** Return whether this target is a XCTest on Apple. */ + bool IsXCTestOnApple() const; + + /** Return whether this target is a CFBundle (plugin) on Apple. */ + bool IsCFBundleOnApple() const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; @@ -364,15 +471,42 @@ public: class TargetPropertyEntry; + bool HaveInstallTreeRPATH() const; + + /** Whether this library has \@rpath and platform supports it. */ + bool HasMacOSXRpathInstallNameDir(const std::string& config) const; + + /** Whether this library defaults to \@rpath. */ + bool MacOSXRpathInstallNameDirDefault() const; + + /** Test for special case of a third-party shared library that has + no soname at all. */ + bool IsImportedSharedLibWithoutSOName(const std::string& config) const; + + const char* ImportedGetLocation(const std::string& config) const; + + /** Get the target major and minor version numbers interpreted from + the VERSION property. Version 0 is returned if the property is + not set or cannot be parsed. */ + void GetTargetVersion(int& major, int& minor) const; + + /** Get the target major, minor, and patch version numbers + interpreted from the VERSION or SOVERSION property. Version 0 + is returned if the property is not set or cannot be parsed. */ + void + GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector<cmSourceFile*> Depends; }; typedef std::map<cmSourceFile const*, SourceEntry> SourceEntriesType; - SourceEntriesType SourceEntries; + SourceEntriesType SourceDepends; mutable std::map<cmSourceFile const*, std::string> Objects; std::set<cmSourceFile const*> ExplicitObjectName; mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache; + mutable std::string ExportMacro; + void ConstructSourceFileFlags() const; mutable bool SourceFileFlagsConstructed; mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; @@ -388,6 +522,16 @@ private: typedef std::map<std::string, LinkClosure> LinkClosureMapType; mutable LinkClosureMapType LinkClosureMap; + // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. + const char* GetOutputTargetType(bool implib) const; + + void ComputeVersionedName(std::string& vName, + std::string const& prefix, + std::string const& base, + std::string const& suffix, + std::string const& name, + const char* version) const; + struct CompatibleInterfacesBase { std::set<std::string> PropsBool; @@ -415,7 +559,7 @@ private: cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); - struct LinkImplClosure: public std::vector<cmTarget const*> + struct LinkImplClosure: public std::vector<cmGeneratorTarget const*> { LinkImplClosure(): Done(false) {} bool Done; @@ -432,36 +576,103 @@ private: cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap( std::string const& config) const; + // Cache import information from properties for each configuration. + struct ImportInfo + { + ImportInfo(): NoSOName(false), Multiplicity(0) {} + bool NoSOName; + int Multiplicity; + std::string Location; + std::string SOName; + std::string ImportLibrary; + std::string Languages; + std::string Libraries; + std::string LibrariesProp; + std::string SharedDeps; + }; + + typedef std::map<std::string, ImportInfo> ImportInfoMapType; + mutable ImportInfoMapType ImportInfoMap; + void ComputeImportInfo(std::string const& desired_config, + ImportInfo& info) const; + ImportInfo const* GetImportInfo(const std::string& config) const; + + /** Strip off leading and trailing whitespace from an item named in + the link dependencies of this target. */ + std::string CheckCMP0004(std::string const& item) const; + cmLinkInterface const* - GetImportLinkInterface(const std::string& config, cmTarget const* head, + GetImportLinkInterface(const std::string& config, + const cmGeneratorTarget* head, bool usage_requirements_only) const; + typedef std::map<std::string, std::vector<cmSourceFile*> > + SourceFilesMapType; + mutable SourceFilesMapType SourceFilesMap; + std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries; std::vector<TargetPropertyEntry*> CompileOptionsEntries; std::vector<TargetPropertyEntry*> CompileFeaturesEntries; std::vector<TargetPropertyEntry*> CompileDefinitionsEntries; + std::vector<TargetPropertyEntry*> SourceEntries; + mutable std::set<std::string> LinkImplicitNullProperties; void ExpandLinkItems(std::string const& prop, std::string const& value, - std::string const& config, cmTarget const* headTarget, + std::string const& config, + const cmGeneratorTarget* headTarget, bool usage_requirements_only, std::vector<cmLinkItem>& items, bool& hadHeadSensitiveCondition) const; void LookupLinkItems(std::vector<std::string> const& names, std::vector<cmLinkItem>& items) const; + void GetSourceFiles(std::vector<std::string>& files, + const std::string& config) const; + + struct HeadToLinkImplementationMap: + public std::map<cmTarget const*, cmOptionalLinkImplementation> {}; + typedef std::map<std::string, + HeadToLinkImplementationMap> LinkImplMapType; + mutable LinkImplMapType LinkImplMap; + + cmLinkImplementationLibraries const* + GetLinkImplementationLibrariesInternal(const std::string& config, + const cmGeneratorTarget* head) const; + bool + ComputeOutputDir(const std::string& config, + bool implib, std::string& out) const; + + typedef std::map<std::string, OutputInfo> OutputInfoMapType; + mutable OutputInfoMapType OutputInfoMap; + typedef std::pair<std::string, bool> OutputNameKey; typedef std::map<OutputNameKey, std::string> OutputNameMapType; mutable OutputNameMapType OutputNameMap; + mutable std::set<cmLinkItem> UtilityItems; + cmPolicies::PolicyMap PolicyMap; mutable bool PolicyWarnedCMP0022; mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; mutable bool DebugCompileFeaturesDone; mutable bool DebugCompileDefinitionsDone; + mutable bool DebugSourcesDone; + mutable bool LinkImplementationLanguageIsContextDependent; + mutable bool UtilityItemsDone; + bool DLLPlatform; + + bool ComputePDBOutputDir(const std::string& kind, const std::string& config, + std::string& out) const; public: - std::vector<cmTarget const*> const& - GetLinkImplementationClosure(const std::string& config) const; + const std::vector<const cmGeneratorTarget*>& + GetLinkImplementationClosure(const std::string& config) const; + mutable std::map<std::string, std::string> MaxLanguageStandards; + std::map<std::string, std::string> const& + GetMaxLanguageStandards() const + { + return this->MaxLanguageStandards; + } }; struct cmStrictTargetComparison { diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx index 248ce59..1a91183 100644 --- a/Source/cmGetCMakePropertyCommand.cxx +++ b/Source/cmGetCMakePropertyCommand.cxx @@ -12,7 +12,6 @@ #include "cmGetCMakePropertyCommand.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmake.h" #include "cmState.h" #include "cmAlgorithms.h" diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 4c42f53..617a811 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -15,7 +15,6 @@ #include "cmState.h" #include "cmTest.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmSourceFile.h" #include "cmPropertyDefinition.h" diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index cae5c2f..01e6f8c 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -27,7 +27,7 @@ cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget *target) , LocalGenerator(static_cast<cmLocalGhsMultiGenerator *>( target->GetLocalGenerator())) , Makefile(target->Target->GetMakefile()) - , TargetGroup(DetermineIfTargetGroup(target->Target)) + , TargetGroup(DetermineIfTargetGroup(target)) , DynamicDownload(false) { this->RelBuildFilePath = this->GetRelBuildFilePath(target->Target); @@ -68,7 +68,9 @@ cmGhsMultiTargetGenerator::GetRelBuildFilePath(const cmTarget *target) std::string cmGhsMultiTargetGenerator::GetAbsPathToRoot(const cmTarget *target) { - return target->GetMakefile()->GetHomeOutputDirectory(); + cmGeneratorTarget* gt = target->GetMakefile()->GetGlobalGenerator() + ->GetGeneratorTarget(target); + return gt->GetLocalGenerator()->GetBinaryDirectory(); } std::string @@ -146,7 +148,7 @@ void cmGhsMultiTargetGenerator::Generate() this->WriteCompilerFlags(config, language); this->WriteCompilerDefinitions(config, language); this->WriteIncludes(config, language); - if (this->Target->GetType() == cmTarget::EXECUTABLE) + if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { this->WriteTargetLinkLibraries(); } @@ -172,23 +174,24 @@ std::vector<cmSourceFile *> cmGhsMultiTargetGenerator::GetSources() const { std::vector<cmSourceFile *> output; std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - this->Target->GetSourceFiles(output, config); + this->GeneratorTarget->GetSourceFiles(output, config); return output; } GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag() const { - return cmGhsMultiTargetGenerator::GetGpjTag(this->Target); + return cmGhsMultiTargetGenerator::GetGpjTag(this->GeneratorTarget); } -GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag(const cmTarget *target) +GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag( + const cmGeneratorTarget *target) { GhsMultiGpj::Types output; if (cmGhsMultiTargetGenerator::DetermineIfTargetGroup(target)) { output = GhsMultiGpj::INTERGRITY_APPLICATION; } - else if (target->GetType() == cmTarget::STATIC_LIBRARY) + else if (target->GetType() == cmState::STATIC_LIBRARY) { output = GhsMultiGpj::LIBRARY; } @@ -212,13 +215,13 @@ void cmGhsMultiTargetGenerator::WriteTypeSpecifics(const std::string &config, std::string outputDir(this->GetOutputDirectory(config)); std::string outputFilename(this->GetOutputFilename(config)); - if (this->Target->GetType() == cmTarget::STATIC_LIBRARY) + if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) { - *this->GetFolderBuildStreams() << " {optgroup=GhsCommonOptions} -o \"" + *this->GetFolderBuildStreams() << " -o \"" << outputDir << outputFilename << ".a\"" << std::endl; } - else if (this->Target->GetType() == cmTarget::EXECUTABLE) + else if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { if (notKernel && !this->IsTargetGroup()) { @@ -227,7 +230,7 @@ void cmGhsMultiTargetGenerator::WriteTypeSpecifics(const std::string &config, if (this->IsTargetGroup()) { *this->GetFolderBuildStreams() - << " {optgroup=GhsCommonOptions} -o \"" << outputDir + << " -o \"" << outputDir << outputFilename << ".elf\"" << std::endl; *this->GetFolderBuildStreams() << " :extraOutputFile=\"" << outputDir << outputFilename << ".elf.ael\"" @@ -235,7 +238,7 @@ void cmGhsMultiTargetGenerator::WriteTypeSpecifics(const std::string &config, } else { - *this->GetFolderBuildStreams() << " {optgroup=GhsCommonOptions} -o \"" + *this->GetFolderBuildStreams() << " -o \"" << outputDir << outputFilename << ".as\"" << std::endl; } @@ -262,8 +265,11 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const &config, this->LocalGenerator->AddLanguageFlags( flags, lang + std::string("_GHS_KERNEL"), config); } - this->LocalGenerator->AddCMP0018Flags(flags, this->Target, lang, config); - this->LocalGenerator->AddVisibilityPresetFlags(flags, this->Target, lang); + this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, + lang, config); + this->LocalGenerator->AddVisibilityPresetFlags(flags, + this->GeneratorTarget, + lang); // Append old-style preprocessor definition flags. if (std::string(" ") != std::string(this->Makefile->GetDefineFlags())) @@ -273,7 +279,8 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const &config, } // Add target-specific flags. - this->LocalGenerator->AddCompileOptions(flags, this->Target, lang, config); + this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, + lang, config); std::map<std::string, std::string>::value_type entry(language, flags); i = this->FlagsByLanguage.insert(entry).first; @@ -290,13 +297,14 @@ std::string cmGhsMultiTargetGenerator::GetDefines(const std::string &language, std::set<std::string> defines; const char *lang = language.c_str(); // Add the export symbol definition for shared library objects. - if (const char *exportMacro = this->Target->GetExportMacro()) + if (const char *exportMacro = this->GeneratorTarget->GetExportMacro()) { this->LocalGenerator->AppendDefines(defines, exportMacro); } // Add preprocessor definitions for this target and configuration. - this->LocalGenerator->AddCompileDefinitions(defines, this->Target, config, + this->LocalGenerator->AddCompileDefinitions(defines, + this->GeneratorTarget, config, language); std::string definesString; @@ -449,7 +457,7 @@ void cmGhsMultiTargetGenerator::WriteSources( cmSystemTools::ConvertToUnixSlashes(sgPath); cmGlobalGhsMultiGenerator::AddFilesUpToPath( this->GetFolderBuildStreams(), &this->FolderBuildStreams, - this->Makefile->GetHomeOutputDirectory(), sgPath, + this->LocalGenerator->GetBinaryDirectory(), sgPath, GhsMultiGpj::SUBPROJECT, this->RelBuildFilePath); std::string fullSourcePath((*si)->GetFullPath()); @@ -566,12 +574,13 @@ bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const &config, return output; } -bool cmGhsMultiTargetGenerator::DetermineIfTargetGroup(const cmTarget *target) +bool cmGhsMultiTargetGenerator::DetermineIfTargetGroup( + const cmGeneratorTarget *target) { bool output = false; std::vector<cmSourceFile *> sources; std::string config = - target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); + target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); target->GetSourceFiles(sources, config); for (std::vector<cmSourceFile *>::const_iterator sources_i = sources.begin(); sources.end() != sources_i; ++sources_i) diff --git a/Source/cmGhsMultiTargetGenerator.h b/Source/cmGhsMultiTargetGenerator.h index c29a31e..d1c17f4 100644 --- a/Source/cmGhsMultiTargetGenerator.h +++ b/Source/cmGhsMultiTargetGenerator.h @@ -36,7 +36,7 @@ public: bool IncludeThisTarget(); std::vector<cmSourceFile *> GetSources() const; GhsMultiGpj::Types GetGpjTag() const; - static GhsMultiGpj::Types GetGpjTag(const cmTarget *target); + static GhsMultiGpj::Types GetGpjTag(const cmGeneratorTarget* target); const char *GetAbsBuildFilePath() const { return this->AbsBuildFilePath.c_str(); @@ -95,7 +95,7 @@ private: std::string GetOutputFilename(const std::string &config) const; bool IsNotKernel(std::string const &config, const std::string &language); - static bool DetermineIfTargetGroup(const cmTarget *target); + static bool DetermineIfTargetGroup(const cmGeneratorTarget* target); bool DetermineIfDynamicDownload(std::string const &config, const std::string &language); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ee1b192..086ff25 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -22,7 +22,7 @@ #include "cmake.h" #include "cmState.h" #include "cmMakefile.h" -#include "cmQtAutoGenerators.h" +#include "cmQtAutoGeneratorInitializer.h" #include "cmSourceFile.h" #include "cmVersion.h" #include "cmTargetExport.h" @@ -72,6 +72,8 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm) this->ExtraGenerator = 0; this->CurrentMakefile = 0; this->TryCompileOuterMakefile = 0; + + this->ConfigureDoneCMP0026AndCMP0024 = false; } cmGlobalGenerator::~cmGlobalGenerator() @@ -232,6 +234,16 @@ bool cmGlobalGenerator::GenerateImportFile(const std::string &file) if (it != this->BuildExportSets.end()) { bool result = it->second->GenerateImportFile(); + + if (!this->ConfigureDoneCMP0026AndCMP0024) + { + for (std::vector<cmMakefile*>::const_iterator mit = + this->Makefiles.begin(); mit != this->Makefiles.end(); ++mit) + { + (*mit)->RemoveExportBuildFileGeneratorCMP0024(it->second); + } + } + delete it->second; it->second = 0; this->BuildExportSets.erase(it); @@ -397,7 +409,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, bool fatalError = false; mf->AddDefinition("RUN_CONFIGURE", true); - std::string rootBin = mf->GetHomeOutputDirectory(); + std::string rootBin = this->CMakeInstance->GetHomeOutputDirectory(); rootBin += cmake::GetCMakeFilesDirectory(); // If the configuration files path has been set, @@ -433,19 +445,22 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, { #if defined(_WIN32) && !defined(__CYGWIN__) /* Windows version number data. */ - OSVERSIONINFO osvi; - ZeroMemory(&osvi, sizeof(osvi)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + OSVERSIONINFOEXW osviex; + ZeroMemory(&osviex, sizeof(osviex)); + osviex.dwOSVersionInfoSize = sizeof(osviex); + #ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx # pragma warning (push) # pragma warning (disable:4996) #endif - GetVersionEx (&osvi); + GetVersionExW((OSVERSIONINFOW*)&osviex); #ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx # pragma warning (pop) #endif std::ostringstream windowsVersionString; - windowsVersionString << osvi.dwMajorVersion << "." << osvi.dwMinorVersion; + windowsVersionString << osviex.dwMajorVersion << "." + << osviex.dwMinorVersion << "." + << osviex.dwBuildNumber; windowsVersionString.str(); mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION", windowsVersionString.str().c_str()); @@ -1086,30 +1101,43 @@ void cmGlobalGenerator::ClearEnabledLanguages() return this->CMakeInstance->GetState()->ClearEnabledLanguages(); } +void cmGlobalGenerator::CreateLocalGenerators() +{ + cmDeleteAll(this->LocalGenerators); + this->LocalGenerators.clear(); + this->LocalGenerators.reserve(this->Makefiles.size()); + for (std::vector<cmMakefile*>::const_iterator it = this->Makefiles.begin(); + it != this->Makefiles.end(); ++it) + { + this->LocalGenerators.push_back(this->CreateLocalGenerator(*it)); + } +} + void cmGlobalGenerator::Configure() { this->FirstTimeProgress = 0.0f; this->ClearGeneratorMembers(); - cmMakefile* dirMf = - new cmMakefile(this, this->GetCMakeInstance()->GetCurrentSnapshot()); - this->Makefiles.push_back(dirMf); - cmLocalGenerator *lg = this->CreateLocalGenerator(dirMf); - this->LocalGenerators.push_back(lg); + cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); - // set the Start directories - dirMf->SetCurrentSourceDirectory + snapshot.GetDirectory().SetCurrentSource (this->CMakeInstance->GetHomeDirectory()); - dirMf->SetCurrentBinaryDirectory + snapshot.GetDirectory().SetCurrentBinary (this->CMakeInstance->GetHomeOutputDirectory()); + cmMakefile* dirMf = new cmMakefile(this, snapshot); + this->Makefiles.push_back(dirMf); + this->BinaryDirectories.insert( this->CMakeInstance->GetHomeOutputDirectory()); // now do it + this->ConfigureDoneCMP0026AndCMP0024 = false; dirMf->Configure(); dirMf->EnforceDirectoryLevelRules(); + this->ConfigureDoneCMP0026AndCMP0024 = true; + // Put a copy of each global target in every directory. cmTargets globalTargets; this->CreateDefaultGlobalTargets(&globalTargets); @@ -1167,9 +1195,31 @@ void cmGlobalGenerator::Configure() void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes) { + this->CreateLocalGenerators(); cmDeleteAll(this->GeneratorTargets); this->GeneratorTargets.clear(); this->CreateGeneratorTargets(targetTypes); + this->ComputeBuildFileGenerators(); +} + +void cmGlobalGenerator::CreateImportedGenerationObjects(cmMakefile* mf, + const std::vector<std::string>& targets, + std::vector<const cmGeneratorTarget*>& exports) +{ + this->CreateGenerationObjects(ImportedOnly); + std::vector<cmMakefile*>::iterator mfit = + std::find(this->Makefiles.begin(), this->Makefiles.end(), mf); + cmLocalGenerator* lg = + this->LocalGenerators[std::distance(this->Makefiles.begin(), mfit)]; + for (std::vector<std::string>::const_iterator it = targets.begin(); + it != targets.end(); ++it) + { + cmGeneratorTarget* gt = lg->FindGeneratorTargetToUse(*it); + if (gt) + { + exports.push_back(gt); + } + } } cmExportBuildFileGenerator* @@ -1207,6 +1257,20 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const return false; } +void cmGlobalGenerator::ComputeBuildFileGenerators() +{ + for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) + { + std::vector<cmExportBuildFileGenerator*> gens = + this->Makefiles[i]->GetExportBuildFileGenerators(); + for (std::vector<cmExportBuildFileGenerator*>::const_iterator it = + gens.begin(); it != gens.end(); ++it) + { + (*it)->Compute(this->LocalGenerators[i]); + } + } +} + bool cmGlobalGenerator::Compute() { // Some generators track files replaced during the Generate. @@ -1232,30 +1296,23 @@ bool cmGlobalGenerator::Compute() #ifdef CMAKE_BUILD_WITH_CMAKE // Iterate through all targets and set up automoc for those which have // the AUTOMOC, AUTOUIC or AUTORCC property set - AutogensType autogens; - this->CreateQtAutoGeneratorsTargets(autogens); + std::vector<cmGeneratorTarget const*> autogenTargets = + this->CreateQtAutoGeneratorsTargets(); #endif unsigned int i; - for (i = 0; i < this->LocalGenerators.size(); ++i) - { - this->LocalGenerators[i]->ComputeObjectMaxPath(); - } - // Add generator specific helper commands for (i = 0; i < this->LocalGenerators.size(); ++i) { this->LocalGenerators[i]->AddHelperCommands(); } - this->InitGeneratorTargets(); - #ifdef CMAKE_BUILD_WITH_CMAKE - for (AutogensType::iterator it = autogens.begin(); it != autogens.end(); - ++it) + for (std::vector<cmGeneratorTarget const*>::iterator it = + autogenTargets.begin(); it != autogenTargets.end(); ++it) { - it->first.SetupAutoGenerateTarget(it->second); + cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(*it); } #endif @@ -1270,12 +1327,7 @@ bool cmGlobalGenerator::Compute() } } - return true; -} - -void cmGlobalGenerator::Generate() -{ - unsigned int i; + this->AddExtraIDETargets(); // Trace the dependencies, after that no custom commands should be added // because their dependencies might not be handled correctly @@ -1295,22 +1347,27 @@ void cmGlobalGenerator::Generate() // Compute the inter-target dependencies. if(!this->ComputeTargetDepends()) { - return; + return false; } + for (i = 0; i < this->LocalGenerators.size(); ++i) + { + this->LocalGenerators[i]->ComputeHomeRelativeOutputPath(); + } + + return true; +} + +void cmGlobalGenerator::Generate() +{ // Create a map from local generator to the complete set of targets // it builds by default. this->InitializeProgressMarks(); this->ProcessEvaluationFiles(); - for (i = 0; i < this->LocalGenerators.size(); ++i) - { - this->LocalGenerators[i]->ComputeHomeRelativeOutputPath(); - } - // Generate project files - for (i = 0; i < this->LocalGenerators.size(); ++i) + for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { this->SetCurrentMakefile(this->LocalGenerators[i]->GetMakefile()); this->LocalGenerators[i]->Generate(); @@ -1391,53 +1448,67 @@ bool cmGlobalGenerator::ComputeTargetDepends() } //---------------------------------------------------------------------------- -void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) +std::vector<const cmGeneratorTarget*> +cmGlobalGenerator::CreateQtAutoGeneratorsTargets() { + std::vector<const cmGeneratorTarget*> autogenTargets; + #ifdef CMAKE_BUILD_WITH_CMAKE for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) { cmTargets& targets = this->LocalGenerators[i]->GetMakefile()->GetTargets(); - std::vector<std::string> targetNames; - targetNames.reserve(targets.size()); + std::vector<cmGeneratorTarget*> filteredTargets; + filteredTargets.reserve(targets.size()); for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) { - if (ti->second.GetType() == cmTarget::GLOBAL_TARGET) + if (ti->second.GetType() == cmState::GLOBAL_TARGET) { continue; } - targetNames.push_back(ti->second.GetName()); - } - for(std::vector<std::string>::iterator ti = targetNames.begin(); - ti != targetNames.end(); ++ti) - { - cmTarget& target = *this->LocalGenerators[i] - ->GetMakefile()->FindTarget(*ti, true); - if(target.GetType() == cmTarget::EXECUTABLE || - target.GetType() == cmTarget::STATIC_LIBRARY || - target.GetType() == cmTarget::SHARED_LIBRARY || - target.GetType() == cmTarget::MODULE_LIBRARY || - target.GetType() == cmTarget::OBJECT_LIBRARY) + if(ti->second.GetType() != cmState::EXECUTABLE && + ti->second.GetType() != cmState::STATIC_LIBRARY && + ti->second.GetType() != cmState::SHARED_LIBRARY && + ti->second.GetType() != cmState::MODULE_LIBRARY && + ti->second.GetType() != cmState::OBJECT_LIBRARY) { - if((target.GetPropertyAsBool("AUTOMOC") - || target.GetPropertyAsBool("AUTOUIC") - || target.GetPropertyAsBool("AUTORCC")) - && !target.IsImported()) - { - cmQtAutoGenerators autogen; - if(autogen.InitializeAutogenTarget(this->LocalGenerators[i], - &target)) - { - autogens.push_back(std::make_pair(autogen, &target)); - } - } + continue; + } + if((!ti->second.GetPropertyAsBool("AUTOMOC") + && !ti->second.GetPropertyAsBool("AUTOUIC") + && !ti->second.GetPropertyAsBool("AUTORCC")) + || ti->second.IsImported()) + { + continue; + } + // don't do anything if there is no Qt4 or Qt5Core (which contains moc): + cmMakefile* mf = ti->second.GetMakefile(); + std::string qtMajorVersion = mf->GetSafeDefinition("QT_VERSION_MAJOR"); + if (qtMajorVersion == "") + { + qtMajorVersion = mf->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); } + if (qtMajorVersion != "4" && qtMajorVersion != "5") + { + continue; + } + + cmGeneratorTarget* gt = this->GetGeneratorTarget(&ti->second); + + cmQtAutoGeneratorInitializer::InitializeAutogenSources(gt); + filteredTargets.push_back(gt); + } + for(std::vector<cmGeneratorTarget*>::iterator ti = filteredTargets.begin(); + ti != filteredTargets.end(); ++ti) + { + cmQtAutoGeneratorInitializer::InitializeAutogenTarget( + this->LocalGenerators[i], *ti); + autogenTargets.push_back(*ti); } } -#else - (void)autogens; #endif + return autogenTargets; } //---------------------------------------------------------------------------- @@ -1458,14 +1529,14 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() ti != targets.end(); ++ti) { cmTarget* t = &ti->second; - if (t->GetType() == cmTarget::GLOBAL_TARGET) + if (t->GetType() == cmState::GLOBAL_TARGET) { continue; } t->AppendBuildInterfaceIncludes(); - if (t->GetType() == cmTarget::INTERFACE_LIBRARY) + if (t->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -1503,7 +1574,6 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, cmLocalGenerator *lg) { - cmGeneratorTargetsType generatorTargets; cmMakefile* mf = lg->GetMakefile(); if (targetTypes == AllTargets) { @@ -1514,7 +1584,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, cmTarget* t = &ti->second; cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; - generatorTargets[t] = gt; + lg->AddGeneratorTarget(t, gt); } } @@ -1524,21 +1594,6 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, { cmGeneratorTarget* gt = new cmGeneratorTarget(*j, lg); this->GeneratorTargets[*j] = gt; - generatorTargets[*j] = gt; - } - mf->SetGeneratorTargets(generatorTargets); -} - -//---------------------------------------------------------------------------- -void cmGlobalGenerator::InitGeneratorTargets() -{ - for(cmGeneratorTargetsType::iterator ti = - this->GeneratorTargets.begin(); ti != this->GeneratorTargets.end(); ++ti) - { - if (!ti->second->Target->IsImported()) - { - this->ComputeTargetObjectDirectory(ti->second); - } } } @@ -1611,7 +1666,7 @@ void cmGlobalGenerator::CheckTargetProperties() for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) { - if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + if (l->second.GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -1928,12 +1983,6 @@ void cmGlobalGenerator::AddMakefile(cmMakefile *mf) this->CMakeInstance->UpdateProgress("Configuring", prog); } -//---------------------------------------------------------------------------- -void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) -{ - this->LocalGenerators.push_back(lg); -} - void cmGlobalGenerator::AddInstallComponent(const char* component) { if(component && *component) @@ -2025,8 +2074,8 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const { - if(target->GetType() == cmTarget::INTERFACE_LIBRARY - || target->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target->GetType() == cmState::INTERFACE_LIBRARY + || target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -2098,7 +2147,7 @@ cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const for(std::vector<cmLocalGenerator*>::const_iterator it = this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it) { - std::string sd = (*it)->GetMakefile()->GetCurrentSourceDirectory(); + std::string sd = (*it)->GetCurrentSourceDirectory(); if (sd == start_dir) { return *it; @@ -2156,7 +2205,8 @@ cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const if(cmTarget* tgt = this->FindTarget(libname)) { - if(tgt->IsFrameworkOnApple()) + cmGeneratorTarget* gt = this->GetGeneratorTarget(tgt); + if(gt->IsFrameworkOnApple()) { return true; } @@ -2486,7 +2536,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( { // Package cmTarget target; - target.SetType(cmTarget::GLOBAL_TARGET, name); + target.SetType(cmState::GLOBAL_TARGET, name); target.SetProperty("EXCLUDE_FROM_ALL","TRUE"); std::vector<std::string> no_outputs; @@ -2651,13 +2701,13 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, for (cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { cmTarget* target = &l->second; - if(this->IsRootOnlyTarget(target) && + cmGeneratorTarget* gt = this->GetGeneratorTarget(target); + if(this->IsRootOnlyTarget(gt) && target->GetMakefile() != root->GetMakefile()) { continue; } // put the target in the set of original targets - cmGeneratorTarget* gt = this->GetGeneratorTarget(target); originalTargets.insert(gt); // Get the set of targets that depend on target this->AddTargetDepends(gt, projectTargets); @@ -2666,9 +2716,9 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const +bool cmGlobalGenerator::IsRootOnlyTarget(cmGeneratorTarget* target) const { - return (target->GetType() == cmTarget::GLOBAL_TARGET || + return (target->GetType() == cmState::GLOBAL_TARGET || target->GetName() == this->GetAllTargetName()); } @@ -2872,10 +2922,8 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile) //---------------------------------------------------------------------------- void cmGlobalGenerator::WriteSummary() { - cmMakefile* mf = this->LocalGenerators[0]->GetMakefile(); - // Record all target directories in a central location. - std::string fname = mf->GetHomeOutputDirectory(); + std::string fname = this->CMakeInstance->GetHomeOutputDirectory(); fname += cmake::GetCMakeFilesDirectory(); fname += "/TargetDirectories.txt"; cmGeneratedFileStream fout(fname.c_str()); @@ -2884,17 +2932,18 @@ void cmGlobalGenerator::WriteSummary() for(TargetMap::const_iterator ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti) { - if ((ti->second)->GetType() == cmTarget::INTERFACE_LIBRARY) + if ((ti->second)->GetType() == cmState::INTERFACE_LIBRARY) { continue; } - this->WriteSummary(ti->second); - fout << ti->second->GetSupportDirectory() << "\n"; + cmGeneratorTarget* gt = this->GetGeneratorTarget(ti->second); + this->WriteSummary(gt); + fout << gt->GetSupportDirectory() << "\n"; } } //---------------------------------------------------------------------------- -void cmGlobalGenerator::WriteSummary(cmTarget* target) +void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) { // Place the labels file in a per-target support directory. std::string dir = target->GetSupportDirectory(); @@ -2937,7 +2986,7 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target) fout << "# Source files and their labels\n"; std::vector<cmSourceFile*> sources; std::vector<std::string> configs; - target->GetMakefile()->GetConfigurations(configs); + target->Target->GetMakefile()->GetConfigurations(configs); if (configs.empty()) { configs.push_back(""); @@ -2997,13 +3046,13 @@ std::string cmGlobalGenerator::EscapeJSON(const std::string& s) { //---------------------------------------------------------------------------- void cmGlobalGenerator::SetFilenameTargetDepends(cmSourceFile* sf, - std::set<cmTarget const*> tgts) + std::set<cmGeneratorTarget const*> tgts) { this->FilenameTargetDepends[sf] = tgts; } //---------------------------------------------------------------------------- -std::set<cmTarget const*> const& +std::set<cmGeneratorTarget const*> const& cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const { return this->FilenameTargetDepends[sf]; } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9fc2d45..c59d42d 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -41,7 +41,6 @@ class cmTarget; class cmInstallTargetGenerator; class cmInstallFilesGenerator; class cmExportBuildFileGenerator; -class cmQtAutoGenerators; /** \class cmGlobalGenerator * \brief Responsible for overseeing the generation process for the entire tree @@ -84,13 +83,17 @@ public: */ virtual void Configure(); - virtual bool Compute(); + bool Compute(); + virtual void AddExtraIDETargets() {} enum TargetTypes { AllTargets, ImportedOnly }; + void CreateImportedGenerationObjects(cmMakefile* mf, + std::vector<std::string> const& targets, + std::vector<cmGeneratorTarget const*>& exports); void CreateGenerationObjects(TargetTypes targetTypes = AllTargets); /** @@ -124,7 +127,7 @@ public: /** * Try to determine system information, get it from another generator */ - virtual void EnableLanguagesFromGenerator(cmGlobalGenerator *gen, + void EnableLanguagesFromGenerator(cmGlobalGenerator *gen, cmMakefile* mf); /** @@ -186,7 +189,6 @@ public: {this->CurrentMakefile = mf;} void AddMakefile(cmMakefile *mf); - void AddLocalGenerator(cmLocalGenerator *lg); ///! Set an generator for an "external makefile based project" void SetExternalMakefileProjectGenerator( @@ -355,14 +357,17 @@ public: void CreateEvaluationSourceFiles(std::string const& config) const; void SetFilenameTargetDepends(cmSourceFile* sf, - std::set<cmTarget const*> tgts); - std::set<cmTarget const*> const& + std::set<const cmGeneratorTarget*> tgts); + const std::set<const cmGeneratorTarget*>& GetFilenameTargetDepends(cmSourceFile* sf) const; #if defined(CMAKE_BUILD_WITH_CMAKE) cmFileLockPool& GetFileLockPool() { return FileLockPool; } #endif + bool GetConfigureDoneCMP0026() const + { return this->ConfigureDoneCMP0026AndCMP0024; } + std::string MakeSilentFlag; protected: typedef std::vector<cmLocalGenerator*> GeneratorVector; @@ -371,7 +376,7 @@ protected: void GetTargetSets(TargetDependSet& projectTargets, TargetDependSet& originalTargets, cmLocalGenerator* root, GeneratorVector const&); - bool IsRootOnlyTarget(cmTarget* target) const; + bool IsRootOnlyTarget(cmGeneratorTarget* target) const; void AddTargetDepends(const cmGeneratorTarget* target, TargetDependSet& projectTargets); void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf); @@ -384,9 +389,7 @@ protected: virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const; - typedef std::vector<std::pair<cmQtAutoGenerators, - cmTarget const*> > AutogensType; - void CreateQtAutoGeneratorsTargets(AutogensType& autogens); + std::vector<const cmGeneratorTarget*> CreateQtAutoGeneratorsTargets(); std::string SelectMakeProgram(const std::string& makeProgram, const std::string& makeDefault = "") const; @@ -459,14 +462,18 @@ private: void WriteRuleHashes(std::string const& pfile); void WriteSummary(); - void WriteSummary(cmTarget* target); + void WriteSummary(cmGeneratorTarget* target); void FinalizeTargetCompileInfo(); virtual void ForceLinkerLanguages(); + void CreateLocalGenerators(); + void CheckCompilerIdCompatibility(cmMakefile* mf, std::string const& lang) const; + void ComputeBuildFileGenerators(); + cmExternalMakefileProjectGenerator* ExtraGenerator; // track files replaced during a Generate @@ -480,7 +487,6 @@ private: cmGeneratorTargetsType GeneratorTargets; friend class cmake; void CreateGeneratorTargets(TargetTypes targetTypes, cmLocalGenerator* lg); - void InitGeneratorTargets(); void CreateGeneratorTargets(TargetTypes targetTypes); void ClearGeneratorMembers(); @@ -505,7 +511,7 @@ private: // track targets to issue CMP0042 warning for. std::set<std::string> CMP0042WarnTargets; - mutable std::map<cmSourceFile*, std::set<cmTarget const*> > + mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*> > FilenameTargetDepends; #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -520,6 +526,7 @@ protected: bool ForceUnixPaths; bool ToolSupportsColor; bool InstallTargetEnabled; + bool ConfigureDoneCMP0026AndCMP0024; }; #endif diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 6dde1e3..45a1509 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -287,7 +287,7 @@ void cmGlobalGhsMultiGenerator::Generate() { cmLocalGhsMultiGenerator *lg = static_cast<cmLocalGhsMultiGenerator *>(this->LocalGenerators[i]); - cmGeneratorTargetsType tgts = lg->GetMakefile()->GetGeneratorTargets(); + cmGeneratorTargetsType tgts = lg->GetGeneratorTargets(); this->UpdateBuildFiles(&tgts); } } @@ -509,7 +509,8 @@ void cmGlobalGhsMultiGenerator::UpdateBuildFiles( splitPath.back()); *this->TargetFolderBuildStreams[folderName] << foldNameRelBuildFile << " "; - GhsMultiGpj::WriteGpjTag(cmGhsMultiTargetGenerator::GetGpjTag(tgt), + GhsMultiGpj::WriteGpjTag(cmGhsMultiTargetGenerator::GetGpjTag( + tgtsI->second), this->TargetFolderBuildStreams[folderName]); } } @@ -520,7 +521,8 @@ bool cmGlobalGhsMultiGenerator::IsTgtForBuild(const cmTarget *tgt) const std::string config = tgt->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); std::vector<cmSourceFile *> tgtSources; - tgt->GetSourceFiles(tgtSources, config); + cmGeneratorTarget* gt = this->GetGeneratorTarget(tgt); + gt->GetSourceFiles(tgtSources, config); bool tgtInBuild = true; char const *excludeFromAll = tgt->GetProperty("EXCLUDE_FROM_ALL"); if (NULL != excludeFromAll && '1' == excludeFromAll[0] && diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 138ddbb..4eec3fb 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -49,10 +49,9 @@ void cmGlobalKdevelopGenerator::Generate() it!= this->GlobalGenerator->GetProjectMap().end(); ++it) { - cmMakefile* mf = it->second[0]->GetMakefile(); - std::string outputDir=mf->GetCurrentBinaryDirectory(); - std::string projectDir=mf->GetHomeDirectory(); - std::string projectName=mf->GetProjectName(); + std::string outputDir=it->second[0]->GetCurrentBinaryDirectory(); + std::string projectDir=it->second[0]->GetSourceDirectory(); + std::string projectName=it->second[0]->GetProjectName(); std::string cmakeFilePattern("CMakeLists.txt;*.cmake;"); std::string fileToOpen; const std::vector<cmLocalGenerator*>& lgs= it->second; @@ -69,12 +68,11 @@ void cmGlobalKdevelopGenerator::Generate() for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin(); lg!=lgs.end(); lg++) { - cmMakefile* makefile=(*lg)->GetMakefile(); - cmGeneratorTargetsType const& targets = makefile->GetGeneratorTargets(); + cmGeneratorTargetsType const& targets = (*lg)->GetGeneratorTargets(); for (cmGeneratorTargetsType::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { - if (ti->second->GetType()==cmTarget::EXECUTABLE) + if (ti->second->GetType()==cmState::EXECUTABLE) { executable = ti->second->GetLocation(""); break; @@ -139,7 +137,9 @@ bool cmGlobalKdevelopGenerator ti != targets.end(); ti++) { std::vector<cmSourceFile*> sources; - ti->second.GetSourceFiles(sources, ti->second.GetMakefile() + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&ti->second); + gt->GetSourceFiles(sources, ti->second.GetMakefile() ->GetSafeDefinition("CMAKE_BUILD_TYPE")); for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); si!=sources.end(); si++) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 120bb03..89a6dff 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -717,13 +717,11 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const void cmGlobalNinjaGenerator ::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { - cmTarget* target = gt->Target; - // Compute full path to object file directory for this target. std::string dir; dir += gt->Makefile->GetCurrentBinaryDirectory(); dir += "/"; - dir += gt->LocalGenerator->GetTargetDirectory(*target); + dir += gt->LocalGenerator->GetTargetDirectory(gt); dir += "/"; gt->ObjectDirectory = dir; } @@ -818,6 +816,17 @@ void cmGlobalNinjaGenerator::CloseRulesFileStream() } } +std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path) +{ + cmLocalNinjaGenerator *ng = + static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]); + std::string convPath = ng->Convert(path, cmOutputConverter::HOME_OUTPUT); +#ifdef _WIN32 + cmSystemTools::ReplaceString(convPath, "/", "\\"); +#endif + return convPath; +} + void cmGlobalNinjaGenerator::AddCXXCompileCommand( const std::string &commandLine, const std::string &sourceFile) @@ -907,29 +916,28 @@ cmGlobalNinjaGenerator { std::string configName = target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmLocalNinjaGenerator *ng = - static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]); + + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(target); // for frameworks, we want the real name, not smple name // frameworks always appear versioned, and the build.ninja // will always attempt to manage symbolic links instead // of letting cmOSXBundleGenerator do it. - bool realname = target->IsFrameworkOnApple(); + bool realname = gtgt->IsFrameworkOnApple(); switch (target->GetType()) { - case cmTarget::EXECUTABLE: - case cmTarget::SHARED_LIBRARY: - case cmTarget::STATIC_LIBRARY: - case cmTarget::MODULE_LIBRARY: + case cmState::EXECUTABLE: + case cmState::SHARED_LIBRARY: + case cmState::STATIC_LIBRARY: + case cmState::MODULE_LIBRARY: { - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(target); - outputs.push_back(ng->ConvertToNinjaPath( + outputs.push_back(this->ConvertToNinjaPath( gtgt->GetFullPath(configName, false, realname))); break; } - case cmTarget::OBJECT_LIBRARY: - case cmTarget::UTILITY: { - std::string path = ng->ConvertToNinjaPath( + case cmState::OBJECT_LIBRARY: + case cmState::UTILITY: { + std::string path = this->ConvertToNinjaPath( target->GetMakefile()->GetCurrentBinaryDirectory()); if (path.empty() || path == ".") outputs.push_back(target->GetName()); @@ -941,7 +949,7 @@ cmGlobalNinjaGenerator break; } - case cmTarget::GLOBAL_TARGET: + case cmState::GLOBAL_TARGET: // Always use the target in HOME instead of an unused duplicate in a // subdirectory. outputs.push_back(target->GetName()); @@ -956,7 +964,7 @@ void cmGlobalNinjaGenerator ::AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs) { - if (target->GetType() == cmTarget::GLOBAL_TARGET) { + if (target->GetType() == cmState::GLOBAL_TARGET) { // Global targets only depend on other utilities, which may not appear in // the TargetDepends set (e.g. "all"). std::set<std::string> const& utils = target->GetUtilities(); @@ -967,7 +975,7 @@ cmGlobalNinjaGenerator for (cmTargetDependSet::const_iterator i = targetDeps.begin(); i != targetDeps.end(); ++i) { - if ((*i)->GetType() == cmTarget::INTERFACE_LIBRARY) + if ((*i)->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -1041,8 +1049,6 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) //get the list of files that cmake itself has generated as a //product of configuration. - cmLocalNinjaGenerator *ng = - static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]); for (std::vector<cmLocalGenerator *>::const_iterator i = this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) @@ -1054,7 +1060,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) typedef std::vector<std::string>::const_iterator vect_it; for(vect_it j = files.begin(); j != files.end(); ++j) { - knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); + knownDependencies.insert( this->ConvertToNinjaPath( *j ) ); } //get list files which are implicit dependencies as well and will be phony //for rebuild manifest @@ -1062,7 +1068,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) typedef std::vector<std::string>::const_iterator vect_it; for(vect_it j = lf.begin(); j != lf.end(); ++j) { - knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); + knownDependencies.insert( this->ConvertToNinjaPath( *j ) ); } std::vector<cmGeneratorExpressionEvaluationFile*> const& ef = (*i)->GetMakefile()->GetEvaluationFiles(); @@ -1074,7 +1080,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) std::vector<std::string> evaluationFiles = (*li)->GetFiles(); for(vect_it j = evaluationFiles.begin(); j != evaluationFiles.end(); ++j) { - knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); + knownDependencies.insert( this->ConvertToNinjaPath( *j ) ); } } } @@ -1084,7 +1090,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) i != this->TargetAliases.end(); ++i) { - knownDependencies.insert( ng->ConvertToNinjaPath(i->first) ); + knownDependencies.insert( this->ConvertToNinjaPath(i->first) ); } //remove all source files we know will exist. @@ -1093,7 +1099,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) i != this->AssumedSourceDependencies.end(); ++i) { - knownDependencies.insert( ng->ConvertToNinjaPath(i->first) ); + knownDependencies.insert( this->ConvertToNinjaPath(i->first) ); } //now we difference with CombinedCustomCommandExplicitDependencies to find @@ -1191,16 +1197,15 @@ void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os) void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) { cmLocalGenerator *lg = this->LocalGenerators[0]; - cmMakefile* mfRoot = lg->GetMakefile(); std::ostringstream cmd; cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL) << " -H" - << lg->ConvertToOutputFormat(mfRoot->GetHomeDirectory(), + << lg->ConvertToOutputFormat(lg->GetSourceDirectory(), cmLocalGenerator::SHELL) << " -B" - << lg->ConvertToOutputFormat(mfRoot->GetHomeOutputDirectory(), + << lg->ConvertToOutputFormat(lg->GetBinaryDirectory(), cmLocalGenerator::SHELL); WriteRule(*this->RulesFileStream, "RERUN_CMAKE", @@ -1214,8 +1219,6 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) /*restat=*/ "", /*generator=*/ true); - cmLocalNinjaGenerator *ng = static_cast<cmLocalNinjaGenerator *>(lg); - cmNinjaDeps implicitDeps; for(std::vector<cmLocalGenerator*>::const_iterator i = this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) @@ -1224,7 +1227,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) for(std::vector<std::string>::const_iterator fi = lf.begin(); fi != lf.end(); ++fi) { - implicitDeps.push_back(ng->ConvertToNinjaPath(*fi)); + implicitDeps.push_back(this->ConvertToNinjaPath(*fi)); } } implicitDeps.push_back("CMakeCache.txt"); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index d204a50..292f7c7 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -220,6 +220,19 @@ public: cmGeneratedFileStream* GetRulesFileStream() const { return this->RulesFileStream; } + std::string ConvertToNinjaPath(const std::string& path); + + struct MapToNinjaPathImpl { + cmGlobalNinjaGenerator* GG; + MapToNinjaPathImpl(cmGlobalNinjaGenerator* gg): GG(gg) {} + std::string operator()(std::string const& path) { + return this->GG->ConvertToNinjaPath(path); + } + }; + MapToNinjaPathImpl MapToNinjaPath() { + return MapToNinjaPathImpl(this); + } + void AddCXXCompileCommand(const std::string &commandLine, const std::string &sourceFile); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index cf4fd69..44e3de6 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -114,13 +114,11 @@ void cmGlobalUnixMakefileGenerator3 ::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { - cmTarget* target = gt->Target; - // Compute full path to object file directory for this target. std::string dir; dir += gt->Makefile->GetCurrentBinaryDirectory(); dir += "/"; - dir += gt->LocalGenerator->GetTargetDirectory(*target); + dir += gt->LocalGenerator->GetTargetDirectory(gt); dir += "/"; gt->ObjectDirectory = dir; } @@ -163,7 +161,7 @@ void cmGlobalUnixMakefileGenerator3::Generate() { cmLocalUnixMakefileGenerator3 *lg = static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]); - std::string markFileName = lg->GetMakefile()->GetCurrentBinaryDirectory(); + std::string markFileName = lg->GetCurrentBinaryDirectory(); markFileName += "/"; markFileName += cmake::GetCMakeFilesDirectory(); markFileName += "/progress.marks"; @@ -395,7 +393,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() { lg = static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]); - tmpStr = lg->GetMakefile()->GetCurrentBinaryDirectory(); + tmpStr = lg->GetCurrentBinaryDirectory(); tmpStr += cmake::GetCMakeFilesDirectory(); tmpStr += "/CMakeDirectoryInformation.cmake"; cmakefileStream << " \"" << @@ -428,14 +426,15 @@ void cmGlobalUnixMakefileGenerator3 for (cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin(); l != lg->GetMakefile()->GetTargets().end(); l++) { - if((l->second.GetType() == cmTarget::EXECUTABLE) || - (l->second.GetType() == cmTarget::STATIC_LIBRARY) || - (l->second.GetType() == cmTarget::SHARED_LIBRARY) || - (l->second.GetType() == cmTarget::MODULE_LIBRARY) || - (l->second.GetType() == cmTarget::OBJECT_LIBRARY) || - (l->second.GetType() == cmTarget::UTILITY)) + if((l->second.GetType() == cmState::EXECUTABLE) || + (l->second.GetType() == cmState::STATIC_LIBRARY) || + (l->second.GetType() == cmState::SHARED_LIBRARY) || + (l->second.GetType() == cmState::MODULE_LIBRARY) || + (l->second.GetType() == cmState::OBJECT_LIBRARY) || + (l->second.GetType() == cmState::UTILITY)) { - std::string tname = lg->GetRelativeTargetDirectory(l->second); + cmGeneratorTarget* gt = this->GetGeneratorTarget(&l->second); + std::string tname = lg->GetRelativeTargetDirectory(gt); tname += "/DependInfo.cmake"; cmSystemTools::ConvertToUnixSlashes(tname); cmakefileStream << " \"" << tname << "\"\n"; @@ -454,37 +453,33 @@ cmGlobalUnixMakefileGenerator3 bool check_relink) { // Get the relative path to the subdirectory from the top. - std::string makeTarget = lg->GetMakefile()->GetCurrentBinaryDirectory(); + std::string makeTarget = lg->GetCurrentBinaryDirectory(); makeTarget += "/"; makeTarget += pass; // The directory-level rule should depend on the target-level rules // for all targets in the directory. std::vector<std::string> depends; - cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); + cmGeneratorTargetsType targets = lg->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator l = targets.begin(); l != targets.end(); ++l) { cmGeneratorTarget* gtarget = l->second; int type = gtarget->GetType(); - if((type == cmTarget::EXECUTABLE) || - (type == cmTarget::STATIC_LIBRARY) || - (type == cmTarget::SHARED_LIBRARY) || - (type == cmTarget::MODULE_LIBRARY) || - (type == cmTarget::OBJECT_LIBRARY) || - (type == cmTarget::UTILITY)) + if((type == cmState::EXECUTABLE) || + (type == cmState::STATIC_LIBRARY) || + (type == cmState::SHARED_LIBRARY) || + (type == cmState::MODULE_LIBRARY) || + (type == cmState::OBJECT_LIBRARY) || + (type == cmState::UTILITY)) { - if(gtarget->Target->IsImported()) - { - continue; - } // Add this to the list of depends rules in this directory. if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName()))) { - std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target); + std::string tname = lg->GetRelativeTargetDirectory(gtarget); tname += "/"; tname += pass; depends.push_back(tname); @@ -495,7 +490,7 @@ cmGlobalUnixMakefileGenerator3 // The directory-level rule should depend on the directory-level // rules of the subdirectories. std::vector<cmState::Snapshot> children - = lg->GetMakefile()->GetStateSnapshot().GetChildren(); + = lg->GetStateSnapshot().GetChildren(); for(std::vector<cmState::Snapshot>::const_iterator ci = children.begin(); ci != children.end(); ++ci) { @@ -534,7 +529,7 @@ cmGlobalUnixMakefileGenerator3 } // Begin the directory-level rules section. - std::string dir = lg->GetMakefile()->GetCurrentBinaryDirectory(); + std::string dir = lg->GetCurrentBinaryDirectory(); dir = lg->Convert(dir, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKERULE); lg->WriteDivider(ruleFileStream); @@ -578,24 +573,19 @@ void cmGlobalUnixMakefileGenerator3 if (!targetName.empty()) { cmMakefile* mf; - cmLocalUnixMakefileGenerator3 *lg; - if (!this->LocalGenerators.empty()) + if (!this->Makefiles.empty()) { - lg = static_cast<cmLocalUnixMakefileGenerator3 *> - (this->LocalGenerators[0]); - mf = lg->GetMakefile(); + mf = this->Makefiles[0]; } else { cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); - mf = new cmMakefile(this, snapshot); - lg = static_cast<cmLocalUnixMakefileGenerator3 *> - (this->CreateLocalGenerator(mf)); - // set the Start directories - lg->GetMakefile()->SetCurrentSourceDirectory + snapshot.GetDirectory().SetCurrentSource (this->CMakeInstance->GetHomeDirectory()); - lg->GetMakefile()->SetCurrentBinaryDirectory + snapshot.GetDirectory().SetCurrentBinary (this->CMakeInstance->GetHomeOutputDirectory()); + snapshot.SetDefaultDefinitions(); + mf = new cmMakefile(this, snapshot); } std::string tname = targetName; @@ -603,12 +593,12 @@ void cmGlobalUnixMakefileGenerator3 { tname += "/fast"; } - tname = lg->Convert(tname,cmLocalGenerator::HOME_OUTPUT); + cmOutputConverter conv(mf->GetStateSnapshot()); + tname = conv.Convert(tname,cmOutputConverter::HOME_OUTPUT); cmSystemTools::ConvertToOutputSlashes(tname); makeCommand.push_back(tname); - if (this->LocalGenerators.empty()) + if (this->Makefiles.empty()) { - delete lg; delete mf; } } @@ -633,15 +623,11 @@ cmGlobalUnixMakefileGenerator3 lg = static_cast<cmLocalUnixMakefileGenerator3 *> (this->LocalGenerators[i]); // for each target Generate the rule files for each target. - cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); + cmGeneratorTargetsType targets = lg->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* gtarget = t->second; - if(gtarget->Target->IsImported()) - { - continue; - } // Don't emit the same rule twice (e.g. two targets with the same // simple name) int type = gtarget->GetType(); @@ -650,12 +636,12 @@ cmGlobalUnixMakefileGenerator3 emitted.insert(name).second && // Handle user targets here. Global targets are handled in // the local generator on a per-directory basis. - ((type == cmTarget::EXECUTABLE) || - (type == cmTarget::STATIC_LIBRARY) || - (type == cmTarget::SHARED_LIBRARY) || - (type == cmTarget::MODULE_LIBRARY) || - (type == cmTarget::OBJECT_LIBRARY) || - (type == cmTarget::UTILITY))) + ((type == cmState::EXECUTABLE) || + (type == cmState::STATIC_LIBRARY) || + (type == cmState::SHARED_LIBRARY) || + (type == cmState::MODULE_LIBRARY) || + (type == cmState::OBJECT_LIBRARY) || + (type == cmState::UTILITY))) { // Add a rule to build the target by name. lg->WriteDivider(ruleFileStream); @@ -678,7 +664,7 @@ cmGlobalUnixMakefileGenerator3 // Add a fast rule to build the target std::string localName = - lg->GetRelativeTargetDirectory(*gtarget->Target); + lg->GetRelativeTargetDirectory(gtarget); std::string makefileName; makefileName = localName; makefileName += "/build.make"; @@ -698,7 +684,7 @@ cmGlobalUnixMakefileGenerator3 if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { - makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target); + makeTargetName = lg->GetRelativeTargetDirectory(gtarget); makeTargetName += "/preinstall"; localName = name; localName += "/preinstall"; @@ -734,28 +720,24 @@ cmGlobalUnixMakefileGenerator3 depends.push_back("cmake_check_build_system"); // for each target Generate the rule files for each target. - cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); + cmGeneratorTargetsType targets = lg->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* gtarget = t->second; - if(gtarget->Target->IsImported()) - { - continue; - } int type = gtarget->GetType(); std::string name = gtarget->GetName(); if (!name.empty() - && ( (type == cmTarget::EXECUTABLE) - || (type == cmTarget::STATIC_LIBRARY) - || (type == cmTarget::SHARED_LIBRARY) - || (type == cmTarget::MODULE_LIBRARY) - || (type == cmTarget::OBJECT_LIBRARY) - || (type == cmTarget::UTILITY))) + && ( (type == cmState::EXECUTABLE) + || (type == cmState::STATIC_LIBRARY) + || (type == cmState::SHARED_LIBRARY) + || (type == cmState::MODULE_LIBRARY) + || (type == cmState::OBJECT_LIBRARY) + || (type == cmState::UTILITY))) { std::string makefileName; // Add a rule to build the target by name. - localName = lg->GetRelativeTargetDirectory(*gtarget->Target); + localName = lg->GetRelativeTargetDirectory(gtarget); makefileName = localName; makefileName += "/build.make"; @@ -790,7 +772,7 @@ cmGlobalUnixMakefileGenerator3 depends.clear(); cmLocalUnixMakefileGenerator3::EchoProgress progress; - progress.Dir = lg->GetMakefile()->GetHomeOutputDirectory(); + progress.Dir = lg->GetBinaryDirectory(); progress.Dir += cmake::GetCMakeFilesDirectory(); { std::ostringstream progressArg; @@ -866,7 +848,7 @@ cmGlobalUnixMakefileGenerator3 } depends.clear(); depends.push_back("cmake_check_build_system"); - localName = lg->GetRelativeTargetDirectory(*gtarget->Target); + localName = lg->GetRelativeTargetDirectory(gtarget); localName += "/rule"; lg->WriteMakeRule(ruleFileStream, "Build rule for subdir invocation for target.", @@ -883,7 +865,7 @@ cmGlobalUnixMakefileGenerator3 if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { - localName = lg->GetRelativeTargetDirectory(*gtarget->Target); + localName = lg->GetRelativeTargetDirectory(gtarget); localName += "/preinstall"; depends.clear(); commands.clear(); @@ -904,7 +886,7 @@ cmGlobalUnixMakefileGenerator3 } // add the clean rule - localName = lg->GetRelativeTargetDirectory(*gtarget->Target); + localName = lg->GetRelativeTargetDirectory(gtarget); makeTargetName = localName; makeTargetName += "/clean"; depends.clear(); @@ -942,8 +924,8 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() cmLocalGenerator* tlg = gt->GetLocalGenerator(); - if(gt->GetType() == cmTarget::INTERFACE_LIBRARY - || gt->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(gt->GetType() == cmState::INTERFACE_LIBRARY + || gt->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { continue; } @@ -989,7 +971,7 @@ cmGlobalUnixMakefileGenerator3 for(TargetDependSet::const_iterator di = depends.begin(); di != depends.end(); ++di) { - if ((*di)->GetType() == cmTarget::INTERFACE_LIBRARY) + if ((*di)->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -1065,13 +1047,14 @@ cmGlobalUnixMakefileGenerator3 { // Create the target-level dependency. cmGeneratorTarget const* dep = *i; - if (dep->GetType() == cmTarget::INTERFACE_LIBRARY) + if (dep->GetType() == cmState::INTERFACE_LIBRARY) { continue; } cmLocalUnixMakefileGenerator3* lg3 = static_cast<cmLocalUnixMakefileGenerator3*>(dep->GetLocalGenerator()); - std::string tgtName = lg3->GetRelativeTargetDirectory(*(*dep).Target); + std::string tgtName = + lg3->GetRelativeTargetDirectory(const_cast<cmGeneratorTarget*>(dep)); tgtName += "/all"; depends.push_back(tgtName); } @@ -1110,14 +1093,14 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) { cmTarget const& target = t->second; - cmTarget::TargetType type = target.GetType(); - if((type == cmTarget::EXECUTABLE) || - (type == cmTarget::STATIC_LIBRARY) || - (type == cmTarget::SHARED_LIBRARY) || - (type == cmTarget::MODULE_LIBRARY) || - (type == cmTarget::OBJECT_LIBRARY) || - (type == cmTarget::GLOBAL_TARGET) || - (type == cmTarget::UTILITY)) + cmState::TargetType type = target.GetType(); + if((type == cmState::EXECUTABLE) || + (type == cmState::STATIC_LIBRARY) || + (type == cmState::SHARED_LIBRARY) || + (type == cmState::MODULE_LIBRARY) || + (type == cmState::OBJECT_LIBRARY) || + (type == cmState::GLOBAL_TARGET) || + (type == cmState::UTILITY)) { std::string name = target.GetName(); if(emittedTargets.insert(name).second) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 44d632d..161b532 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -176,7 +176,14 @@ cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts, //---------------------------------------------------------------------------- bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf) { - if (this->SystemName == "WindowsCE") + if (this->SystemName == "Windows") + { + if (!this->InitializeWindows(mf)) + { + return false; + } + } + else if (this->SystemName == "WindowsCE") { this->SystemIsWindowsCE = true; if (!this->InitializeWindowsCE(mf)) @@ -184,7 +191,7 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf) return false; } } - else if(this->SystemName == "WindowsPhone") + else if (this->SystemName == "WindowsPhone") { this->SystemIsWindowsPhone = true; if(!this->InitializeWindowsPhone(mf)) @@ -192,7 +199,7 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf) return false; } } - else if(this->SystemName == "WindowsStore") + else if (this->SystemName == "WindowsStore") { this->SystemIsWindowsStore = true; if(!this->InitializeWindowsStore(mf)) @@ -229,6 +236,12 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf) } //---------------------------------------------------------------------------- +bool cmGlobalVisualStudio10Generator::InitializeWindows(cmMakefile*) +{ + return true; +} + +//---------------------------------------------------------------------------- bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf) { if (this->DefaultPlatformName != "Win32") @@ -312,19 +325,9 @@ cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator( return new cmLocalVisualStudio10Generator(this, mf); } -//---------------------------------------------------------------------------- -bool cmGlobalVisualStudio10Generator::Compute() -{ - if (!cmGlobalVisualStudio8Generator::Compute()) - { - return false; - } - this->LongestSource = LongestSourcePath(); - return true; -} - void cmGlobalVisualStudio10Generator::Generate() { + this->LongestSource = LongestSourcePath(); this->cmGlobalVisualStudio8Generator::Generate(); if(this->LongestSource.Length > 0) { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 8de7b09..7600a0d 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -45,8 +45,6 @@ public: std::vector<std::string> const& makeOptions = std::vector<std::string>() ); - virtual bool Compute(); - ///! create the correct local generator virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); @@ -74,6 +72,10 @@ public: /** Return the CMAKE_SYSTEM_VERSION. */ std::string const& GetSystemVersion() const { return this->SystemVersion; } + /** Return the Windows version targeted on VS 2015 and above. */ + std::string const& GetWindowsTargetPlatformVersion() const + { return this->WindowsTargetPlatformVersion; } + /** Return true if building for WindowsCE */ bool TargetsWindowsCE() const { return this->SystemIsWindowsCE; } @@ -105,6 +107,7 @@ public: protected: virtual void Generate(); virtual bool InitializeSystem(cmMakefile* mf); + virtual bool InitializeWindows(cmMakefile* mf); virtual bool InitializeWindowsCE(cmMakefile* mf); virtual bool InitializeWindowsPhone(cmMakefile* mf); virtual bool InitializeWindowsStore(cmMakefile* mf); @@ -119,6 +122,7 @@ protected: std::string GeneratorToolset; std::string DefaultPlatformToolset; + std::string WindowsTargetPlatformVersion; std::string SystemName; std::string SystemVersion; std::string NsightTegraVersion; diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 419bf8a..b9b4fff 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -278,10 +278,10 @@ cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs() //---------------------------------------------------------------------------- bool -cmGlobalVisualStudio11Generator::NeedsDeploy(cmTarget::TargetType type) const +cmGlobalVisualStudio11Generator::NeedsDeploy(cmState::TargetType type) const { - if((type == cmTarget::EXECUTABLE || - type == cmTarget::SHARED_LIBRARY) && + if((type == cmState::EXECUTABLE || + type == cmState::SHARED_LIBRARY) && (this->SystemIsWindowsPhone || this->SystemIsWindowsStore)) { diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 9499d80..f3f6b2b 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -48,7 +48,7 @@ protected: static std::set<std::string> GetInstalledWindowsCESDKs(); /** Return true if the configuration needs to be deployed */ - virtual bool NeedsDeploy(cmTarget::TargetType type) const; + virtual bool NeedsDeploy(cmState::TargetType type) const; private: class Factory; friend class Factory; diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index d73eedf..41825fb 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -111,6 +111,84 @@ cmGlobalVisualStudio14Generator::MatchesGeneratorName( } //---------------------------------------------------------------------------- +bool cmGlobalVisualStudio14Generator::InitializeWindows(cmMakefile* mf) +{ + if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) + { + return this->SelectWindows10SDK(mf); + } + return true; +} + +//---------------------------------------------------------------------------- +bool cmGlobalVisualStudio14Generator::InitializeWindowsStore(cmMakefile* mf) +{ + std::ostringstream e; + if(!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset)) + { + if(this->DefaultPlatformToolset.empty()) + { + e << this->GetName() << " supports Windows Store '8.0', '8.1' and " + "'10.0', but not '" << this->SystemVersion << + "'. Check CMAKE_SYSTEM_VERSION."; + } + else + { + e << "A Windows Store component with CMake requires both the Windows " + << "Desktop SDK as well as the Windows Store '" << this->SystemVersion + << "' SDK. Please make sure that you have both installed"; + } + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) + { + return this->SelectWindows10SDK(mf); + } + return true; +} + +//---------------------------------------------------------------------------- +bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf) +{ + // Find the default version of the Windows 10 SDK. + this->WindowsTargetPlatformVersion = this->GetWindows10SDKVersion(); + if (this->WindowsTargetPlatformVersion.empty()) + { + std::ostringstream e; + e << "Could not find an appropriate version of the Windows 10 SDK" + << " installed on this machine"; + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + mf->AddDefinition("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION", + this->WindowsTargetPlatformVersion.c_str()); + return true; +} + +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset( + std::string& toolset) const +{ + if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) + { + if (this->IsWindowsStoreToolsetInstalled() && + this->IsWindowsDesktopToolsetInstalled()) + { + toolset = "v140"; + return true; + } + else + { + return false; + } + } + return + this->cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset(toolset); +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout) { // Visual Studio 14 writes .sln format 12.00 @@ -137,3 +215,77 @@ cmGlobalVisualStudio14Generator::IsWindowsDesktopToolsetInstalled() const return cmSystemTools::GetRegistrySubKeys(desktop10Key, vc14, cmSystemTools::KeyWOW64_32); } + +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio14Generator::IsWindowsStoreToolsetInstalled() const +{ + const char universal10Key[] = + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + "VisualStudio\\14.0\\Setup\\Build Tools for Windows 10;SrcPath"; + + std::string win10SDK; + return cmSystemTools::ReadRegistryValue(universal10Key, + win10SDK, cmSystemTools::KeyWOW64_32); +} + +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() +{ +#if defined(_WIN32) && !defined(__CYGWIN__) + // This logic is taken from the vcvarsqueryregistry.bat file from VS2015 + // Try HKLM and then HKCU. + std::string win10Root; + if (!cmSystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + "Windows Kits\\Installed Roots;KitsRoot10", win10Root, + cmSystemTools::KeyWOW64_32) && + !cmSystemTools::ReadRegistryValue( + "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\" + "Windows Kits\\Installed Roots;KitsRoot10", win10Root, + cmSystemTools::KeyWOW64_32)) + { + return std::string(); + } + + std::vector<std::string> sdks; + std::string path = win10Root + "Include/*"; + // Grab the paths of the different SDKs that are installed + cmSystemTools::GlobDirs(path, sdks); + if (!sdks.empty()) + { + // Only use the filename, which will be the SDK version. + for (std::vector<std::string>::iterator i = sdks.begin(); + i != sdks.end(); ++i) + { + *i = cmSystemTools::GetFilenameName(*i); + } + + // Sort the results to make sure we select the most recent one that + // has a version less or equal to our version of the operating system + std::sort(sdks.begin(), sdks.end(), cmSystemTools::VersionCompareGreater); + + // Select a suitable SDK version. + if (this->SystemVersion == "10.0") + { + // Use the latest Windows 10 SDK since no build version was given. + return sdks.at(0); + } + else + { + // Find the SDK less or equal to our specified version + for (std::vector<std::string>::iterator i = sdks.begin(); + i != sdks.end(); ++i) + { + if (!cmSystemTools::VersionCompareGreater(*i, this->SystemVersion)) + { + // This is the most recent SDK that we can run safely + return *i; + } + } + } + } +#endif + // Return an empty string + return std::string(); +} diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index 02c6274..76c15d9 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -30,12 +30,23 @@ public: virtual const char* GetToolsVersion() { return "14.0"; } protected: + virtual bool InitializeWindows(cmMakefile* mf); + virtual bool InitializeWindowsStore(cmMakefile* mf); + virtual bool SelectWindowsStoreToolset(std::string& toolset) const; + + // These aren't virtual because we need to check if the selected version + // of the toolset is installed + bool IsWindowsStoreToolsetInstalled() const; + virtual const char* GetIDEVersion() { return "14.0"; } + virtual bool SelectWindows10SDK(cmMakefile* mf); // Used to verify that the Desktop toolset for the current generator is // installed on the machine. virtual bool IsWindowsDesktopToolsetInstalled() const; + std::string GetWindows10SDKVersion(); + private: class Factory; }; diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index df49948..12eccf9 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -217,14 +217,14 @@ void cmGlobalVisualStudio6Generator TargetDependSet projectTargets; TargetDependSet originalTargets; this->GetTargetSets(projectTargets, originalTargets, root, generators); - OrderedTargetDependSet orderedProjectTargets(projectTargets); + OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD"); for(OrderedTargetDependSet::const_iterator tt = orderedProjectTargets.begin(); tt != orderedProjectTargets.end(); ++tt) { cmTarget const* target = (*tt)->Target; - if(target->GetType() == cmTarget::INTERFACE_LIBRARY) + if(target->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -260,7 +260,7 @@ void cmGlobalVisualStudio6Generator } std::string fname = root->GetMakefile()->GetCurrentBinaryDirectory(); fname += "/"; - fname += root->GetMakefile()->GetProjectName(); + fname += root->GetProjectName(); fname += ".dsw"; cmsys::ofstream fout(fname.c_str()); if(!fout) diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 607642c..9bb37ce 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -94,7 +94,7 @@ void cmGlobalVisualStudio71Generator TargetDependSet projectTargets; TargetDependSet originalTargets; this->GetTargetSets(projectTargets, originalTargets, root, generators); - OrderedTargetDependSet orderedProjectTargets(projectTargets); + OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD"); this->WriteTargetsToSolution(fout, root, orderedProjectTargets); @@ -272,7 +272,7 @@ void cmGlobalVisualStudio71Generator // executables to the libraries it uses are also done here void cmGlobalVisualStudio71Generator ::WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmTarget::TargetType, + std::ostream& fout, const std::string& name, cmState::TargetType, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, std::string const& platformMapping) diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index fbb9ecc..7f88e34 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -64,7 +64,7 @@ protected: const std::string& name, const char* path, cmTarget const& t); virtual void WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmTarget::TargetType type, + std::ostream& fout, const std::string& name, cmState::TargetType type, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping = ""); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 0175062..1909f21 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -362,10 +362,10 @@ void cmGlobalVisualStudio7Generator { return; } - this->CurrentProject = root->GetMakefile()->GetProjectName(); - std::string fname = root->GetMakefile()->GetCurrentBinaryDirectory(); + this->CurrentProject = root->GetProjectName(); + std::string fname = root->GetCurrentBinaryDirectory(); fname += "/"; - fname += root->GetMakefile()->GetProjectName(); + fname += root->GetProjectName(); fname += ".sln"; cmGeneratedFileStream fout(fname.c_str()); fout.SetCopyIfDifferent(true); @@ -402,7 +402,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( projectTargets.begin(); tt != projectTargets.end(); ++tt) { cmTarget const* target = (*tt)->Target; - if(target->GetType() == cmTarget::INTERFACE_LIBRARY) + if(target->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -442,7 +442,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( projectTargets.begin(); tt != projectTargets.end(); ++tt) { cmTarget const* target = (*tt)->Target; - if(target->GetType() == cmTarget::INTERFACE_LIBRARY) + if(target->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -468,8 +468,10 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( target->GetProperty("GENERATOR_FILE_NAME"); if(vcprojName) { - cmMakefile* tmf = target->GetMakefile(); - std::string dir = tmf->GetCurrentBinaryDirectory(); + cmLocalGenerator* lg = + root->GetGlobalGenerator()->GetGeneratorTarget(target) + ->GetLocalGenerator(); + std::string dir = lg->GetCurrentBinaryDirectory(); dir = root->Convert(dir.c_str(), cmLocalGenerator::START_OUTPUT); if(dir == ".") @@ -534,7 +536,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends( projectTargets.begin(); tt != projectTargets.end(); ++tt) { cmTarget const* target = (*tt)->Target; - if(target->GetType() == cmTarget::INTERFACE_LIBRARY) + if(target->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -568,7 +570,7 @@ void cmGlobalVisualStudio7Generator TargetDependSet projectTargets; TargetDependSet originalTargets; this->GetTargetSets(projectTargets, originalTargets, root, generators); - OrderedTargetDependSet orderedProjectTargets(projectTargets); + OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD"); this->WriteTargetsToSolution(fout, root, orderedProjectTargets); @@ -760,7 +762,7 @@ cmGlobalVisualStudio7Generator // executables to the libraries it uses are also done here void cmGlobalVisualStudio7Generator ::WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmTarget::TargetType, + std::ostream& fout, const std::string& name, cmState::TargetType, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping) @@ -1000,7 +1002,7 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( // if it is a utilitiy target then only make it part of the // default build if another target depends on it int type = target->GetType(); - if (type == cmTarget::GLOBAL_TARGET) + if (type == cmState::GLOBAL_TARGET) { // check if INSTALL target is part of default build if(target->GetName() == "INSTALL") @@ -1014,7 +1016,8 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(propertyValue); - if(cmSystemTools::IsOn(cge->Evaluate(target->GetMakefile(), *i))) + cmGeneratorTarget* gt = this->GetGeneratorTarget(target); + if(cmSystemTools::IsOn(cge->Evaluate(gt->GetLocalGenerator(), *i))) { activeConfigs.insert(*i); } @@ -1022,7 +1025,7 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( } return activeConfigs; } - if(type == cmTarget::UTILITY && !this->IsDependedOn(projectTargets, target)) + if(type == cmState::UTILITY && !this->IsDependedOn(projectTargets, target)) { return activeConfigs; } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 35575d1..4ef0990 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -128,7 +128,7 @@ protected: const std::string& name, const char* path, cmTarget const&t); virtual void WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmTarget::TargetType type, + std::ostream& fout, const std::string& name, cmState::TargetType type, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping = ""); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 28f0425..61b19cf 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -256,7 +256,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() noCommandLines); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); - mf->AddGeneratorTarget(tgt, gt); + lg->AddGeneratorTarget(tgt, gt); + this->AddGeneratorTarget(tgt, gt); // Organize in the "predefined targets" folder: // @@ -312,10 +313,10 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() cmCustomCommandLine commandLine; commandLine.push_back(cmSystemTools::GetCMakeCommand()); std::string argH = "-H"; - argH += mf->GetHomeDirectory(); + argH += lg->GetSourceDirectory(); commandLine.push_back(argH); std::string argB = "-B"; - argB += mf->GetHomeOutputDirectory(); + argB += lg->GetBinaryDirectory(); commandLine.push_back(argB); commandLine.push_back("--check-stamp-list"); commandLine.push_back(stampList.c_str()); @@ -336,7 +337,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() no_main_dependency, commandLines, "Checking Build System", no_working_directory, true)) { - tgt->AddSource(file->GetFullPath()); + gt->AddSource(file->GetFullPath()); } else { @@ -348,13 +349,9 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() } //---------------------------------------------------------------------------- -bool cmGlobalVisualStudio8Generator::Compute() +void cmGlobalVisualStudio8Generator::AddExtraIDETargets() { - if (!cmGlobalVisualStudio7Generator::Compute()) - { - return false; - } - + cmGlobalVisualStudio7Generator::AddExtraIDETargets(); if(this->AddCheckTarget()) { // All targets depend on the build-system check target. @@ -368,7 +365,6 @@ bool cmGlobalVisualStudio8Generator::Compute() } } } - return true; } //---------------------------------------------------------------------------- @@ -391,7 +387,7 @@ cmGlobalVisualStudio8Generator void cmGlobalVisualStudio8Generator ::WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmTarget::TargetType type, + std::ostream& fout, const std::string& name, cmState::TargetType type, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, std::string const& platformMapping) @@ -428,10 +424,10 @@ cmGlobalVisualStudio8Generator //---------------------------------------------------------------------------- bool -cmGlobalVisualStudio8Generator::NeedsDeploy(cmTarget::TargetType type) const +cmGlobalVisualStudio8Generator::NeedsDeploy(cmState::TargetType type) const { - bool needsDeploy = (type == cmTarget::EXECUTABLE || - type == cmTarget::SHARED_LIBRARY); + bool needsDeploy = (type == cmState::EXECUTABLE || + type == cmState::SHARED_LIBRARY); return this->TargetsWindowsCE() && needsDeploy; } @@ -449,11 +445,11 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends( { cmGeneratorTarget* gt = this->GetGeneratorTarget(&t); TargetDependSet const& unordered = this->GetTargetDirectDepends(gt); - OrderedTargetDependSet depends(unordered); + OrderedTargetDependSet depends(unordered, std::string()); for(OrderedTargetDependSet::const_iterator i = depends.begin(); i != depends.end(); ++i) { - if((*i)->GetType() == cmTarget::INTERFACE_LIBRARY) + if((*i)->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -473,7 +469,7 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies( { if(cmTarget* depTarget = this->FindTarget(ui->c_str())) { - if(depTarget->GetType() != cmTarget::INTERFACE_LIBRARY + if(depTarget->GetType() != cmState::INTERFACE_LIBRARY && depTarget->GetProperty("EXTERNAL_MSPROJECT")) { // This utility dependency names an external .vcproj target. diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 1c61103..60c63d1 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -67,7 +67,7 @@ public: return !this->WindowsCEVersion.empty(); } protected: - virtual bool Compute(); + virtual void AddExtraIDETargets(); virtual const char* GetIDEVersion() { return "8.0"; } virtual std::string FindDevEnvCommand(); @@ -77,14 +77,14 @@ protected: bool AddCheckTarget(); /** Return true if the configuration needs to be deployed */ - virtual bool NeedsDeploy(cmTarget::TargetType type) const; + virtual bool NeedsDeploy(cmState::TargetType type) const; static cmIDEFlagTable const* GetExtraFlagTableVS8(); virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSolutionConfigurations( std::ostream& fout, std::vector<std::string> const& configs); virtual void WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmTarget::TargetType type, + std::ostream& fout, const std::string& name, cmState::TargetType type, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping = ""); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2bf04b4..91ca9a3 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -64,13 +64,8 @@ std::string cmGlobalVisualStudioGenerator::GetRegistryBase( } //---------------------------------------------------------------------------- -bool cmGlobalVisualStudioGenerator::Compute() +void cmGlobalVisualStudioGenerator::AddExtraIDETargets() { - if (!cmGlobalGenerator::Compute()) - { - return false; - } - // Add a special target that depends on ALL projects for easy build // of one configuration only. const char* no_working_dir = 0; @@ -92,7 +87,8 @@ bool cmGlobalVisualStudioGenerator::Compute() "Build all projects"); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); - allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); + gen[0]->AddGeneratorTarget(allBuild, gt); + this->AddGeneratorTarget(allBuild, gt); #if 0 // Can't activate this code because we want ALL_BUILD @@ -113,11 +109,11 @@ bool cmGlobalVisualStudioGenerator::Compute() i != gen.end(); ++i) { cmGeneratorTargetsType targets = - (*i)->GetMakefile()->GetGeneratorTargets(); + (*i)->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->GetType() == cmTarget::GLOBAL_TARGET + if (t->second->GetType() == cmState::GLOBAL_TARGET || t->first->IsImported()) { continue; @@ -144,7 +140,6 @@ bool cmGlobalVisualStudioGenerator::Compute() static_cast<cmLocalVisualStudioGenerator*>(*lgi); lg->AddCMakeListsRules(); } - return true; } //---------------------------------------------------------------------------- @@ -153,7 +148,7 @@ void cmGlobalVisualStudioGenerator { std::string dir = gt->Makefile->GetCurrentBinaryDirectory(); dir += "/"; - std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(*gt->Target); + std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(gt); if(!tgtDir.empty()) { dir += tgtDir; @@ -192,7 +187,7 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros() cmMakefile* mf = this->LocalGenerators[0]->GetMakefile(); std::string dir = this->GetUserMacrosDirectory(); - if (mf != 0 && dir != "") + if (dir != "") { std::string src = mf->GetRequiredDefinition("CMAKE_ROOT"); src += "/Templates/" CMAKE_VSMACROS_FILENAME; @@ -233,13 +228,12 @@ cmGlobalVisualStudioGenerator std::string dir = this->GetUserMacrosDirectory(); // Only really try to call the macro if: - // - mf is non-NULL // - there is a UserMacrosDirectory // - the CMake vsmacros file exists // - the CMake vsmacros file is registered // - there were .sln/.vcproj files changed during generation // - if (mf != 0 && dir != "") + if (dir != "") { std::string macrosFile = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME; std::string nextSubkeyName; @@ -257,7 +251,7 @@ cmGlobalVisualStudioGenerator { topLevelSlnName = mf->GetCurrentBinaryDirectory(); topLevelSlnName += "/"; - topLevelSlnName += mf->GetProjectName(); + topLevelSlnName += this->LocalGenerators[0]->GetProjectName(); topLevelSlnName += ".sln"; } @@ -344,12 +338,12 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmTarget* target) void cmGlobalVisualStudioGenerator::FollowLinkDepends( cmTarget const* target, std::set<cmTarget const*>& linked) { - if(target->GetType() == cmTarget::INTERFACE_LIBRARY) + if(target->GetType() == cmState::INTERFACE_LIBRARY) { return; } if(linked.insert(target).second && - target->GetType() == cmTarget::STATIC_LIBRARY) + target->GetType() == cmState::STATIC_LIBRARY) { // Static library targets do not list their link dependencies so // we must follow them transitively now. @@ -392,9 +386,9 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() } //---------------------------------------------------------------------------- -static bool VSLinkable(cmTarget const* t) +static bool VSLinkable(cmGeneratorTarget const* t) { - return t->IsLinkable() || t->GetType() == cmTarget::OBJECT_LIBRARY; + return t->IsLinkable() || t->GetType() == cmState::OBJECT_LIBRARY; } //---------------------------------------------------------------------------- @@ -424,10 +418,10 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) // leaving them out for the static library itself but following them // transitively for other targets. - bool allowLinkable = (target.GetType() != cmTarget::STATIC_LIBRARY && - target.GetType() != cmTarget::SHARED_LIBRARY && - target.GetType() != cmTarget::MODULE_LIBRARY && - target.GetType() != cmTarget::EXECUTABLE); + bool allowLinkable = (target.GetType() != cmState::STATIC_LIBRARY && + target.GetType() != cmState::SHARED_LIBRARY && + target.GetType() != cmState::MODULE_LIBRARY && + target.GetType() != cmState::EXECUTABLE); cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); TargetDependSet const& depends = this->GetTargetDirectDepends(gt); @@ -436,7 +430,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) // Static libraries cannot depend on their link implementation // due to behavior (2), but they do not really need to. std::set<cmTarget const*> linkDepends; - if(target.GetType() != cmTarget::STATIC_LIBRARY) + if(target.GetType() != cmState::STATIC_LIBRARY) { for(TargetDependSet::const_iterator di = depends.begin(); di != depends.end(); ++di) @@ -464,7 +458,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) // Collect all targets linked by this target so we can avoid // intermediate targets below. TargetSet linked; - if(target.GetType() != cmTarget::STATIC_LIBRARY) + if(target.GetType() != cmState::STATIC_LIBRARY) { linked = this->GetTargetLinkClosure(&target); } @@ -482,7 +476,8 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) di != utilDepends.end(); ++di) { cmTarget const* dep = *di; - if(allowLinkable || !VSLinkable(dep) || linked.count(dep)) + cmGeneratorTarget* dgt = this->GetGeneratorTarget(dep); + if(allowLinkable || !VSLinkable(dgt) || linked.count(dep)) { // Direct dependency allowed. vsTargetDepend.insert(dep->GetName()); @@ -864,28 +859,34 @@ bool cmGlobalVisualStudioGenerator::TargetCompare ::operator()(cmGeneratorTarget const* l, cmGeneratorTarget const* r) const { - // Make sure ALL_BUILD is first so it is the default active project. - if(r->GetName() == "ALL_BUILD") + // Make sure a given named target is ordered first, + // e.g. to set ALL_BUILD as the default active project. + // When the empty string is named this is a no-op. + if (r->GetName() == this->First) { return false; } - if(l->GetName() == "ALL_BUILD") + if (l->GetName() == this->First) { return true; } - return strcmp(l->GetName().c_str(), r->GetName().c_str()) < 0; + return l->GetName() < r->GetName(); } //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::OrderedTargetDependSet -::OrderedTargetDependSet(TargetDependSet const& targets) +::OrderedTargetDependSet(TargetDependSet const& targets, + std::string const& first): + derived(TargetCompare(first)) { this->insert(targets.begin(), targets.end()); } //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::OrderedTargetDependSet -::OrderedTargetDependSet(TargetSet const& targets) +::OrderedTargetDependSet(TargetSet const& targets, + std::string const& first): + derived(TargetCompare(first)) { for (TargetSet::const_iterator it = targets.begin(); it != targets.end(); ++it) diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 64440ad..41d0b88 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -89,8 +89,11 @@ public: virtual bool TargetsWindowsCE() const { return false; } class TargetSet: public std::set<cmTarget const*> {}; - struct TargetCompare + class TargetCompare { + std::string First; + public: + TargetCompare(std::string const& first): First(first) {} bool operator()(cmGeneratorTarget const* l, cmGeneratorTarget const* r) const; }; @@ -108,7 +111,7 @@ public: cmGeneratorTarget*, std::vector<cmCustomCommand>& commands, std::string const& configName); protected: - virtual bool Compute(); + virtual void AddExtraIDETargets(); // Does this VS version link targets to each other if there are // dependencies in the SLN file? This was done for VS versions @@ -151,11 +154,14 @@ class cmGlobalVisualStudioGenerator::OrderedTargetDependSet: public std::multiset<cmTargetDepend, cmGlobalVisualStudioGenerator::TargetCompare> { + typedef std::multiset<cmTargetDepend, + cmGlobalVisualStudioGenerator::TargetCompare> + derived; public: typedef cmGlobalGenerator::TargetDependSet TargetDependSet; typedef cmGlobalVisualStudioGenerator::TargetSet TargetSet; - OrderedTargetDependSet(TargetDependSet const&); - OrderedTargetDependSet(TargetSet const&); + OrderedTargetDependSet(TargetDependSet const&, std::string const& first); + OrderedTargetDependSet(TargetSet const&, std::string const& first); }; #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 33babec..df208f6 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -376,14 +376,8 @@ cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf) return new cmLocalXCodeGenerator(this, mf); } -//---------------------------------------------------------------------------- -bool cmGlobalXCodeGenerator::Compute() +void cmGlobalXCodeGenerator::AddExtraIDETargets() { - if (!cmGlobalGenerator::Compute()) - { - return false; - } - std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it; // make sure extra targets are added before calling // the parent generate which will call trace depends @@ -394,7 +388,6 @@ bool cmGlobalXCodeGenerator::Compute() // add ALL_BUILD, INSTALL, etc this->AddExtraTargets(root, it->second); } - return true; } void cmGlobalXCodeGenerator::Generate() @@ -417,15 +410,17 @@ void cmGlobalXCodeGenerator::Generate() //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::SetGenerationRoot(cmLocalGenerator* root) { - this->CurrentProject = root->GetMakefile()->GetProjectName(); + this->CurrentProject = root->GetProjectName(); this->SetCurrentLocalGenerator(root); - cmSystemTools::SplitPath(this->CurrentMakefile->GetCurrentSourceDirectory(), - this->ProjectSourceDirectoryComponents); - cmSystemTools::SplitPath(this->CurrentMakefile->GetCurrentBinaryDirectory(), - this->ProjectOutputDirectoryComponents); + cmSystemTools::SplitPath( + this->CurrentLocalGenerator->GetCurrentSourceDirectory(), + this->ProjectSourceDirectoryComponents); + cmSystemTools::SplitPath( + this->CurrentLocalGenerator->GetCurrentBinaryDirectory(), + this->ProjectOutputDirectoryComponents); this->CurrentXCodeHackMakefile = - root->GetMakefile()->GetCurrentBinaryDirectory(); + root->GetCurrentBinaryDirectory(); this->CurrentXCodeHackMakefile += "/CMakeScripts"; cmSystemTools::MakeDirectory(this->CurrentXCodeHackMakefile.c_str()); this->CurrentXCodeHackMakefile += "/XCODE_DEPEND_HELPER.make"; @@ -464,16 +459,17 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, "echo", "Build all projects"); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); - mf->AddGeneratorTarget(allbuild, allBuildGt); + root->AddGeneratorTarget(allbuild, allBuildGt); + root->GetGlobalGenerator()->AddGeneratorTarget(allbuild, allBuildGt); // Refer to the main build configuration file for easy editing. - std::string listfile = mf->GetCurrentSourceDirectory(); + std::string listfile = root->GetCurrentSourceDirectory(); listfile += "/"; listfile += "CMakeLists.txt"; - allbuild->AddSourceCMP0049(listfile.c_str()); + allBuildGt->AddSource(listfile.c_str()); // Add XCODE depend helper - std::string dir = mf->GetCurrentBinaryDirectory(); + std::string dir = root->GetCurrentBinaryDirectory(); cmCustomCommandLine makeHelper; if(this->XcodeVersion < 50) { @@ -499,7 +495,8 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, "make", "-f", file.c_str()); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); - mf->AddGeneratorTarget(check, checkGt); + root->AddGeneratorTarget(check, checkGt); + root->GetGlobalGenerator()->AddGeneratorTarget(check, checkGt); } // now make the allbuild depend on all the non-utility targets @@ -518,7 +515,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, { cmTarget& target = l->second; - if (target.GetType() == cmTarget::GLOBAL_TARGET) + if (target.GetType() == cmState::GLOBAL_TARGET) { continue; } @@ -533,12 +530,12 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, // this will make sure that when the next target is built // things are up-to-date if(!makeHelper.empty() && - (target.GetType() == cmTarget::EXECUTABLE || + (target.GetType() == cmState::EXECUTABLE || // Nope - no post-build for OBJECT_LIRBRARY -// target.GetType() == cmTarget::OBJECT_LIBRARY || - target.GetType() == cmTarget::STATIC_LIBRARY || - target.GetType() == cmTarget::SHARED_LIBRARY || - target.GetType() == cmTarget::MODULE_LIBRARY)) +// target.GetType() == cmState::OBJECT_LIBRARY || + target.GetType() == cmState::STATIC_LIBRARY || + target.GetType() == cmState::SHARED_LIBRARY || + target.GetType() == cmState::MODULE_LIBRARY)) { makeHelper[makeHelper.size()-1] = // fill placeholder this->PostBuildMakeTarget(target.GetName(), "$(CONFIGURATION)"); @@ -554,17 +551,19 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, dir.c_str()); } - if(target.GetType() != cmTarget::INTERFACE_LIBRARY + if(target.GetType() != cmState::INTERFACE_LIBRARY && !target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) { allbuild->AddUtility(target.GetName()); } + cmGeneratorTarget* targetGT = this->GetGeneratorTarget(&target); + // Refer to the build configuration file for easy editing. - listfile = lg->GetMakefile()->GetCurrentSourceDirectory(); + listfile = lg->GetCurrentSourceDirectory(); listfile += "/"; listfile += "CMakeLists.txt"; - target.AddSourceCMP0049(listfile.c_str()); + targetGT->AddSource(listfile.c_str()); } } } @@ -573,7 +572,6 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, void cmGlobalXCodeGenerator::CreateReRunCMakeFile( cmLocalGenerator* root, std::vector<cmLocalGenerator*> const& gens) { - cmMakefile* mf = root->GetMakefile(); std::vector<std::string> lfiles; for(std::vector<cmLocalGenerator*>::const_iterator gi = gens.begin(); gi != gens.end(); ++gi) @@ -587,7 +585,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( std::vector<std::string>::iterator new_end = std::unique(lfiles.begin(), lfiles.end()); lfiles.erase(new_end, lfiles.end()); - this->CurrentReRunCMakeMakefile = mf->GetCurrentBinaryDirectory(); + this->CurrentReRunCMakeMakefile = root->GetCurrentBinaryDirectory(); this->CurrentReRunCMakeMakefile += "/CMakeScripts"; cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile.c_str()); this->CurrentReRunCMakeMakefile += "/ReRunCMake.make"; @@ -595,7 +593,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( (this->CurrentReRunCMakeMakefile.c_str()); makefileStream.SetCopyIfDifferent(true); makefileStream << "# Generated by CMake, DO NOT EDIT\n"; - std::string checkCache = mf->GetHomeOutputDirectory(); + std::string checkCache = root->GetBinaryDirectory(); checkCache += "/"; checkCache += cmake::GetCMakeFilesDirectoryPostSlash(); checkCache += "cmake.check_cache"; @@ -609,9 +607,9 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( makefileStream << "\n\t" << this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand().c_str()) << " -H" << this->ConvertToRelativeForMake( - mf->GetHomeDirectory()) + root->GetSourceDirectory()) << " -B" << this->ConvertToRelativeForMake( - mf->GetHomeOutputDirectory()) << "\n"; + root->GetBinaryDirectory()) << "\n"; } //---------------------------------------------------------------------------- @@ -791,14 +789,16 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, // Is this a resource file in this target? Add it to the resources group... // + + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); cmGeneratorTarget::SourceFileFlags tsFlags = - this->GetGeneratorTarget(&cmtarget)->GetTargetSourceFileFlags(sf); + gtgt->GetTargetSourceFileFlags(sf); bool isResource = tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource; // Is this a "private" or "public" framework header file? // Set the ATTRIBUTES attribute appropriately... // - if(cmtarget.IsFrameworkOnApple()) + if(gtgt->IsFrameworkOnApple()) { if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) { @@ -1038,7 +1038,7 @@ void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen) this->CurrentLocalGenerator = gen; this->CurrentMakefile = gen->GetMakefile(); std::string outdir = - cmSystemTools::CollapseFullPath(this->CurrentMakefile-> + cmSystemTools::CollapseFullPath(this->CurrentLocalGenerator-> GetCurrentBinaryDirectory()); cmSystemTools::SplitPath(outdir.c_str(), this->CurrentOutputDirectoryComponents); @@ -1104,13 +1104,13 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, continue; } - if(cmtarget.GetType() == cmTarget::INTERFACE_LIBRARY) + if(cmtarget.GetType() == cmState::INTERFACE_LIBRARY) { continue; } - if(cmtarget.GetType() == cmTarget::UTILITY || - cmtarget.GetType() == cmTarget::GLOBAL_TARGET) + if(cmtarget.GetType() == cmState::UTILITY || + cmtarget.GetType() == cmState::GLOBAL_TARGET) { cmXCodeObject* t = this->CreateUtilityTarget(cmtarget); if (!t) @@ -1197,9 +1197,9 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, } // some build phases only apply to bundles and/or frameworks - bool isFrameworkTarget = cmtarget.IsFrameworkOnApple(); + bool isFrameworkTarget = gtgt->IsFrameworkOnApple(); bool isBundleTarget = cmtarget.GetPropertyAsBool("MACOSX_BUNDLE"); - bool isCFBundleTarget = cmtarget.IsCFBundleOnApple(); + bool isCFBundleTarget = gtgt->IsCFBundleOnApple(); cmXCodeObject* buildFiles = 0; @@ -1293,7 +1293,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, copyFilesBuildPhase->AddAttribute("dstSubfolderSpec", this->CreateString("6")); std::ostringstream ostr; - if (cmtarget.IsFrameworkOnApple()) + if (gtgt->IsFrameworkOnApple()) { // dstPath in frameworks is relative to Versions/<version> ostr << mit->first; @@ -1370,9 +1370,9 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguages() void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) { // This matters only for targets that link. - if(cmtarget.GetType() != cmTarget::EXECUTABLE && - cmtarget.GetType() != cmTarget::SHARED_LIBRARY && - cmtarget.GetType() != cmTarget::MODULE_LIBRARY) + if(cmtarget.GetType() != cmState::EXECUTABLE && + cmtarget.GetType() != cmState::SHARED_LIBRARY && + cmtarget.GetType() != cmState::MODULE_LIBRARY) { return; } @@ -1394,7 +1394,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) // linker language. This should convince Xcode to choose the proper // language. cmMakefile* mf = cmtarget.GetMakefile(); - std::string fname = mf->GetCurrentBinaryDirectory(); + std::string fname = gtgt->GetLocalGenerator()->GetCurrentBinaryDirectory(); fname += cmake::GetCMakeFilesDirectory(); fname += "/"; fname += cmtarget.GetName(); @@ -1408,7 +1408,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) if(cmSourceFile* sf = mf->GetOrCreateSource(fname.c_str())) { sf->SetProperty("LANGUAGE", llang.c_str()); - cmtarget.AddSource(fname); + gtgt->AddSource(fname); } } @@ -1471,8 +1471,10 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, std::vector<cmCustomCommand> postbuild = cmtarget.GetPostBuildCommands(); - if(cmtarget.GetType() == cmTarget::SHARED_LIBRARY && - !cmtarget.IsFrameworkOnApple()) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + + if(cmtarget.GetType() == cmState::SHARED_LIBRARY && + !gtgt->IsFrameworkOnApple()) { cmCustomCommandLines cmd; cmd.resize(1); @@ -1504,7 +1506,6 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector<cmSourceFile*> classes; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); if (!gtgt->GetConfigCommonSourceFiles(classes)) { return; @@ -1623,7 +1624,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, const & commands, const char* name) { - std::string dir = this->CurrentMakefile->GetCurrentBinaryDirectory(); + std::string dir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory(); dir += "/CMakeScripts"; cmSystemTools::MakeDirectory(dir.c_str()); std::string makefile = dir; @@ -1644,7 +1645,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, currentConfig->c_str()); } - std::string cdir = this->CurrentMakefile->GetCurrentBinaryDirectory(); + std::string cdir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory(); cdir = this->ConvertToRelativeForXCode(cdir.c_str()); std::string makecmd = "make -C "; makecmd += cdir; @@ -1790,17 +1791,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, cmXCodeObject* buildSettings, const std::string& configName) { - if(target.GetType() == cmTarget::INTERFACE_LIBRARY) + if(target.GetType() == cmState::INTERFACE_LIBRARY) { return; } std::string defFlags; - bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) || - (target.GetType() == cmTarget::MODULE_LIBRARY)); - bool binary = ((target.GetType() == cmTarget::OBJECT_LIBRARY) || - (target.GetType() == cmTarget::STATIC_LIBRARY) || - (target.GetType() == cmTarget::EXECUTABLE) || + bool shared = ((target.GetType() == cmState::SHARED_LIBRARY) || + (target.GetType() == cmState::MODULE_LIBRARY)); + bool binary = ((target.GetType() == cmState::OBJECT_LIBRARY) || + (target.GetType() == cmState::STATIC_LIBRARY) || + (target.GetType() == cmState::EXECUTABLE) || shared); // Compute the compilation flags for each language. @@ -1818,14 +1819,14 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CurrentLocalGenerator->AddLanguageFlags(flags, lang, configName); // Add shared-library flags if needed. - this->CurrentLocalGenerator->AddCMP0018Flags(flags, &target, + this->CurrentLocalGenerator->AddCMP0018Flags(flags, gtgt, lang, configName); - this->CurrentLocalGenerator->AddVisibilityPresetFlags(flags, &target, + this->CurrentLocalGenerator->AddVisibilityPresetFlags(flags, gtgt, lang); this->CurrentLocalGenerator-> - AddCompileOptions(flags, &target, lang, configName); + AddCompileOptions(flags, gtgt, lang, configName); } std::string llang = gtgt->GetLinkerLanguage(configName); @@ -1849,7 +1850,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->AppendDefines(ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\""); } - if(const char* exportMacro = target.GetExportMacro()) + if(const char* exportMacro = gtgt->GetExportMacro()) { // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); @@ -1862,15 +1863,15 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string extraLinkOptionsVar; std::string extraLinkOptions; - if(target.GetType() == cmTarget::EXECUTABLE) + if(target.GetType() == cmState::EXECUTABLE) { extraLinkOptionsVar = "CMAKE_EXE_LINKER_FLAGS"; } - else if(target.GetType() == cmTarget::SHARED_LIBRARY) + else if(target.GetType() == cmState::SHARED_LIBRARY) { extraLinkOptionsVar = "CMAKE_SHARED_LINKER_FLAGS"; } - else if(target.GetType() == cmTarget::MODULE_LIBRARY) + else if(target.GetType() == cmState::MODULE_LIBRARY) { extraLinkOptionsVar = "CMAKE_MODULE_LINKER_FLAGS"; } @@ -1882,13 +1883,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, configName); } - if(target.GetType() == cmTarget::OBJECT_LIBRARY || - target.GetType() == cmTarget::STATIC_LIBRARY) + if(target.GetType() == cmState::OBJECT_LIBRARY || + target.GetType() == cmState::STATIC_LIBRARY) { this->CurrentLocalGenerator ->GetStaticLibraryFlags(extraLinkOptions, cmSystemTools::UpperCase(configName), - &target); + gtgt); } else { @@ -1947,7 +1948,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); - if(!gtgt->HasSOName(configName) || target.IsFrameworkOnApple()) + if(!gtgt->HasSOName(configName) || gtgt->IsFrameworkOnApple()) { version = 0; soversion = 0; @@ -1972,17 +1973,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } // Set attributes to specify the proper name for the target. - std::string pndir = this->CurrentMakefile->GetCurrentBinaryDirectory(); - if(target.GetType() == cmTarget::STATIC_LIBRARY || - target.GetType() == cmTarget::SHARED_LIBRARY || - target.GetType() == cmTarget::MODULE_LIBRARY || - target.GetType() == cmTarget::EXECUTABLE) + std::string pndir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory(); + if(target.GetType() == cmState::STATIC_LIBRARY || + target.GetType() == cmState::SHARED_LIBRARY || + target.GetType() == cmState::MODULE_LIBRARY || + target.GetType() == cmState::EXECUTABLE) { if(this->XcodeVersion >= 21) { - if(!target.UsesDefaultOutputDir(configName, false)) + if(!gtgt->UsesDefaultOutputDir(configName, false)) { - std::string pncdir = target.GetDirectory(configName); + std::string pncdir = gtgt->GetDirectory(configName); buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", this->CreateString(pncdir.c_str())); } @@ -1991,10 +1992,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { buildSettings->AddAttribute("OBJROOT", this->CreateString(pndir.c_str())); - pndir = target.GetDirectory(configName); + pndir = gtgt->GetDirectory(configName); } - if(target.IsFrameworkOnApple() || target.IsCFBundleOnApple()) + if(gtgt->IsFrameworkOnApple() || gtgt->IsCFBundleOnApple()) { pnprefix = ""; } @@ -2004,7 +2005,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, buildSettings->AddAttribute("EXECUTABLE_SUFFIX", this->CreateString(pnsuffix.c_str())); } - else if(target.GetType() == cmTarget::OBJECT_LIBRARY) + else if(target.GetType() == cmState::OBJECT_LIBRARY) { pnprefix = "lib"; pnbase = target.GetName(); @@ -2035,19 +2036,19 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Handle settings for each target type. switch(target.GetType()) { - case cmTarget::OBJECT_LIBRARY: - case cmTarget::STATIC_LIBRARY: + case cmState::OBJECT_LIBRARY: + case cmState::STATIC_LIBRARY: { buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("STATIC")); break; } - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: { buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("BUNDLE")); - if (target.IsCFBundleOnApple()) + if (gtgt->IsCFBundleOnApple()) { // It turns out that a BUNDLE is basically the same // in many ways as an application bundle, as far as @@ -2066,7 +2067,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // a per-configuration Info.plist file. The cfbundle plist // is very similar to the application bundle plist this->CurrentLocalGenerator - ->GenerateAppleInfoPList(&target, "$(EXECUTABLE_NAME)", + ->GenerateAppleInfoPList(gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); std::string path = this->ConvertToRelativeForXCode(plist.c_str()); @@ -2102,7 +2103,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } break; } - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: { if(target.GetPropertyAsBool("FRAMEWORK")) { @@ -2115,7 +2116,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // so let it replace the framework name. This avoids creating // a per-configuration Info.plist file. this->CurrentLocalGenerator - ->GenerateFrameworkInfoPList(&target, "$(EXECUTABLE_NAME)", + ->GenerateFrameworkInfoPList(gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); std::string path = this->ConvertToRelativeForXCode(plist.c_str()); @@ -2139,7 +2140,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString("DYNAMIC")); break; } - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: { // Add the flags to create an executable. std::string createFlags = @@ -2158,7 +2159,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // so let it replace the executable name. This avoids creating // a per-configuration Info.plist file. this->CurrentLocalGenerator - ->GenerateAppleInfoPList(&target, "$(EXECUTABLE_NAME)", + ->GenerateAppleInfoPList(gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); std::string path = this->ConvertToRelativeForXCode(plist.c_str()); @@ -2331,7 +2332,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Create the INSTALL_PATH attribute. std::string install_name_dir; - if(target.GetType() == cmTarget::SHARED_LIBRARY) + if(target.GetType() == cmState::SHARED_LIBRARY) { // Get the install_name directory for the build tree. install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName); @@ -2419,14 +2420,14 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } // Runtime version information. - if(target.GetType() == cmTarget::SHARED_LIBRARY) + if(target.GetType() == cmState::SHARED_LIBRARY) { int major; int minor; int patch; // VERSION -> current_version - target.GetTargetVersion(false, major, minor, patch); + gtgt->GetTargetVersion(false, major, minor, patch); std::ostringstream v; // Xcode always wants at least 1.0.0 or nothing @@ -2438,7 +2439,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(v.str().c_str())); // SOVERSION -> compatibility_version - target.GetTargetVersion(true, major, minor, patch); + gtgt->GetTargetVersion(true, major, minor, patch); std::ostringstream vso; // Xcode always wants at least 1.0.0 or nothing @@ -2490,7 +2491,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { cmGeneratorExpression ge; std::string processed = ge.Parse(i->second.GetValue()) - ->Evaluate(this->CurrentMakefile, configName); + ->Evaluate(this->CurrentLocalGenerator, configName); buildSettings->AddAttribute(attribute.c_str(), this->CreateString(processed)); } @@ -2554,7 +2555,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) this->XCodeObjectMap[&cmtarget] = target; // Add source files without build rules for editing convenience. - if(cmtarget.GetType() == cmTarget::UTILITY) + if(cmtarget.GetType() == cmState::UTILITY) { std::vector<cmSourceFile*> sources; cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); @@ -2631,8 +2632,8 @@ const char* cmGlobalXCodeGenerator::GetTargetLinkFlagsVar(cmTarget const& cmtarget) const { if(this->XcodeVersion >= 60 && - (cmtarget.GetType() == cmTarget::STATIC_LIBRARY || - cmtarget.GetType() == cmTarget::OBJECT_LIBRARY)) + (cmtarget.GetType() == cmState::STATIC_LIBRARY || + cmtarget.GetType() == cmState::OBJECT_LIBRARY)) { return "OTHER_LIBTOOLFLAGS"; } @@ -2643,25 +2644,26 @@ cmGlobalXCodeGenerator::GetTargetLinkFlagsVar(cmTarget const& cmtarget) const } //---------------------------------------------------------------------------- -const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget) +const char* cmGlobalXCodeGenerator::GetTargetFileType( + cmGeneratorTarget* target) { - switch(cmtarget.GetType()) + switch(target->GetType()) { - case cmTarget::OBJECT_LIBRARY: - case cmTarget::STATIC_LIBRARY: + case cmState::OBJECT_LIBRARY: + case cmState::STATIC_LIBRARY: return "archive.ar"; - case cmTarget::MODULE_LIBRARY: - if (cmtarget.IsXCTestOnApple()) + case cmState::MODULE_LIBRARY: + if (target->IsXCTestOnApple()) return "wrapper.cfbundle"; - else if (cmtarget.IsCFBundleOnApple()) + else if (target->IsCFBundleOnApple()) return "wrapper.plug-in"; else return ((this->XcodeVersion >= 22)? "compiled.mach-o.executable" : "compiled.mach-o.dylib"); - case cmTarget::SHARED_LIBRARY: - return (cmtarget.GetPropertyAsBool("FRAMEWORK")? + case cmState::SHARED_LIBRARY: + return (target->GetPropertyAsBool("FRAMEWORK")? "wrapper.framework" : "compiled.mach-o.dylib"); - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: return "compiled.mach-o.executable"; default: break; } @@ -2669,28 +2671,29 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget) } //---------------------------------------------------------------------------- -const char* cmGlobalXCodeGenerator::GetTargetProductType(cmTarget& cmtarget) +const char* cmGlobalXCodeGenerator::GetTargetProductType( + cmGeneratorTarget* target) { - switch(cmtarget.GetType()) + switch(target->GetType()) { - case cmTarget::OBJECT_LIBRARY: - case cmTarget::STATIC_LIBRARY: + case cmState::OBJECT_LIBRARY: + case cmState::STATIC_LIBRARY: return "com.apple.product-type.library.static"; - case cmTarget::MODULE_LIBRARY: - if (cmtarget.IsXCTestOnApple()) + case cmState::MODULE_LIBRARY: + if (target->IsXCTestOnApple()) return "com.apple.product-type.bundle.unit-test"; - else if (cmtarget.IsCFBundleOnApple()) + else if (target->IsCFBundleOnApple()) return "com.apple.product-type.bundle"; else return ((this->XcodeVersion >= 22)? "com.apple.product-type.tool" : "com.apple.product-type.library.dynamic"); - case cmTarget::SHARED_LIBRARY: - return (cmtarget.GetPropertyAsBool("FRAMEWORK")? + case cmState::SHARED_LIBRARY: + return (target->GetPropertyAsBool("FRAMEWORK")? "com.apple.product-type.framework" : "com.apple.product-type.library.dynamic"); - case cmTarget::EXECUTABLE: - return (cmtarget.GetPropertyAsBool("MACOSX_BUNDLE")? + case cmState::EXECUTABLE: + return (target->GetPropertyAsBool("MACOSX_BUNDLE")? "com.apple.product-type.application" : "com.apple.product-type.tool"); default: break; @@ -2703,7 +2706,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, cmXCodeObject* buildPhases) { - if(cmtarget.GetType() == cmTarget::INTERFACE_LIBRARY) + if(cmtarget.GetType() == cmState::INTERFACE_LIBRARY) { return 0; } @@ -2731,14 +2734,16 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, target->AddAttribute("name", this->CreateString(cmtarget.GetName())); target->AddAttribute("productName",this->CreateString(cmtarget.GetName())); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference); - if(const char* fileType = this->GetTargetFileType(cmtarget)) + if(const char* fileType = this->GetTargetFileType(gtgt)) { fileRef->AddAttribute("explicitFileType", this->CreateString(fileType)); } std::string fullName; - if(cmtarget.GetType() == cmTarget::OBJECT_LIBRARY) + if(cmtarget.GetType() == cmState::OBJECT_LIBRARY) { fullName = "lib"; fullName += cmtarget.GetName(); @@ -2746,7 +2751,6 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } else { - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); @@ -2756,7 +2760,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, fileRef->SetComment(cmtarget.GetName().c_str()); target->AddAttribute("productReference", this->CreateObjectReference(fileRef)); - if(const char* productType = this->GetTargetProductType(cmtarget)) + if(const char* productType = this->GetTargetProductType(gtgt)) { target->AddAttribute("productType", this->CreateString(productType)); } @@ -2913,7 +2917,7 @@ void cmGlobalXCodeGenerator ::AddDependAndLinkInformation(cmXCodeObject* target) { cmTarget* cmtarget = target->GetTarget(); - if(cmtarget->GetType() == cmTarget::INTERFACE_LIBRARY) + if(cmtarget->GetType() == cmState::INTERFACE_LIBRARY) { return; } @@ -2962,8 +2966,8 @@ void cmGlobalXCodeGenerator } // Skip link information for object libraries. - if(cmtarget->GetType() == cmTarget::OBJECT_LIBRARY || - cmtarget->GetType() == cmTarget::STATIC_LIBRARY) + if(cmtarget->GetType() == cmState::OBJECT_LIBRARY || + cmtarget->GetType() == cmState::STATIC_LIBRARY) { continue; } @@ -3028,7 +3032,7 @@ void cmGlobalXCodeGenerator linkLibs += this->XCodeEscapePath(li->Value.c_str()); } else if (!li->Target - || li->Target->GetType() != cmTarget::INTERFACE_LIBRARY) + || li->Target->GetType() != cmState::INTERFACE_LIBRARY) { linkLibs += li->Value; } @@ -3067,26 +3071,27 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, // end up with (empty anyhow) ALL_BUILD and XCODE_DEPEND_HELPER source // groups: // - if(cmtarget.GetType() == cmTarget::GLOBAL_TARGET) + if(cmtarget.GetType() == cmState::GLOBAL_TARGET) { continue; } - if(cmtarget.GetType() == cmTarget::INTERFACE_LIBRARY) + if(cmtarget.GetType() == cmState::INTERFACE_LIBRARY) { continue; } + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + // add the soon to be generated Info.plist file as a source for a // MACOSX_BUNDLE file if(cmtarget.GetPropertyAsBool("MACOSX_BUNDLE")) { std::string plist = this->ComputeInfoPListLocation(cmtarget); mf->GetOrCreateSource(plist, true); - cmtarget.AddSource(plist); + gtgt->AddSource(plist); } std::vector<cmSourceFile*> classes; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; @@ -3346,7 +3351,7 @@ bool cmGlobalXCodeGenerator this->RootObject->SetComment("Project object"); std::string project_id = "PROJECT_"; - project_id += root->GetMakefile()->GetProjectName(); + project_id += root->GetProjectName(); this->RootObject->SetId(this->GetOrCreateId( project_id.c_str(), this->RootObject->GetId()).c_str()); @@ -3376,7 +3381,7 @@ bool cmGlobalXCodeGenerator // Point Xcode at the top of the source tree. { std::string pdir = - this->RelativeToBinary(root->GetMakefile()->GetCurrentSourceDirectory()); + this->RelativeToBinary(root->GetCurrentSourceDirectory()); this->RootObject->AddAttribute("projectDirPath", this->CreateString(pdir.c_str())); this->RootObject->AddAttribute("projectRoot", this->CreateString("")); @@ -3488,7 +3493,7 @@ bool cmGlobalXCodeGenerator } } - std::string symroot = root->GetMakefile()->GetCurrentBinaryDirectory(); + std::string symroot = root->GetCurrentBinaryDirectory(); symroot += "/build"; buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot.c_str())); @@ -3627,21 +3632,21 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( cmTarget* t =target->GetTarget(); cmGeneratorTarget *gt = this->GetGeneratorTarget(t); - if(t->GetType() == cmTarget::EXECUTABLE || + if(t->GetType() == cmState::EXECUTABLE || // Nope - no post-build for OBJECT_LIRBRARY -// t->GetType() == cmTarget::OBJECT_LIBRARY || - t->GetType() == cmTarget::STATIC_LIBRARY || - t->GetType() == cmTarget::SHARED_LIBRARY || - t->GetType() == cmTarget::MODULE_LIBRARY) +// t->GetType() == cmState::OBJECT_LIBRARY || + t->GetType() == cmState::STATIC_LIBRARY || + t->GetType() == cmState::SHARED_LIBRARY || + t->GetType() == cmState::MODULE_LIBRARY) { // Declare an entry point for the target post-build phase. makefileStream << this->PostBuildMakeTarget(t->GetName(), *ct) << ":\n"; } - if(t->GetType() == cmTarget::EXECUTABLE || - t->GetType() == cmTarget::SHARED_LIBRARY || - t->GetType() == cmTarget::MODULE_LIBRARY) + if(t->GetType() == cmState::EXECUTABLE || + t->GetType() == cmState::SHARED_LIBRARY || + t->GetType() == cmState::MODULE_LIBRARY) { std::string tfull = gt->GetFullPath(configName); std::string trel = this->ConvertToRelativeForMake(tfull.c_str()); @@ -3731,9 +3736,9 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, { return; } - std::string xcodeDir = root->GetMakefile()->GetCurrentBinaryDirectory(); + std::string xcodeDir = root->GetCurrentBinaryDirectory(); xcodeDir += "/"; - xcodeDir += root->GetMakefile()->GetProjectName(); + xcodeDir += root->GetProjectName(); xcodeDir += ".xcode"; if(this->XcodeVersion > 20) { @@ -3753,7 +3758,7 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, // Since this call may have created new cache entries, save the cache: // root->GetMakefile()->GetCMakeInstance()->SaveCache( - root->GetMakefile()->GetHomeOutputDirectory()); + root->GetBinaryDirectory()); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 102c036..feb5009 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -87,7 +87,7 @@ public: virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); void AppendFlag(std::string& flags, std::string const& flag); protected: - virtual bool Compute(); + virtual void AddExtraIDETargets(); virtual void Generate(); private: cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget, @@ -137,8 +137,8 @@ private: void ForceLinkerLanguages(); void ForceLinkerLanguage(cmTarget& cmtarget); const char* GetTargetLinkFlagsVar(cmTarget const& cmtarget) const; - const char* GetTargetFileType(cmTarget& cmtarget); - const char* GetTargetProductType(cmTarget& cmtarget); + const char* GetTargetFileType(cmGeneratorTarget* target); + const char* GetTargetProductType(cmGeneratorTarget* target); std::string AddConfigurations(cmXCodeObject* target, cmTarget& cmtarget); void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr, const char* value); diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 2023697..cc36c62 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -26,13 +26,13 @@ static const char* getShapeForTarget(const cmTarget* target) switch ( target->GetType() ) { - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: return "house"; - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: return "diamond"; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: return "polygon"; - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: return "octagon"; default: break; @@ -67,6 +67,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, cmake cm; cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); + cm.GetCurrentSnapshot().SetDefaultDefinitions(); cmGlobalGenerator ggi(&cm); cmsys::auto_ptr<cmMakefile> mf( new cmMakefile(&ggi, cm.GetCurrentSnapshot())); @@ -581,18 +582,18 @@ bool cmGraphVizWriter::IgnoreThisTarget(const std::string& name) } -bool cmGraphVizWriter::GenerateForTargetType(cmTarget::TargetType targetType) +bool cmGraphVizWriter::GenerateForTargetType(cmState::TargetType targetType) const { switch (targetType) { - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: return this->GenerateForExecutables; - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: return this->GenerateForStaticLibs; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: return this->GenerateForSharedLibs; - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: return this->GenerateForModuleLibs; default: break; diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index 64de684..0a20e6e 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -62,7 +62,7 @@ protected: bool IgnoreThisTarget(const std::string& name); - bool GenerateForTargetType(cmTarget::TargetType targetType) const; + bool GenerateForTargetType(cmState::TargetType targetType) const; std::string GraphType; std::string GraphName; diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 20448c1..5964ef1 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -11,6 +11,7 @@ ============================================================================*/ #include "cmIfCommand.h" #include "cmStringCommand.h" +#include "cmOutputConverter.h" #include "cmConditionEvaluator.h" @@ -106,7 +107,14 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmake::MessageType messType; - cmConditionEvaluator conditionEvaluator(mf); + cmListFileContext conditionContext = + cmConditionEvaluator::GetConditionContext( + &mf, this->Functions[c], + this->GetStartingContext().FilePath); + + cmConditionEvaluator conditionEvaluator( + mf, conditionContext, + mf.GetBacktrace(this->Functions[c])); bool isTrue = conditionEvaluator.IsTrue( expandedArguments, errorString, messType); @@ -195,7 +203,16 @@ bool cmIfCommand cmake::MessageType status; - cmConditionEvaluator conditionEvaluator(*(this->Makefile)); + cmListFileContext execContext = this->Makefile->GetExecutionContext(); + + cmCommandContext commandContext; + commandContext.Line = execContext.Line; + commandContext.Name = execContext.Name; + + cmConditionEvaluator conditionEvaluator( + *(this->Makefile), cmConditionEvaluator::GetConditionContext( + this->Makefile, commandContext, execContext.FilePath), + this->Makefile->GetBacktrace()); bool isTrue = conditionEvaluator.IsTrue( expandedArguments, errorString, status); diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx index 1e7258a..c64d128 100644 --- a/Source/cmIncludeExternalMSProjectCommand.cxx +++ b/Source/cmIncludeExternalMSProjectCommand.cxx @@ -77,7 +77,7 @@ bool cmIncludeExternalMSProjectCommand } // Create a target instance for this utility. - cmTarget* target=this->Makefile->AddNewTarget(cmTarget::UTILITY, + cmTarget* target=this->Makefile->AddNewTarget(cmState::UTILITY, utility_name.c_str()); target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str()); diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 333c2ff..6b06fce 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -383,12 +383,12 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) if(cmTarget* target=this->Makefile->FindTarget(*targetIt)) { // Found the target. Check its type. - if(target->GetType() != cmTarget::EXECUTABLE && - target->GetType() != cmTarget::STATIC_LIBRARY && - target->GetType() != cmTarget::SHARED_LIBRARY && - target->GetType() != cmTarget::MODULE_LIBRARY && - target->GetType() != cmTarget::OBJECT_LIBRARY && - target->GetType() != cmTarget::INTERFACE_LIBRARY) + if(target->GetType() != cmState::EXECUTABLE && + target->GetType() != cmState::STATIC_LIBRARY && + target->GetType() != cmState::SHARED_LIBRARY && + target->GetType() != cmState::MODULE_LIBRARY && + target->GetType() != cmState::OBJECT_LIBRARY && + target->GetType() != cmState::INTERFACE_LIBRARY) { std::ostringstream e; e << "TARGETS given target \"" << (*targetIt) @@ -396,7 +396,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) this->SetError(e.str()); return false; } - else if(target->GetType() == cmTarget::OBJECT_LIBRARY) + else if(target->GetType() == cmState::OBJECT_LIBRARY) { std::ostringstream e; e << "TARGETS given OBJECT library \"" << (*targetIt) @@ -449,7 +449,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) switch(target.GetType()) { - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: { // Shared libraries are handled differently on DLL and non-DLL // platforms. All windows platforms are DLL platforms including @@ -532,7 +532,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } } break; - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: { // Static libraries use ARCHIVE properties. if (!archiveArgs.GetDestination().empty()) @@ -550,7 +550,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } } break; - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: { // Modules use LIBRARY properties. if (!libraryArgs.GetDestination().empty()) @@ -571,7 +571,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } } break; - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: { if(target.IsAppBundleOnApple()) { @@ -635,7 +635,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } } break; - case cmTarget::INTERFACE_LIBRARY: + case cmState::INTERFACE_LIBRARY: // Nothing to do. An INTERFACE_LIBRARY can be installed, but the // only effect of that is to make it exportable. It installs no // other files itself. @@ -654,7 +654,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) bool createInstallGeneratorsForTargetFileSets = true; if(target.IsFrameworkOnApple() - || target.GetType() == cmTarget::INTERFACE_LIBRARY) + || target.GetType() == cmState::INTERFACE_LIBRARY) { createInstallGeneratorsForTargetFileSets = false; } @@ -773,7 +773,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) if(!exports.GetString().empty() && !namelinkOnly) { cmTargetExport *te = new cmTargetExport; - te->Target = ⌖ + te->TargetName = target.GetName(); te->ArchiveGenerator = archiveGenerator; te->BundleGenerator = bundleGenerator; te->FrameworkGenerator = frameworkGenerator; @@ -1379,16 +1379,17 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) tei != exportSet->GetTargetExports()->end(); ++tei) { cmTargetExport const* te = *tei; + cmTarget* tgt = this->Makefile->FindTarget(te->TargetName); const bool newCMP0022Behavior = - te->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN - && te->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD; + tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN + && tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD; if(!newCMP0022Behavior) { std::ostringstream e; e << "INSTALL(EXPORT) given keyword \"" << "EXPORT_LINK_INTERFACE_LIBRARIES" << "\", but target \"" - << te->Target->GetName() + << te->TargetName << "\" does not have policy CMP0022 set to NEW."; this->SetError(e.str()); return false; diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index 7593380..edd6a0e 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -12,6 +12,8 @@ #include "cmInstallDirectoryGenerator.h" #include "cmTarget.h" +#include "cmGeneratorExpression.h" +#include "cmLocalGenerator.h" //---------------------------------------------------------------------------- cmInstallDirectoryGenerator @@ -25,10 +27,16 @@ cmInstallDirectoryGenerator const char* literal_args, bool optional): cmInstallGenerator(dest, configurations, component, message), + LocalGenerator(0), Directories(dirs), FilePermissions(file_permissions), DirPermissions(dir_permissions), LiteralArguments(literal_args), Optional(optional) { + // We need per-config actions if destination have generator expressions. + if(cmGeneratorExpression::Find(Destination) != std::string::npos) + { + this->ActionsPerConfig = true; + } } //---------------------------------------------------------------------------- @@ -37,15 +45,43 @@ cmInstallDirectoryGenerator { } +void cmInstallDirectoryGenerator::Compute(cmLocalGenerator* lg) +{ + LocalGenerator = lg; +} + //---------------------------------------------------------------------------- void cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os, Indent const& indent) { + if(this->ActionsPerConfig) + { + this->cmInstallGenerator::GenerateScriptActions(os, indent); + } + else + { + this->AddDirectoryInstallRule(os, "", indent); + } +} + +void cmInstallDirectoryGenerator::GenerateScriptForConfig( + std::ostream& os, + const std::string& config, + Indent const& indent) +{ + this->AddDirectoryInstallRule(os, config, indent); +} + +void cmInstallDirectoryGenerator::AddDirectoryInstallRule( + std::ostream& os, + const std::string& config, + Indent const& indent) +{ // Write code to install the directories. const char* no_rename = 0; this->AddInstallRule(os, - this->Destination, + this->GetDestination(config), cmInstallType_DIRECTORY, this->Directories, this->Optional, @@ -54,3 +90,12 @@ cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os, no_rename, this->LiteralArguments.c_str(), indent); } + +//---------------------------------------------------------------------------- +std::string +cmInstallDirectoryGenerator::GetDestination(std::string const& config) const +{ + cmGeneratorExpression ge; + return ge.Parse(this->Destination) + ->Evaluate(this->LocalGenerator, config); +} diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h index 165ab91..04107e1 100644 --- a/Source/cmInstallDirectoryGenerator.h +++ b/Source/cmInstallDirectoryGenerator.h @@ -31,8 +31,19 @@ public: bool optional = false); virtual ~cmInstallDirectoryGenerator(); + void Compute(cmLocalGenerator* lg); + + std::string GetDestination(std::string const& config) const; + protected: virtual void GenerateScriptActions(std::ostream& os, Indent const& indent); + virtual void GenerateScriptForConfig(std::ostream& os, + const std::string& config, + Indent const& indent); + void AddDirectoryInstallRule(std::ostream& os, + const std::string& config, + Indent const& indent); + cmLocalGenerator* LocalGenerator; std::vector<std::string> Directories; std::string FilePermissions; std::string DirPermissions; diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 97b9405..9570ba3 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -56,6 +56,7 @@ cmInstallExportGenerator::~cmInstallExportGenerator() void cmInstallExportGenerator::Compute(cmLocalGenerator* lg) { this->LocalGenerator = lg; + this->ExportSet->Compute(lg); } //---------------------------------------------------------------------------- @@ -64,7 +65,7 @@ void cmInstallExportGenerator::ComputeTempDir() // Choose a temporary directory in which to generate the import // files to be installed. this->TempDir = - this->LocalGenerator->GetMakefile()->GetCurrentBinaryDirectory(); + this->LocalGenerator->GetCurrentBinaryDirectory(); this->TempDir += cmake::GetCMakeFilesDirectory(); this->TempDir += "/Export"; if(this->Destination.empty()) diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h index 4551ab1..8062d11 100644 --- a/Source/cmInstallFilesCommand.h +++ b/Source/cmInstallFilesCommand.h @@ -52,12 +52,6 @@ public: virtual void FinalPass(); virtual bool HasFinalPass() const { return !this->IsFilesForm; } - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - cmTypeMacro(cmInstallFilesCommand, cmCommand); protected: diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index c18b174..383031b 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -34,6 +34,12 @@ cmInstallFilesGenerator Programs(programs), Optional(optional) { + // We need per-config actions if the destination has generator expressions. + if(cmGeneratorExpression::Find(Destination) != std::string::npos) + { + this->ActionsPerConfig = true; + } + // We need per-config actions if any files have generator expressions. for(std::vector<std::string>::const_iterator i = files.begin(); !this->ActionsPerConfig && i != files.end(); ++i) @@ -57,14 +63,25 @@ void cmInstallFilesGenerator::Compute(cmLocalGenerator* lg) } //---------------------------------------------------------------------------- +std::string +cmInstallFilesGenerator::GetDestination(std::string const& config) const +{ + cmGeneratorExpression ge; + return ge.Parse(this->Destination) + ->Evaluate(this->LocalGenerator, config); +} + +//---------------------------------------------------------------------------- void cmInstallFilesGenerator::AddFilesInstallRule( - std::ostream& os, Indent const& indent, + std::ostream& os, + const std::string config, + Indent const& indent, std::vector<std::string> const& files) { // Write code to install the files. const char* no_dir_permissions = 0; this->AddInstallRule(os, - this->Destination, + this->GetDestination(config), (this->Programs ? cmInstallType_PROGRAMS : cmInstallType_FILES), @@ -84,7 +101,7 @@ void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os, } else { - this->AddFilesInstallRule(os, indent, this->Files); + this->AddFilesInstallRule(os, "", indent, this->Files); } } @@ -100,7 +117,7 @@ void cmInstallFilesGenerator::GenerateScriptForConfig(std::ostream& os, { cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*i); cmSystemTools::ExpandListArgument(cge->Evaluate( - this->LocalGenerator->GetMakefile(), config), files); + this->LocalGenerator, config), files); } - this->AddFilesInstallRule(os, indent, files); + this->AddFilesInstallRule(os, config, indent, files); } diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index 00b3a79..bfe4039 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -32,12 +32,16 @@ public: void Compute(cmLocalGenerator* lg); + std::string GetDestination(std::string const& config) const; + protected: virtual void GenerateScriptActions(std::ostream& os, Indent const& indent); virtual void GenerateScriptForConfig(std::ostream& os, const std::string& config, Indent const& indent); - void AddFilesInstallRule(std::ostream& os, Indent const& indent, + void AddFilesInstallRule(std::ostream& os, + const std::string config, + Indent const& indent, std::vector<std::string> const& files); cmLocalGenerator* LocalGenerator; diff --git a/Source/cmInstallProgramsCommand.h b/Source/cmInstallProgramsCommand.h index 90c7ba3..524debf 100644 --- a/Source/cmInstallProgramsCommand.h +++ b/Source/cmInstallProgramsCommand.h @@ -53,12 +53,6 @@ public: virtual bool HasFinalPass() const { return true; } - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - cmTypeMacro(cmInstallProgramsCommand, cmCommand); protected: diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 30cf175..a97cc5f 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -83,7 +83,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, else { fromDirConfig = - this->Target->Target->GetDirectory(config, this->ImportLibrary); + this->Target->GetDirectory(config, this->ImportLibrary); fromDirConfig += "/"; } std::string toDir = @@ -94,29 +94,28 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::vector<std::string> filesFrom; std::vector<std::string> filesTo; std::string literal_args; - cmTarget::TargetType targetType = - static_cast<cmTarget::TargetType>(this->Target->GetType()); + cmState::TargetType targetType = this->Target->GetType(); cmInstallType type = cmInstallType(); switch(targetType) { - case cmTarget::EXECUTABLE: type = cmInstallType_EXECUTABLE; break; - case cmTarget::STATIC_LIBRARY: type = cmInstallType_STATIC_LIBRARY; break; - case cmTarget::SHARED_LIBRARY: type = cmInstallType_SHARED_LIBRARY; break; - case cmTarget::MODULE_LIBRARY: type = cmInstallType_MODULE_LIBRARY; break; - case cmTarget::INTERFACE_LIBRARY: + case cmState::EXECUTABLE: type = cmInstallType_EXECUTABLE; break; + case cmState::STATIC_LIBRARY: type = cmInstallType_STATIC_LIBRARY; break; + case cmState::SHARED_LIBRARY: type = cmInstallType_SHARED_LIBRARY; break; + case cmState::MODULE_LIBRARY: type = cmInstallType_MODULE_LIBRARY; break; + case cmState::INTERFACE_LIBRARY: // Not reachable. We never create a cmInstallTargetGenerator for // an INTERFACE_LIBRARY. assert(0 && "INTERFACE_LIBRARY targets have no installable outputs."); break; - case cmTarget::OBJECT_LIBRARY: - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: - case cmTarget::UNKNOWN_LIBRARY: + case cmState::OBJECT_LIBRARY: + case cmState::UTILITY: + case cmState::GLOBAL_TARGET: + case cmState::UNKNOWN_LIBRARY: this->Target->Target->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, "cmInstallTargetGenerator created with non-installable target."); return; } - if(targetType == cmTarget::EXECUTABLE) + if(targetType == cmState::EXECUTABLE) { // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); @@ -135,7 +134,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); std::string targetNameImportLib; - if(this->Target->Target->GetImplibGNUtoMS(targetNameImport, + if(this->Target->GetImplibGNUtoMS(targetNameImport, targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); @@ -151,7 +150,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string to1 = toDir + targetName; // Handle OSX Bundles. - if(this->Target->Target->IsAppBundleOnApple()) + if(this->Target->IsAppBundleOnApple()) { // Install the whole app bundle directory. type = cmInstallType_DIRECTORY; @@ -199,7 +198,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); std::string targetNameImportLib; - if(this->Target->Target->GetImplibGNUtoMS(targetNameImport, + if(this->Target->GetImplibGNUtoMS(targetNameImport, targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); @@ -209,7 +208,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, // An import library looks like a static library. type = cmInstallType_STATIC_LIBRARY; } - else if(this->Target->Target->IsFrameworkOnApple()) + else if(this->Target->IsFrameworkOnApple()) { // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); @@ -227,7 +226,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); } - else if(this->Target->Target->IsCFBundleOnApple()) + else if(this->Target->IsCFBundleOnApple()) { // Install the whole app bundle directory. type = cmInstallType_DIRECTORY; @@ -351,7 +350,7 @@ cmInstallTargetGenerator::GetDestination(std::string const& config) const { cmGeneratorExpression ge; return ge.Parse(this->Destination) - ->Evaluate(this->Target->Target->GetMakefile(), config); + ->Evaluate(this->Target->GetLocalGenerator(), config); } //---------------------------------------------------------------------------- @@ -360,28 +359,25 @@ cmInstallTargetGenerator::GetInstallFilename(const std::string& config) const { NameType nameType = this->ImportLibrary? NameImplib : NameNormal; return - cmInstallTargetGenerator::GetInstallFilename(this->Target->Target, config, + cmInstallTargetGenerator::GetInstallFilename(this->Target, config, nameType); } //---------------------------------------------------------------------------- std::string -cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, +cmInstallTargetGenerator::GetInstallFilename(cmGeneratorTarget const* target, const std::string& config, NameType nameType) { std::string fname; // Compute the name of the library. - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - if(target->GetType() == cmTarget::EXECUTABLE) + if(target->GetType() == cmState::EXECUTABLE) { std::string targetName; std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - gtgt->GetExecutableNames(targetName, targetNameReal, + target->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) @@ -411,7 +407,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - gtgt->GetLibraryNames(targetName, targetNameSO, targetNameReal, + target->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) { @@ -542,9 +538,9 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { if(this->ImportLibrary || - !(this->Target->GetType() == cmTarget::SHARED_LIBRARY || - this->Target->GetType() == cmTarget::MODULE_LIBRARY || - this->Target->GetType() == cmTarget::EXECUTABLE)) + !(this->Target->GetType() == cmState::SHARED_LIBRARY || + this->Target->GetType() == cmState::MODULE_LIBRARY || + this->Target->GetType() == cmState::EXECUTABLE)) { return; } @@ -563,12 +559,12 @@ cmInstallTargetGenerator std::map<std::string, std::string> install_name_remap; if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { - std::set<cmTarget const*> const& sharedLibs + std::set<cmGeneratorTarget const*> const& sharedLibs = cli->GetSharedLibrariesLinked(); - for(std::set<cmTarget const*>::const_iterator j = sharedLibs.begin(); - j != sharedLibs.end(); ++j) + for(std::set<cmGeneratorTarget const*>::const_iterator j + = sharedLibs.begin(); j != sharedLibs.end(); ++j) { - cmTarget const* tgt = *j; + cmGeneratorTarget const* tgt = *j; // The install_name of an imported target does not change. if(tgt->IsImported()) @@ -576,14 +572,11 @@ cmInstallTargetGenerator continue; } - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); // If the build tree and install tree use different path // components of the install_name field then we need to create a // mapping to be applied after installation. - std::string for_build = gtgt->GetInstallNameDirForBuildTree(config); - std::string for_install = gtgt->GetInstallNameDirForInstallTree(); + std::string for_build = tgt->GetInstallNameDirForBuildTree(config); + std::string for_install = tgt->GetInstallNameDirForInstallTree(); if(for_build != for_install) { // The directory portions differ. Append the filename to @@ -605,14 +598,14 @@ cmInstallTargetGenerator // Edit the install_name of the target itself if necessary. std::string new_id; - if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) + if(this->Target->GetType() == cmState::SHARED_LIBRARY) { std::string for_build = this->Target->GetInstallNameDirForBuildTree(config); std::string for_install = this->Target->GetInstallNameDirForInstallTree(); - if(this->Target->Target->IsFrameworkOnApple() && for_install.empty()) + if(this->Target->IsFrameworkOnApple() && for_install.empty()) { // Frameworks seem to have an id corresponding to their own full // path. @@ -626,7 +619,7 @@ cmInstallTargetGenerator { // Prepare to refer to the install-tree install_name. new_id = for_install; - new_id += this->GetInstallFilename(this->Target->Target, config, NameSO); + new_id += this->GetInstallFilename(this->Target, config, NameSO); } } @@ -816,14 +809,14 @@ cmInstallTargetGenerator::AddStripRule(std::ostream& os, // don't strip static and import libraries, because it removes the only // symbol table they have so you can't link to them anymore - if(this->Target->GetType()==cmTarget::STATIC_LIBRARY || this->ImportLibrary) + if(this->Target->GetType()==cmState::STATIC_LIBRARY || this->ImportLibrary) { return; } // Don't handle OSX Bundles. if(this->Target->Target->GetMakefile()->IsOn("APPLE") && - this->Target->Target->GetPropertyAsBool("MACOSX_BUNDLE")) + this->Target->GetPropertyAsBool("MACOSX_BUNDLE")) { return; } @@ -847,7 +840,7 @@ cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, const std::string& toDestDirPath) { // Static libraries need ranlib on this platform. - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Target->GetType() != cmState::STATIC_LIBRARY) { return; } diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index a8f4a75..ec89c05 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -14,7 +14,6 @@ #include "cmInstallGenerator.h" -class cmTarget; class cmGeneratorTarget; /** \class cmInstallTargetGenerator @@ -54,7 +53,7 @@ public: NameReal }; - static std::string GetInstallFilename(cmTarget const* target, + static std::string GetInstallFilename(const cmGeneratorTarget* target, const std::string& config, NameType nameType = NameNormal); diff --git a/Source/cmInstallTargetsCommand.h b/Source/cmInstallTargetsCommand.h index e6cbe6e..05160eb 100644 --- a/Source/cmInstallTargetsCommand.h +++ b/Source/cmInstallTargetsCommand.h @@ -44,12 +44,6 @@ public: */ virtual std::string GetName() const { return "install_targets";} - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - cmTypeMacro(cmInstallTargetsCommand, cmCommand); }; diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index 10dd465..b603bcc 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -14,8 +14,9 @@ #define cmLinkItem_h #include "cmListFileCache.h" +#include "cmSystemTools.h" -class cmTarget; +class cmGeneratorTarget; // Basic information about each link item. class cmLinkItem: public std::string @@ -24,9 +25,9 @@ class cmLinkItem: public std::string public: cmLinkItem(): std_string(), Target(0) {} cmLinkItem(const std_string& n, - cmTarget const* t): std_string(n), Target(t) {} + cmGeneratorTarget const* t): std_string(n), Target(t) {} cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {} - cmTarget const* Target; + cmGeneratorTarget const* Target; }; class cmLinkImplItem: public cmLinkItem @@ -34,7 +35,7 @@ class cmLinkImplItem: public cmLinkItem public: cmLinkImplItem(): cmLinkItem(), Backtrace(), FromGenex(false) {} cmLinkImplItem(std::string const& n, - cmTarget const* t, + cmGeneratorTarget const* t, cmListFileBacktrace const& bt, bool fromGenex): cmLinkItem(n, t), Backtrace(bt), FromGenex(fromGenex) {} @@ -97,7 +98,7 @@ struct cmOptionalLinkInterface: public cmLinkInterface }; struct cmHeadToLinkInterfaceMap: - public std::map<cmTarget const*, cmOptionalLinkInterface> + public std::map<cmGeneratorTarget const*, cmOptionalLinkInterface> { }; @@ -118,4 +119,27 @@ struct cmOptionalLinkImplementation: public cmLinkImplementation bool HadHeadSensitiveCondition; }; +/** Compute the link type to use for the given configuration. */ +inline cmTargetLinkLibraryType +CMP0003_ComputeLinkType(const std::string& config, + std::vector<std::string> const& debugConfigs) +{ + // No configuration is always optimized. + if(config.empty()) + { + return OPTIMIZED_LibraryType; + } + + // Check if any entry in the list matches this configuration. + std::string configUpper = cmSystemTools::UpperCase(config); + if (std::find(debugConfigs.begin(), debugConfigs.end(), configUpper) != + debugConfigs.end()) + { + return DEBUG_LibraryType; + } + // The current configuration is not a debug configuration. + return OPTIMIZED_LibraryType; +} + + #endif diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx index 996b538..eb3bfce 100644 --- a/Source/cmLinkLibrariesCommand.cxx +++ b/Source/cmLinkLibrariesCommand.cxx @@ -34,7 +34,7 @@ bool cmLinkLibrariesCommand return false; } this->Makefile->AddLinkLibrary(*i, - cmTarget::DEBUG); + DEBUG_LibraryType); } else if (*i == "optimized") { @@ -46,7 +46,7 @@ bool cmLinkLibrariesCommand return false; } this->Makefile->AddLinkLibrary(*i, - cmTarget::OPTIMIZED); + OPTIMIZED_LibraryType); } else { diff --git a/Source/cmLinkLibrariesCommand.h b/Source/cmLinkLibrariesCommand.h index c572439..1ddefc4 100644 --- a/Source/cmLinkLibrariesCommand.h +++ b/Source/cmLinkLibrariesCommand.h @@ -44,12 +44,6 @@ public: */ virtual std::string GetName() const { return "link_libraries";} - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - cmTypeMacro(cmLinkLibrariesCommand, cmCommand); }; diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index bff2986..5050229 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -12,7 +12,7 @@ #include "cmListFileCache.h" #include "cmListFileLexer.h" -#include "cmLocalGenerator.h" +#include "cmOutputConverter.h" #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmVersion.h" diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index 0afd7f5..5f1a310 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -111,13 +111,4 @@ struct cmListFile std::vector<cmListFileFunction> Functions; }; -struct cmValueWithOrigin { - cmValueWithOrigin(const std::string &value, - const cmListFileBacktrace &bt) - : Value(value), Backtrace(bt) - {} - std::string Value; - cmListFileBacktrace Backtrace; -}; - #endif diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h index 4581269..445e167 100644 --- a/Source/cmLoadCommandCommand.h +++ b/Source/cmLoadCommandCommand.h @@ -21,7 +21,6 @@ public: virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); virtual std::string GetName() const {return "load_command";} - virtual bool IsDiscouraged() const { return true; } cmTypeMacro(cmLoadCommandCommand, cmCommand); }; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index b360c22..8a76c21 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -54,6 +54,8 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, this->EmitUniversalBinaryFlags = true; this->BackwardsCompatibility = 0; this->BackwardsCompatibilityFinal = false; + + this->ComputeObjectMaxPath(); } cmLocalGenerator::~cmLocalGenerator() @@ -130,12 +132,11 @@ void cmLocalGenerator::TraceDependencies() this->GlobalGenerator->CreateEvaluationSourceFiles(*ci); } // Generate the rule files for each target. - cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->Target->IsImported() - || t->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + if (t->second->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -446,6 +447,12 @@ void cmLocalGenerator::GenerateInstallRules() } } + +void cmLocalGenerator::AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt) +{ + this->GeneratorTargets[t] = gt; +} + //---------------------------------------------------------------------------- void cmLocalGenerator::ComputeTargetManifest() { @@ -458,16 +465,12 @@ void cmLocalGenerator::ComputeTargetManifest() } // Add our targets to the manifest for each configuration. - cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget& target = *t->second; - if (target.Target->GetType() == cmTarget::INTERFACE_LIBRARY) - { - continue; - } - if (target.Target->IsImported()) + if (target.GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -487,7 +490,7 @@ cmState* cmLocalGenerator::GetState() const cmState::Snapshot cmLocalGenerator::GetStateSnapshot() const { - return this->StateSnapshot; + return this->Makefile->GetStateSnapshot(); } // List of variables that are replaced when @@ -525,6 +528,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, return replaceValues.LinkFlags; } } + if(replaceValues.Manifests) + { + if(variable == "MANIFESTS") + { + return replaceValues.Manifests; + } + } if(replaceValues.Flags) { if(variable == "FLAGS") @@ -744,7 +754,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } if(variable == "TARGET_TYPE") { - return cmTarget::GetTargetTypeName(replaceValues.CMTarget->GetType()); + return cmState::GetTargetTypeName(replaceValues.CMTarget->GetType()); } } if(replaceValues.Output) @@ -904,7 +914,7 @@ cmLocalGenerator::ExpandRuleVariables(std::string& s, } //---------------------------------------------------------------------------- -const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target, +const char* cmLocalGenerator::GetRuleLauncher(cmGeneratorTarget* target, const std::string& prop) { if(target) @@ -918,7 +928,8 @@ const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target, } //---------------------------------------------------------------------------- -void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target, +void cmLocalGenerator::InsertRuleLauncher(std::string& s, + cmGeneratorTarget* target, const std::string& prop) { if(const char* val = this->GetRuleLauncher(target, prop)) @@ -1071,27 +1082,23 @@ std::string cmLocalGenerator::GetIncludeFlags( //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, - cmTarget const* target, + cmGeneratorTarget const* target, const std::string& config, const std::string& lang) { std::vector<std::string> targetDefines; - cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(target); - gtgt->GetCompileDefinitions(targetDefines, config, lang); + target->GetCompileDefinitions(targetDefines, config, lang); this->AppendDefines(defines, targetDefines); } //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileOptions( - std::string& flags, cmTarget* target, + std::string& flags, cmGeneratorTarget* target, const std::string& lang, const std::string& config ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(target); - if(const char* langFlagRegexStr = this->Makefile->GetDefinition(langFlagRegexVar)) { @@ -1102,7 +1109,7 @@ void cmLocalGenerator::AddCompileOptions( { cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); } - gtgt->GetCompileOptions(opts, config, lang); + target->GetCompileOptions(opts, config, lang); for(std::vector<std::string>::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1123,7 +1130,7 @@ void cmLocalGenerator::AddCompileOptions( this->AppendFlags(flags, targetFlags); } std::vector<std::string> opts; - gtgt->GetCompileOptions(opts, config, lang); + target->GetCompileOptions(opts, config, lang); for(std::vector<std::string>::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1132,11 +1139,11 @@ void cmLocalGenerator::AddCompileOptions( } } std::vector<std::string> features; - gtgt->GetCompileFeatures(features, config); + target->GetCompileFeatures(features, config); for(std::vector<std::string>::const_iterator it = features.begin(); it != features.end(); ++it) { - if (!this->Makefile->AddRequiredTargetFeature(target, *it)) + if (!this->Makefile->AddRequiredTargetFeature(target->Target, *it)) { return; } @@ -1171,7 +1178,7 @@ void cmLocalGenerator::AddCompileOptions( //---------------------------------------------------------------------------- void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, - cmGeneratorTarget* target, + cmGeneratorTarget const* target, const std::string& lang, const std::string& config, bool stripImplicitInclDirs @@ -1298,7 +1305,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, std::string const& config, - cmTarget* target) + cmGeneratorTarget* target) { this->AppendFlags(flags, this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS")); @@ -1331,12 +1338,12 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, switch(target->GetType()) { - case cmTarget::STATIC_LIBRARY: - this->GetStaticLibraryFlags(linkFlags, buildType, target->Target); + case cmState::STATIC_LIBRARY: + this->GetStaticLibraryFlags(linkFlags, buildType, target); break; - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS"; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: { linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable); linkFlags += " "; @@ -1388,7 +1395,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, *target, false, false, useWatcomQuote); } break; - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: { linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); @@ -1405,7 +1412,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target->Target->GetName().c_str()); + target->GetName().c_str()); return; } this->AddLanguageFlags(flags, linkLanguage, buildType); @@ -1431,7 +1438,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); linkFlags += " "; } - if (target->Target->IsExecutableWithExports()) + if (target->IsExecutableWithExports()) { std::string exportFlagVar = "CMAKE_EXE_EXPORTS_"; exportFlagVar += linkLanguage; @@ -1533,13 +1540,49 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); // Flags to link an executable to shared libraries. - std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_"; - linkFlagsVar += linkLanguage; - linkFlagsVar += "_FLAGS"; - if( tgt.GetType() == cmTarget::EXECUTABLE ) + if (tgt.GetType() == cmState::EXECUTABLE && + this->StateSnapshot.GetState()-> + GetGlobalPropertyAsBool("TARGET_SUPPORTS_SHARED_LIBS")) { - linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar); - linkLibs += " "; + bool add_shlib_flags = false; + switch(tgt.GetPolicyStatusCMP0065()) + { + case cmPolicies::WARN: + if(!tgt.GetPropertyAsBool("ENABLE_EXPORTS") && + this->Makefile->PolicyOptionalWarningEnabled( + "CMAKE_POLICY_WARNING_CMP0065")) + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0065) << "\n" + "For compatibility with older versions of CMake, " + "additional flags may be added to export symbols on all " + "executables regardless of thier ENABLE_EXPORTS property."; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + case cmPolicies::OLD: + // OLD behavior is to always add the flags + add_shlib_flags = true; + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065) + ); + case cmPolicies::NEW: + // NEW behavior is to only add the flags if ENABLE_EXPORTS is on + add_shlib_flags = tgt.GetPropertyAsBool("ENABLE_EXPORTS"); + break; + } + + if(add_shlib_flags) + { + std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_"; + linkFlagsVar += linkLanguage; + linkFlagsVar += "_FLAGS"; + linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar); + linkLibs += " "; + } } // Append the framework search path flags. @@ -1579,7 +1622,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, ItemVector const& items = cli.GetItems(); for(ItemVector::const_iterator li = items.begin(); li != items.end(); ++li) { - if(li->Target && li->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + if(li->Target && li->Target->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -1722,6 +1765,17 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, } //---------------------------------------------------------------------------- +cmGeneratorTarget* +cmLocalGenerator::FindGeneratorTargetToUse(const std::string& name) const +{ + if (cmTarget *t = this->Makefile->FindTargetToUse(name)) + { + return this->GetGlobalGenerator()->GetGeneratorTarget(t); + } + return 0; +} + +//---------------------------------------------------------------------------- bool cmLocalGenerator::GetRealDependency(const std::string& inName, const std::string& config, std::string& dep) @@ -1747,15 +1801,15 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName, // Look for a CMake target with the given name. if(cmGeneratorTarget* target = - this->Makefile->FindGeneratorTargetToUse(name)) + this->FindGeneratorTargetToUse(name)) { // make sure it is not just a coincidence that the target name // found is part of the inName if(cmSystemTools::FileIsFullPath(inName.c_str())) { std::string tLocation; - if(target->GetType() >= cmTarget::EXECUTABLE && - target->GetType() <= cmTarget::MODULE_LIBRARY) + if(target->GetType() >= cmState::EXECUTABLE && + target->GetType() <= cmState::MODULE_LIBRARY) { tLocation = target->GetLocation(config); tLocation = cmSystemTools::GetFilenamePath(tLocation); @@ -1775,23 +1829,23 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName, } switch (target->GetType()) { - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - case cmTarget::UNKNOWN_LIBRARY: + case cmState::EXECUTABLE: + case cmState::STATIC_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: + case cmState::UNKNOWN_LIBRARY: dep = target->GetLocation(config); return true; - case cmTarget::OBJECT_LIBRARY: + case cmState::OBJECT_LIBRARY: // An object library has no single file on which to depend. // This was listed to get the target-level dependency. return false; - case cmTarget::INTERFACE_LIBRARY: + case cmState::INTERFACE_LIBRARY: // An interface library has no file on which to depend. // This was listed to get the target-level dependency. return false; - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: + case cmState::UTILITY: + case cmState::GLOBAL_TARGET: // A utility target has no file on which to depend. This was listed // only to get the target-level dependency. return false; @@ -1841,7 +1895,8 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator:: -AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, +AddCompilerRequirementFlag(std::string &flags, + cmGeneratorTarget const* target, const std::string& lang) { if (lang.empty()) @@ -1879,7 +1934,8 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, "CMAKE_" + lang + standardProp + "_" + type + "_COMPILE_OPTION"; - const char *opt = target->GetMakefile()->GetDefinition(option_flag); + const char *opt = target->Target->GetMakefile() + ->GetDefinition(option_flag); if (!opt) { std::ostringstream e; @@ -1944,7 +2000,7 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, + "_" + type + "_COMPILE_OPTION"; const char *opt = - target->GetMakefile()->GetRequiredDefinition(option_flag); + target->Target->GetMakefile()->GetRequiredDefinition(option_flag); this->AppendFlagEscape(flags, opt); return; } @@ -1955,7 +2011,8 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, "CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION"; - if (const char *opt = target->GetMakefile()->GetDefinition(option_flag)) + if (const char *opt = target->Target + ->GetMakefile()->GetDefinition(option_flag)) { this->AppendFlagEscape(flags, opt); return; @@ -2031,7 +2088,7 @@ static void AddInlineVisibilityCompileOption(std::string &flags, //---------------------------------------------------------------------------- void cmLocalGenerator -::AddVisibilityPresetFlags(std::string &flags, cmTarget const* target, +::AddVisibilityPresetFlags(std::string &flags, cmGeneratorTarget const* target, const std::string& lang) { if (lang.empty()) @@ -2041,8 +2098,8 @@ void cmLocalGenerator std::string warnCMP0063; std::string *pWarnCMP0063 = 0; - if (target->GetType() != cmTarget::SHARED_LIBRARY && - target->GetType() != cmTarget::MODULE_LIBRARY && + if (target->GetType() != cmState::SHARED_LIBRARY && + target->GetType() != cmState::MODULE_LIBRARY && !target->IsExecutableWithExports()) { switch (target->GetPolicyStatusCMP0063()) @@ -2057,11 +2114,12 @@ void cmLocalGenerator } } - AddVisibilityCompileOption(flags, target, this, lang, pWarnCMP0063); + AddVisibilityCompileOption(flags, target->Target, this, lang, pWarnCMP0063); if(lang == "CXX") { - AddInlineVisibilityCompileOption(flags, target, this, pWarnCMP0063); + AddInlineVisibilityCompileOption(flags, target->Target, + this, pWarnCMP0063); } if (!warnCMP0063.empty() && @@ -2071,25 +2129,26 @@ void cmLocalGenerator w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0063) << "\n" "Target \"" << target->GetName() << "\" of " - "type \"" << cmTarget::GetTargetTypeName(target->GetType()) << "\" " + "type \"" << cmState::GetTargetTypeName(target->GetType()) << "\" " "has the following visibility properties set for " << lang << ":\n" << warnCMP0063 << "For compatibility CMake is not honoring them for this target."; - target->GetMakefile()->GetCMakeInstance() - ->IssueMessage(cmake::AUTHOR_WARNING, w.str(), target->GetBacktrace()); + target->Target->GetMakefile()->GetCMakeInstance() + ->IssueMessage(cmake::AUTHOR_WARNING, w.str(), + target->GetBacktrace()); } } //---------------------------------------------------------------------------- void cmLocalGenerator::AddCMP0018Flags(std::string &flags, - cmTarget const* target, + cmGeneratorTarget const* target, std::string const& lang, const std::string& config) { int targetType = target->GetType(); - bool shared = ((targetType == cmTarget::SHARED_LIBRARY) || - (targetType == cmTarget::MODULE_LIBRARY)); + bool shared = ((targetType == cmState::SHARED_LIBRARY) || + (targetType == cmState::MODULE_LIBRARY)); if (this->GetShouldUseOldFlags(shared, lang)) { @@ -2097,7 +2156,7 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, } else { - if (target->GetType() == cmTarget::OBJECT_LIBRARY) + if (target->GetType() == cmState::OBJECT_LIBRARY) { if (target->GetPropertyAsBool("POSITION_INDEPENDENT_CODE")) { @@ -2106,9 +2165,7 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, return; } - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(target); - if (gtgt->GetLinkInterfaceDependentBoolProperty( + if (target->GetLinkInterfaceDependentBoolProperty( "POSITION_INDEPENDENT_CODE", config)) { @@ -2171,7 +2228,7 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, { const char* picFlags = 0; - if(targetType == cmTarget::EXECUTABLE) + if(targetType == cmState::EXECUTABLE) { std::string flagsVar = "CMAKE_"; flagsVar += lang; @@ -2386,6 +2443,11 @@ const char* cmLocalGenerator::GetFeature(const std::string& feature, return 0; } +std::string cmLocalGenerator::GetProjectName() const +{ + return this->StateSnapshot.GetProjectName(); +} + //---------------------------------------------------------------------------- std::string cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg, @@ -2444,7 +2506,7 @@ cmLocalGenerator cmTargets& tgts = this->Makefile->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { - if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + if (l->second.GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -2472,9 +2534,9 @@ cmLocalGenerator // Generate the proper install generator for this target type. switch(l->second.GetType()) { - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::MODULE_LIBRARY: + case cmState::EXECUTABLE: + case cmState::STATIC_LIBRARY: + case cmState::MODULE_LIBRARY: { // Use a target install generator. cmInstallTargetGeneratorLocal @@ -2482,7 +2544,7 @@ cmLocalGenerator g.Generate(os, config, configurationTypes); } break; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: { #if defined(_WIN32) || defined(__CYGWIN__) // Special code to handle DLL. Install the import library @@ -2813,9 +2875,34 @@ cmLocalGenerator return source.GetLanguage(); } +cmake* cmLocalGenerator::GetCMakeInstance() const +{ + return this->GlobalGenerator->GetCMakeInstance(); +} + +const char* cmLocalGenerator::GetSourceDirectory() const +{ + return this->GetCMakeInstance()->GetHomeDirectory(); +} + +const char* cmLocalGenerator::GetBinaryDirectory() const +{ + return this->GetCMakeInstance()->GetHomeOutputDirectory(); +} + +const char* cmLocalGenerator::GetCurrentBinaryDirectory() const +{ + return this->StateSnapshot.GetDirectory().GetCurrentBinary(); +} + +const char* cmLocalGenerator::GetCurrentSourceDirectory() const +{ + return this->StateSnapshot.GetDirectory().GetCurrentSource(); +} + //---------------------------------------------------------------------------- std::string -cmLocalGenerator::GetTargetDirectory(cmTarget const&) const +cmLocalGenerator::GetTargetDirectory(const cmGeneratorTarget*) const { cmSystemTools::Error("GetTargetDirectory" " called on cmLocalGenerator"); @@ -2843,7 +2930,7 @@ cmIML_INT_uint64_t cmLocalGenerator::GetBackwardsCompatibility() } } this->BackwardsCompatibility = CMake_VERSION_ENCODE(major, minor, patch); - this->BackwardsCompatibilityFinal = this->Makefile->IsConfigured(); + this->BackwardsCompatibilityFinal = true; } return this->BackwardsCompatibility; @@ -2919,7 +3006,7 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const } //---------------------------------------------------------------------------- -static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, +static void cmLGInfoProp(cmMakefile* mf, cmGeneratorTarget* target, const std::string& prop) { if(const char* val = target->GetProperty(prop)) @@ -2929,7 +3016,7 @@ static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, } //---------------------------------------------------------------------------- -void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, +void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target, const std::string& targetName, const char* fname) { @@ -2973,7 +3060,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, } //---------------------------------------------------------------------------- -void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target, +void cmLocalGenerator::GenerateFrameworkInfoPList(cmGeneratorTarget* target, const std::string& targetName, const char* fname) { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index b051e5d..307c67f 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -20,7 +20,6 @@ class cmMakefile; class cmGlobalGenerator; class cmGeneratorTarget; -class cmTarget; class cmTargetManifest; class cmSourceFile; class cmCustomCommand; @@ -91,13 +90,15 @@ public: void AddLanguageFlags(std::string& flags, const std::string& lang, const std::string& config); - void AddCMP0018Flags(std::string &flags, cmTarget const* target, + void AddCMP0018Flags(std::string &flags, cmGeneratorTarget const* target, std::string const& lang, const std::string& config); - void AddVisibilityPresetFlags(std::string &flags, cmTarget const* target, + void AddVisibilityPresetFlags(std::string &flags, + cmGeneratorTarget const* target, const std::string& lang); void AddConfigVariableFlags(std::string& flags, const std::string& var, const std::string& config); - void AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, + void AddCompilerRequirementFlag(std::string &flags, + cmGeneratorTarget const* target, const std::string& lang); ///! Append flags to a string. virtual void AppendFlags(std::string& flags, const std::string& newFlags); @@ -112,6 +113,15 @@ public: bool forResponseFile = false, const std::string& config = ""); + const cmGeneratorTargetsType &GetGeneratorTargets() const + { + return this->GeneratorTargets; + } + + void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt); + + cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const; + /** * Encode a list of preprocessor definitions for the compiler * command line. @@ -171,23 +181,25 @@ public: /** Get the include flags for the current makefile and language. */ void GetIncludeDirectories(std::vector<std::string>& dirs, - cmGeneratorTarget* target, + cmGeneratorTarget const* target, const std::string& lang = "C", const std::string& config = "", bool stripImplicitInclDirs = true) const; - void AddCompileOptions(std::string& flags, cmTarget* target, + void AddCompileOptions(std::string& flags, cmGeneratorTarget* target, const std::string& lang, const std::string& config); void AddCompileDefinitions(std::set<std::string>& defines, - cmTarget const* target, + cmGeneratorTarget const* target, const std::string& config, const std::string& lang); + std::string GetProjectName() const; + /** Compute the language used to compile the given source file. */ std::string GetSourceFileLanguage(const cmSourceFile& source); // Fill the vector with the target names for the object files, // preprocessed files and assembly files. - virtual void GetIndividualFileTargets(std::vector<std::string>&) {} + void GetIndividualFileTargets(std::vector<std::string>&) {} // Create a struct to hold the varibles passed into // ExpandRuleVariables @@ -197,7 +209,7 @@ public: { memset(this, 0, sizeof(*this)); } - cmTarget* CMTarget; + cmGeneratorTarget* CMTarget; const char* TargetPDB; const char* TargetCompilePDB; const char* TargetVersionMajor; @@ -219,6 +231,7 @@ public: const char* TargetSOName; const char* TargetInstallNameDir; const char* LinkFlags; + const char* Manifests; const char* LanguageCompileFlags; const char* Defines; const char* Includes; @@ -231,7 +244,8 @@ public: * Get the relative path from the generator output directory to a * per-target support directory. */ - virtual std::string GetTargetDirectory(cmTarget const& target) const; + virtual std::string + GetTargetDirectory(cmGeneratorTarget const* target) const; /** * Get the level of backwards compatibility requested by the project @@ -250,16 +264,25 @@ public: */ bool NeedBackwardsCompatibility_2_4(); + cmake* GetCMakeInstance() const; + + const char* GetSourceDirectory() const; + const char* GetBinaryDirectory() const; + + const char* GetCurrentBinaryDirectory() const; + const char* GetCurrentSourceDirectory() const; + /** * Generate a Mac OS X application bundle Info.plist file. */ - void GenerateAppleInfoPList(cmTarget* target, const std::string& targetName, + void GenerateAppleInfoPList(cmGeneratorTarget* target, + const std::string& targetName, const char* fname); /** * Generate a Mac OS X framework Info.plist file. */ - void GenerateFrameworkInfoPList(cmTarget* target, + void GenerateFrameworkInfoPList(cmGeneratorTarget* target, const std::string& targetName, const char* fname); /** Construct a comment for a custom command. */ @@ -273,7 +296,7 @@ public: /** Fill out the static linker flags for the given target. */ void GetStaticLibraryFlags(std::string& flags, std::string const& config, - cmTarget* target); + cmGeneratorTarget* target); /** Fill out these strings for the given target. Libraries to link, * flags, and linkflags. */ @@ -299,7 +322,6 @@ public: void CreateEvaluationFileOutputs(const std::string& config); void ProcessEvaluationFiles(std::vector<std::string>& generatedFiles); - void ComputeObjectMaxPath(); protected: ///! put all the libraries for a target on into the given stream void OutputLinkLibraries(std::string& linkLibraries, @@ -317,8 +339,9 @@ protected: std::string ExpandRuleVariable(std::string const& variable, const RuleVariables& replaceValues); - const char* GetRuleLauncher(cmTarget* target, const std::string& prop); - void InsertRuleLauncher(std::string& s, cmTarget* target, + const char* GetRuleLauncher(cmGeneratorTarget* target, + const std::string& prop); + void InsertRuleLauncher(std::string& s, cmGeneratorTarget* target, const std::string& prop); // Handle old-style install rules stored in the targets. @@ -343,7 +366,8 @@ protected: std::string::size_type ObjectPathMax; std::set<std::string> ObjectMaxPathViolations; - std::set<cmTarget const*> WarnCMP0063; + std::set<cmGeneratorTarget const*> WarnCMP0063; + cmGeneratorTargetsType GeneratorTargets; bool EmitUniversalBinaryFlags; @@ -359,6 +383,8 @@ private: bool GetShouldUseOldFlags(bool shared, const std::string &lang) const; void AddPositionIndependentFlags(std::string& flags, std::string const& l, int targetType); + + void ComputeObjectMaxPath(); }; #endif diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index bac989f..869ba2c 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -26,13 +26,12 @@ cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator() {} void cmLocalGhsMultiGenerator::Generate() { - cmGeneratorTargetsType tgts = this->GetMakefile()->GetGeneratorTargets(); + cmGeneratorTargetsType tgts = this->GetGeneratorTargets(); for (cmGeneratorTargetsType::iterator l = tgts.begin(); l != tgts.end(); ++l) { - if (l->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY - || l->second->Target->IsImported()) + if (l->second->GetType() == cmState::INTERFACE_LIBRARY) { continue; } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 7525bf2..756c139 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -73,12 +73,11 @@ void cmLocalNinjaGenerator::Generate() } } - cmGeneratorTargetsType targets = this->GetMakefile()->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY - || t->second->Target->IsImported()) + if (t->second->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -100,10 +99,10 @@ void cmLocalNinjaGenerator::Generate() // TODO: Picked up from cmLocalUnixMakefileGenerator3. Refactor it. std::string cmLocalNinjaGenerator -::GetTargetDirectory(cmTarget const& target) const +::GetTargetDirectory(cmGeneratorTarget const* target) const { std::string dir = cmake::GetCMakeFilesDirectoryPostSlash(); - dir += target.GetName(); + dir += target->GetName(); #if defined(__VMS) dir += "_dir"; #else @@ -183,7 +182,7 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os) { cmGlobalNinjaGenerator::WriteDivider(os); os - << "# Project: " << this->GetMakefile()->GetProjectName() << std::endl + << "# Project: " << this->GetProjectName() << std::endl << "# Configuration: " << this->ConfigName << std::endl ; cmGlobalNinjaGenerator::WriteDivider(os); @@ -284,15 +283,6 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os) os << std::endl; } -std::string cmLocalNinjaGenerator::ConvertToNinjaPath(const std::string& path) -{ - std::string convPath = this->Convert(path, cmLocalGenerator::HOME_OUTPUT); -#ifdef _WIN32 - cmSystemTools::ReplaceString(convPath, "/", "\\"); -#endif - return convPath; -} - void cmLocalNinjaGenerator ::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) @@ -316,7 +306,8 @@ void cmLocalNinjaGenerator::AppendCustomCommandDeps( i != deps.end(); ++i) { std::string dep; if (this->GetRealDependency(*i, this->GetConfigName(), dep)) - ninjaDeps.push_back(ConvertToNinjaPath(dep)); + ninjaDeps.push_back( + this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(dep)); } } @@ -371,7 +362,7 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines( if (ccg.GetNumberOfCommands() > 0) { std::string wd = ccg.GetWorkingDirectory(); if (wd.empty()) - wd = this->GetMakefile()->GetCurrentBinaryDirectory(); + wd = this->GetCurrentBinaryDirectory(); std::ostringstream cdCmd; #ifdef _WIN32 @@ -413,9 +404,11 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( at us. How to know which ExternalProject step actually provides it? #endif std::transform(outputs.begin(), outputs.end(), - ninjaOutputs.begin(), MapToNinjaPath()); + ninjaOutputs.begin(), + this->GetGlobalNinjaGenerator()->MapToNinjaPath()); std::transform(byproducts.begin(), byproducts.end(), - ninjaOutputs.begin() + outputs.size(), MapToNinjaPath()); + ninjaOutputs.begin() + outputs.size(), + this->GetGlobalNinjaGenerator()->MapToNinjaPath()); this->AppendCustomCommandDeps(ccg, ninjaDeps); for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end(); diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 8d3d49c..ce5f82d 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -37,7 +37,8 @@ public: virtual void Generate(); - virtual std::string GetTargetDirectory(cmTarget const& target) const; + virtual + std::string GetTargetDirectory(cmGeneratorTarget const* target) const; const cmGlobalNinjaGenerator* GetGlobalNinjaGenerator() const; cmGlobalNinjaGenerator* GetGlobalNinjaGenerator(); @@ -50,21 +51,6 @@ public: std::string GetHomeRelativeOutputPath() const { return this->HomeRelativeOutputPath; } - std::string ConvertToNinjaPath(const std::string& path); - - struct map_to_ninja_path { - cmLocalNinjaGenerator *LocalGenerator; - map_to_ninja_path(cmLocalNinjaGenerator *LocalGen) - : LocalGenerator(LocalGen) {} - std::string operator()(const std::string &path) { - return LocalGenerator->ConvertToNinjaPath(path); - } - }; - - map_to_ninja_path MapToNinjaPath() { - return map_to_ninja_path(this); - } - void ExpandRuleVariables(std::string& string, const RuleVariables& replaceValues) { cmLocalGenerator::ExpandRuleVariables(string, replaceValues); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index b131a63..5485da4 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -113,14 +113,13 @@ void cmLocalUnixMakefileGenerator3::Generate() this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES"); // Generate the rule files for each target. - cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); cmGlobalUnixMakefileGenerator3* gg = static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY - || t->second->Target->IsImported()) + if (t->second->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -175,12 +174,12 @@ void cmLocalUnixMakefileGenerator3:: GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles) { std::set<std::string> emitted; - cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator ti = targets.begin(); ti != targets.end(); ++ti) { cmGeneratorTarget* gt = ti->second; - if (gt->GetType() == cmTarget::INTERFACE_LIBRARY) + if (gt->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -191,7 +190,7 @@ GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles) std::string dir; dir += gt->Makefile->GetCurrentBinaryDirectory(); dir += "/"; - dir += this->GetTargetDirectory(*gt->Target); + dir += this->GetTargetDirectory(gt); dir += "/"; // Compute the name of each object file. for(std::vector<cmSourceFile const*>::iterator @@ -209,7 +208,7 @@ GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles) } LocalObjectInfo& info = localObjectFiles[objectName]; info.HasSourceExtension = hasSourceExtension; - info.push_back(LocalObjectEntry(gt->Target, sf->GetLanguage())); + info.push_back(LocalObjectEntry(gt, sf->GetLanguage())); } } } @@ -389,7 +388,7 @@ cmLocalUnixMakefileGenerator3 t != info.end(); ++t) { std::string tgtMakefileName = - this->GetRelativeTargetDirectory(*(t->Target)); + this->GetRelativeTargetDirectory(t->Target); std::string targetName = tgtMakefileName; tgtMakefileName += "/build.make"; targetName += "/"; @@ -399,7 +398,7 @@ cmLocalUnixMakefileGenerator3 ); } this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); // Write the rule to the makefile. @@ -418,27 +417,22 @@ void cmLocalUnixMakefileGenerator3 // for each target we just provide a rule to cd up to the top and do a make // on the target - cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); std::string localName; for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if((t->second->GetType() == cmTarget::EXECUTABLE) || - (t->second->GetType() == cmTarget::STATIC_LIBRARY) || - (t->second->GetType() == cmTarget::SHARED_LIBRARY) || - (t->second->GetType() == cmTarget::MODULE_LIBRARY) || - (t->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (t->second->GetType() == cmTarget::UTILITY)) + if((t->second->GetType() == cmState::EXECUTABLE) || + (t->second->GetType() == cmState::STATIC_LIBRARY) || + (t->second->GetType() == cmState::SHARED_LIBRARY) || + (t->second->GetType() == cmState::MODULE_LIBRARY) || + (t->second->GetType() == cmState::OBJECT_LIBRARY) || + (t->second->GetType() == cmState::UTILITY)) { - if (t->second->Target->IsImported()) - { - continue; - } - emitted.insert(t->second->GetName()); // for subdirs add a rule to build this specific target by name. - localName = this->GetRelativeTargetDirectory(*t->second->Target); + localName = this->GetRelativeTargetDirectory(t->second); localName += "/rule"; commands.clear(); depends.clear(); @@ -449,7 +443,7 @@ void cmLocalUnixMakefileGenerator3 commands.push_back(this->GetRecursiveMakeCall (makefile2.c_str(),localName)); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "Convenience name for target.", localName, depends, commands, true); @@ -465,11 +459,11 @@ void cmLocalUnixMakefileGenerator3 // Add a fast rule to build the target std::string makefileName = - this->GetRelativeTargetDirectory(*t->second->Target); + this->GetRelativeTargetDirectory(t->second); makefileName += "/build.make"; // make sure the makefile name is suitable for a makefile std::string makeTargetName = - this->GetRelativeTargetDirectory(*t->second->Target); + this->GetRelativeTargetDirectory(t->second); makeTargetName += "/build"; localName = t->second->GetName(); localName += "/fast"; @@ -478,7 +472,7 @@ void cmLocalUnixMakefileGenerator3 commands.push_back(this->GetRecursiveMakeCall (makefileName.c_str(), makeTargetName)); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "fast build rule for target.", localName, depends, commands, true); @@ -487,7 +481,7 @@ void cmLocalUnixMakefileGenerator3 // installation. if(t->second->NeedRelinkBeforeInstall(this->ConfigName)) { - makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); + makeTargetName = this->GetRelativeTargetDirectory(t->second); makeTargetName += "/preinstall"; localName = t->second->GetName(); localName += "/preinstall"; @@ -496,7 +490,7 @@ void cmLocalUnixMakefileGenerator3 commands.push_back(this->GetRecursiveMakeCall (makefile2.c_str(), makeTargetName)); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "Manual pre-install relink rule for target.", @@ -750,13 +744,13 @@ cmLocalUnixMakefileGenerator3 makefileStream << "# The top-level source directory on which CMake was run.\n" << "CMAKE_SOURCE_DIR = " - << this->Convert(this->Makefile->GetHomeDirectory(), FULL, SHELL) + << this->Convert(this->GetSourceDirectory(), FULL, SHELL) << "\n" << "\n"; makefileStream << "# The top-level build directory on which CMake was run.\n" << "CMAKE_BINARY_DIR = " - << this->Convert(this->Makefile->GetHomeOutputDirectory(), FULL, SHELL) + << this->Convert(this->GetBinaryDirectory(), FULL, SHELL) << "\n" << "\n"; } @@ -889,7 +883,7 @@ void cmLocalUnixMakefileGenerator3 if(!this->GetMakefile()->IsRootMakefile()) { this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); } this->WriteMakeRule(makefileStream, @@ -933,7 +927,7 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- std::string cmLocalUnixMakefileGenerator3 -::GetRelativeTargetDirectory(cmTarget const& target) +::GetRelativeTargetDirectory(cmGeneratorTarget* target) { std::string dir = this->HomeRelativeOutputPath; dir += this->GetTargetDirectory(target); @@ -1034,7 +1028,7 @@ void cmLocalUnixMakefileGenerator3 ::AppendCustomCommands(std::vector<std::string>& commands, const std::vector<cmCustomCommand>& ccs, - cmTarget* target, + cmGeneratorTarget* target, cmLocalGenerator::RelativeRoot relative) { for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin(); @@ -1050,7 +1044,7 @@ void cmLocalUnixMakefileGenerator3 ::AppendCustomCommand(std::vector<std::string>& commands, cmCustomCommandGenerator const& ccg, - cmTarget* target, + cmGeneratorTarget* target, bool echo_comment, cmLocalGenerator::RelativeRoot relative, std::ostream* content) @@ -1181,7 +1175,7 @@ cmLocalUnixMakefileGenerator3 std::string cmLocalUnixMakefileGenerator3::MakeLauncher( cmCustomCommandGenerator const& ccg, - cmTarget* target, RelativeRoot relative) + cmGeneratorTarget* target, RelativeRoot relative) { // Short-circuit if there is no launcher. const char* prop = "RULE_LAUNCH_CUSTOM"; @@ -1218,7 +1212,7 @@ void cmLocalUnixMakefileGenerator3 ::AppendCleanCommand(std::vector<std::string>& commands, const std::vector<std::string>& files, - cmTarget& target, const char* filename) + cmGeneratorTarget* target, const char* filename) { std::string cleanfile = this->Makefile->GetCurrentBinaryDirectory(); cleanfile += "/"; @@ -1256,9 +1250,7 @@ cmLocalUnixMakefileGenerator3 { // Get the set of source languages in the target. std::set<std::string> languages; - cmGeneratorTarget *gtgt = - this->GlobalGenerator->GetGeneratorTarget(&target); - gtgt->GetLanguages(languages, + target->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" @@ -1774,7 +1766,7 @@ void cmLocalUnixMakefileGenerator3 cmTargets::iterator glIt; for ( glIt = targets->begin(); glIt != targets->end(); ++ glIt ) { - if ( glIt->second.GetType() == cmTarget::GLOBAL_TARGET ) + if ( glIt->second.GetType() == cmState::GLOBAL_TARGET ) { std::string targetString = "Special rule for the target " + glIt->first; std::vector<std::string> commands; @@ -1790,6 +1782,9 @@ void cmLocalUnixMakefileGenerator3 this->AppendEcho(commands, text, cmLocalUnixMakefileGenerator3::EchoGlobal); + cmGeneratorTarget* gt = this->GlobalGenerator + ->GetGeneratorTarget(&glIt->second); + // Global targets store their rules in pre- and post-build commands. this->AppendCustomDepends(depends, glIt->second.GetPreBuildCommands()); @@ -1797,11 +1792,11 @@ void cmLocalUnixMakefileGenerator3 glIt->second.GetPostBuildCommands()); this->AppendCustomCommands(commands, glIt->second.GetPreBuildCommands(), - &glIt->second, + gt, cmLocalGenerator::START_OUTPUT); this->AppendCustomCommands(commands, glIt->second.GetPostBuildCommands(), - &glIt->second, + gt, cmLocalGenerator::START_OUTPUT); std::string targetName = glIt->second.GetName(); this->WriteMakeRule(ruleFileStream, targetString.c_str(), @@ -1838,7 +1833,7 @@ void cmLocalUnixMakefileGenerator3 depends.push_back("cmake_check_build_system"); - std::string progressDir = this->Makefile->GetHomeOutputDirectory(); + std::string progressDir = this->GetBinaryDirectory(); progressDir += cmake::GetCMakeFilesDirectory(); { std::ostringstream progCmd; @@ -1862,7 +1857,7 @@ void cmLocalUnixMakefileGenerator3 commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); { std::ostringstream progCmd; @@ -1884,7 +1879,7 @@ void cmLocalUnixMakefileGenerator3 commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "The main clean target", "clean", depends, commands, true); @@ -1914,7 +1909,7 @@ void cmLocalUnixMakefileGenerator3 commands.push_back (this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.", "preinstall", depends, commands, true); @@ -1935,7 +1930,7 @@ void cmLocalUnixMakefileGenerator3 runRule += " 1"; commands.push_back(runRule); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "clear depends", "depend", @@ -1978,10 +1973,11 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf, void cmLocalUnixMakefileGenerator3 -::WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &target) +::WriteDependLanguageInfo(std::ostream& cmakefileStream, + cmGeneratorTarget* target) { ImplicitDependLanguageMap const& implicitLangs = - this->GetImplicitDepends(target); + this->GetImplicitDepends(*target->Target); // list the languages cmakefileStream @@ -2032,7 +2028,7 @@ void cmLocalUnixMakefileGenerator3 // Build a list of preprocessor definitions for the target. std::set<std::string> defines; - this->AddCompileDefinitions(defines, &target, + this->AddCompileDefinitions(defines, target, this->ConfigName, l->first); if(!defines.empty()) { @@ -2058,12 +2054,10 @@ void cmLocalUnixMakefileGenerator3 << "set(CMAKE_" << l->first << "_TARGET_INCLUDE_PATH\n"; std::vector<std::string> includes; - cmGeneratorTarget* gt = this->GetGlobalGenerator() - ->GetGeneratorTarget(&target); const std::string& config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - this->GetIncludeDirectories(includes, gt, + this->GetIncludeDirectories(includes, target, l->first, config); for(std::vector<std::string>::iterator i = includes.begin(); i != includes.end(); ++i) @@ -2086,7 +2080,7 @@ void cmLocalUnixMakefileGenerator3 cmSystemTools::ExpandListArgument(xform, transformRules); } if(const char* xform = - target.GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) + target->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) { cmSystemTools::ExpandListArgument(xform, transformRules); } @@ -2284,10 +2278,10 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p, //---------------------------------------------------------------------------- std::string cmLocalUnixMakefileGenerator3 -::GetTargetDirectory(cmTarget const& target) const +::GetTargetDirectory(cmGeneratorTarget const* target) const { std::string dir = cmake::GetCMakeFilesDirectoryPostSlash(); - dir += target.GetName(); + dir += target->GetName(); #if defined(__VMS) dir += "_dir"; #else diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 98f15e6..7e0f248 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -19,7 +19,6 @@ class cmCustomCommand; class cmCustomCommandGenerator; -class cmDependInformation; class cmDepends; class cmMakefileTargetGenerator; class cmTarget; @@ -106,7 +105,8 @@ public: /** Get whether the makefile is to have color. */ bool GetColorMakefile() const { return this->ColorMakefile; } - virtual std::string GetTargetDirectory(cmTarget const& target) const; + virtual + std::string GetTargetDirectory(cmGeneratorTarget const* target) const; // create a command that cds to the start dir then runs the commands void CreateCDCommand(std::vector<std::string>& commands, @@ -131,7 +131,7 @@ public: void WriteSpecialTargetsTop(std::ostream& makefileStream); void WriteSpecialTargetsBottom(std::ostream& makefileStream); - std::string GetRelativeTargetDirectory(cmTarget const& target); + std::string GetRelativeTargetDirectory(cmGeneratorTarget* target); // File pairs for implicit dependency scanning. The key of the map // is the depender and the value is the explicit dependee. @@ -181,7 +181,8 @@ protected: // write the depend info - void WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &tgt); + void WriteDependLanguageInfo(std::ostream& cmakefileStream, + cmGeneratorTarget *tgt); // write the local help rule void WriteHelpRule(std::ostream& ruleFileStream); @@ -214,19 +215,19 @@ protected: cmCustomCommandGenerator const& cc); void AppendCustomCommands(std::vector<std::string>& commands, const std::vector<cmCustomCommand>& ccs, - cmTarget* target, + cmGeneratorTarget* target, cmLocalGenerator::RelativeRoot relative = cmLocalGenerator::HOME_OUTPUT); void AppendCustomCommand(std::vector<std::string>& commands, cmCustomCommandGenerator const& ccg, - cmTarget* target, + cmGeneratorTarget* target, bool echo_comment=false, cmLocalGenerator::RelativeRoot relative = cmLocalGenerator::HOME_OUTPUT, std::ostream* content = 0); void AppendCleanCommand(std::vector<std::string>& commands, const std::vector<std::string>& files, - cmTarget& target, const char* filename =0); + cmGeneratorTarget* target, const char* filename =0); // Helper methods for dependeny updates. bool ScanDependencies(const char* targetDir, @@ -236,7 +237,7 @@ protected: private: std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root); std::string MakeLauncher(cmCustomCommandGenerator const& ccg, - cmTarget* target, RelativeRoot relative); + cmGeneratorTarget* target, RelativeRoot relative); virtual void ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, @@ -254,10 +255,10 @@ private: struct LocalObjectEntry { - cmTarget* Target; + cmGeneratorTarget* Target; std::string Language; LocalObjectEntry(): Target(0), Language() {} - LocalObjectEntry(cmTarget* t, const std::string& lang): + LocalObjectEntry(cmGeneratorTarget* t, const std::string& lang): Target(t), Language(lang) {} }; struct LocalObjectInfo: public std::vector<LocalObjectEntry> diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index b043b00..63fc283 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -77,7 +77,7 @@ void cmLocalVisualStudio10Generator::Generate() cmTargets &tgts = this->Makefile->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { - if(l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + if(l->second.GetType() == cmState::INTERFACE_LIBRARY) { continue; } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index cc94cd4..a51eb67 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -86,8 +86,8 @@ void cmLocalVisualStudio6Generator::AddCMakeListsRules() for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { - if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY - || l->second.GetType() == cmTarget::GLOBAL_TARGET) + if (l->second.GetType() == cmState::INTERFACE_LIBRARY + || l->second.GetType() == cmState::GLOBAL_TARGET) { continue; } @@ -111,14 +111,14 @@ void cmLocalVisualStudio6Generator::Generate() void cmLocalVisualStudio6Generator::OutputDSPFile() { // If not an in source build, then create the output directory - if(strcmp(this->Makefile->GetCurrentBinaryDirectory(), - this->Makefile->GetHomeDirectory()) != 0) + if(strcmp(this->GetCurrentBinaryDirectory(), + this->GetSourceDirectory()) != 0) { if(!cmSystemTools::MakeDirectory - (this->Makefile->GetCurrentBinaryDirectory())) + (this->GetCurrentBinaryDirectory())) { cmSystemTools::Error("Error creating directory ", - this->Makefile->GetCurrentBinaryDirectory()); + this->GetCurrentBinaryDirectory()); } } @@ -132,22 +132,22 @@ void cmLocalVisualStudio6Generator::OutputDSPFile() { switch(l->second.GetType()) { - case cmTarget::STATIC_LIBRARY: - case cmTarget::OBJECT_LIBRARY: + case cmState::STATIC_LIBRARY: + case cmState::OBJECT_LIBRARY: this->SetBuildType(STATIC_LIBRARY, l->first.c_str(), l->second); break; - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: this->SetBuildType(DLL, l->first.c_str(), l->second); break; - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: this->SetBuildType(EXECUTABLE,l->first.c_str(), l->second); break; - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: + case cmState::UTILITY: + case cmState::GLOBAL_TARGET: this->SetBuildType(UTILITY, l->first.c_str(), l->second); break; - case cmTarget::INTERFACE_LIBRARY: + case cmState::INTERFACE_LIBRARY: continue; default: cmSystemTools::Error("Bad target type: ", l->first.c_str()); @@ -163,7 +163,7 @@ void cmLocalVisualStudio6Generator::OutputDSPFile() std::string::size_type pos = l->first.rfind('/'); if(pos != std::string::npos) { - std::string dir = this->Makefile->GetCurrentBinaryDirectory(); + std::string dir = this->GetCurrentBinaryDirectory(); dir += "/"; dir += l->first.substr(0, pos); if(!cmSystemTools::MakeDirectory(dir.c_str())) @@ -189,7 +189,7 @@ void cmLocalVisualStudio6Generator::CreateSingleDSP(const std::string& lname, // create the dsp.cmake file std::string fname; - fname = this->Makefile->GetCurrentBinaryDirectory(); + fname = this->GetCurrentBinaryDirectory(); fname += "/"; fname += pname; fname += ".dsp"; @@ -215,7 +215,7 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt) dspname += ".dsp.cmake"; cmCustomCommandLine commandLine; commandLine.push_back(cmSystemTools::GetCMakeCommand()); - std::string makefileIn = this->Makefile->GetCurrentSourceDirectory(); + std::string makefileIn = this->GetCurrentSourceDirectory(); makefileIn += "/"; makefileIn += "CMakeLists.txt"; if(!cmSystemTools::FileExists(makefileIn.c_str())) @@ -226,10 +226,10 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt) comment += makefileIn; std::string args; args = "-H"; - args += this->Makefile->GetHomeDirectory(); + args += this->GetSourceDirectory(); commandLine.push_back(args); args = "-B"; - args += this->Makefile->GetHomeOutputDirectory(); + args += this->GetBinaryDirectory(); commandLine.push_back(args); std::vector<std::string> const& listFiles = this->Makefile->GetListFiles(); @@ -243,7 +243,8 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt) no_working_directory, true); if(this->Makefile->GetSource(makefileIn.c_str())) { - tgt.AddSource(makefileIn); + cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&tgt); + gt->AddSource(makefileIn); } else { @@ -262,8 +263,8 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, // special care for dependencies. The first rule must depend on all // the dependencies of all the rules. The later rules must each // depend only on the previous rule. - if ((target.GetType() == cmTarget::UTILITY || - target.GetType() == cmTarget::GLOBAL_TARGET) && + if ((target.GetType() == cmState::UTILITY || + target.GetType() == cmState::GLOBAL_TARGET) && (!target.GetPreBuildCommands().empty() || !target.GetPostBuildCommands().empty())) { @@ -481,8 +482,8 @@ void cmLocalVisualStudio6Generator cmSystemTools::ExpandListArgument(dependsValue, depends); } if (GetVS6TargetName(source) != libName || - target.GetType() == cmTarget::UTILITY || - target.GetType() == cmTarget::GLOBAL_TARGET) + target.GetType() == cmState::UTILITY || + target.GetType() == cmState::GLOBAL_TARGET) { fout << "# Begin Source File\n\n"; @@ -577,9 +578,9 @@ cmLocalVisualStudio6Generator const cmCustomCommand& origCommand) { // Create a fake output that forces the rule to run. - char* output = new char[(strlen(this->Makefile->GetCurrentBinaryDirectory()) + char* output = new char[(strlen(this->GetCurrentBinaryDirectory()) + target.GetName().size() + 30)]; - sprintf(output,"%s/%s_force_%i", this->Makefile->GetCurrentBinaryDirectory(), + sprintf(output,"%s/%s_force_%i", this->GetCurrentBinaryDirectory(), target.GetName().c_str(), count); const char* comment = origCommand.GetComment(); if(!comment && origCommand.GetOutputs().empty()) @@ -595,7 +596,8 @@ cmLocalVisualStudio6Generator origCommand.GetCommandLines(), comment, origCommand.GetWorkingDirectory().c_str())) { - target.AddSource(outsf->GetFullPath()); + cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target); + gt->AddSource(outsf->GetFullPath()); } // Replace the dependencies with the output of this rule so that the @@ -802,8 +804,12 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target, // VS6 forgets to create the output directory for archives if it // differs from the intermediate directory. - if(target.GetType() != cmTarget::STATIC_LIBRARY) { return pcc; } - std::string outDir = target.GetDirectory(config, false); + if(target.GetType() != cmState::STATIC_LIBRARY) { return pcc; } + + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + + std::string outDir = gt->GetDirectory(config, false); // Add a pre-link event to create the directory. cmCustomCommandLine command; @@ -829,7 +835,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target, const std::string& configName, const std::string& /* libName */) { - if (target.GetType() >= cmTarget::UTILITY ) + if (target.GetType() >= cmState::UTILITY ) { return ""; } @@ -942,8 +948,8 @@ void cmLocalVisualStudio6Generator const std::string& libName, cmTarget &target, std::vector<cmSourceGroup> &) { - bool targetBuilds = (target.GetType() >= cmTarget::EXECUTABLE && - target.GetType() <= cmTarget::MODULE_LIBRARY); + bool targetBuilds = (target.GetType() >= cmState::EXECUTABLE && + target.GetType() <= cmState::MODULE_LIBRARY); #ifdef CM_USE_OLD_VS6 // Lookup the library and executable output directories. std::string libPath; @@ -1102,12 +1108,12 @@ void cmLocalVisualStudio6Generator // add libraries to executables and dlls (but never include // a library in a library, bad recursion) // NEVER LINK STATIC LIBRARIES TO OTHER STATIC LIBRARIES - if ((target.GetType() != cmTarget::SHARED_LIBRARY - && target.GetType() != cmTarget::STATIC_LIBRARY - && target.GetType() != cmTarget::MODULE_LIBRARY) || - (target.GetType()==cmTarget::SHARED_LIBRARY + if ((target.GetType() != cmState::SHARED_LIBRARY + && target.GetType() != cmState::STATIC_LIBRARY + && target.GetType() != cmState::MODULE_LIBRARY) || + (target.GetType()==cmState::SHARED_LIBRARY && libName != GetVS6TargetName(j->first)) || - (target.GetType()==cmTarget::MODULE_LIBRARY + (target.GetType()==cmState::MODULE_LIBRARY && libName != GetVS6TargetName(j->first))) { // Compute the proper name to use to link this library. @@ -1139,7 +1145,7 @@ void cmLocalVisualStudio6Generator libDebug = this->ConvertToOutputFormat(libDebug.c_str(), SHELL); - if (j->second == cmTarget::GENERAL) + if (j->second == GENERAL_LibraryType) { libOptions += " "; libOptions += lib; @@ -1150,7 +1156,7 @@ void cmLocalVisualStudio6Generator libMultiLineOptionsForDebug += libDebug; libMultiLineOptionsForDebug += "\n"; } - if (j->second == cmTarget::DEBUG) + if (j->second == DEBUG_LibraryType) { libDebugOptions += " "; libDebugOptions += lib; @@ -1159,7 +1165,7 @@ void cmLocalVisualStudio6Generator libMultiLineDebugOptions += libDebug; libMultiLineDebugOptions += "\n"; } - if (j->second == cmTarget::OPTIMIZED) + if (j->second == OPTIMIZED_LibraryType) { libOptimizedOptions += " "; libOptimizedOptions += lib; @@ -1189,7 +1195,7 @@ void cmLocalVisualStudio6Generator std::string extraLinkOptionsRelease; std::string extraLinkOptionsMinSizeRel; std::string extraLinkOptionsRelWithDebInfo; - if(target.GetType() == cmTarget::EXECUTABLE) + if(target.GetType() == cmState::EXECUTABLE) { extraLinkOptions = this->Makefile-> GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"); @@ -1202,7 +1208,7 @@ void cmLocalVisualStudio6Generator extraLinkOptionsRelWithDebInfo = this->Makefile-> GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO"); } - if(target.GetType() == cmTarget::SHARED_LIBRARY) + if(target.GetType() == cmState::SHARED_LIBRARY) { extraLinkOptions = this->Makefile-> GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS"); @@ -1215,7 +1221,7 @@ void cmLocalVisualStudio6Generator extraLinkOptionsRelWithDebInfo = this->Makefile-> GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO"); } - if(target.GetType() == cmTarget::MODULE_LIBRARY) + if(target.GetType() == cmState::MODULE_LIBRARY) { extraLinkOptions = this->Makefile-> GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS"); @@ -1307,13 +1313,13 @@ void cmLocalVisualStudio6Generator // Compute version number information. std::string targetVersionFlag; - if(target.GetType() == cmTarget::EXECUTABLE || - target.GetType() == cmTarget::SHARED_LIBRARY || - target.GetType() == cmTarget::MODULE_LIBRARY) + if(target.GetType() == cmState::EXECUTABLE || + target.GetType() == cmState::SHARED_LIBRARY || + target.GetType() == cmState::MODULE_LIBRARY) { int major; int minor; - target.GetTargetVersion(major, minor); + gt->GetTargetVersion(major, minor); std::ostringstream targetVersionStream; targetVersionStream << "/version:" << major << "." << minor; targetVersionFlag = targetVersionStream.str(); @@ -1326,10 +1332,10 @@ void cmLocalVisualStudio6Generator std::string outputNameRelease = outputName; std::string outputNameMinSizeRel = outputName; std::string outputNameRelWithDebInfo = outputName; - if(target.GetType() == cmTarget::EXECUTABLE || - target.GetType() == cmTarget::STATIC_LIBRARY || - target.GetType() == cmTarget::SHARED_LIBRARY || - target.GetType() == cmTarget::MODULE_LIBRARY) + if(target.GetType() == cmState::EXECUTABLE || + target.GetType() == cmState::STATIC_LIBRARY || + target.GetType() == cmState::SHARED_LIBRARY || + target.GetType() == cmState::MODULE_LIBRARY) { outputName = gt->GetFullName(); outputNameDebug = gt->GetFullName("Debug"); @@ -1337,7 +1343,7 @@ void cmLocalVisualStudio6Generator outputNameMinSizeRel = gt->GetFullName("MinSizeRel"); outputNameRelWithDebInfo = gt->GetFullName("RelWithDebInfo"); } - else if(target.GetType() == cmTarget::OBJECT_LIBRARY) + else if(target.GetType() == cmState::OBJECT_LIBRARY) { outputName = target.GetName(); outputName += ".lib"; @@ -1353,30 +1359,30 @@ void cmLocalVisualStudio6Generator std::string outputDirRelease; std::string outputDirMinSizeRel; std::string outputDirRelWithDebInfo; - if(target.GetType() == cmTarget::EXECUTABLE || - target.GetType() == cmTarget::STATIC_LIBRARY || - target.GetType() == cmTarget::SHARED_LIBRARY || - target.GetType() == cmTarget::MODULE_LIBRARY) + if(target.GetType() == cmState::EXECUTABLE || + target.GetType() == cmState::STATIC_LIBRARY || + target.GetType() == cmState::SHARED_LIBRARY || + target.GetType() == cmState::MODULE_LIBRARY) { #ifdef CM_USE_OLD_VS6 outputDirOld = removeQuotes(this->ConvertToOutputFormat - (target.GetDirectory().c_str(), SHELL)); + (gt->GetDirectory().c_str(), SHELL)); #endif outputDirDebug = removeQuotes(this->ConvertToOutputFormat( - target.GetDirectory("Debug").c_str(), SHELL)); + gt->GetDirectory("Debug").c_str(), SHELL)); outputDirRelease = removeQuotes(this->ConvertToOutputFormat( - target.GetDirectory("Release").c_str(), SHELL)); + gt->GetDirectory("Release").c_str(), SHELL)); outputDirMinSizeRel = removeQuotes(this->ConvertToOutputFormat( - target.GetDirectory("MinSizeRel").c_str(), SHELL)); + gt->GetDirectory("MinSizeRel").c_str(), SHELL)); outputDirRelWithDebInfo = removeQuotes(this->ConvertToOutputFormat( - target.GetDirectory("RelWithDebInfo").c_str(), SHELL)); + gt->GetDirectory("RelWithDebInfo").c_str(), SHELL)); } - else if(target.GetType() == cmTarget::OBJECT_LIBRARY) + else if(target.GetType() == cmState::OBJECT_LIBRARY) { std::string outputDir = cmake::GetCMakeFilesDirectoryPostSlash(); outputDirDebug = outputDir + "Debug"; @@ -1390,9 +1396,9 @@ void cmLocalVisualStudio6Generator std::string optionsRelease; std::string optionsMinSizeRel; std::string optionsRelWithDebInfo; - if(target.GetType() == cmTarget::EXECUTABLE || - target.GetType() == cmTarget::SHARED_LIBRARY || - target.GetType() == cmTarget::MODULE_LIBRARY) + if(target.GetType() == cmState::EXECUTABLE || + target.GetType() == cmState::SHARED_LIBRARY || + target.GetType() == cmState::MODULE_LIBRARY) { extraLinkOptionsDebug = extraLinkOptions + " " + extraLinkOptionsDebug; @@ -1418,16 +1424,16 @@ void cmLocalVisualStudio6Generator std::string targetImplibFlagRelease; std::string targetImplibFlagMinSizeRel; std::string targetImplibFlagRelWithDebInfo; - if(target.GetType() == cmTarget::SHARED_LIBRARY || - target.GetType() == cmTarget::MODULE_LIBRARY || - target.GetType() == cmTarget::EXECUTABLE) + if(target.GetType() == cmState::SHARED_LIBRARY || + target.GetType() == cmState::MODULE_LIBRARY || + target.GetType() == cmState::EXECUTABLE) { - std::string fullPathImpDebug = target.GetDirectory("Debug", true); - std::string fullPathImpRelease = target.GetDirectory("Release", true); + std::string fullPathImpDebug = gt->GetDirectory("Debug", true); + std::string fullPathImpRelease = gt->GetDirectory("Release", true); std::string fullPathImpMinSizeRel = - target.GetDirectory("MinSizeRel", true); + gt->GetDirectory("MinSizeRel", true); std::string fullPathImpRelWithDebInfo = - target.GetDirectory("RelWithDebInfo", true); + gt->GetDirectory("RelWithDebInfo", true); fullPathImpDebug += "/"; fullPathImpRelease += "/"; fullPathImpMinSizeRel += "/"; @@ -1488,7 +1494,7 @@ void cmLocalVisualStudio6Generator std::string staticLibOptionsRelease; std::string staticLibOptionsMinSizeRel; std::string staticLibOptionsRelWithDebInfo; - if(target.GetType() == cmTarget::STATIC_LIBRARY ) + if(target.GetType() == cmState::STATIC_LIBRARY ) { const char *libflagsGlobal = this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS"); @@ -1537,7 +1543,7 @@ void cmLocalVisualStudio6Generator // Add the export symbol definition for shared library objects. std::string exportSymbol; - if(const char* exportMacro = target.GetExportMacro()) + if(const char* exportMacro = gt->GetExportMacro()) { exportSymbol = exportMacro; } @@ -1561,8 +1567,8 @@ void cmLocalVisualStudio6Generator libnameExports.c_str()); cmSystemTools::ReplaceString(line, "CMAKE_MFC_FLAG", mfcFlag); - if(target.GetType() == cmTarget::STATIC_LIBRARY || - target.GetType() == cmTarget::OBJECT_LIBRARY) + if(target.GetType() == cmState::STATIC_LIBRARY || + target.GetType() == cmState::OBJECT_LIBRARY) { cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_DEBUG", staticLibOptionsDebug.c_str()); @@ -1668,7 +1674,7 @@ void cmLocalVisualStudio6Generator (exePath.c_str(), SHELL)).c_str()); #endif - if(targetBuilds || target.GetType() == cmTarget::OBJECT_LIBRARY) + if(targetBuilds || target.GetType() == cmState::OBJECT_LIBRARY) { cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_DEBUG", outputDirDebug.c_str()); @@ -1692,8 +1698,8 @@ void cmLocalVisualStudio6Generator = this->Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"); cmSystemTools::ReplaceString(line, "DEBUG_POSTFIX", debugPostfix?debugPostfix:""); - if(target.GetType() >= cmTarget::EXECUTABLE && - target.GetType() <= cmTarget::OBJECT_LIBRARY) + if(target.GetType() >= cmState::EXECUTABLE && + target.GetType() <= cmState::OBJECT_LIBRARY) { // store flags for each configuration std::string flags = " "; @@ -1744,12 +1750,12 @@ void cmLocalVisualStudio6Generator flagsRelWithDebInfo = this->Makefile->GetSafeDefinition(flagVar.c_str()); flagsRelWithDebInfo += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" "; - this->AddCompileOptions(flags, &target, linkLanguage, ""); - this->AddCompileOptions(flagsDebug, &target, linkLanguage, "Debug"); - this->AddCompileOptions(flagsRelease, &target, linkLanguage, "Release"); - this->AddCompileOptions(flagsMinSizeRel, &target, linkLanguage, + this->AddCompileOptions(flags, gt, linkLanguage, ""); + this->AddCompileOptions(flagsDebug, gt, linkLanguage, "Debug"); + this->AddCompileOptions(flagsRelease, gt, linkLanguage, "Release"); + this->AddCompileOptions(flagsMinSizeRel, gt, linkLanguage, "MinSizeRel"); - this->AddCompileOptions(flagsRelWithDebInfo, &target, linkLanguage, + this->AddCompileOptions(flagsRelWithDebInfo, gt, linkLanguage, "RelWithDebInfo"); // if _UNICODE and _SBCS are not found, then add -D_MBCS @@ -1769,14 +1775,14 @@ void cmLocalVisualStudio6Generator std::set<std::string> minsizeDefinesSet; std::set<std::string> debugrelDefinesSet; - this->AddCompileDefinitions(definesSet, &target, "", linkLanguage); - this->AddCompileDefinitions(debugDefinesSet, &target, + this->AddCompileDefinitions(definesSet, gt, "", linkLanguage); + this->AddCompileDefinitions(debugDefinesSet, gt, "DEBUG", linkLanguage); - this->AddCompileDefinitions(releaseDefinesSet, &target, + this->AddCompileDefinitions(releaseDefinesSet, gt, "RELEASE", linkLanguage); - this->AddCompileDefinitions(minsizeDefinesSet, &target, + this->AddCompileDefinitions(minsizeDefinesSet, gt, "MINSIZEREL", linkLanguage); - this->AddCompileDefinitions(debugrelDefinesSet, &target, + this->AddCompileDefinitions(debugrelDefinesSet, gt, "RELWITHDEBINFO", linkLanguage); std::string defines = " "; @@ -1893,7 +1899,7 @@ void cmLocalVisualStudio6Generator this->ConvertToOutputFormat(l->Value.c_str(), SHELL); } else if (!l->Target - || l->Target->GetType() != cmTarget::INTERFACE_LIBRARY) + || l->Target->GetType() != cmState::INTERFACE_LIBRARY) { options += l->Value; } @@ -1933,7 +1939,7 @@ void cmLocalVisualStudio6Generator std::string cmLocalVisualStudio6Generator -::GetTargetDirectory(cmTarget const&) const +::GetTargetDirectory(cmGeneratorTarget const*) const { // No per-target directory for this generator (yet). return ""; @@ -1962,7 +1968,7 @@ cmLocalVisualStudio6Generator // files directory for any configuration. This is used to construct // object file names that do not produce paths that are too long. std::string dir_max; - dir_max += this->Makefile->GetCurrentBinaryDirectory(); + dir_max += this->GetCurrentBinaryDirectory(); dir_max += "/"; dir_max += config_max; dir_max += "/"; diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index 828d252..b3b61bb 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -49,7 +49,8 @@ public: */ void SetBuildType(BuildType, const std::string& libName, cmTarget&); - virtual std::string GetTargetDirectory(cmTarget const& target) const; + virtual + std::string GetTargetDirectory(cmGeneratorTarget const* target) const; virtual std::string ComputeLongestObjectDirectory(cmTarget&) const; private: std::string DSPHeaderTemplate; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index cf67251..819998c 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -71,7 +71,7 @@ void cmLocalVisualStudio7Generator::AddHelperCommands() for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { - if(l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + if(l->second.GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -106,13 +106,15 @@ void cmLocalVisualStudio7Generator::AddCMakeListsRules() // Add the rule to targets that need it. for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { - if (l->second.GetType() == cmTarget::GLOBAL_TARGET) + if (l->second.GetType() == cmState::GLOBAL_TARGET) { continue; } if(l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET) { - l->second.AddSource(sf->GetFullPath()); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&l->second); + gt->AddSource(sf->GetFullPath()); } } } @@ -129,7 +131,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() l != tgts.end(); l++) { cmTarget& tgt = l->second; - if(tgt.GetType() == cmTarget::GLOBAL_TARGET) + if(tgt.GetType() == cmState::GLOBAL_TARGET) { std::vector<std::string> no_depends; cmCustomCommandLine force_command; @@ -138,7 +140,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() cmCustomCommandLines force_commands; force_commands.push_back(force_command); std::string no_main_dependency = ""; - std::string force = this->Makefile->GetCurrentBinaryDirectory(); + std::string force = this->GetCurrentBinaryDirectory(); force += cmake::GetCMakeFilesDirectory(); force += "/"; force += tgt.GetName(); @@ -148,7 +150,9 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() force.c_str(), no_depends, no_main_dependency, force_commands, " ", 0, true)) { - tgt.AddSource(file->GetFullPath()); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&tgt); + gt->AddSource(file->GetFullPath()); } } } @@ -160,14 +164,14 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() void cmLocalVisualStudio7Generator::WriteProjectFiles() { // If not an in source build, then create the output directory - if(strcmp(this->Makefile->GetCurrentBinaryDirectory(), - this->Makefile->GetHomeDirectory()) != 0) + if(strcmp(this->GetCurrentBinaryDirectory(), + this->GetSourceDirectory()) != 0) { if(!cmSystemTools::MakeDirectory - (this->Makefile->GetCurrentBinaryDirectory())) + (this->GetCurrentBinaryDirectory())) { cmSystemTools::Error("Error creating directory ", - this->Makefile->GetCurrentBinaryDirectory()); + this->GetCurrentBinaryDirectory()); } } @@ -178,7 +182,7 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles() for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { - if(l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + if(l->second.GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -196,7 +200,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles() { // Touch a timestamp file used to determine when the project file is // out of date. - std::string stampName = this->Makefile->GetCurrentBinaryDirectory(); + std::string stampName = this->GetCurrentBinaryDirectory(); stampName += cmake::GetCMakeFilesDirectory(); cmSystemTools::MakeDirectory(stampName.c_str()); stampName += "/"; @@ -243,7 +247,7 @@ void cmLocalVisualStudio7Generator target.SetProperty("GENERATOR_FILE_NAME",lname.c_str()); // create the dsp.cmake file std::string fname; - fname = this->Makefile->GetCurrentBinaryDirectory(); + fname = this->GetCurrentBinaryDirectory(); fname += "/"; fname += lname; if(this->FortranProject) @@ -272,13 +276,13 @@ void cmLocalVisualStudio7Generator //---------------------------------------------------------------------------- cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() { - std::string stampName = this->Makefile->GetCurrentBinaryDirectory(); + std::string stampName = this->GetCurrentBinaryDirectory(); stampName += "/"; stampName += cmake::GetCMakeFilesDirectoryPostSlash(); stampName += "generate.stamp"; cmCustomCommandLine commandLine; commandLine.push_back(cmSystemTools::GetCMakeCommand()); - std::string makefileIn = this->Makefile->GetCurrentSourceDirectory(); + std::string makefileIn = this->GetCurrentSourceDirectory(); makefileIn += "/"; makefileIn += "CMakeLists.txt"; makefileIn = cmSystemTools::CollapseFullPath(makefileIn.c_str()); @@ -290,10 +294,10 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() comment += makefileIn; std::string args; args = "-H"; - args += this->Makefile->GetHomeDirectory(); + args += this->GetSourceDirectory(); commandLine.push_back(args); args = "-B"; - args += this->Makefile->GetHomeOutputDirectory(); + args += this->GetBinaryDirectory(); commandLine.push_back(args); commandLine.push_back("--check-stamp-file"); std::string stampFilename = this->Convert(stampName.c_str(), FULL, @@ -668,22 +672,22 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, switch(target.GetType()) { - case cmTarget::OBJECT_LIBRARY: + case cmState::OBJECT_LIBRARY: targetBuilds = false; // no manifest tool for object library - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: projectType = "typeStaticLibrary"; configType = "4"; break; - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: projectType = "typeDynamicLibrary"; configType = "2"; break; - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: configType = "1"; break; - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: + case cmState::UTILITY: + case cmState::GLOBAL_TARGET: configType = "10"; default: targetBuilds = false; @@ -729,7 +733,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, } // Add the target-specific flags. - this->AddCompileOptions(flags, &target, linkLanguage, configName); + this->AddCompileOptions(flags, gt, linkLanguage, configName); } if(this->FortranProject) @@ -773,22 +777,22 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.AddDefine(configDefine); // Add the export symbol definition for shared library objects. - if(const char* exportMacro = target.GetExportMacro()) + if(const char* exportMacro = gt->GetExportMacro()) { targetOptions.AddDefine(exportMacro); } // The intermediate directory name consists of a directory for the // target and a subdirectory for the configuration name. - std::string intermediateDir = this->GetTargetDirectory(target); + std::string intermediateDir = this->GetTargetDirectory(gt); intermediateDir += "/"; intermediateDir += configName; - if (target.GetType() < cmTarget::UTILITY) + if (target.GetType() < cmState::UTILITY) { std::string const& outDir = - target.GetType() == cmTarget::OBJECT_LIBRARY? - intermediateDir : target.GetDirectory(configName); + target.GetType() == cmState::OBJECT_LIBRARY? + intermediateDir : gt->GetDirectory(configName); fout << "\t\t\tOutputDirectory=\"" << this->ConvertToXMLOutputPathSingle(outDir.c_str()) << "\"\n"; } @@ -878,7 +882,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.OutputFlagMap(fout, "\t\t\t\t"); targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX"); fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n"; - if(target.GetType() <= cmTarget::OBJECT_LIBRARY) + if(target.GetType() <= cmState::OBJECT_LIBRARY) { // Specify the compiler program database file if configured. std::string pdb = gt->GetCompilePDBPath(configName); @@ -972,25 +976,43 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, fout << "\t\t\t\tProxyFileName=\"$(InputName)_p.c\"/>\n"; // end of <Tool Name=VCMIDLTool - // Check if we need the FAT32 workaround. + // Add manifest tool settings. if(targetBuilds && this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8) { + const char* manifestTool = "VCManifestTool"; + if (this->FortranProject) + { + manifestTool = "VFManifestTool"; + } + fout << + "\t\t\t<Tool\n" + "\t\t\t\tName=\"" << manifestTool << "\""; + + std::vector<cmSourceFile const*> manifest_srcs; + gt->GetManifests(manifest_srcs, configName); + if (!manifest_srcs.empty()) + { + fout << "\n\t\t\t\tAdditionalManifestFiles=\""; + for (std::vector<cmSourceFile const*>::const_iterator + mi = manifest_srcs.begin(); mi != manifest_srcs.end(); ++mi) + { + std::string m = (*mi)->GetFullPath(); + fout << this->ConvertToXMLOutputPath(m.c_str()) << ";"; + } + fout << "\""; + } + + // Check if we need the FAT32 workaround. // Check the filesystem type where the target will be written. - if(cmLVS6G_IsFAT(target.GetDirectory(configName).c_str())) + if (cmLVS6G_IsFAT(gt->GetDirectory(configName).c_str())) { // Add a flag telling the manifest tool to use a workaround // for FAT32 file systems, which can cause an empty manifest // to be embedded into the resulting executable. See CMake // bug #2617. - const char* manifestTool = "VCManifestTool"; - if(this->FortranProject) - { - manifestTool = "VFManifestTool"; - } - fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << manifestTool << "\"\n" - << "\t\t\t\tUseFAT32Workaround=\"true\"\n" - << "\t\t\t/>\n"; + fout << "\n\t\t\t\tUseFAT32Workaround=\"true\""; } + fout << "/>\n"; } this->OutputTargetRules(fout, configName, target, libName); @@ -1023,21 +1045,21 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator); std::string temp; std::string extraLinkOptions; - if(target.GetType() == cmTarget::EXECUTABLE) + if(target.GetType() == cmState::EXECUTABLE) { extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS") + std::string(" ") + GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName); } - if(target.GetType() == cmTarget::SHARED_LIBRARY) + if(target.GetType() == cmState::SHARED_LIBRARY) { extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS") + std::string(" ") + GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName); } - if(target.GetType() == cmTarget::MODULE_LIBRARY) + if(target.GetType() == cmState::MODULE_LIBRARY) { extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS") @@ -1077,7 +1099,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target); - if (target.GetType() == cmTarget::SHARED_LIBRARY && + if (target.GetType() == cmState::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { if (target.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) @@ -1087,11 +1109,11 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } switch(target.GetType()) { - case cmTarget::UNKNOWN_LIBRARY: + case cmState::UNKNOWN_LIBRARY: break; - case cmTarget::OBJECT_LIBRARY: + case cmState::OBJECT_LIBRARY: { - std::string libpath = this->GetTargetDirectory(target); + std::string libpath = this->GetTargetDirectory(gt); libpath += "/"; libpath += configName; libpath += "/"; @@ -1105,10 +1127,10 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << "\"/>\n"; break; } - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: { std::string targetNameFull = gt->GetFullName(configName); - std::string libpath = target.GetDirectory(configName); + std::string libpath = gt->GetDirectory(configName); libpath += "/"; libpath += targetNameFull; const char* tool = "VCLibrarianTool"; @@ -1130,7 +1152,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } } std::string libflags; - this->GetStaticLibraryFlags(libflags, configTypeUpper, &target); + this->GetStaticLibraryFlags(libflags, configTypeUpper, gt); if(!libflags.empty()) { fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n"; @@ -1139,8 +1161,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << "\"/>\n"; break; } - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: { std::string targetName; std::string targetNameSO; @@ -1188,17 +1210,17 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, fout << " "; this->Internal->OutputLibraries(fout, cli.GetItems()); fout << "\"\n"; - temp = target.GetDirectory(configName); + temp = gt->GetDirectory(configName); temp += "/"; temp += targetNameFull; fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; - this->WriteTargetVersionAttribute(fout, target); + this->WriteTargetVersionAttribute(fout, gt); linkOptions.OutputFlagMap(fout, "\t\t\t\t"); fout << "\t\t\t\tAdditionalLibraryDirectories=\""; this->OutputLibraryDirectories(fout, cli.GetDirectories()); fout << "\"\n"; - temp = target.GetPDBDirectory(configName); + temp = gt->GetPDBDirectory(configName); temp += "/"; temp += targetNamePDB; fout << "\t\t\t\tProgramDatabaseFile=\"" << @@ -1226,7 +1248,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, { fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n"; } - temp = target.GetDirectory(configName, true); + temp = gt->GetDirectory(configName, true); temp += "/"; temp += targetNameImport; fout << "\t\t\t\tImportLibrary=\"" @@ -1238,7 +1260,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, fout << "/>\n"; } break; - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: { std::string targetName; std::string targetNameFull; @@ -1287,18 +1309,18 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, fout << " "; this->Internal->OutputLibraries(fout, cli.GetItems()); fout << "\"\n"; - temp = target.GetDirectory(configName); + temp = gt->GetDirectory(configName); temp += "/"; temp += targetNameFull; fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; - this->WriteTargetVersionAttribute(fout, target); + this->WriteTargetVersionAttribute(fout, gt); linkOptions.OutputFlagMap(fout, "\t\t\t\t"); fout << "\t\t\t\tAdditionalLibraryDirectories=\""; this->OutputLibraryDirectories(fout, cli.GetDirectories()); fout << "\"\n"; std::string path = this->ConvertToXMLOutputPathSingle( - target.GetPDBDirectory(configName).c_str()); + gt->GetPDBDirectory(configName).c_str()); fout << "\t\t\t\tProgramDatabaseFile=\"" << path << "/" << targetNamePDB << "\"\n"; @@ -1345,16 +1367,16 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, { fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\""; } - temp = target.GetDirectory(configName, true); + temp = gt->GetDirectory(configName, true); temp += "/"; temp += targetNameImport; fout << "\t\t\t\tImportLibrary=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n"; break; } - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: - case cmTarget::INTERFACE_LIBRARY: + case cmState::UTILITY: + case cmState::GLOBAL_TARGET: + case cmState::INTERFACE_LIBRARY: break; } } @@ -1362,11 +1384,11 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, //---------------------------------------------------------------------------- void cmLocalVisualStudio7Generator -::WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target) +::WriteTargetVersionAttribute(std::ostream& fout, cmGeneratorTarget* gt) { int major; int minor; - target.GetTargetVersion(major, minor); + gt->GetTargetVersion(major, minor); fout << "\t\t\t\tVersion=\"" << major << "." << minor << "\"\n"; } @@ -1386,7 +1408,7 @@ cmLocalVisualStudio7GeneratorInternals fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " "; } else if (!l->Target - || l->Target->GetType() != cmTarget::INTERFACE_LIBRARY) + || l->Target->GetType() != cmState::INTERFACE_LIBRARY) { fout << l->Value << " "; } @@ -1701,9 +1723,11 @@ cmLocalVisualStudio7Generator // files directory for any configuration. This is used to construct // object file names that do not produce paths that are too long. std::string dir_max; - dir_max += this->Makefile->GetCurrentBinaryDirectory(); + dir_max += this->GetCurrentBinaryDirectory(); dir_max += "/"; - dir_max += this->GetTargetDirectory(target); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + dir_max += this->GetTargetDirectory(gt); dir_max += "/"; dir_max += config_max; dir_max += "/"; @@ -1753,8 +1777,8 @@ bool cmLocalVisualStudio7Generator std::string source = (*sf)->GetFullPath(); FCInfo fcinfo(this, target, *(*sf), configs); - if (source != libName || target.GetType() == cmTarget::UTILITY || - target.GetType() == cmTarget::GLOBAL_TARGET ) + if (source != libName || target.GetType() == cmState::UTILITY || + target.GetType() == cmState::GLOBAL_TARGET ) { fout << "\t\t\t<File\n"; std::string d = this->ConvertToXMLOutputPathSingle(source.c_str()); @@ -2004,7 +2028,7 @@ void cmLocalVisualStudio7Generator cmTarget &target, const std::string& /*libName*/) { - if (target.GetType() > cmTarget::GLOBAL_TARGET) + if (target.GetType() > cmState::GLOBAL_TARGET) { return; } @@ -2021,7 +2045,7 @@ void cmLocalVisualStudio7Generator tool = this->FortranProject? "VFPreLinkEventTool":"VCPreLinkEventTool"; event.Start(tool); bool addedPrelink = false; - if (target.GetType() == cmTarget::SHARED_LIBRARY && + if (target.GetType() == cmState::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { if (target.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) @@ -2102,30 +2126,30 @@ cmLocalVisualStudio7Generator const char* projectType = 0; switch(target.GetType()) { - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: projectType = "typeStaticLibrary"; if(keyword) { keyword = "Static Library"; } break; - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: projectType = "typeDynamicLibrary"; if(!keyword) { keyword = "Dll"; } break; - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: if(!keyword) { keyword = "Console Application"; } projectType = 0; break; - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: + case cmState::UTILITY: + case cmState::GLOBAL_TARGET: default: break; } @@ -2347,10 +2371,10 @@ void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID( //---------------------------------------------------------------------------- std::string cmLocalVisualStudio7Generator -::GetTargetDirectory(cmTarget const& target) const +::GetTargetDirectory(cmGeneratorTarget const* target) const { std::string dir; - dir += target.GetName(); + dir += target->GetName(); dir += ".dir"; return dir; } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index bc05a06..16cf004 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -53,7 +53,8 @@ public: */ void SetBuildType(BuildType,const std::string& name); - virtual std::string GetTargetDirectory(cmTarget const&) const; + virtual + std::string GetTargetDirectory(cmGeneratorTarget const* target) const; cmSourceFile* CreateVCProjBuildRule(); void WriteStampFiles(); virtual std::string ComputeLongestObjectDirectory(cmTarget&) const; @@ -105,7 +106,8 @@ private: const char* source, const cmCustomCommand& command, FCInfo& fcinfo); - void WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target); + void WriteTargetVersionAttribute(std::ostream& fout, + cmGeneratorTarget* gt); bool WriteGroup(const cmSourceGroup *sg, cmTarget& target, std::ostream &fout, diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index c0072de..2f44fb7 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -89,11 +89,13 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target, // If an executable exports symbols then VS wants to create an // import library but forgets to create the output directory. // The Intel Fortran plugin always forgets to the directory. - if(target.GetType() != cmTarget::EXECUTABLE && - !(isFortran && target.GetType() == cmTarget::SHARED_LIBRARY)) + if(target.GetType() != cmState::EXECUTABLE && + !(isFortran && target.GetType() == cmState::SHARED_LIBRARY)) { return pcc; } - std::string outDir = target.GetDirectory(config, false); - std::string impDir = target.GetDirectory(config, true); + cmGeneratorTarget* gt = + this->GetGlobalGenerator()->GetGeneratorTarget(&target); + std::string outDir = gt->GetDirectory(config, false); + std::string impDir = gt->GetDirectory(config, true); if(impDir == outDir) { return pcc; } // Add a pre-build event to create the directory. diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index b19112d..3b430d2 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -31,7 +31,7 @@ cmLocalXCodeGenerator::~cmLocalXCodeGenerator() //---------------------------------------------------------------------------- std::string -cmLocalXCodeGenerator::GetTargetDirectory(cmTarget const&) const +cmLocalXCodeGenerator::GetTargetDirectory(cmGeneratorTarget const*) const { // No per-target directory for this generator (yet). return ""; @@ -56,7 +56,8 @@ void cmLocalXCodeGenerator::Generate() iter != targets.end(); ++iter) { cmTarget* t = &iter->second; - t->HasMacOSXRpathInstallNameDir(""); + cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(t); + gt->HasMacOSXRpathInstallNameDir(""); } } @@ -70,7 +71,8 @@ void cmLocalXCodeGenerator::GenerateInstallRules() iter != targets.end(); ++iter) { cmTarget* t = &iter->second; - t->HasMacOSXRpathInstallNameDir(""); + cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(t); + gt->HasMacOSXRpathInstallNameDir(""); } } diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index 6d0926f..4381a6d 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -28,7 +28,8 @@ public: cmMakefile* mf); virtual ~cmLocalXCodeGenerator(); - virtual std::string GetTargetDirectory(cmTarget const& target) const; + virtual + std::string GetTargetDirectory(cmGeneratorTarget const* target) const; virtual void AppendFlagEscape(std::string& flags, const std::string& rawFlag); virtual void Generate(); diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx deleted file mode 100644 index cbc7e02..0000000 --- a/Source/cmMakeDepend.cxx +++ /dev/null @@ -1,361 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - 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 "cmMakeDepend.h" -#include "cmSystemTools.h" -#include "cmGeneratorExpression.h" -#include "cmAlgorithms.h" - -#include <cmsys/RegularExpression.hxx> -#include <cmsys/FStream.hxx> - -void cmDependInformation::AddDependencies(cmDependInformation* info) -{ - if(this != info) - { - this->DependencySet.insert(info); - } -} - -cmMakeDepend::cmMakeDepend() -{ - this->Verbose = false; - this->IncludeFileRegularExpression.compile("^.*$"); - this->ComplainFileRegularExpression.compile("^$"); -} - - -cmMakeDepend::~cmMakeDepend() -{ - cmDeleteAll(this->DependInformationMap); -} - - -// Set the makefile that depends will be made from. -// The pointer is kept so the cmSourceFile array can -// be updated with the depend information in the cmMakefile. - -void cmMakeDepend::SetMakefile(cmMakefile* makefile) -{ - this->Makefile = makefile; - - // Now extract the include file regular expression from the makefile. - this->IncludeFileRegularExpression.compile( - this->Makefile->GetIncludeRegularExpression()); - this->ComplainFileRegularExpression.compile( - this->Makefile->ComplainFileRegularExpression.c_str()); - - // Now extract any include paths from the targets - std::set<std::string> uniqueIncludes; - std::vector<std::string> orderedAndUniqueIncludes; - cmTargets &targets = this->Makefile->GetTargets(); - for (cmTargets::iterator l = targets.begin(); - l != targets.end(); ++l) - { - const char *incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES"); - if (!incDirProp) - { - continue; - } - - std::string incDirs = cmGeneratorExpression::Preprocess(incDirProp, - cmGeneratorExpression::StripAllGeneratorExpressions); - - std::vector<std::string> includes; - cmSystemTools::ExpandListArgument(incDirs, includes); - - for(std::vector<std::string>::const_iterator j = includes.begin(); - j != includes.end(); ++j) - { - std::string path = *j; - this->Makefile->ExpandVariablesInString(path); - if(uniqueIncludes.insert(path).second) - { - orderedAndUniqueIncludes.push_back(path); - } - } - } - - for(std::vector<std::string>::const_iterator - it = orderedAndUniqueIncludes.begin(); - it != orderedAndUniqueIncludes.end(); - ++it) - { - this->AddSearchPath(*it); - } -} - - -const cmDependInformation* cmMakeDepend::FindDependencies(const char* file) -{ - cmDependInformation* info = this->GetDependInformation(file,0); - this->GenerateDependInformation(info); - return info; -} - -void cmMakeDepend::GenerateDependInformation(cmDependInformation* info) -{ - // If dependencies are already done, stop now. - if(info->DependDone) - { - return; - } - else - { - // Make sure we don't visit the same file more than once. - info->DependDone = true; - } - const char* path = info->FullPath.c_str(); - if(!path) - { - cmSystemTools::Error( - "Attempt to find dependencies for file without path!"); - return; - } - - bool found = false; - - // If the file exists, use it to find dependency information. - if(cmSystemTools::FileExists(path, true)) - { - // Use the real file to find its dependencies. - this->DependWalk(info); - found = true; - } - - - // See if the cmSourceFile for it has any files specified as - // dependency hints. - if(info->SourceFile != 0) - { - - // Get the cmSourceFile corresponding to this. - const cmSourceFile& cFile = *(info->SourceFile); - // See if there are any hints for finding dependencies for the missing - // file. - if(!cFile.GetDepends().empty()) - { - // Dependency hints have been given. Use them to begin the - // recursion. - for(std::vector<std::string>::const_iterator file = - cFile.GetDepends().begin(); file != cFile.GetDepends().end(); - ++file) - { - this->AddDependency(info, file->c_str()); - } - - // Found dependency information. We are done. - found = true; - } - } - - if(!found) - { - // Try to find the file amongst the sources - cmSourceFile *srcFile = this->Makefile->GetSource - (cmSystemTools::GetFilenameWithoutExtension(path)); - if (srcFile) - { - if (srcFile->GetFullPath() == path) - { - found=true; - } - else - { - //try to guess which include path to use - for(std::vector<std::string>::iterator t = - this->IncludeDirectories.begin(); - t != this->IncludeDirectories.end(); ++t) - { - std::string incpath = *t; - if (!incpath.empty() && incpath[incpath.size() - 1] != '/') - { - incpath = incpath + "/"; - } - incpath = incpath + path; - if (srcFile->GetFullPath() == incpath) - { - // set the path to the guessed path - info->FullPath = incpath; - found=true; - } - } - } - } - } - - if(!found) - { - // Couldn't find any dependency information. - if(this->ComplainFileRegularExpression.find(info->IncludeName.c_str())) - { - cmSystemTools::Error("error cannot find dependencies for ", path); - } - else - { - // Destroy the name of the file so that it won't be output as a - // dependency. - info->FullPath = ""; - } - } -} - -// This function actually reads the file specified and scans it for -// #include directives -void cmMakeDepend::DependWalk(cmDependInformation* info) -{ - cmsys::RegularExpression includeLine - ("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)[\">]"); - cmsys::ifstream fin(info->FullPath.c_str()); - if(!fin) - { - cmSystemTools::Error("Cannot open ", info->FullPath.c_str()); - return; - } - - // TODO: Write real read loop (see cmSystemTools::CopyFile). - std::string line; - while( cmSystemTools::GetLineFromStream(fin, line) ) - { - if(includeLine.find(line.c_str())) - { - // extract the file being included - std::string includeFile = includeLine.match(1); - // see if the include matches the regular expression - if(!this->IncludeFileRegularExpression.find(includeFile)) - { - if(this->Verbose) - { - std::string message = "Skipping "; - message += includeFile; - message += " for file "; - message += info->FullPath.c_str(); - cmSystemTools::Error(message.c_str(), 0); - } - continue; - } - - // Add this file and all its dependencies. - this->AddDependency(info, includeFile.c_str()); - } - } -} - - -void cmMakeDepend::AddDependency(cmDependInformation* info, const char* file) -{ - cmDependInformation* dependInfo = - this->GetDependInformation(file, info->PathOnly.c_str()); - this->GenerateDependInformation(dependInfo); - info->AddDependencies(dependInfo); -} - -cmDependInformation* cmMakeDepend::GetDependInformation(const char* file, - const char *extraPath) -{ - // Get the full path for the file so that lookup is unambiguous. - std::string fullPath = this->FullPath(file, extraPath); - - // Try to find the file's instance of cmDependInformation. - DependInformationMapType::const_iterator result = - this->DependInformationMap.find(fullPath); - if(result != this->DependInformationMap.end()) - { - // Found an instance, return it. - return result->second; - } - else - { - // Didn't find an instance. Create a new one and save it. - cmDependInformation* info = new cmDependInformation; - info->FullPath = fullPath; - info->PathOnly = cmSystemTools::GetFilenamePath(fullPath); - info->IncludeName = file; - this->DependInformationMap[fullPath] = info; - return info; - } -} - - -// find the full path to fname by searching the this->IncludeDirectories array -std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath) -{ - DirectoryToFileToPathMapType::iterator m; - if(extraPath) - { - m = this->DirectoryToFileToPathMap.find(extraPath); - } - else - { - m = this->DirectoryToFileToPathMap.find(""); - } - - if(m != this->DirectoryToFileToPathMap.end()) - { - FileToPathMapType& map = m->second; - FileToPathMapType::iterator p = map.find(fname); - if(p != map.end()) - { - return p->second; - } - } - - if(cmSystemTools::FileExists(fname, true)) - { - std::string fp = cmSystemTools::CollapseFullPath(fname); - this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; - return fp; - } - - for(std::vector<std::string>::iterator i = this->IncludeDirectories.begin(); - i != this->IncludeDirectories.end(); ++i) - { - std::string path = *i; - if (!path.empty() && path[path.size() - 1] != '/') - { - path = path + "/"; - } - path = path + fname; - if(cmSystemTools::FileExists(path.c_str(), true) - && !cmSystemTools::FileIsDirectory(path)) - { - std::string fp = cmSystemTools::CollapseFullPath(path); - this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; - return fp; - } - } - - if (extraPath) - { - std::string path = extraPath; - if (!path.empty() && path[path.size() - 1] != '/') - { - path = path + "/"; - } - path = path + fname; - if(cmSystemTools::FileExists(path.c_str(), true) - && !cmSystemTools::FileIsDirectory(path)) - { - std::string fp = cmSystemTools::CollapseFullPath(path); - this->DirectoryToFileToPathMap[extraPath][fname] = fp; - return fp; - } - } - - // Couldn't find the file. - return std::string(fname); -} - -// Add a directory to the search path -void cmMakeDepend::AddSearchPath(const std::string& path) -{ - this->IncludeDirectories.push_back(path); -} diff --git a/Source/cmMakeDepend.h b/Source/cmMakeDepend.h deleted file mode 100644 index 2c9d515..0000000 --- a/Source/cmMakeDepend.h +++ /dev/null @@ -1,150 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - 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 cmMakeDepend_h -#define cmMakeDepend_h - -#include "cmMakefile.h" -#include "cmSourceFile.h" - -#include <cmsys/RegularExpression.hxx> - -/** \class cmDependInformation - * \brief Store dependency information for a single source file. - * - * This structure stores the depend information for a single source file. - */ -class cmDependInformation -{ -public: - /** - * Construct with dependency generation marked not done; instance - * not placed in cmMakefile's list. - */ - cmDependInformation(): DependDone(false), SourceFile(0) {} - - /** - * The set of files on which this one depends. - */ - typedef std::set<cmDependInformation*> DependencySetType; - DependencySetType DependencySet; - - /** - * This flag indicates whether dependency checking has been - * performed for this file. - */ - bool DependDone; - - /** - * If this object corresponds to a cmSourceFile instance, this points - * to it. - */ - const cmSourceFile *SourceFile; - - /** - * Full path to this file. - */ - std::string FullPath; - - /** - * Full path not including file name. - */ - std::string PathOnly; - - /** - * Name used to #include this file. - */ - std::string IncludeName; - - /** - * This method adds the dependencies of another file to this one. - */ - void AddDependencies(cmDependInformation*); -}; - - -// cmMakeDepend is used to generate dependancy information for -// the classes in a makefile -class cmMakeDepend -{ -public: - /** - * Construct the object with verbose turned off. - */ - cmMakeDepend(); - - /** - * Destructor. - */ - virtual ~cmMakeDepend(); - - /** - * Set the makefile that is used as a source of classes. - */ - virtual void SetMakefile(cmMakefile* makefile); - - /** - * Add a directory to the search path for include files. - */ - virtual void AddSearchPath(const std::string&); - - /** - * Generate dependencies for the file given. Returns a pointer to - * the cmDependInformation object for the file. - */ - const cmDependInformation* FindDependencies(const char* file); - -protected: - /** - * Compute the depend information for this class. - */ - virtual void DependWalk(cmDependInformation* info); - - /** - * Add a dependency. Possibly walk it for more dependencies. - */ - virtual void AddDependency(cmDependInformation* info, const char* file); - - /** - * Fill in the given object with dependency information. If the - * information is already complete, nothing is done. - */ - void GenerateDependInformation(cmDependInformation* info); - - /** - * Get an instance of cmDependInformation corresponding to the given file - * name. - */ - cmDependInformation* GetDependInformation(const char* file, - const char *extraPath); - - /** - * Find the full path name for the given file name. - * This uses the include directories. - * TODO: Cache path conversions to reduce FileExists calls. - */ - std::string FullPath(const char *filename, const char *extraPath); - - cmMakefile* Makefile; - bool Verbose; - cmsys::RegularExpression IncludeFileRegularExpression; - cmsys::RegularExpression ComplainFileRegularExpression; - std::vector<std::string> IncludeDirectories; - typedef std::map<std::string, std::string> FileToPathMapType; - typedef std::map<std::string, FileToPathMapType> - DirectoryToFileToPathMapType; - typedef std::map<std::string, cmDependInformation*> - DependInformationMapType; - DependInformationMapType DependInformationMap; - DirectoryToFileToPathMapType DirectoryToFileToPathMap; -}; - -#endif diff --git a/Source/cmMakeDirectoryCommand.h b/Source/cmMakeDirectoryCommand.h index 71b97eb..617f1fe 100644 --- a/Source/cmMakeDirectoryCommand.h +++ b/Source/cmMakeDirectoryCommand.h @@ -51,12 +51,6 @@ public: */ virtual bool IsScriptable() const { return true; } - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - cmTypeMacro(cmMakeDirectoryCommand, cmCommand); }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8a3d197..264b169 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -50,15 +50,11 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, { this->IsSourceFileTryCompile = false; - // Initialize these first since AddDefaultDefinitions calls AddDefinition this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused(); this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars(); - this->Configured = false; this->SuppressWatches = false; - // Setup the default include file regular expression (match everything). - this->SetProperty("INCLUDE_REGULAR_EXPRESSION", "^.*$"); // Setup the default include complaint regular expression (match nothing). this->ComplainFileRegularExpression = "^$"; // Source and header file extensions that we can handle @@ -89,8 +85,6 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, this->DefineFlags = " "; - this->AddDefaultDefinitions(); - this->cmDefineRegex.compile("#cmakedefine[ \t]+([A-Za-z_0-9]*)"); this->cmDefine01Regex.compile("#cmakedefine01[ \t]+([A-Za-z_0-9]*)"); this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)"); @@ -120,17 +114,6 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, this->AddSourceGroup("Resources", "\\.plist$"); this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$"); #endif - - { - const char* dir = this->GetCMakeInstance()->GetHomeDirectory(); - this->AddDefinition("CMAKE_SOURCE_DIR", dir); - this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir); - } - { - const char* dir = this->GetCMakeInstance()->GetHomeOutputDirectory(); - this->AddDefinition("CMAKE_BINARY_DIR", dir); - this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir); - } } cmMakefile::~cmMakefile() @@ -143,9 +126,6 @@ cmMakefile::~cmMakefile() cmDeleteAll(this->FinalPassCommands); cmDeleteAll(this->FunctionBlockers); cmDeleteAll(this->EvaluationFiles); - this->EvaluationFiles.clear(); - - this->FunctionBlockers.clear(); } //---------------------------------------------------------------------------- @@ -687,6 +667,29 @@ cmMakefile::GetEvaluationFiles() const return this->EvaluationFiles; } +std::vector<cmExportBuildFileGenerator*> +cmMakefile::GetExportBuildFileGenerators() const +{ + return this->ExportBuildFileGenerators; +} + +void cmMakefile::RemoveExportBuildFileGeneratorCMP0024( + cmExportBuildFileGenerator* gen) +{ + std::vector<cmExportBuildFileGenerator*>::iterator it = + std::find(this->ExportBuildFileGenerators.begin(), + this->ExportBuildFileGenerators.end(), gen); + if(it != this->ExportBuildFileGenerators.end()) + { + this->ExportBuildFileGenerators.erase(it); + } +} + +void cmMakefile::AddExportBuildFileGenerator(cmExportBuildFileGenerator* gen) +{ + this->ExportBuildFileGenerators.push_back(gen); +} + namespace { struct file_not_persistent @@ -756,7 +759,7 @@ void cmMakefile::ConfigureFinalPass() for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end(); l++) { - if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + if (l->second.GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -807,7 +810,7 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target, return; } - if(ti->second.GetType() == cmTarget::OBJECT_LIBRARY) + if(ti->second.GetType() == cmState::OBJECT_LIBRARY) { std::ostringstream e; e << "Target \"" << target << "\" is an OBJECT library " @@ -815,7 +818,7 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target, this->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - if(ti->second.GetType() == cmTarget::INTERFACE_LIBRARY) + if(ti->second.GetType() == cmState::INTERFACE_LIBRARY) { std::ostringstream e; e << "Target \"" << target << "\" is an INTERFACE library " @@ -1181,7 +1184,7 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName, bool uses_terminal) { // Create a target instance for this utility. - cmTarget* target = this->AddNewTarget(cmTarget::UTILITY, utilityName); + cmTarget* target = this->AddNewTarget(cmState::UTILITY, utilityName); if (excludeFromAll) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); @@ -1397,7 +1400,7 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) } void cmMakefile::AddLinkLibrary(const std::string& lib, - cmTarget::LinkLibraryType llt) + cmTargetLinkLibraryType llt) { cmTarget::LibraryID tmp; tmp.first = lib; @@ -1407,7 +1410,7 @@ void cmMakefile::AddLinkLibrary(const std::string& lib, void cmMakefile::AddLinkLibraryForTarget(const std::string& target, const std::string& lib, - cmTarget::LinkLibraryType llt) + cmTargetLinkLibraryType llt) { cmTargets::iterator i = this->Targets.find(target); if ( i != this->Targets.end()) @@ -1416,14 +1419,14 @@ void cmMakefile::AddLinkLibraryForTarget(const std::string& target, if(tgt) { // if it is not a static or shared library then you can not link to it - if(!((tgt->GetType() == cmTarget::STATIC_LIBRARY) || - (tgt->GetType() == cmTarget::SHARED_LIBRARY) || - (tgt->GetType() == cmTarget::INTERFACE_LIBRARY) || + if(!((tgt->GetType() == cmState::STATIC_LIBRARY) || + (tgt->GetType() == cmState::SHARED_LIBRARY) || + (tgt->GetType() == cmState::INTERFACE_LIBRARY) || tgt->IsExecutableWithExports())) { std::ostringstream e; e << "Target \"" << lib << "\" of type " - << cmTarget::GetTargetTypeName(tgt->GetType()) + << cmState::GetTargetTypeName(tgt->GetType()) << " may not be linked into another target. " << "One may link only to STATIC or SHARED libraries, or " << "to executables with the ENABLE_EXPORTS property set."; @@ -1468,18 +1471,11 @@ void cmMakefile::AddLinkDirectoryForTarget(const std::string& target, void cmMakefile::AddLinkLibrary(const std::string& lib) { - this->AddLinkLibrary(lib,cmTarget::GENERAL); + this->AddLinkLibrary(lib,GENERAL_LibraryType); } void cmMakefile::InitializeFromParent(cmMakefile* parent) { - this->StateSnapshot.InitializeFromParent(); - - this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", - this->GetCurrentSourceDirectory()); - this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", - this->GetCurrentBinaryDirectory()); - this->SystemIncludeDirectories = parent->SystemIncludeDirectories; // define flags @@ -1518,7 +1514,7 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) parent->GetProperty("LINK_DIRECTORIES")); // the initial project name - this->SetProjectName(parent->GetProjectName()); + this->StateSnapshot.SetProjectName(parent->StateSnapshot.GetProjectName()); // Copy include regular expressions. this->ComplainFileRegularExpression = parent->ComplainFileRegularExpression; @@ -1658,7 +1654,6 @@ void cmMakefile::Configure() cmParseFileScope pfs(this); if (!listFile.ParseFile(currentStart.c_str(), this->IsRootMakefile(), this)) { - this->SetConfigured(); return; } } @@ -1675,11 +1670,11 @@ void cmMakefile::Configure() std::vector<cmMakefile*>::iterator sdi = subdirs.begin(); for (; sdi != subdirs.end(); ++sdi) { + (*sdi)->StateSnapshot.InitializeFromParent_ForSubdirsCommand(); this->ConfigureSubDirectory(*sdi); } this->AddCMakeDependFilesFromUser(); - this->SetConfigured(); } void cmMakefile::ConfigureSubDirectory(cmMakefile *mf) @@ -1723,7 +1718,6 @@ void cmMakefile::ConfigureSubDirectory(cmMakefile *mf) // NEW behavior prints the error. this->IssueMessage(cmake::FATAL_ERROR, e.str()); } - mf->SetConfigured(); return; } // finally configure the subdir @@ -1753,17 +1747,14 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, this->ContextStack.back()->Name, this->ContextStack.back()->Line); + newSnapshot.GetDirectory().SetCurrentSource(srcPath); + newSnapshot.GetDirectory().SetCurrentBinary(binPath); + + cmSystemTools::MakeDirectory(binPath.c_str()); + cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot); this->GetGlobalGenerator()->AddMakefile(subMf); - // create a new local generator and set its parent - cmLocalGenerator *lg2 = this->GetGlobalGenerator() - ->CreateLocalGenerator(subMf); - this->GetGlobalGenerator()->AddLocalGenerator(lg2); - - // set the subdirs start dirs - subMf->SetCurrentSourceDirectory(srcPath); - subMf->SetCurrentBinaryDirectory(binPath); if(excludeFromAll) { subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); @@ -1779,37 +1770,16 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, } } -void cmMakefile::SetCurrentSourceDirectory(const std::string& dir) -{ - this->StateSnapshot.GetDirectory().SetCurrentSource(dir); - this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", - this->StateSnapshot.GetDirectory().GetCurrentSource()); -} - const char* cmMakefile::GetCurrentSourceDirectory() const { return this->StateSnapshot.GetDirectory().GetCurrentSource(); } -void cmMakefile::SetCurrentBinaryDirectory(const std::string& dir) -{ - this->StateSnapshot.GetDirectory().SetCurrentBinary(dir); - const char* binDir = this->StateSnapshot.GetDirectory().GetCurrentBinary(); - cmSystemTools::MakeDirectory(binDir); - this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", binDir); -} - const char* cmMakefile::GetCurrentBinaryDirectory() const { return this->StateSnapshot.GetDirectory().GetCurrentBinary(); } -void cmMakefile::AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt) -{ - this->GeneratorTargets[t] = gt; - this->GetGlobalGenerator()->AddGeneratorTarget(t, gt); -} - //---------------------------------------------------------------------------- void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs, bool before) @@ -1920,13 +1890,13 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, nvalue += files[cc]; } - this->GetState()->AddCacheEntry(name, nvalue.c_str(), doc, type); + this->GetCMakeInstance()->AddCacheEntry(name, nvalue.c_str(), doc, type); val = this->GetState()->GetInitializedCacheValue(name); haveVal = true; } } - this->GetState()->AddCacheEntry(name, haveVal ? val.c_str() : 0, + this->GetCMakeInstance()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc, type); // if there was a definition then remove it this->StateSnapshot.RemoveDefinition(name); @@ -2042,20 +2012,15 @@ void cmMakefile::SetProjectName(std::string const& p) this->StateSnapshot.SetProjectName(p); } -std::string cmMakefile::GetProjectName() const -{ - return this->StateSnapshot.GetProjectName(); -} - void cmMakefile::AddGlobalLinkInformation(const std::string& name, cmTarget& target) { // for these targets do not add anything switch(target.GetType()) { - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: - case cmTarget::INTERFACE_LIBRARY: + case cmState::UTILITY: + case cmState::GLOBAL_TARGET: + case cmState::INTERFACE_LIBRARY: return; default:; } @@ -2092,20 +2057,20 @@ void cmMakefile::AddAlias(const std::string& lname, cmTarget *tgt) } cmTarget* cmMakefile::AddLibrary(const std::string& lname, - cmTarget::TargetType type, + cmState::TargetType type, const std::vector<std::string> &srcs, bool excludeFromAll) { // wrong type ? default to STATIC - if ( (type != cmTarget::STATIC_LIBRARY) - && (type != cmTarget::SHARED_LIBRARY) - && (type != cmTarget::MODULE_LIBRARY) - && (type != cmTarget::OBJECT_LIBRARY) - && (type != cmTarget::INTERFACE_LIBRARY)) + if ( (type != cmState::STATIC_LIBRARY) + && (type != cmState::SHARED_LIBRARY) + && (type != cmState::MODULE_LIBRARY) + && (type != cmState::OBJECT_LIBRARY) + && (type != cmState::INTERFACE_LIBRARY)) { this->IssueMessage(cmake::INTERNAL_ERROR, "cmMakefile::AddLibrary given invalid target type."); - type = cmTarget::STATIC_LIBRARY; + type = cmState::STATIC_LIBRARY; } cmTarget* target = this->AddNewTarget(type, lname); @@ -2126,7 +2091,7 @@ cmTarget* cmMakefile::AddExecutable(const char *exeName, const std::vector<std::string> &srcs, bool excludeFromAll) { - cmTarget* target = this->AddNewTarget(cmTarget::EXECUTABLE, exeName); + cmTarget* target = this->AddNewTarget(cmState::EXECUTABLE, exeName); if(excludeFromAll) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); @@ -2138,7 +2103,7 @@ cmTarget* cmMakefile::AddExecutable(const char *exeName, //---------------------------------------------------------------------------- cmTarget* -cmMakefile::AddNewTarget(cmTarget::TargetType type, const std::string& name) +cmMakefile::AddNewTarget(cmState::TargetType type, const std::string& name) { cmTargets::iterator it = this->Targets.insert(cmTargets::value_type(name, cmTarget())).first; @@ -2334,8 +2299,8 @@ void cmMakefile::ExpandVariablesCMP0019() l != this->Targets.end(); ++l) { cmTarget &t = l->second; - if (t.GetType() == cmTarget::INTERFACE_LIBRARY - || t.GetType() == cmTarget::GLOBAL_TARGET) + if (t.GetType() == cmState::INTERFACE_LIBRARY + || t.GetType() == cmState::GLOBAL_TARGET) { continue; } @@ -3172,62 +3137,10 @@ void cmMakefile::RemoveVariablesInString(std::string& source, } } -/** - * Add the default definitions to the makefile. These values must not - * be dependent on anything that isn't known when this cmMakefile instance - * is constructed. - */ -void cmMakefile::AddDefaultDefinitions() -{ -/* Up to CMake 2.4 here only WIN32, UNIX and APPLE were set. - With CMake must separate between target and host platform. In most cases - the tests for WIN32, UNIX and APPLE will be for the target system, so an - additional set of variables for the host system is required -> - CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE. - WIN32, UNIX and APPLE are now set in the platform files in - Modules/Platforms/. - To keep cmake scripts (-P) and custom language and compiler modules - working, these variables are still also set here in this place, but they - will be reset in CMakeSystemSpecificInformation.cmake before the platform - files are executed. */ -#if defined(_WIN32) - this->AddDefinition("WIN32", "1"); - this->AddDefinition("CMAKE_HOST_WIN32", "1"); -#else - this->AddDefinition("UNIX", "1"); - this->AddDefinition("CMAKE_HOST_UNIX", "1"); -#endif -#if defined(__CYGWIN__) - if(cmSystemTools::IsOn(cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32"))) - { - this->AddDefinition("WIN32", "1"); - this->AddDefinition("CMAKE_HOST_WIN32", "1"); - } -#endif -#if defined(__APPLE__) - this->AddDefinition("APPLE", "1"); - this->AddDefinition("CMAKE_HOST_APPLE", "1"); -#endif - - char temp[1024]; - sprintf(temp, "%d", cmVersion::GetMinorVersion()); - this->AddDefinition("CMAKE_MINOR_VERSION", temp); - sprintf(temp, "%d", cmVersion::GetMajorVersion()); - this->AddDefinition("CMAKE_MAJOR_VERSION", temp); - sprintf(temp, "%d", cmVersion::GetPatchVersion()); - this->AddDefinition("CMAKE_PATCH_VERSION", temp); - sprintf(temp, "%d", cmVersion::GetTweakVersion()); - this->AddDefinition("CMAKE_TWEAK_VERSION", temp); - this->AddDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion()); - - this->AddDefinition("CMAKE_FILES_DIRECTORY", - cmake::GetCMakeFilesDirectory()); -} - //---------------------------------------------------------------------------- std::string cmMakefile::GetConfigurations(std::vector<std::string>& configs, - bool single) const + bool singleConfig) const { if(this->GetGlobalGenerator()->IsMultiConfig()) { @@ -3241,7 +3154,7 @@ cmMakefile::GetConfigurations(std::vector<std::string>& configs, else { const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE"); - if(single && !buildType.empty()) + if(singleConfig && !buildType.empty()) { configs.push_back(buildType); } @@ -4265,7 +4178,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef) //---------------------------------------------------------------------------- cmTarget* cmMakefile::AddImportedTarget(const std::string& name, - cmTarget::TargetType type, + cmState::TargetType type, bool global) { // Create the target. @@ -4318,17 +4231,6 @@ bool cmMakefile::IsAlias(const std::string& name) const } //---------------------------------------------------------------------------- -cmGeneratorTarget* -cmMakefile::FindGeneratorTargetToUse(const std::string& name) const -{ - if (cmTarget *t = this->FindTargetToUse(name)) - { - return this->GetGlobalGenerator()->GetGeneratorTarget(t); - } - return 0; -} - -//---------------------------------------------------------------------------- bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, bool isCustom) const { @@ -4377,7 +4279,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, // The conflict is with a non-imported target. // Allow this if the user has requested support. cmake* cm = this->GetCMakeInstance(); - if(isCustom && existing->GetType() == cmTarget::UTILITY && + if(isCustom && existing->GetType() == cmState::UTILITY && this != existing->GetMakefile() && cm->GetState() ->GetGlobalPropertyAsBool("ALLOW_DUPLICATE_CUSTOM_TARGETS")) @@ -4393,22 +4295,22 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, << "The existing target is "; switch(existing->GetType()) { - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: e << "an executable "; break; - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: e << "a static library "; break; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: e << "a shared library "; break; - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: e << "a module library "; break; - case cmTarget::UTILITY: + case cmState::UTILITY: e << "a custom target "; break; - case cmTarget::INTERFACE_LIBRARY: + case cmState::INTERFACE_LIBRARY: e << "an interface library "; break; default: break; @@ -4667,9 +4569,10 @@ bool cmMakefile::SetPolicyVersion(const char *version) } //---------------------------------------------------------------------------- -bool cmMakefile::HasCMP0054AlreadyBeenReported() const +bool cmMakefile::HasCMP0054AlreadyBeenReported( + cmListFileContext const& context) const { - return !this->CMP0054ReportedIds.insert(this->GetExecutionContext()).second; + return !this->CMP0054ReportedIds.insert(context).second; } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 3cf20a6..725448b 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -17,7 +17,6 @@ #include "cmSystemTools.h" #include "cmTarget.h" #include "cmNewLineStyle.h" -#include "cmGeneratorTarget.h" #include "cmExpandedCommandArgument.h" #include "cmake.h" #include "cmState.h" @@ -42,7 +41,6 @@ class cmFunctionBlocker; class cmCommand; class cmInstallGenerator; -class cmMakeDepend; class cmSourceFile; class cmTest; class cmTestGenerator; @@ -51,6 +49,7 @@ class cmake; class cmMakefileCall; class cmCMakePolicyCommand; class cmGeneratorExpressionEvaluationFile; +class cmExportBuildFileGenerator; /** \class cmMakefile * \brief Process the input CMakeLists.txt file. @@ -172,10 +171,10 @@ public: /** Create a new imported target with the name and type given. */ cmTarget* AddImportedTarget(const std::string& name, - cmTarget::TargetType type, + cmState::TargetType type, bool global); - cmTarget* AddNewTarget(cmTarget::TargetType type, const std::string& name); + cmTarget* AddNewTarget(cmState::TargetType type, const std::string& name); /** * Add an executable to the build. @@ -219,9 +218,9 @@ public: * Add a link library to the build. */ void AddLinkLibrary(const std::string&); - void AddLinkLibrary(const std::string&, cmTarget::LinkLibraryType type); + void AddLinkLibrary(const std::string&, cmTargetLinkLibraryType type); void AddLinkLibraryForTarget(const std::string& tgt, const std::string&, - cmTarget::LinkLibraryType type); + cmTargetLinkLibraryType type); void AddLinkDirectoryForTarget(const std::string& tgt, const std::string& d); /** @@ -274,11 +273,6 @@ public: */ void SetProjectName(std::string const& name); - /** - * Get the name of the project for this build. - */ - std::string GetProjectName() const; - /** Get the configurations to be generated. */ std::string GetConfigurations(std::vector<std::string>& configs, bool single = true) const; @@ -286,7 +280,7 @@ public: /** * Set the name of the library. */ - cmTarget* AddLibrary(const std::string& libname, cmTarget::TargetType type, + cmTarget* AddLibrary(const std::string& libname, cmState::TargetType type, const std::vector<std::string> &srcs, bool excludeFromAll = false); void AddAlias(const std::string& libname, cmTarget *tgt); @@ -336,7 +330,7 @@ public: * Determine if the given context, name pair has already been reported * in context of CMP0054. */ - bool HasCMP0054AlreadyBeenReported() const; + bool HasCMP0054AlreadyBeenReported(const cmListFileContext &context) const; bool IgnoreErrorsCMP0061() const; @@ -353,9 +347,7 @@ public: */ void SetArgcArgv(const std::vector<std::string>& args); - void SetCurrentSourceDirectory(const std::string& dir); const char* GetCurrentSourceDirectory() const; - void SetCurrentBinaryDirectory(const std::string& dir); const char* GetCurrentBinaryDirectory() const; //@} @@ -399,17 +391,6 @@ public: return this->ImportedTargetsOwned; } - const cmGeneratorTargetsType &GetGeneratorTargets() const - { - return this->GeneratorTargets; - } - - void SetGeneratorTargets(const cmGeneratorTargetsType &targets) - { - this->GeneratorTargets = targets; - } - void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt); - cmTarget* FindTarget(const std::string& name, bool excludeAliases = false) const; @@ -418,7 +399,6 @@ public: cmTarget* FindTargetToUse(const std::string& name, bool excludeAliases = false) const; bool IsAlias(const std::string& name) const; - cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const; /** * Mark include directories as system directories. @@ -750,9 +730,6 @@ public: cmStringRange GetCompileDefinitionsEntries() const; cmBacktraceRange GetCompileDefinitionsBacktraces() const; - bool IsConfigured() const { return this->Configured; } - void SetConfigured(){ this->Configured = true; } - void AddQtUiFileWithOptions(cmSourceFile *sf); std::vector<cmSourceFile*> GetQtUiFilesWithOptions() const; @@ -799,6 +776,11 @@ public: bool inputIsContent); std::vector<cmGeneratorExpressionEvaluationFile*> GetEvaluationFiles() const; + std::vector<cmExportBuildFileGenerator*> + GetExportBuildFileGenerators() const; + void RemoveExportBuildFileGeneratorCMP0024(cmExportBuildFileGenerator* gen); + void AddExportBuildFileGenerator(cmExportBuildFileGenerator* gen); + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const std::string& name, cmTarget& target); @@ -820,7 +802,6 @@ protected: typedef std::map<std::string, cmTarget*> TargetMap; #endif TargetMap AliasTargets; - cmGeneratorTargetsType GeneratorTargets; std::vector<cmSourceFile*> SourceFiles; // Tests @@ -874,10 +855,6 @@ private: bool EnforceUniqueDir(const std::string& srcPath, const std::string& binPath) const; - friend class cmMakeDepend; // make depend needs direct access - // to the Sources array - - void AddDefaultDefinitions(); typedef std::vector<cmFunctionBlocker*> FunctionBlockersType; FunctionBlockersType FunctionBlockers; std::vector<FunctionBlockersType::size_type> FunctionBlockerBarriers; @@ -892,6 +869,7 @@ private: mutable cmsys::RegularExpression cmNamedCurly; std::vector<cmMakefile*> UnConfiguredDirectories; + std::vector<cmExportBuildFileGenerator*> ExportBuildFileGenerators; std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles; @@ -988,7 +966,6 @@ private: bool WarnUnused; bool CheckSystemVars; bool CheckCMP0000; - bool Configured; bool IsSourceFileTryCompile; mutable bool SuppressWatches; }; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index ccb0974..020e64c 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -99,8 +99,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->ConfigName); // Construct the full path version of the names. - std::string outpath = this->Target->GetDirectory(this->ConfigName); - if(this->Target->IsAppBundleOnApple()) + std::string outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); + if(this->GeneratorTarget->IsAppBundleOnApple()) { this->OSXBundleGenerator->CreateAppBundle(targetName, outpath); } @@ -123,7 +123,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmSystemTools::MakeDirectory(outpath.c_str()); if(!targetNameImport.empty()) { - outpathImp = this->Target->GetDirectory(this->ConfigName, true); + outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true); cmSystemTools::MakeDirectory(outpathImp.c_str()); outpathImp += "/"; } @@ -133,7 +133,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); - std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); + std::string pdbOutputPath = + this->GeneratorTarget->GetPDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(pdbOutputPath.c_str()); pdbOutputPath += "/"; @@ -167,7 +168,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) if(linkLanguage.empty()) { cmSystemTools::Error("Cannot determine link language for target \"", - this->Target->GetName().c_str(), "\"."); + this->GeneratorTarget->GetName().c_str(), "\"."); return; } @@ -196,7 +197,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->ConfigName); - if(this->Target->GetPropertyAsBool("WIN32_EXECUTABLE")) + if(this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) { this->LocalGenerator->AppendFlags (linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE")); @@ -208,7 +209,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } // Add symbol export flags if necessary. - if(this->Target->IsExecutableWithExports()) + if(this->GeneratorTarget->IsExecutableWithExports()) { std::string export_flag_var = "CMAKE_EXE_EXPORTS_"; export_flag_var += linkLanguage; @@ -225,11 +226,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Add target-specific linker flags. this->LocalGenerator->AppendFlags - (linkFlags, this->Target->GetProperty("LINK_FLAGS")); + (linkFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS")); std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (linkFlags, this->Target->GetProperty(linkFlagsConfig)); + (linkFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig)); this->AddModuleDefinitionFlag(linkFlags); @@ -258,7 +259,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); std::string implib; - if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) + if(this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib)) { exeCleanFiles.push_back(this->Convert(implib, cmLocalGenerator::START_OUTPUT, @@ -279,10 +280,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) { this->LocalGenerator ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(), - this->Target); + this->GeneratorTarget); this->LocalGenerator ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(), - this->Target); + this->GeneratorTarget); } // Determine whether a link script will be used. @@ -296,7 +297,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string linkRule = this->GetLinkRule(linkRuleVar); std::vector<std::string> commands1; cmSystemTools::ExpandListArgument(linkRule, real_link_commands); - if(this->Target->IsExecutableWithExports()) + if(this->GeneratorTarget->IsExecutableWithExports()) { // If a separate rule for creating an import library is specified // add it now. @@ -353,12 +354,14 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) useResponseFileForObjects, buildObjs, depends, useWatcomQuote); + std::string manifests = this->GetManifests(); + cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_LINK"; - vars.CMTarget = this->Target; + vars.CMTarget = this->GeneratorTarget; vars.Language = linkLanguage.c_str(); vars.Objects = buildObjs.c_str(); - std::string objectDir = this->Target->GetSupportDirectory(); + std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); objectDir = this->Convert(objectDir, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); @@ -379,7 +382,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::ostringstream minorStream; int major; int minor; - this->Target->GetTargetVersion(major, minor); + this->GeneratorTarget->GetTargetVersion(major, minor); majorStream << major; minorStream << minor; targetVersionMajor = majorStream.str(); @@ -391,6 +394,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) vars.LinkLibraries = linkLibs.c_str(); vars.Flags = flags.c_str(); vars.LinkFlags = linkFlags.c_str(); + vars.Manifests = manifests.c_str(); + // Expand placeholders in the commands. this->LocalGenerator->TargetImplib = targetOutPathImport; for(std::vector<std::string>::iterator i = real_link_commands.begin(); @@ -444,7 +449,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) { this->LocalGenerator-> AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), - this->Target); + this->GeneratorTarget); } // Write the build rule. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 2f995e8..df2a8c9 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -26,7 +26,7 @@ cmMakefileLibraryTargetGenerator cmMakefileTargetGenerator(target) { this->CustomCommandDriver = OnDepends; - if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) + if (this->GeneratorTarget->GetType() != cmState::INTERFACE_LIBRARY) { this->GeneratorTarget->GetLibraryNames( this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, @@ -62,12 +62,12 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() // write the link rules // Write the rule for this target type. - switch(this->Target->GetType()) + switch(this->GeneratorTarget->GetType()) { - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: this->WriteStaticLibraryRules(); break; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: this->WriteSharedLibraryRules(false); if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { @@ -75,7 +75,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() this->WriteSharedLibraryRules(true); } break; - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: this->WriteModuleLibraryRules(false); if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { @@ -83,7 +83,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() this->WriteModuleLibraryRules(true); } break; - case cmTarget::OBJECT_LIBRARY: + case cmState::OBJECT_LIBRARY: this->WriteObjectLibraryRules(); break; default: @@ -115,18 +115,18 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() // Add post-build rules. this->LocalGenerator-> AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), - this->Target); + this->GeneratorTarget); // Depend on the object files. this->AppendObjectDepends(depends); // Write the rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - this->Target->GetName(), + this->GeneratorTarget->GetName(), depends, commands, true); // Write the main driver rule to build everything in this target. - this->WriteTargetDriverRule(this->Target->GetName(), false); + this->WriteTargetDriverRule(this->GeneratorTarget->GetName(), false); } //---------------------------------------------------------------------------- @@ -146,14 +146,14 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() std::string extraFlags; this->LocalGenerator->GetStaticLibraryFlags(extraFlags, - cmSystemTools::UpperCase(this->ConfigName), this->Target); + cmSystemTools::UpperCase(this->ConfigName), this->GeneratorTarget); this->WriteLibraryRules(linkRuleVar, extraFlags, false); } //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) { - if(this->Target->IsFrameworkOnApple()) + if(this->GeneratorTarget->IsFrameworkOnApple()) { this->WriteFrameworkRules(relink); return; @@ -166,11 +166,11 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) std::string extraFlags; this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty("LINK_FLAGS")); + (extraFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS")); std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty(linkFlagsConfig)); + (extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig)); this->LocalGenerator->AddConfigVariableFlags (extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName); @@ -190,11 +190,11 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) std::string extraFlags; this->LocalGenerator->AppendFlags(extraFlags, - this->Target->GetProperty("LINK_FLAGS")); + this->GeneratorTarget->GetProperty("LINK_FLAGS")); std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty(linkFlagsConfig)); + (extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig)); this->LocalGenerator->AddConfigVariableFlags (extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName); this->AddModuleDefinitionFlag(extraFlags); @@ -213,11 +213,11 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) std::string extraFlags; this->LocalGenerator->AppendFlags(extraFlags, - this->Target->GetProperty("LINK_FLAGS")); + this->GeneratorTarget->GetProperty("LINK_FLAGS")); std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty(linkFlagsConfig)); + (extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig)); this->LocalGenerator->AddConfigVariableFlags (extraFlags, "CMAKE_MACOSX_FRAMEWORK_LINKER_FLAGS", this->ConfigName); @@ -244,7 +244,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules if(linkLanguage.empty()) { cmSystemTools::Error("Cannot determine link language for target \"", - this->Target->GetName().c_str(), "\"."); + this->GeneratorTarget->GetName().c_str(), "\"."); return; } @@ -253,8 +253,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules this->LocalGenerator->AppendFlags(linkFlags, extraFlags); // Add OSX version flags, if any. - if(this->Target->GetType() == cmTarget::SHARED_LIBRARY || - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + if(this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || + this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) { this->AppendOSXVerFlag(linkFlags, linkLanguage, "COMPATIBILITY", true); this->AppendOSXVerFlag(linkFlags, linkLanguage, "CURRENT", false); @@ -273,15 +273,15 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Construct the full path version of the names. std::string outpath; std::string outpathImp; - if(this->Target->IsFrameworkOnApple()) + if(this->GeneratorTarget->IsFrameworkOnApple()) { - outpath = this->Target->GetDirectory(this->ConfigName); + outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); this->OSXBundleGenerator->CreateFramework(targetName, outpath); outpath += "/"; } - else if(this->Target->IsCFBundleOnApple()) + else if(this->GeneratorTarget->IsCFBundleOnApple()) { - outpath = this->Target->GetDirectory(this->ConfigName); + outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); this->OSXBundleGenerator->CreateCFBundle(targetName, outpath); outpath += "/"; } @@ -299,12 +299,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } else { - outpath = this->Target->GetDirectory(this->ConfigName); + outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); cmSystemTools::MakeDirectory(outpath.c_str()); outpath += "/"; if(!targetNameImport.empty()) { - outpathImp = this->Target->GetDirectory(this->ConfigName, true); + outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true); cmSystemTools::MakeDirectory(outpathImp.c_str()); outpathImp += "/"; } @@ -314,7 +314,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); - std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); + std::string pdbOutputPath = + this->GeneratorTarget->GetPDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(pdbOutputPath.c_str()); pdbOutputPath += "/"; @@ -350,16 +351,16 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Add the link message. std::string buildEcho = "Linking "; buildEcho += linkLanguage; - switch(this->Target->GetType()) + switch(this->GeneratorTarget->GetType()) { - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: buildEcho += " static library "; break; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: buildEcho += " shared library "; break; - case cmTarget::MODULE_LIBRARY: - if (this->Target->IsCFBundleOnApple()) + case cmState::MODULE_LIBRARY: + if (this->GeneratorTarget->IsCFBundleOnApple()) buildEcho += " CFBundle"; buildEcho += " shared module "; break; @@ -374,12 +375,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } const char* forbiddenFlagVar = 0; - switch(this->Target->GetType()) + switch(this->GeneratorTarget->GetType()) { - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: forbiddenFlagVar = "_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS"; break; - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: forbiddenFlagVar = "_CREATE_SHARED_MODULE_FORBIDDEN_FLAGS"; break; default: break; @@ -409,7 +410,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); std::string implib; - if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) + if(this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib)) { libCleanFiles.push_back(this->Convert(implib, cmLocalGenerator::START_OUTPUT, @@ -428,7 +429,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules #ifdef _WIN32 // There may be a manifest file for this target. Add it to the // clean set just in case. - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY) { libCleanFiles.push_back( this->Convert((targetFullPath+".manifest").c_str(), @@ -440,10 +441,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::vector<std::string> commands1; // Add a command to remove any existing files for this library. // for static libs only - if(this->Target->GetType() == cmTarget::STATIC_LIBRARY) + if(this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) { this->LocalGenerator->AppendCleanCommand(commands1, libCleanFiles, - *this->Target, "target"); + this->GeneratorTarget, "target"); this->LocalGenerator->CreateCDCommand (commands1, this->Makefile->GetCurrentBinaryDirectory(), @@ -457,10 +458,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { this->LocalGenerator ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(), - this->Target); + this->GeneratorTarget); this->LocalGenerator ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(), - this->Target); + this->GeneratorTarget); } // Determine whether a link script will be used. @@ -496,7 +497,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::vector<std::string> archiveAppendCommands; std::vector<std::string> archiveFinishCommands; std::string::size_type archiveCommandLimit = std::string::npos; - if(this->Target->GetType() == cmTarget::STATIC_LIBRARY) + if(this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) { haveStaticLibraryRule = this->Makefile->GetDefinition(linkRuleVar)? true:false; @@ -551,7 +552,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Collect up flags to link in needed libraries. std::string linkLibs; - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY) { this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends, useWatcomQuote); @@ -565,15 +566,15 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules useWatcomQuote); // maybe create .def file from list of objects - if (this->Target->GetType() == cmTarget::SHARED_LIBRARY && + if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { - if(this->Target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) + if(this->GeneratorTarget->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { std::string name_of_def_file = - this->Target->GetSupportDirectory(); + this->GeneratorTarget->GetSupportDirectory(); name_of_def_file += std::string("/") + - this->Target->GetName(); + this->GeneratorTarget->GetName(); name_of_def_file += ".def"; std::string cmd = cmSystemTools::GetCMakeCommand(); cmd = this->Convert(cmd, cmLocalGenerator::NONE, @@ -616,6 +617,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } } + std::string manifests = this->GetManifests(); + cmLocalGenerator::RuleVariables vars; vars.TargetPDB = targetOutPathPDB.c_str(); @@ -627,7 +630,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::ostringstream minorStream; int major; int minor; - this->Target->GetTargetVersion(major, minor); + this->GeneratorTarget->GetTargetVersion(major, minor); majorStream << major; minorStream << minor; targetVersionMajor = majorStream.str(); @@ -637,10 +640,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.TargetVersionMinor = targetVersionMinor.c_str(); vars.RuleLauncher = "RULE_LAUNCH_LINK"; - vars.CMTarget = this->Target; + vars.CMTarget = this->GeneratorTarget; vars.Language = linkLanguage.c_str(); vars.Objects = buildObjs.c_str(); - std::string objectDir = this->Target->GetSupportDirectory(); + std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); objectDir = this->Convert(objectDir, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); @@ -660,9 +663,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } vars.LinkFlags = linkFlags.c_str(); + vars.Manifests = manifests.c_str(); + // Compute the directory portion of the install_name setting. std::string install_name_dir; - if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) + if(this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY) { // Get the install_name directory for the build tree. install_name_dir = @@ -786,7 +791,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Add a rule to create necessary symlinks for the library. // Frameworks are handled by cmOSXBundleGenerator. - if(targetOutPath != targetOutPathReal && !this->Target->IsFrameworkOnApple()) + if(targetOutPath != targetOutPathReal + && !this->GeneratorTarget->IsFrameworkOnApple()) { std::string symlink = "$(CMAKE_COMMAND) -E cmake_symlink_library "; symlink += targetOutPathReal; @@ -806,7 +812,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { this->LocalGenerator-> AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), - this->Target); + this->GeneratorTarget); } // Compute the list of outputs. @@ -857,7 +863,7 @@ cmMakefileLibraryTargetGenerator int major; int minor; int patch; - this->Target->GetTargetVersion(so, major, minor, patch); + this->GeneratorTarget->GetTargetVersion(so, major, minor, patch); if(major > 0 || minor > 0 || patch > 0) { // Append the flag since a non-zero version is specified. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index cf88a74..b7970fd 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -68,16 +68,16 @@ cmMakefileTargetGenerator::New(cmGeneratorTarget *tgt) switch (tgt->GetType()) { - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: result = new cmMakefileExecutableTargetGenerator(tgt); break; - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - case cmTarget::OBJECT_LIBRARY: + case cmState::STATIC_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: + case cmState::OBJECT_LIBRARY: result = new cmMakefileLibraryTargetGenerator(tgt); break; - case cmTarget::UTILITY: + case cmState::UTILITY: result = new cmMakefileUtilityTargetGenerator(tgt); break; default: @@ -92,7 +92,7 @@ void cmMakefileTargetGenerator::CreateRuleFile() { // Create a directory for this target. this->TargetBuildDirectory = - this->LocalGenerator->GetTargetDirectory(*this->Target); + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->TargetBuildDirectoryFull = this->LocalGenerator->ConvertToFullPath(this->TargetBuildDirectory); cmSystemTools::MakeDirectory(this->TargetBuildDirectoryFull.c_str()); @@ -147,8 +147,11 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(additional_clean_files); - cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile, config, - false, this->Target, 0, 0), + cmSystemTools::ExpandListArgument(cge->Evaluate(this->LocalGenerator, + config, + false, + this->GeneratorTarget, + 0, 0), this->CleanFiles); } @@ -245,7 +248,8 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() // Write an empty dependency file. cmGeneratedFileStream depFileStream(dependFileNameFull.c_str()); depFileStream - << "# Empty dependencies file for " << this->Target->GetName() << ".\n" + << "# Empty dependencies file for " + << this->GeneratorTarget->GetName() << ".\n" << "# This may be replaced when dependencies are built." << std::endl; } @@ -375,7 +379,8 @@ void cmMakefileTargetGenerator // Get the full path name of the object file. std::string const& objectName = this->GeneratorTarget ->GetObjectName(&source); - std::string obj = this->LocalGenerator->GetTargetDirectory(*this->Target); + std::string obj = + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); obj += "/"; obj += objectName; @@ -390,7 +395,7 @@ void cmMakefileTargetGenerator err << "Warning: Source file \"" << source.GetFullPath() << "\" is listed multiple times for target \"" - << this->Target->GetName() + << this->GeneratorTarget->GetName() << "\"."; cmSystemTools::Message(err.str().c_str(), "Warning"); return; @@ -419,7 +424,7 @@ void cmMakefileTargetGenerator this->WriteObjectBuildFile(obj, lang, source, depends); // The object file should be checked for dependency integrity. - std::string objFullPath = this->Makefile->GetCurrentBinaryDirectory(); + std::string objFullPath = this->LocalGenerator->GetCurrentBinaryDirectory(); objFullPath += "/"; objFullPath += obj; objFullPath = @@ -539,24 +544,26 @@ cmMakefileTargetGenerator std::string targetFullPathReal; std::string targetFullPathPDB; std::string targetFullPathCompilePDB; - if(this->Target->GetType() == cmTarget::EXECUTABLE || - this->Target->GetType() == cmTarget::STATIC_LIBRARY || - this->Target->GetType() == cmTarget::SHARED_LIBRARY || - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + if(this->GeneratorTarget->GetType() == cmState::EXECUTABLE || + this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY || + this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || + this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) { targetFullPathReal = this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); - targetFullPathPDB = this->Target->GetPDBDirectory(this->ConfigName); + targetFullPathPDB = + this->GeneratorTarget->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName); } - if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) + if(this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) { targetFullPathCompilePDB = this->GeneratorTarget->GetCompilePDBPath(this->ConfigName); if(targetFullPathCompilePDB.empty()) { - targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; + targetFullPathCompilePDB = + this->GeneratorTarget->GetSupportDirectory() + "/"; } } @@ -582,7 +589,7 @@ cmMakefileTargetGenerator } cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; - vars.CMTarget = this->Target; + vars.CMTarget = this->GeneratorTarget; vars.Language = lang.c_str(); vars.Target = targetOutPathReal.c_str(); vars.TargetPDB = targetOutPathPDB.c_str(); @@ -593,7 +600,7 @@ cmMakefileTargetGenerator cmLocalGenerator::NONE, cmLocalGenerator::SHELL); vars.Object = shellObj.c_str(); - std::string objectDir = this->Target->GetSupportDirectory(); + std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); objectDir = this->Convert(objectDir, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); @@ -642,7 +649,8 @@ cmMakefileTargetGenerator this->LocalGenerator->ExpandRuleVariables(compileCommand, vars); std::string workingDirectory = this->LocalGenerator->Convert( - this->Makefile->GetCurrentBinaryDirectory(), cmLocalGenerator::FULL); + this->LocalGenerator->GetCurrentBinaryDirectory(), + cmLocalGenerator::FULL); compileCommand.replace(compileCommand.find(langFlags), langFlags.size(), this->GetFlags(lang)); std::string langDefines = std::string("$(") + lang + "_DEFINES)"; @@ -659,7 +667,7 @@ cmMakefileTargetGenerator if (!compileCommands.empty() && (lang == "C" || lang == "CXX")) { std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE"; - const char *iwyu = this->Target->GetProperty(iwyu_prop); + const char *iwyu = this->GeneratorTarget->GetProperty(iwyu_prop); if (iwyu && *iwyu) { std::string run_iwyu = "$(CMAKE_COMMAND) -E __run_iwyu --iwyu="; @@ -673,7 +681,7 @@ cmMakefileTargetGenerator if (!compileCommands.empty() && (lang == "C" || lang == "CXX")) { std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; - const char *clauncher = this->Target->GetProperty(clauncher_prop); + const char *clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); if (clauncher && *clauncher) { std::vector<std::string> launcher_cmd; @@ -698,7 +706,7 @@ cmMakefileTargetGenerator // Change the command working directory to the local build tree. this->LocalGenerator->CreateCDCommand (compileCommands, - this->Makefile->GetCurrentBinaryDirectory(), + this->LocalGenerator->GetCurrentBinaryDirectory(), cmLocalGenerator::HOME_OUTPUT); commands.insert(commands.end(), compileCommands.begin(), compileCommands.end()); @@ -771,7 +779,7 @@ cmMakefileTargetGenerator this->LocalGenerator->CreateCDCommand (preprocessCommands, - this->Makefile->GetCurrentBinaryDirectory(), + this->LocalGenerator->GetCurrentBinaryDirectory(), cmLocalGenerator::HOME_OUTPUT); commands.insert(commands.end(), preprocessCommands.begin(), @@ -828,7 +836,7 @@ cmMakefileTargetGenerator this->LocalGenerator->CreateCDCommand (assemblyCommands, - this->Makefile->GetCurrentBinaryDirectory(), + this->LocalGenerator->GetCurrentBinaryDirectory(), cmLocalGenerator::HOME_OUTPUT); commands.insert(commands.end(), assemblyCommands.begin(), @@ -864,7 +872,7 @@ cmMakefileTargetGenerator temp += ".provides.build"; std::vector<std::string> r_commands; std::string tgtMakefileName = - this->LocalGenerator->GetRelativeTargetDirectory(*this->Target); + this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget); tgtMakefileName += "/build.make"; r_commands.push_back (this->LocalGenerator->GetRecursiveMakeCall(tgtMakefileName.c_str(), @@ -892,7 +900,7 @@ void cmMakefileTargetGenerator::WriteTargetRequiresRules() // Construct the name of the dependency generation target. std::string depTarget = - this->LocalGenerator->GetRelativeTargetDirectory(*this->Target); + this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget); depTarget += "/requires"; // This target drives dependency generation for all object files. @@ -921,15 +929,15 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules() // Construct the clean target name. std::string cleanTarget = - this->LocalGenerator->GetRelativeTargetDirectory(*this->Target); + this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget); cleanTarget += "/clean"; // Construct the clean command. this->LocalGenerator->AppendCleanCommand(commands, this->CleanFiles, - *this->Target); + this->GeneratorTarget); this->LocalGenerator->CreateCDCommand (commands, - this->Makefile->GetCurrentBinaryDirectory(), + this->LocalGenerator->GetCurrentBinaryDirectory(), cmLocalGenerator::HOME_OUTPUT); // Write the rule. @@ -1018,7 +1026,8 @@ bool cmMakefileTargetGenerator::WriteMakeRule( void cmMakefileTargetGenerator::WriteTargetDependRules() { // must write the targets depend info file - std::string dir = this->LocalGenerator->GetTargetDirectory(*this->Target); + std::string dir = + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->InfoFileNameFull = dir; this->InfoFileNameFull += "/DependInfo.cmake"; this->InfoFileNameFull = @@ -1031,7 +1040,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() return; } this->LocalGenerator-> - WriteDependLanguageInfo(*this->InfoFileStream,*this->Target); + WriteDependLanguageInfo(*this->InfoFileStream, this->GeneratorTarget); // Store multiple output pairs in the depend info file. if(!this->MultipleOutputPairs.empty()) @@ -1080,7 +1089,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() // Construct the name of the dependency generation target. std::string depTarget = - this->LocalGenerator->GetRelativeTargetDirectory(*this->Target); + this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget); depTarget += "/depend"; // Add a command to call CMake to scan dependencies. CMake will @@ -1095,7 +1104,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() // translation table for the dependency scanning process. depCmd << "cd " << (this->LocalGenerator->Convert( - this->Makefile->GetHomeOutputDirectory(), + this->LocalGenerator->GetBinaryDirectory(), cmLocalGenerator::FULL, cmLocalGenerator::SHELL)) << " && "; #endif @@ -1110,16 +1119,16 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() // the state of our local generator sufficiently for its needs. depCmd << "$(CMAKE_COMMAND) -E cmake_depends \"" << this->GlobalGenerator->GetName() << "\" " - << this->Convert(this->Makefile->GetHomeDirectory(), + << this->Convert(this->LocalGenerator->GetSourceDirectory(), cmLocalGenerator::FULL, cmLocalGenerator::SHELL) << " " - << this->Convert(this->Makefile->GetCurrentSourceDirectory(), + << this->Convert(this->LocalGenerator->GetCurrentSourceDirectory(), cmLocalGenerator::FULL, cmLocalGenerator::SHELL) << " " - << this->Convert(this->Makefile->GetHomeOutputDirectory(), + << this->Convert(this->LocalGenerator->GetBinaryDirectory(), cmLocalGenerator::FULL, cmLocalGenerator::SHELL) << " " - << this->Convert(this->Makefile->GetCurrentBinaryDirectory(), + << this->Convert(this->LocalGenerator->GetCurrentBinaryDirectory(), cmLocalGenerator::FULL, cmLocalGenerator::SHELL) << " " << this->Convert(this->InfoFileNameFull, @@ -1149,7 +1158,7 @@ cmMakefileTargetGenerator { // Depend on all custom command outputs. std::vector<cmSourceFile*> sources; - this->Target->GetSourceFiles(sources, + this->GeneratorTarget->GetSourceFiles(sources, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); source != sources.end(); ++source) @@ -1202,7 +1211,8 @@ void cmMakefileTargetGenerator // Now append the actual user-specified commands. std::ostringstream content; - this->LocalGenerator->AppendCustomCommand(commands, ccg, this->Target, false, + this->LocalGenerator->AppendCustomCommand(commands, ccg, + this->GeneratorTarget, false, cmLocalGenerator::HOME_OUTPUT, &content); @@ -1242,7 +1252,7 @@ void cmMakefileTargetGenerator ::MakeEchoProgress(cmLocalUnixMakefileGenerator3::EchoProgress& progress) const { - progress.Dir = this->Makefile->GetHomeOutputDirectory(); + progress.Dir = this->LocalGenerator->GetBinaryDirectory(); progress.Dir += cmake::GetCMakeFilesDirectory(); std::ostringstream progressArg; progressArg << "$(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")"; @@ -1259,10 +1269,10 @@ cmMakefileTargetGenerator // Write a make variable assignment that lists all objects for the // target. variableName = - this->LocalGenerator->CreateMakeVariable(this->Target->GetName(), + this->LocalGenerator->CreateMakeVariable(this->GeneratorTarget->GetName(), "_OBJECTS"); *this->BuildFileStream - << "# Object files for target " << this->Target->GetName() << "\n" + << "# Object files for target " << this->GeneratorTarget->GetName() << "\n" << variableName << " ="; std::string object; const char* lineContinue = @@ -1284,12 +1294,12 @@ cmMakefileTargetGenerator // Write a make variable assignment that lists all external objects // for the target. variableNameExternal = - this->LocalGenerator->CreateMakeVariable(this->Target->GetName(), + this->LocalGenerator->CreateMakeVariable(this->GeneratorTarget->GetName(), "_EXTERNAL_OBJECTS"); *this->BuildFileStream << "\n" << "# External object files for target " - << this->Target->GetName() << "\n" + << this->GeneratorTarget->GetName() << "\n" << variableNameExternal << " ="; for(std::vector<std::string>::const_iterator i = this->ExternalObjects.begin(); @@ -1394,7 +1404,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule( { // Compute the name of the driver target. std::string dir = - this->LocalGenerator->GetRelativeTargetDirectory(*this->Target); + this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget); std::string buildTargetRuleName = dir; buildTargetRuleName += relink?"/preinstall":"/build"; buildTargetRuleName = this->Convert(buildTargetRuleName, @@ -1439,7 +1449,7 @@ void cmMakefileTargetGenerator ::AppendTargetDepends(std::vector<std::string>& depends) { // Static libraries never depend on anything for linking. - if(this->Target->GetType() == cmTarget::STATIC_LIBRARY) + if(this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) { return; } @@ -1493,9 +1503,18 @@ void cmMakefileTargetGenerator depends.push_back(this->ModuleDefinitionFile); } + // Add a dependency on user-specified manifest files, if any. + std::vector<cmSourceFile const*> manifest_srcs; + this->GeneratorTarget->GetManifests(manifest_srcs, this->ConfigName); + for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin(); + mi != manifest_srcs.end(); ++mi) + { + depends.push_back((*mi)->GetFullPath()); + } + // Add user-specified dependencies. if(const char* linkDepends = - this->Target->GetProperty("LINK_DEPENDS")) + this->GeneratorTarget->GetProperty("LINK_DEPENDS")) { cmSystemTools::ExpandListArgument(linkDepends, depends); } @@ -1506,7 +1525,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( const std::string& linkRuleVar) { std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar); - if(this->Target->HasImplibGNUtoMS()) + if(this->GeneratorTarget->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index fd4527b..e38c50b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -18,7 +18,6 @@ #include "cmOSXBundleGenerator.h" class cmCustomCommandGenerator; -class cmDependInformation; class cmDepends; class cmGeneratorTarget; class cmGeneratedFileStream; diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index 303ca63..11601c5 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -42,7 +42,8 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() this->CreateRuleFile(); *this->BuildFileStream - << "# Utility rule file for " << this->Target->GetName() << ".\n\n"; + << "# Utility rule file for " + << this->GeneratorTarget->GetName() << ".\n\n"; if(!this->NoRuleMessages) { @@ -73,13 +74,13 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() (depends, this->Target->GetPostBuildCommands()); this->LocalGenerator->AppendCustomCommands - (commands, this->Target->GetPreBuildCommands(), this->Target); + (commands, this->Target->GetPreBuildCommands(), this->GeneratorTarget); // Depend on all custom command outputs for sources this->DriveCustomCommands(depends); this->LocalGenerator->AppendCustomCommands - (commands, this->Target->GetPostBuildCommands(), this->Target); + (commands, this->Target->GetPostBuildCommands(), this->GeneratorTarget); // Add dependencies on targets that must be built first. this->AppendTargetDepends(depends); @@ -101,11 +102,11 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() // Write the rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - this->Target->GetName(), + this->GeneratorTarget->GetName(), depends, commands, true); // Write the main driver rule to build everything in this target. - this->WriteTargetDriverRule(this->Target->GetName(), false); + this->WriteTargetDriverRule(this->GeneratorTarget->GetName(), false); // Write clean target this->WriteTargetCleanRules(); diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx index 10d30f3..8d0e2b3 100644 --- a/Source/cmMarkAsAdvancedCommand.cxx +++ b/Source/cmMarkAsAdvancedCommand.cxx @@ -39,7 +39,8 @@ bool cmMarkAsAdvancedCommand cmState* state = this->Makefile->GetState(); if (!state->GetCacheEntryValue(variable)) { - state->AddCacheEntry(variable, 0, 0, cmState::UNINITIALIZED); + this->Makefile->GetCMakeInstance()->AddCacheEntry( + variable, 0, 0, cmState::UNINITIALIZED); overwrite = true; } if (!state->GetCacheEntryValue(variable)) diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index 467555f..2854a82 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -43,19 +43,7 @@ bool cmMessageCommand } else if (*i == "AUTHOR_WARNING") { - if (this->Makefile->IsOn("CMAKE_ERROR_DEVELOPER_WARNINGS")) - { - fatal = true; - type = cmake::AUTHOR_ERROR; - } - else if (!this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) - { - type = cmake::AUTHOR_WARNING; - } - else - { - return true; - } + type = cmake::AUTHOR_WARNING; ++i; } else if (*i == "STATUS") diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index b855bea..dafbda9 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -41,7 +41,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetLinkLanguage("") { this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); - if (target->GetType() == cmTarget::EXECUTABLE) + if (target->GetType() == cmState::EXECUTABLE) this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, @@ -55,11 +55,11 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); - if(target->GetType() != cmTarget::OBJECT_LIBRARY) + if(target->GetType() != cmState::OBJECT_LIBRARY) { // on Windows the output dir is already needed at compile time // ensure the directory exists (OutDir test) - EnsureDirectoryExists(target->Target->GetDirectory(this->GetConfigName())); + EnsureDirectoryExists(target->GetDirectory(this->GetConfigName())); } this->OSXBundleGenerator = new cmOSXBundleGenerator(target, @@ -77,7 +77,7 @@ void cmNinjaNormalTargetGenerator::Generate() if (this->TargetLinkLanguage.empty()) { cmSystemTools::Error("CMake can not determine linker language for " "target: ", - this->GetTarget()->GetName().c_str()); + this->GetGeneratorTarget()->GetName().c_str()); return; } @@ -87,7 +87,7 @@ void cmNinjaNormalTargetGenerator::Generate() // Write the build statements this->WriteObjectBuildStatements(); - if(this->GetTarget()->GetType() == cmTarget::OBJECT_LIBRARY) + if(this->GetGeneratorTarget()->GetType() == cmState::OBJECT_LIBRARY) { this->WriteObjectLibStatement(); } @@ -103,7 +103,7 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() cmGlobalNinjaGenerator::WriteDivider(this->GetRulesFileStream()); this->GetRulesFileStream() << "# Rules for each languages for " - << cmTarget::GetTargetTypeName(this->GetTarget()->GetType()) + << cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) << " target " << this->GetTargetName() << "\n\n"; @@ -112,7 +112,7 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() // Write rules for languages compiled in this target. std::set<std::string> languages; std::vector<cmSourceFile*> sourceFiles; - this->GetTarget()->GetSourceFiles(sourceFiles, + this->GetGeneratorTarget()->GetSourceFiles(sourceFiles, this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::vector<cmSourceFile*>::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) @@ -133,17 +133,17 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() const char *cmNinjaNormalTargetGenerator::GetVisibleTypeName() const { - switch (this->GetTarget()->GetType()) { - case cmTarget::STATIC_LIBRARY: + switch (this->GetGeneratorTarget()->GetType()) { + case cmState::STATIC_LIBRARY: return "static library"; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: return "shared library"; - case cmTarget::MODULE_LIBRARY: - if (this->GetTarget()->IsCFBundleOnApple()) + case cmState::MODULE_LIBRARY: + if (this->GetGeneratorTarget()->IsCFBundleOnApple()) return "CFBundle shared module"; else return "shared module"; - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: return "executable"; default: return 0; @@ -156,9 +156,10 @@ cmNinjaNormalTargetGenerator { return this->TargetLinkLanguage + "_" - + cmTarget::GetTargetTypeName(this->GetTarget()->GetType()) + + cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) + "_LINKER__" - + cmGlobalNinjaGenerator::EncodeRuleName(this->GetTarget()->GetName()) + + cmGlobalNinjaGenerator::EncodeRuleName( + this->GetGeneratorTarget()->GetName()) ; } @@ -166,7 +167,8 @@ void cmNinjaNormalTargetGenerator ::WriteLinkRule(bool useResponseFile) { - cmTarget::TargetType targetType = this->GetTarget()->GetType(); + cmState::TargetType targetType = + this->GetGeneratorTarget()->GetType(); std::string ruleName = this->LanguageLinkerRule(); // Select whether to use a response file for objects. @@ -176,7 +178,7 @@ cmNinjaNormalTargetGenerator if (!this->GetGlobalGenerator()->HasRule(ruleName)) { cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_LINK"; - vars.CMTarget = this->GetTarget(); + vars.CMTarget = this->GetGeneratorTarget(); vars.Language = this->TargetLinkLanguage.c_str(); std::string responseFlag; @@ -226,7 +228,7 @@ cmNinjaNormalTargetGenerator std::ostringstream minorStream; int major; int minor; - this->GetTarget()->GetTargetVersion(major, minor); + this->GetGeneratorTarget()->GetTargetVersion(major, minor); majorStream << major; minorStream << minor; targetVersionMajor = majorStream.str(); @@ -237,9 +239,10 @@ cmNinjaNormalTargetGenerator vars.Flags = "$FLAGS"; vars.LinkFlags = "$LINK_FLAGS"; + vars.Manifests = "$MANIFESTS"; std::string langFlags; - if (targetType != cmTarget::EXECUTABLE) + if (targetType != cmState::EXECUTABLE) { langFlags += "$LANGUAGE_COMPILE_FLAGS $ARCH_FLAGS"; vars.LanguageCompileFlags = langFlags.c_str(); @@ -278,11 +281,11 @@ cmNinjaNormalTargetGenerator } if (this->TargetNameOut != this->TargetNameReal && - !this->GetTarget()->IsFrameworkOnApple()) { + !this->GetGeneratorTarget()->IsFrameworkOnApple()) { std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat( cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); - if (targetType == cmTarget::EXECUTABLE) + if (targetType == cmState::EXECUTABLE) this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_EXECUTABLE", cmakeCommand + " -E cmake_symlink_executable" @@ -329,8 +332,8 @@ cmNinjaNormalTargetGenerator return linkCmds; } } - switch (this->GetTarget()->GetType()) { - case cmTarget::STATIC_LIBRARY: { + switch (this->GetGeneratorTarget()->GetType()) { + case cmState::STATIC_LIBRARY: { // We have archive link commands set. First, delete the existing archive. { std::string cmakeCommand = @@ -355,9 +358,9 @@ cmNinjaNormalTargetGenerator } return linkCmds; } - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - case cmTarget::EXECUTABLE: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: + case cmState::EXECUTABLE: break; default: assert(0 && "Unexpected target type"); @@ -409,10 +412,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() gt.GetFullPath(cfgName, /*implib=*/true)); - if (target.IsAppBundleOnApple()) + if (gt.IsAppBundleOnApple()) { // Create the app bundle - std::string outpath = target.GetDirectory(cfgName); + std::string outpath = gt.GetDirectory(cfgName); this->OSXBundleGenerator->CreateAppBundle(this->TargetNameOut, outpath); // Calculate the output path @@ -425,25 +428,25 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() targetOutputReal += this->TargetNameReal; targetOutputReal = this->ConvertToNinjaPath(targetOutputReal); } - else if (target.IsFrameworkOnApple()) + else if (gt.IsFrameworkOnApple()) { // Create the library framework. this->OSXBundleGenerator->CreateFramework(this->TargetNameOut, - target.GetDirectory(cfgName)); + gt.GetDirectory(cfgName)); } - else if(target.IsCFBundleOnApple()) + else if(gt.IsCFBundleOnApple()) { // Create the core foundation bundle. this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut, - target.GetDirectory(cfgName)); + gt.GetDirectory(cfgName)); } // Write comments. cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); - const cmTarget::TargetType targetType = target.GetType(); + const cmState::TargetType targetType = target.GetType(); this->GetBuildFileStream() << "# Link build statements for " - << cmTarget::GetTargetTypeName(targetType) + << cmState::GetTargetTypeName(targetType) << " target " << this->GetTargetName() << "\n\n"; @@ -487,13 +490,12 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() &genTarget, useWatcomQuote); if(this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS") - && target.GetType() == cmTarget::SHARED_LIBRARY) + && target.GetType() == cmState::SHARED_LIBRARY) { if(target.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { - std::string dllname = targetOutput; std::string name_of_def_file - = target.GetSupportDirectory(); + = gt.GetSupportDirectory(); name_of_def_file += "/" + target.GetName(); name_of_def_file += ".def "; vars["LINK_FLAGS"] += " /DEF:"; @@ -509,12 +511,14 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["LINK_FLAGS"] = cmGlobalNinjaGenerator ::EncodeLiteral(vars["LINK_FLAGS"]); + vars["MANIFESTS"] = this->GetManifests(); + vars["LINK_PATH"] = frameworkPath + linkPath; // Compute architecture specific link flags. Yes, these go into a different // variable for executables, probably due to a mistake made when duplicating // code between the Makefile executable and library generators. - if (targetType == cmTarget::EXECUTABLE) + if (targetType == cmState::EXECUTABLE) { std::string t = vars["FLAGS"]; localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName); @@ -534,7 +538,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() { vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); vars["SONAME"] = this->TargetNameSO; - if (targetType == cmTarget::SHARED_LIBRARY) + if (targetType == cmState::SHARED_LIBRARY) { std::string install_dir = this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); @@ -556,7 +560,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmLocalGenerator::SHELL); vars["TARGET_IMPLIB"] = impLibPath; EnsureParentDirectoryExists(impLibPath); - if(target.HasImportLibrary()) + if(genTarget.HasImportLibrary()) { byproducts.push_back(targetOutputImplib); } @@ -579,11 +583,14 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["TARGET_PDB"] = base + suffix + dbg_suffix; } + const std::string objPath = GetGeneratorTarget()->GetSupportDirectory(); + vars["OBJECT_DIR"] = + this->GetLocalGenerator()->ConvertToOutputFormat( + this->ConvertToNinjaPath(objPath), cmLocalGenerator::SHELL); + EnsureDirectoryExists(objPath); + if (this->GetGlobalGenerator()->IsGCCOnWindows()) { - const std::string objPath = GetTarget()->GetSupportDirectory(); - vars["OBJECT_DIR"] = ConvertToNinjaPath(objPath); - EnsureDirectoryExists(objPath); // ar.exe can't handle backslashes in rsp files (implicitly used by gcc) std::string& linkLibraries = vars["LINK_LIBRARIES"]; std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/'); @@ -619,7 +626,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } // maybe create .def file from list of objects - if (target.GetType() == cmTarget::SHARED_LIBRARY && + if (target.GetType() == cmState::SHARED_LIBRARY && this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { if(target.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) @@ -627,9 +634,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat( cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); - std::string dllname = targetOutput; std::string name_of_def_file - = target.GetSupportDirectory(); + = gt.GetSupportDirectory(); name_of_def_file += "/" + target.GetName(); name_of_def_file += ".def"; std::string cmd = cmakeCommand; @@ -661,8 +667,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() if (!preLinkCmdLines.empty()) { const std::string homeOutDir = localGen.ConvertToOutputFormat( - mf->GetHomeOutputDirectory(), - cmLocalGenerator::SHELL); + localGen.GetBinaryDirectory(), + cmLocalGenerator::SHELL); preLinkCmdLines.push_back("cd " + homeOutDir); } @@ -726,9 +732,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() &usedResponseFile); this->WriteLinkRule(usedResponseFile); - if (targetOutput != targetOutputReal && !target.IsFrameworkOnApple()) + if (targetOutput != targetOutputReal && !gt.IsFrameworkOnApple()) { - if (targetType == cmTarget::EXECUTABLE) + if (targetType == cmState::EXECUTABLE) { globalGen.WriteBuild(this->GetBuildFileStream(), "Create executable symlink " + targetOutput, diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 81fdde2..b018005 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -31,23 +31,22 @@ cmNinjaTargetGenerator::New(cmGeneratorTarget* target) { switch (target->GetType()) { - case cmTarget::EXECUTABLE: - case cmTarget::SHARED_LIBRARY: - case cmTarget::STATIC_LIBRARY: - case cmTarget::MODULE_LIBRARY: - case cmTarget::OBJECT_LIBRARY: + case cmState::EXECUTABLE: + case cmState::SHARED_LIBRARY: + case cmState::STATIC_LIBRARY: + case cmState::MODULE_LIBRARY: + case cmState::OBJECT_LIBRARY: return new cmNinjaNormalTargetGenerator(target); - case cmTarget::UTILITY: + case cmState::UTILITY: return new cmNinjaUtilityTargetGenerator(target);; - case cmTarget::GLOBAL_TARGET: { + case cmState::GLOBAL_TARGET: { // We only want to process global targets that live in the home // (i.e. top-level) directory. CMake creates copies of these targets // in every directory, which we don't need. - cmMakefile *mf = target->Target->GetMakefile(); - if (strcmp(mf->GetCurrentSourceDirectory(), - mf->GetHomeDirectory()) == 0) + if (strcmp(target->GetLocalGenerator()->GetCurrentSourceDirectory(), + target->GetLocalGenerator()->GetSourceDirectory()) == 0) return new cmNinjaUtilityTargetGenerator(target); // else fallthrough } @@ -93,7 +92,7 @@ std::string cmNinjaTargetGenerator::LanguageCompilerRule( const std::string& lang) const { return lang + "_COMPILER__" + - cmGlobalNinjaGenerator::EncodeRuleName(this->Target->GetName()); + cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()); } std::string @@ -149,17 +148,9 @@ void cmNinjaTargetGenerator::AddIncludeFlags(std::string& languageFlags, bool cmNinjaTargetGenerator::NeedDepTypeMSVC(const std::string& lang) const { - if (lang == "C" || lang == "CXX") - { - cmMakefile* mf = this->GetMakefile(); - return ( - strcmp(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID"), "MSVC") == 0 || - strcmp(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"), "MSVC") == 0 || - strcmp(mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID"), "MSVC") == 0 || - strcmp(mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID"), "MSVC") == 0 - ); - } - return false; + return strcmp( + this->GetMakefile()->GetSafeDefinition("CMAKE_NINJA_DEPTYPE_" + lang), + "msvc") == 0; } // TODO: Refactor with @@ -190,8 +181,8 @@ ComputeDefines(cmSourceFile const* source, const std::string& language) cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const { // Static libraries never depend on other targets for linking. - if (this->Target->GetType() == cmTarget::STATIC_LIBRARY || - this->Target->GetType() == cmTarget::OBJECT_LIBRARY) + if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY || + this->GeneratorTarget->GetType() == cmState::OBJECT_LIBRARY) return cmNinjaDeps(); cmComputeLinkInformation* cli = @@ -209,8 +200,18 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const result.push_back(this->ConvertToNinjaPath(this->ModuleDefinitionFile)); } + // Add a dependency on user-specified manifest files, if any. + std::vector<cmSourceFile const*> manifest_srcs; + this->GeneratorTarget->GetManifests(manifest_srcs, this->ConfigName); + for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin(); + mi != manifest_srcs.end(); ++mi) + { + result.push_back(this->ConvertToNinjaPath((*mi)->GetFullPath())); + } + // Add user-specified dependencies. - if (const char* linkDepends = this->Target->GetProperty("LINK_DEPENDS")) + if (const char* linkDepends = + this->GeneratorTarget->GetProperty("LINK_DEPENDS")) { std::vector<std::string> linkDeps; cmSystemTools::ExpandListArgument(linkDepends, linkDeps); @@ -237,7 +238,7 @@ cmNinjaTargetGenerator path += "/"; std::string const& objectName = this->GeneratorTarget ->GetObjectName(source); - path += this->LocalGenerator->GetTargetDirectory(*this->Target); + path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); path += "/"; path += objectName; return path; @@ -245,7 +246,7 @@ cmNinjaTargetGenerator std::string cmNinjaTargetGenerator::GetTargetOutputDir() const { - std::string dir = this->Target->GetDirectory(this->GetConfigName()); + std::string dir = this->GeneratorTarget->GetDirectory(this->GetConfigName()); return ConvertToNinjaPath(dir); } @@ -263,7 +264,7 @@ cmNinjaTargetGenerator std::string cmNinjaTargetGenerator::GetTargetName() const { - return this->Target->GetName(); + return this->GeneratorTarget->GetName(); } @@ -275,22 +276,22 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const { std::string pdbPath; std::string compilePdbPath; - if(this->Target->GetType() == cmTarget::EXECUTABLE || - this->Target->GetType() == cmTarget::STATIC_LIBRARY || - this->Target->GetType() == cmTarget::SHARED_LIBRARY || - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + if(this->GeneratorTarget->GetType() == cmState::EXECUTABLE || + this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY || + this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || + this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) { - pdbPath = this->Target->GetPDBDirectory(this->GetConfigName()); + pdbPath = this->GeneratorTarget->GetPDBDirectory(this->GetConfigName()); pdbPath += "/"; pdbPath += this->GeneratorTarget->GetPDBName(this->GetConfigName()); } - if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) + if(this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) { compilePdbPath = this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName()); if(compilePdbPath.empty()) { - compilePdbPath = this->Target->GetSupportDirectory() + "/"; + compilePdbPath = this->GeneratorTarget->GetSupportDirectory() + "/"; } } @@ -326,7 +327,7 @@ cmNinjaTargetGenerator { cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; - vars.CMTarget = this->GetTarget(); + vars.CMTarget = this->GetGeneratorTarget(); vars.Language = lang.c_str(); vars.Source = "$in"; vars.Object = "$out"; @@ -350,7 +351,7 @@ cmNinjaTargetGenerator depfile = ""; flags += " /showIncludes"; } - else if (lang == "RC" && this->NeedDepTypeMSVC("C")) + else if (mf->IsOn("CMAKE_NINJA_CMCLDEPS_"+lang)) { // For the MS resource compiler we need cmcldeps, but skip dependencies // for source-file try_compile cases because they are always fresh. @@ -362,7 +363,7 @@ cmNinjaTargetGenerator mf->GetSafeDefinition("CMAKE_C_COMPILER") : mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); cldeps = "\""; - cldeps += mf->GetSafeDefinition("CMAKE_CMCLDEPS_EXECUTABLE"); + cldeps += cmSystemTools::GetCMClDepsCommand(); cldeps += "\" " + lang + " $in \"$DEP_FILE\" $out \""; cldeps += mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX"); cldeps += "\" \"" + cl + "\" "; @@ -402,7 +403,7 @@ cmNinjaTargetGenerator if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) { std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE"; - const char *iwyu = this->Target->GetProperty(iwyu_prop); + const char *iwyu = this->GeneratorTarget->GetProperty(iwyu_prop); if (iwyu && *iwyu) { std::string run_iwyu = @@ -419,7 +420,7 @@ cmNinjaTargetGenerator if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) { std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; - const char *clauncher = this->Target->GetProperty(clauncher_prop); + const char *clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); if (clauncher && *clauncher) { std::vector<std::string> launcher_cmd; @@ -472,7 +473,7 @@ cmNinjaTargetGenerator cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); this->GetBuildFileStream() << "# Object build statements for " - << cmTarget::GetTargetTypeName(this->GetTarget()->GetType()) + << cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) << " target " << this->GetTargetName() << "\n\n"; @@ -559,7 +560,7 @@ cmNinjaTargetGenerator std::string const language = source->GetLanguage(); std::string const sourceFileName = language=="RC" ? source->GetFullPath() : this->GetSourceFilePath(source); - std::string const objectDir = this->Target->GetSupportDirectory(); + std::string const objectDir = this->GeneratorTarget->GetSupportDirectory(); std::string const objectFileName = this->GetObjectFilePath(source); std::string const objectFileDir = cmSystemTools::GetFilenamePath(objectFileName); @@ -762,14 +763,14 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( // Get the input file location. std::string input = source.GetFullPath(); input = - this->Generator->GetLocalGenerator()->ConvertToNinjaPath(input); + this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(input); // Get the output file location. std::string output = macdir; output += "/"; output += cmSystemTools::GetFilenameName(input); output = - this->Generator->GetLocalGenerator()->ConvertToNinjaPath(output); + this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(output); // Write a build statement to copy the content into the bundle. this->Generator->GetGlobalGenerator()->WriteMacOSXContentBuild(input, diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index a10ceba..0267f63 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -17,11 +17,11 @@ #include "cmStandardIncludes.h" #include "cmNinjaTypes.h" +#include "cmGlobalNinjaGenerator.h" #include "cmLocalNinjaGenerator.h" #include "cmOSXBundleGenerator.h" class cmTarget; -class cmGlobalNinjaGenerator; class cmGeneratedFileStream; class cmGeneratorTarget; class cmMakefile; @@ -87,10 +87,10 @@ protected: const std::string& language); std::string ConvertToNinjaPath(const std::string& path) const { - return this->GetLocalGenerator()->ConvertToNinjaPath(path); + return this->GetGlobalGenerator()->ConvertToNinjaPath(path); } - cmLocalNinjaGenerator::map_to_ninja_path MapToNinjaPath() const { - return this->GetLocalGenerator()->MapToNinjaPath(); + cmGlobalNinjaGenerator::MapToNinjaPathImpl MapToNinjaPath() const { + return this->GetGlobalGenerator()->MapToNinjaPath(); } /// @return the list of link dependency for the given target @a target. diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 58b901a..5bbe268 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -58,7 +58,7 @@ void cmNinjaUtilityTargetGenerator::Generate() std::vector<cmSourceFile*> sources; std::string config = this->GetMakefile() ->GetSafeDefinition("CMAKE_BUILD_TYPE"); - this->GetTarget()->GetSourceFiles(sources, config); + this->GetGeneratorTarget()->GetSourceFiles(sources, config); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); source != sources.end(); ++source) { @@ -90,7 +90,8 @@ void cmNinjaUtilityTargetGenerator::Generate() } else { std::string command = this->GetLocalGenerator()->BuildCommandLine(commands); - const char *echoStr = this->GetTarget()->GetProperty("EchoString"); + const char *echoStr = + this->GetGeneratorTarget()->GetProperty("EchoString"); std::string desc; if (echoStr) desc = echoStr; @@ -103,13 +104,13 @@ void cmNinjaUtilityTargetGenerator::Generate() command, "$(CMAKE_SOURCE_DIR)", this->GetLocalGenerator()->ConvertToOutputFormat( - this->GetTarget()->GetMakefile()->GetHomeDirectory(), + this->GetLocalGenerator()->GetSourceDirectory(), cmLocalGenerator::SHELL).c_str()); cmSystemTools::ReplaceString( command, "$(CMAKE_BINARY_DIR)", this->GetLocalGenerator()->ConvertToOutputFormat( - this->GetTarget()->GetMakefile()->GetHomeOutputDirectory(), + this->GetLocalGenerator()->GetBinaryDirectory(), cmLocalGenerator::SHELL).c_str()); cmSystemTools::ReplaceString(command, "$(ARGS)", ""); diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 4fe99e3..e9dc433 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -34,7 +34,7 @@ cmOSXBundleGenerator(cmGeneratorTarget* target, //---------------------------------------------------------------------------- bool cmOSXBundleGenerator::MustSkip() { - return !this->GT->Target->HaveWellDefinedOutputFiles(); + return !this->GT->HaveWellDefinedOutputFiles(); } //---------------------------------------------------------------------------- @@ -59,7 +59,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, plist += "/"; plist += this->GT->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; - this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, + this->LocalGenerator->GenerateAppleInfoPList(this->GT, targetName, plist.c_str()); this->Makefile->AddCMakeOutputFile(plist); @@ -90,7 +90,7 @@ void cmOSXBundleGenerator::CreateFramework( std::string plist = newoutpath; plist += "/Resources/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); - this->LocalGenerator->GenerateFrameworkInfoPList(this->GT->Target, + this->LocalGenerator->GenerateFrameworkInfoPList(this->GT, name, plist.c_str()); @@ -182,7 +182,7 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, this->GT->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); - this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, + this->LocalGenerator->GenerateAppleInfoPList(this->GT, name, plist.c_str()); this->Makefile->AddCMakeOutputFile(plist); diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 35ee127..e3eedc7 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -555,7 +555,7 @@ void cmOrderDirectories::FindImplicitConflicts() << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() ->IssueMessage(cmake::WARNING, w.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } //---------------------------------------------------------------------------- @@ -637,5 +637,5 @@ void cmOrderDirectories::DiagnoseCycle() e << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() ->IssueMessage(cmake::WARNING, e.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 7be5b3f..5acae2f 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -142,21 +142,7 @@ std::string cmOutputConverter::ConvertToOutputFormat(const std::string& source, } else if(output == SHELL || output == WATCOMQUOTE) { - // For the MSYS shell convert drive letters to posix paths, so - // that c:/some/path becomes /c/some/path. This is needed to - // avoid problems with the shell path translation. - if(this->GetState()->UseMSYSShell() && !this->LinkScriptShell) - { - if(result.size() > 2 && result[1] == ':') - { - result[1] = result[0]; - result[0] = '/'; - } - } - if(this->GetState()->UseWindowsShell()) - { - std::replace(result.begin(), result.end(), '/', '\\'); - } + result = this->ConvertDirectorySeparatorsForShell(source); result = this->EscapeForShell(result, true, false, output == WATCOMQUOTE); } else if(output == RESPONSE) @@ -167,6 +153,29 @@ std::string cmOutputConverter::ConvertToOutputFormat(const std::string& source, } //---------------------------------------------------------------------------- +std::string cmOutputConverter::ConvertDirectorySeparatorsForShell( + const std::string& source) const +{ + std::string result = source; + // For the MSYS shell convert drive letters to posix paths, so + // that c:/some/path becomes /c/some/path. This is needed to + // avoid problems with the shell path translation. + if(this->GetState()->UseMSYSShell() && !this->LinkScriptShell) + { + if(result.size() > 2 && result[1] == ':') + { + result[1] = result[0]; + result[0] = '/'; + } + } + if(this->GetState()->UseWindowsShell()) + { + std::replace(result.begin(), result.end(), '/', '\\'); + } + return result; +} + +//---------------------------------------------------------------------------- std::string cmOutputConverter::Convert(RelativeRoot remote, const std::string& local, OutputFormat output, diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index ed7739e..852df5d 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -45,6 +45,8 @@ public: std::string Convert(RelativeRoot remote, const std::string& local, OutputFormat output = UNCHANGED, bool optional = false) const; + std::string ConvertDirectorySeparatorsForShell( + const std::string& source) const; /** * Get path for the specified relative root. diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 2d57d3b..54208ac 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -10,108 +10,239 @@ See the License for more information. ============================================================================*/ #include "cmOutputRequiredFilesCommand.h" -#include "cmMakeDepend.h" #include "cmAlgorithms.h" #include <cmsys/FStream.hxx> -class cmLBDepend : public cmMakeDepend +/** \class cmDependInformation + * \brief Store dependency information for a single source file. + * + * This structure stores the depend information for a single source file. + */ +class cmDependInformation { +public: /** - * Compute the depend information for this class. + * Construct with dependency generation marked not done; instance + * not placed in cmMakefile's list. */ - virtual void DependWalk(cmDependInformation* info); -}; + cmDependInformation(): DependDone(false), SourceFile(0) {} -void cmLBDepend::DependWalk(cmDependInformation* info) -{ - cmsys::ifstream fin(info->FullPath.c_str()); - if(!fin) + /** + * The set of files on which this one depends. + */ + typedef std::set<cmDependInformation*> DependencySetType; + DependencySetType DependencySet; + + /** + * This flag indicates whether dependency checking has been + * performed for this file. + */ + bool DependDone; + + /** + * If this object corresponds to a cmSourceFile instance, this points + * to it. + */ + const cmSourceFile *SourceFile; + + /** + * Full path to this file. + */ + std::string FullPath; + + /** + * Full path not including file name. + */ + std::string PathOnly; + + /** + * Name used to #include this file. + */ + std::string IncludeName; + + /** + * This method adds the dependencies of another file to this one. + */ + void AddDependencies(cmDependInformation* info) + { + if(this != info) { - cmSystemTools::Error("error can not open ", info->FullPath.c_str()); - return; + this->DependencySet.insert(info); } + } +}; - std::string line; - while(cmSystemTools::GetLineFromStream(fin, line)) - { - if(cmHasLiteralPrefix(line.c_str(), "#include")) - { - // if it is an include line then create a string class - std::string currentline = line; - size_t qstart = currentline.find('\"', 8); - size_t qend; - // if a quote is not found look for a < - if(qstart == std::string::npos) - { - qstart = currentline.find('<', 8); - // if a < is not found then move on - if(qstart == std::string::npos) - { - cmSystemTools::Error("unknown include directive ", - currentline.c_str() ); - continue; - } - else - { - qend = currentline.find('>', qstart+1); - } - } - else +class cmLBDepend +{ +public: + /** + * Construct the object with verbose turned off. + */ + cmLBDepend() + { + this->Verbose = false; + this->IncludeFileRegularExpression.compile("^.*$"); + this->ComplainFileRegularExpression.compile("^$"); + } + + /** + * Destructor. + */ + ~cmLBDepend() + { + cmDeleteAll(this->DependInformationMap); + } + + /** + * Set the makefile that is used as a source of classes. + */ + void SetMakefile(cmMakefile* makefile) + { + this->Makefile = makefile; + + // Now extract the include file regular expression from the makefile. + this->IncludeFileRegularExpression.compile( + this->Makefile->GetIncludeRegularExpression()); + this->ComplainFileRegularExpression.compile( + this->Makefile->GetComplainRegularExpression()); + + // Now extract any include paths from the targets + std::set<std::string> uniqueIncludes; + std::vector<std::string> orderedAndUniqueIncludes; + cmTargets &targets = this->Makefile->GetTargets(); + for (cmTargets::iterator l = targets.begin(); + l != targets.end(); ++l) + { + const char *incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES"); + if (!incDirProp) { - qend = currentline.find('\"', qstart+1); + continue; } - // extract the file being included - std::string includeFile = currentline.substr(qstart+1, qend - qstart-1); - // see if the include matches the regular expression - if(!this->IncludeFileRegularExpression.find(includeFile)) + + std::string incDirs = + cmGeneratorExpression::Preprocess(incDirProp, + cmGeneratorExpression::StripAllGeneratorExpressions); + + std::vector<std::string> includes; + cmSystemTools::ExpandListArgument(incDirs, includes); + + for(std::vector<std::string>::const_iterator j = includes.begin(); + j != includes.end(); ++j) { - if(this->Verbose) + std::string path = *j; + this->Makefile->ExpandVariablesInString(path); + if(uniqueIncludes.insert(path).second) { - std::string message = "Skipping "; - message += includeFile; - message += " for file "; - message += info->FullPath.c_str(); - cmSystemTools::Error(message.c_str(), 0); + orderedAndUniqueIncludes.push_back(path); } - continue; } + } - // Add this file and all its dependencies. - this->AddDependency(info, includeFile.c_str()); - /// add the cxx file if it exists - std::string cxxFile = includeFile; - std::string::size_type pos = cxxFile.rfind('.'); - if(pos != std::string::npos) + for(std::vector<std::string>::const_iterator + it = orderedAndUniqueIncludes.begin(); + it != orderedAndUniqueIncludes.end(); + ++it) + { + this->AddSearchPath(*it); + } + } + + /** + * Add a directory to the search path for include files. + */ + void AddSearchPath(const std::string& path) + { + this->IncludeDirectories.push_back(path); + } + + /** + * Generate dependencies for the file given. Returns a pointer to + * the cmDependInformation object for the file. + */ + const cmDependInformation* FindDependencies(const char* file) + { + cmDependInformation* info = this->GetDependInformation(file,0); + this->GenerateDependInformation(info); + return info; + } + +protected: + /** + * Compute the depend information for this class. + */ + + void DependWalk(cmDependInformation* info) + { + cmsys::ifstream fin(info->FullPath.c_str()); + if(!fin) + { + cmSystemTools::Error("error can not open ", info->FullPath.c_str()); + return; + } + + std::string line; + while(cmSystemTools::GetLineFromStream(fin, line)) + { + if(cmHasLiteralPrefix(line.c_str(), "#include")) { - std::string root = cxxFile.substr(0, pos); - cxxFile = root + ".cxx"; - bool found = false; - // try jumping to .cxx .cpp and .c in order - if(cmSystemTools::FileExists(cxxFile.c_str())) + // if it is an include line then create a string class + std::string currentline = line; + size_t qstart = currentline.find('\"', 8); + size_t qend; + // if a quote is not found look for a < + if(qstart == std::string::npos) { - found = true; + qstart = currentline.find('<', 8); + // if a < is not found then move on + if(qstart == std::string::npos) + { + cmSystemTools::Error("unknown include directive ", + currentline.c_str() ); + continue; + } + else + { + qend = currentline.find('>', qstart+1); + } } - for(std::vector<std::string>::iterator i = - this->IncludeDirectories.begin(); - i != this->IncludeDirectories.end(); ++i) + else + { + qend = currentline.find('\"', qstart+1); + } + // extract the file being included + std::string includeFile = + currentline.substr(qstart+1, qend - qstart-1); + // see if the include matches the regular expression + if(!this->IncludeFileRegularExpression.find(includeFile)) { - std::string path = *i; - path = path + "/"; - path = path + cxxFile; - if(cmSystemTools::FileExists(path.c_str())) + if(this->Verbose) { - found = true; + std::string message = "Skipping "; + message += includeFile; + message += " for file "; + message += info->FullPath.c_str(); + cmSystemTools::Error(message.c_str(), 0); } + continue; } - if (!found) + + // Add this file and all its dependencies. + this->AddDependency(info, includeFile.c_str()); + /// add the cxx file if it exists + std::string cxxFile = includeFile; + std::string::size_type pos = cxxFile.rfind('.'); + if(pos != std::string::npos) { - cxxFile = root + ".cpp"; + std::string root = cxxFile.substr(0, pos); + cxxFile = root + ".cxx"; + bool found = false; + // try jumping to .cxx .cpp and .c in order if(cmSystemTools::FileExists(cxxFile.c_str())) { found = true; } for(std::vector<std::string>::iterator i = - this->IncludeDirectories.begin(); + this->IncludeDirectories.begin(); i != this->IncludeDirectories.end(); ++i) { std::string path = *i; @@ -122,55 +253,314 @@ void cmLBDepend::DependWalk(cmDependInformation* info) found = true; } } - } - if (!found) - { - cxxFile = root + ".c"; - if(cmSystemTools::FileExists(cxxFile.c_str())) + if (!found) { - found = true; - } - for(std::vector<std::string>::iterator i = - this->IncludeDirectories.begin(); - i != this->IncludeDirectories.end(); ++i) - { - std::string path = *i; - path = path + "/"; - path = path + cxxFile; - if(cmSystemTools::FileExists(path.c_str())) + cxxFile = root + ".cpp"; + if(cmSystemTools::FileExists(cxxFile.c_str())) { found = true; } + for(std::vector<std::string>::iterator i = + this->IncludeDirectories.begin(); + i != this->IncludeDirectories.end(); ++i) + { + std::string path = *i; + path = path + "/"; + path = path + cxxFile; + if(cmSystemTools::FileExists(path.c_str())) + { + found = true; + } + } } - } - if (!found) - { - cxxFile = root + ".txx"; - if(cmSystemTools::FileExists(cxxFile.c_str())) + if (!found) { - found = true; - } - for(std::vector<std::string>::iterator i = + cxxFile = root + ".c"; + if(cmSystemTools::FileExists(cxxFile.c_str())) + { + found = true; + } + for(std::vector<std::string>::iterator i = this->IncludeDirectories.begin(); - i != this->IncludeDirectories.end(); ++i) + i != this->IncludeDirectories.end(); ++i) + { + std::string path = *i; + path = path + "/"; + path = path + cxxFile; + if(cmSystemTools::FileExists(path.c_str())) + { + found = true; + } + } + } + if (!found) { - std::string path = *i; - path = path + "/"; - path = path + cxxFile; - if(cmSystemTools::FileExists(path.c_str())) + cxxFile = root + ".txx"; + if(cmSystemTools::FileExists(cxxFile.c_str())) { found = true; } + for(std::vector<std::string>::iterator i = + this->IncludeDirectories.begin(); + i != this->IncludeDirectories.end(); ++i) + { + std::string path = *i; + path = path + "/"; + path = path + cxxFile; + if(cmSystemTools::FileExists(path.c_str())) + { + found = true; + } + } + } + if (found) + { + this->AddDependency(info, cxxFile.c_str()); } } - if (found) + } + } + } + + /** + * Add a dependency. Possibly walk it for more dependencies. + */ + void AddDependency(cmDependInformation* info, const char* file) + { + cmDependInformation* dependInfo = + this->GetDependInformation(file, info->PathOnly.c_str()); + this->GenerateDependInformation(dependInfo); + info->AddDependencies(dependInfo); + } + + /** + * Fill in the given object with dependency information. If the + * information is already complete, nothing is done. + */ + void GenerateDependInformation(cmDependInformation* info) + { + // If dependencies are already done, stop now. + if(info->DependDone) + { + return; + } + else + { + // Make sure we don't visit the same file more than once. + info->DependDone = true; + } + const char* path = info->FullPath.c_str(); + if(!path) + { + cmSystemTools::Error( + "Attempt to find dependencies for file without path!"); + return; + } + + bool found = false; + + // If the file exists, use it to find dependency information. + if(cmSystemTools::FileExists(path, true)) + { + // Use the real file to find its dependencies. + this->DependWalk(info); + found = true; + } + + + // See if the cmSourceFile for it has any files specified as + // dependency hints. + if(info->SourceFile != 0) + { + + // Get the cmSourceFile corresponding to this. + const cmSourceFile& cFile = *(info->SourceFile); + // See if there are any hints for finding dependencies for the missing + // file. + if(!cFile.GetDepends().empty()) + { + // Dependency hints have been given. Use them to begin the + // recursion. + for(std::vector<std::string>::const_iterator file = + cFile.GetDepends().begin(); file != cFile.GetDepends().end(); + ++file) { - this->AddDependency(info, cxxFile.c_str()); + this->AddDependency(info, file->c_str()); } + + // Found dependency information. We are done. + found = true; } } - } -} + + if(!found) + { + // Try to find the file amongst the sources + cmSourceFile *srcFile = this->Makefile->GetSource + (cmSystemTools::GetFilenameWithoutExtension(path)); + if (srcFile) + { + if (srcFile->GetFullPath() == path) + { + found=true; + } + else + { + //try to guess which include path to use + for(std::vector<std::string>::iterator t = + this->IncludeDirectories.begin(); + t != this->IncludeDirectories.end(); ++t) + { + std::string incpath = *t; + if (!incpath.empty() && incpath[incpath.size() - 1] != '/') + { + incpath = incpath + "/"; + } + incpath = incpath + path; + if (srcFile->GetFullPath() == incpath) + { + // set the path to the guessed path + info->FullPath = incpath; + found=true; + } + } + } + } + } + + if(!found) + { + // Couldn't find any dependency information. + if(this->ComplainFileRegularExpression.find(info->IncludeName.c_str())) + { + cmSystemTools::Error("error cannot find dependencies for ", path); + } + else + { + // Destroy the name of the file so that it won't be output as a + // dependency. + info->FullPath = ""; + } + } + } + + /** + * Get an instance of cmDependInformation corresponding to the given file + * name. + */ + cmDependInformation* GetDependInformation(const char* file, + const char *extraPath) + { + // Get the full path for the file so that lookup is unambiguous. + std::string fullPath = this->FullPath(file, extraPath); + + // Try to find the file's instance of cmDependInformation. + DependInformationMapType::const_iterator result = + this->DependInformationMap.find(fullPath); + if(result != this->DependInformationMap.end()) + { + // Found an instance, return it. + return result->second; + } + else + { + // Didn't find an instance. Create a new one and save it. + cmDependInformation* info = new cmDependInformation; + info->FullPath = fullPath; + info->PathOnly = cmSystemTools::GetFilenamePath(fullPath); + info->IncludeName = file; + this->DependInformationMap[fullPath] = info; + return info; + } + } + + /** + * Find the full path name for the given file name. + * This uses the include directories. + * TODO: Cache path conversions to reduce FileExists calls. + */ + std::string FullPath(const char *fname, const char *extraPath) + { + DirectoryToFileToPathMapType::iterator m; + if(extraPath) + { + m = this->DirectoryToFileToPathMap.find(extraPath); + } + else + { + m = this->DirectoryToFileToPathMap.find(""); + } + + if(m != this->DirectoryToFileToPathMap.end()) + { + FileToPathMapType& map = m->second; + FileToPathMapType::iterator p = map.find(fname); + if(p != map.end()) + { + return p->second; + } + } + + if(cmSystemTools::FileExists(fname, true)) + { + std::string fp = cmSystemTools::CollapseFullPath(fname); + this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; + return fp; + } + + for(std::vector<std::string>::iterator i = + this->IncludeDirectories.begin(); + i != this->IncludeDirectories.end(); ++i) + { + std::string path = *i; + if (!path.empty() && path[path.size() - 1] != '/') + { + path = path + "/"; + } + path = path + fname; + if(cmSystemTools::FileExists(path.c_str(), true) + && !cmSystemTools::FileIsDirectory(path)) + { + std::string fp = cmSystemTools::CollapseFullPath(path); + this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; + return fp; + } + } + + if (extraPath) + { + std::string path = extraPath; + if (!path.empty() && path[path.size() - 1] != '/') + { + path = path + "/"; + } + path = path + fname; + if(cmSystemTools::FileExists(path.c_str(), true) + && !cmSystemTools::FileIsDirectory(path)) + { + std::string fp = cmSystemTools::CollapseFullPath(path); + this->DirectoryToFileToPathMap[extraPath][fname] = fp; + return fp; + } + } + + // Couldn't find the file. + return std::string(fname); + } + + cmMakefile* Makefile; + bool Verbose; + cmsys::RegularExpression IncludeFileRegularExpression; + cmsys::RegularExpression ComplainFileRegularExpression; + std::vector<std::string> IncludeDirectories; + typedef std::map<std::string, std::string> FileToPathMapType; + typedef std::map<std::string, FileToPathMapType> + DirectoryToFileToPathMapType; + typedef std::map<std::string, cmDependInformation*> + DependInformationMapType; + DependInformationMapType DependInformationMap; + DirectoryToFileToPathMapType DirectoryToFileToPathMap; +}; // cmOutputRequiredFilesCommand bool cmOutputRequiredFilesCommand diff --git a/Source/cmOutputRequiredFilesCommand.h b/Source/cmOutputRequiredFilesCommand.h index 95eba38..b5eb932 100644 --- a/Source/cmOutputRequiredFilesCommand.h +++ b/Source/cmOutputRequiredFilesCommand.h @@ -13,7 +13,8 @@ #define cmOutputRequiredFilesCommand_h #include "cmCommand.h" -#include "cmMakeDepend.h" + +class cmDependInformation; class cmOutputRequiredFilesCommand : public cmCommand { @@ -23,7 +24,6 @@ public: virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); virtual std::string GetName() const { return "output_required_files";} - virtual bool IsDiscouraged() const { return true; } void ListDependencies(cmDependInformation const *info, FILE *fout, diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index a791b89..5023055 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -220,18 +220,39 @@ class cmPolicy; 3, 3, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0064, \ "Support new TEST if() operator.", \ - 3, 3, 0, cmPolicies::WARN) + 3, 4, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0065, \ + "Do not add flags to export symbols from executables without " \ + "the ENABLE_EXPORTS target property.", \ + 3, 4, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ CM_FOR_EACH_POLICY_TABLE(POLICY, CM_SELECT_ID) +#define CM_FOR_EACH_TARGET_POLICY(F) \ + F(CMP0003) \ + F(CMP0004) \ + F(CMP0008) \ + F(CMP0020) \ + F(CMP0021) \ + F(CMP0022) \ + F(CMP0027) \ + F(CMP0038) \ + F(CMP0041) \ + F(CMP0042) \ + F(CMP0046) \ + F(CMP0052) \ + F(CMP0060) \ + F(CMP0063) \ + F(CMP0065) + /** \class cmPolicies * \brief Handles changes in CMake behavior and policies * * See the cmake wiki section on - * <a href="http://www.cmake.org/Wiki/CMake/Policies">policies</a> + * <a href="https://cmake.org/Wiki/CMake/Policies">policies</a> * for an overview of this class's purpose */ class cmPolicies diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx new file mode 100644 index 0000000..16b8942 --- /dev/null +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -0,0 +1,1054 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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 "cmQtAutoGeneratorInitializer.h" + +#include "cmLocalGenerator.h" +#include "cmMakefile.h" +#include "cmSourceFile.h" + +#include <sys/stat.h> + +#include <cmsys/FStream.hxx> + +#if defined(_WIN32) && !defined(__CYGWIN__) +# include "cmGlobalVisualStudioGenerator.h" +#endif + +static void SetupSourceFiles(cmGeneratorTarget const* target, + std::vector<std::string>& skipMoc, + std::vector<std::string>& mocSources, + std::vector<std::string>& mocHeaders, + std::vector<std::string>& skipUic) +{ + cmMakefile* makefile = target->Target->GetMakefile(); + + std::vector<cmSourceFile*> srcFiles; + target->GetConfigCommonSourceFiles(srcFiles); + + std::vector<std::string> newRccFiles; + + for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath()); + bool skipFileForMoc = + cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); + bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")); + + if(cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC"))) + { + skipUic.push_back(absFile); + } + + std::string ext = sf->GetExtension(); + + if (target->GetPropertyAsBool("AUTORCC")) + { + if (ext == "qrc" + && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) + { + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFile); + + std::string rcc_output_dir = target->GetSupportDirectory(); + cmSystemTools::MakeDirectory(rcc_output_dir.c_str()); + std::string rcc_output_file = rcc_output_dir; + rcc_output_file += "/qrc_" + basename + ".cpp"; + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + rcc_output_file.c_str(), false); + makefile->GetOrCreateSource(rcc_output_file, true); + newRccFiles.push_back(rcc_output_file); + } + } + + if (!generated) + { + if (skipFileForMoc) + { + skipMoc.push_back(absFile); + } + else + { + cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat( + ext.c_str()); + if (fileType == cmSystemTools::CXX_FILE_FORMAT) + { + mocSources.push_back(absFile); + } + else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) + { + mocHeaders.push_back(absFile); + } + } + } + } + + for(std::vector<std::string>::const_iterator fileIt = newRccFiles.begin(); + fileIt != newRccFiles.end(); + ++fileIt) + { + const_cast<cmGeneratorTarget*>(target)->AddSource(*fileIt); + } +} + +static void GetCompileDefinitionsAndDirectories( + cmGeneratorTarget const* target, + const std::string& config, + std::string &incs, + std::string &defs) +{ + std::vector<std::string> includeDirs; + cmLocalGenerator *localGen = target->GetLocalGenerator(); + // Get the include dirs for this target, without stripping the implicit + // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667 + localGen->GetIncludeDirectories(includeDirs, target, "CXX", config, false); + + incs = cmJoin(includeDirs, ";"); + + std::set<std::string> defines; + localGen->AddCompileDefinitions(defines, target, config, "CXX"); + + defs += cmJoin(defines, ";"); +} + +static void SetupAutoMocTarget(cmGeneratorTarget const* target, + const std::string &autogenTargetName, + std::vector<std::string> const& skipMoc, + std::vector<std::string> const& mocHeaders, + std::map<std::string, std::string> &configIncludes, + std::map<std::string, std::string> &configDefines) +{ + cmLocalGenerator* lg = target->GetLocalGenerator(); + cmMakefile* makefile = target->Target->GetMakefile(); + + const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS"); + std::string _moc_options = (tmp!=0 ? tmp : ""); + makefile->AddDefinition("_moc_options", + cmOutputConverter::EscapeForCMake(_moc_options).c_str()); + makefile->AddDefinition("_skip_moc", + cmOutputConverter::EscapeForCMake(cmJoin(skipMoc, ";")).c_str()); + makefile->AddDefinition("_moc_headers", + cmOutputConverter::EscapeForCMake(cmJoin(mocHeaders, ";")).c_str()); + bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); + makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE"); + + std::string _moc_incs; + std::string _moc_compile_defs; + std::vector<std::string> configs; + const std::string& config = makefile->GetConfigurations(configs); + GetCompileDefinitionsAndDirectories(target, config, + _moc_incs, _moc_compile_defs); + + makefile->AddDefinition("_moc_incs", + cmOutputConverter::EscapeForCMake(_moc_incs).c_str()); + makefile->AddDefinition("_moc_compile_defs", + cmOutputConverter::EscapeForCMake(_moc_compile_defs).c_str()); + + for (std::vector<std::string>::const_iterator li = configs.begin(); + li != configs.end(); ++li) + { + std::string config_moc_incs; + std::string config_moc_compile_defs; + GetCompileDefinitionsAndDirectories(target, *li, + config_moc_incs, + config_moc_compile_defs); + if (config_moc_incs != _moc_incs) + { + configIncludes[*li] = + cmOutputConverter::EscapeForCMake(config_moc_incs); + if(_moc_incs.empty()) + { + _moc_incs = config_moc_incs; + } + } + if (config_moc_compile_defs != _moc_compile_defs) + { + configDefines[*li] = + cmOutputConverter::EscapeForCMake(config_moc_compile_defs); + if(_moc_compile_defs.empty()) + { + _moc_compile_defs = config_moc_compile_defs; + } + } + } + + const char *qtVersion = makefile->GetDefinition("_target_qt_version"); + if (strcmp(qtVersion, "5") == 0) + { + cmGeneratorTarget *qt5Moc = + lg->FindGeneratorTargetToUse("Qt5::moc"); + if (!qt5Moc) + { + cmSystemTools::Error("Qt5::moc target not found ", + autogenTargetName.c_str()); + return; + } + makefile->AddDefinition("_qt_moc_executable", + qt5Moc->ImportedGetLocation("")); + } + else if (strcmp(qtVersion, "4") == 0) + { + cmGeneratorTarget *qt4Moc = + lg->FindGeneratorTargetToUse("Qt4::moc"); + if (!qt4Moc) + { + cmSystemTools::Error("Qt4::moc target not found ", + autogenTargetName.c_str()); + return; + } + makefile->AddDefinition("_qt_moc_executable", + qt4Moc->ImportedGetLocation("")); + } + else + { + cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and " + "Qt 5 ", autogenTargetName.c_str()); + } +} + +static void GetUicOpts(cmGeneratorTarget const* target, + const std::string& config, + std::string &optString) +{ + std::vector<std::string> opts; + target->GetAutoUicOptions(opts, config); + optString = cmJoin(opts, ";"); +} + +static void SetupAutoUicTarget(cmGeneratorTarget const* target, + std::vector<std::string> const& skipUic, + std::map<std::string, std::string> &configUicOptions) +{ + cmLocalGenerator* lg = target->GetLocalGenerator(); + cmMakefile *makefile = target->Target->GetMakefile(); + + std::set<std::string> skipped; + skipped.insert(skipUic.begin(), skipUic.end()); + + makefile->AddDefinition("_skip_uic", + cmOutputConverter::EscapeForCMake(cmJoin(skipUic, ";")).c_str()); + + std::vector<cmSourceFile*> uiFilesWithOptions + = makefile->GetQtUiFilesWithOptions(); + + const char *qtVersion = makefile->GetDefinition("_target_qt_version"); + + std::string _uic_opts; + std::vector<std::string> configs; + const std::string& config = makefile->GetConfigurations(configs); + GetUicOpts(target, config, _uic_opts); + + if (!_uic_opts.empty()) + { + _uic_opts = cmOutputConverter::EscapeForCMake(_uic_opts); + makefile->AddDefinition("_uic_target_options", _uic_opts.c_str()); + } + for (std::vector<std::string>::const_iterator li = configs.begin(); + li != configs.end(); ++li) + { + std::string config_uic_opts; + GetUicOpts(target, *li, config_uic_opts); + if (config_uic_opts != _uic_opts) + { + configUicOptions[*li] = + cmOutputConverter::EscapeForCMake(config_uic_opts); + if(_uic_opts.empty()) + { + _uic_opts = config_uic_opts; + } + } + } + + std::string uiFileFiles; + std::string uiFileOptions; + const char* sep = ""; + + for(std::vector<cmSourceFile*>::const_iterator fileIt = + uiFilesWithOptions.begin(); + fileIt != uiFilesWithOptions.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath()); + + if (!skipped.insert(absFile).second) + { + continue; + } + uiFileFiles += sep; + uiFileFiles += absFile; + uiFileOptions += sep; + std::string opts = sf->GetProperty("AUTOUIC_OPTIONS"); + cmSystemTools::ReplaceString(opts, ";", "@list_sep@"); + uiFileOptions += opts; + sep = ";"; + } + + makefile->AddDefinition("_qt_uic_options_files", + cmOutputConverter::EscapeForCMake(uiFileFiles).c_str()); + makefile->AddDefinition("_qt_uic_options_options", + cmOutputConverter::EscapeForCMake(uiFileOptions).c_str()); + + std::string targetName = target->GetName(); + if (strcmp(qtVersion, "5") == 0) + { + cmGeneratorTarget *qt5Uic = + lg->FindGeneratorTargetToUse("Qt5::uic"); + if (!qt5Uic) + { + // Project does not use Qt5Widgets, but has AUTOUIC ON anyway + } + else + { + makefile->AddDefinition("_qt_uic_executable", + qt5Uic->ImportedGetLocation("")); + } + } + else if (strcmp(qtVersion, "4") == 0) + { + cmGeneratorTarget *qt4Uic = + lg->FindGeneratorTargetToUse("Qt4::uic"); + if (!qt4Uic) + { + cmSystemTools::Error("Qt4::uic target not found ", + targetName.c_str()); + return; + } + makefile->AddDefinition("_qt_uic_executable", + qt4Uic->ImportedGetLocation("")); + } + else + { + cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and " + "Qt 5 ", targetName.c_str()); + } +} + +static std::string GetRccExecutable(cmGeneratorTarget const* target) +{ + cmLocalGenerator* lg = target->GetLocalGenerator(); + cmMakefile *makefile = target->Target->GetMakefile(); + const char *qtVersion = makefile->GetDefinition("_target_qt_version"); + if (!qtVersion) + { + qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR"); + if (!qtVersion) + { + qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); + } + if (const char *targetQtVersion = + target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", + "")) + { + qtVersion = targetQtVersion; + } + } + + std::string targetName = target->GetName(); + if (strcmp(qtVersion, "5") == 0) + { + cmGeneratorTarget *qt5Rcc = + lg->FindGeneratorTargetToUse("Qt5::rcc"); + if (!qt5Rcc) + { + cmSystemTools::Error("Qt5::rcc target not found ", + targetName.c_str()); + return std::string(); + } + return qt5Rcc->ImportedGetLocation(""); + } + else if (strcmp(qtVersion, "4") == 0) + { + cmGeneratorTarget *qt4Rcc = + lg->FindGeneratorTargetToUse("Qt4::rcc"); + if (!qt4Rcc) + { + cmSystemTools::Error("Qt4::rcc target not found ", + targetName.c_str()); + return std::string(); + } + return qt4Rcc->ImportedGetLocation(""); + } + + cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and " + "Qt 5 ", targetName.c_str()); + return std::string(); +} + +static void MergeRccOptions(std::vector<std::string> &opts, + const std::vector<std::string> &fileOpts, + bool isQt5) +{ + static const char* valueOptions[] = { + "name", + "root", + "compress", + "threshold" + }; + std::vector<std::string> extraOpts; + for(std::vector<std::string>::const_iterator it = fileOpts.begin(); + it != fileOpts.end(); ++it) + { + std::vector<std::string>::iterator existingIt + = std::find(opts.begin(), opts.end(), *it); + if (existingIt != opts.end()) + { + const char *o = it->c_str(); + if (*o == '-') + { + ++o; + } + if (isQt5 && *o == '-') + { + ++o; + } + if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions), + cmStrCmp(*it)) != cmArrayEnd(valueOptions)) + { + assert(existingIt + 1 != opts.end()); + *(existingIt + 1) = *(it + 1); + ++it; + } + } + else + { + extraOpts.push_back(*it); + } + } + opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); +} + +std::string GetAutogenTargetName( + cmGeneratorTarget const* target) +{ + std::string autogenTargetName = target->GetName(); + autogenTargetName += "_automoc"; + return autogenTargetName; +} + +std::string GetAutogenTargetDir( + cmGeneratorTarget const* target) +{ + cmMakefile* makefile = target->Target->GetMakefile(); + std::string targetDir = makefile->GetCurrentBinaryDirectory(); + targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory(); + targetDir += "/"; + targetDir += GetAutogenTargetName(target); + targetDir += ".dir/"; + return targetDir; +} + +static void copyTargetProperty(cmTarget* destinationTarget, + cmTarget* sourceTarget, + const std::string& propertyName) +{ + const char* propertyValue = sourceTarget->GetProperty(propertyName); + if (propertyValue) + { + destinationTarget->SetProperty(propertyName, propertyValue); + } +} + +static std::string cmQtAutoGeneratorsStripCR(std::string const& line) +{ + // Strip CR characters rcc may have printed (possibly more than one!). + std::string::size_type cr = line.find('\r'); + if (cr != line.npos) + { + return line.substr(0, cr); + } + return line; +} + +static std::string ReadAll(const std::string& filename) +{ + cmsys::ifstream file(filename.c_str()); + std::stringstream stream; + stream << file.rdbuf(); + file.close(); + return stream.str(); +} + +static std::string ListQt5RccInputs(cmSourceFile* sf, + cmGeneratorTarget const* target, + std::vector<std::string>& depends) +{ + std::string rccCommand + = GetRccExecutable(target); + std::vector<std::string> qrcEntries; + + std::vector<std::string> command; + command.push_back(rccCommand); + command.push_back("-list"); + + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath()); + + command.push_back(absFile); + + std::string rccStdOut; + std::string rccStdErr; + int retVal = 0; + bool result = cmSystemTools::RunSingleCommand( + command, &rccStdOut, &rccStdErr, + &retVal, 0, cmSystemTools::OUTPUT_NONE); + if (!result || retVal) + { + std::cerr << "AUTOGEN: error: Rcc list process for " << sf->GetFullPath() + << " failed:\n" << rccStdOut << "\n" << rccStdErr << std::endl; + return std::string(); + } + + { + std::istringstream ostr(rccStdOut); + std::string oline; + while(std::getline(ostr, oline)) + { + oline = cmQtAutoGeneratorsStripCR(oline); + if(!oline.empty()) + { + qrcEntries.push_back(oline); + } + } + } + + { + std::istringstream estr(rccStdErr); + std::string eline; + while(std::getline(estr, eline)) + { + eline = cmQtAutoGeneratorsStripCR(eline); + if (cmHasLiteralPrefix(eline, "RCC: Error in")) + { + static std::string searchString = "Cannot find file '"; + + std::string::size_type pos = eline.find(searchString); + if (pos == std::string::npos) + { + std::cerr << "AUTOGEN: error: Rcc lists unparsable output " + << eline << std::endl; + return std::string(); + } + pos += searchString.length(); + std::string::size_type sz = eline.size() - pos - 1; + qrcEntries.push_back(eline.substr(pos, sz)); + } + } + } + + depends.insert(depends.end(), qrcEntries.begin(), qrcEntries.end()); + return cmJoin(qrcEntries, "@list_sep@"); +} + +static std::string ListQt4RccInputs(cmSourceFile* sf, + std::vector<std::string>& depends) +{ + const std::string qrcContents = ReadAll(sf->GetFullPath()); + + cmsys::RegularExpression fileMatchRegex("(<file[^<]+)"); + + std::string entriesList; + const char* sep = ""; + + size_t offset = 0; + while (fileMatchRegex.find(qrcContents.c_str() + offset)) + { + std::string qrcEntry = fileMatchRegex.match(1); + + offset += qrcEntry.size(); + + cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)"); + fileReplaceRegex.find(qrcEntry); + std::string tag = fileReplaceRegex.match(1); + + qrcEntry = qrcEntry.substr(tag.size()); + + if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str())) + { + qrcEntry = sf->GetLocation().GetDirectory() + "/" + qrcEntry; + } + + entriesList += sep; + entriesList += qrcEntry; + sep = "@list_sep@"; + depends.push_back(qrcEntry); + } + return entriesList; +} + +static void SetupAutoRccTarget(cmGeneratorTarget const* target) +{ + std::string _rcc_files; + const char* sepRccFiles = ""; + cmMakefile *makefile = target->Target->GetMakefile(); + + std::vector<cmSourceFile*> srcFiles; + target->GetConfigCommonSourceFiles(srcFiles); + + std::string qrcInputs; + const char* qrcInputsSep = ""; + + std::string rccFileFiles; + std::string rccFileOptions; + const char *optionSep = ""; + + const char *qtVersion = makefile->GetDefinition("_target_qt_version"); + + std::vector<std::string> rccOptions; + if (const char* opts = target->GetProperty("AUTORCC_OPTIONS")) + { + cmSystemTools::ExpandListArgument(opts, rccOptions); + } + std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); + if (qtMajorVersion == "") + { + qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); + } + + for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string ext = sf->GetExtension(); + if (ext == "qrc") + { + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath()); + bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); + + if (!skip) + { + _rcc_files += sepRccFiles; + _rcc_files += absFile; + sepRccFiles = ";"; + + if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS")) + { + std::vector<std::string> optsVec; + cmSystemTools::ExpandListArgument(prop, optsVec); + MergeRccOptions(rccOptions, optsVec, + strcmp(qtVersion, "5") == 0); + } + + if (!rccOptions.empty()) + { + rccFileFiles += optionSep; + rccFileFiles += absFile; + rccFileOptions += optionSep; + } + const char *listSep = ""; + for(std::vector<std::string>::const_iterator it = rccOptions.begin(); + it != rccOptions.end(); + ++it) + { + rccFileOptions += listSep; + rccFileOptions += *it; + listSep = "@list_sep@"; + } + optionSep = ";"; + + std::vector<std::string> depends; + + std::string entriesList; + if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) + { + if (qtMajorVersion == "5") + { + entriesList = ListQt5RccInputs(sf, target, depends); + } + else + { + entriesList = ListQt4RccInputs(sf, depends); + } + if (entriesList.empty()) + { + return; + } + } + qrcInputs += qrcInputsSep; + qrcInputs += entriesList; + qrcInputsSep = ";"; + } + } + } + makefile->AddDefinition("_qt_rcc_inputs_" + target->GetName(), + cmOutputConverter::EscapeForCMake(qrcInputs).c_str()); + + makefile->AddDefinition("_rcc_files", + cmOutputConverter::EscapeForCMake(_rcc_files).c_str()); + + makefile->AddDefinition("_qt_rcc_options_files", + cmOutputConverter::EscapeForCMake(rccFileFiles).c_str()); + makefile->AddDefinition("_qt_rcc_options_options", + cmOutputConverter::EscapeForCMake(rccFileOptions).c_str()); + + makefile->AddDefinition("_qt_rcc_executable", + GetRccExecutable(target).c_str()); +} + +void cmQtAutoGeneratorInitializer::InitializeAutogenSources( + cmGeneratorTarget* target) +{ + cmMakefile* makefile = target->Target->GetMakefile(); + + if (target->GetPropertyAsBool("AUTOMOC")) + { + std::string automocTargetName = GetAutogenTargetName(target); + std::string mocCppFile = makefile->GetCurrentBinaryDirectory(); + mocCppFile += "/"; + mocCppFile += automocTargetName; + mocCppFile += ".cpp"; + makefile->GetOrCreateSource(mocCppFile, true); + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + mocCppFile.c_str(), false); + + target->AddSource(mocCppFile); + } +} + +void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( + cmLocalGenerator* lg, + cmGeneratorTarget* target) +{ + cmMakefile* makefile = target->Target->GetMakefile(); + + std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); + if (qtMajorVersion == "") + { + qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); + } + + // create a custom target for running generators at buildtime: + std::string autogenTargetName = GetAutogenTargetName(target); + + std::string targetDir = GetAutogenTargetDir(target); + + cmCustomCommandLine currentLine; + currentLine.push_back(cmSystemTools::GetCMakeCommand()); + currentLine.push_back("-E"); + currentLine.push_back("cmake_autogen"); + currentLine.push_back(targetDir); + currentLine.push_back("$<CONFIGURATION>"); + + cmCustomCommandLines commandLines; + commandLines.push_back(currentLine); + + std::string workingDirectory = cmSystemTools::CollapseFullPath( + "", makefile->GetCurrentBinaryDirectory()); + + std::vector<std::string> depends; + if (const char *autogenDepends = + target->GetProperty("AUTOGEN_TARGET_DEPENDS")) + { + cmSystemTools::ExpandListArgument(autogenDepends, depends); + } + std::vector<std::string> toolNames; + if (target->GetPropertyAsBool("AUTOMOC")) + { + toolNames.push_back("moc"); + } + if (target->GetPropertyAsBool("AUTOUIC")) + { + toolNames.push_back("uic"); + } + if (target->GetPropertyAsBool("AUTORCC")) + { + toolNames.push_back("rcc"); + } + + std::string tools = toolNames[0]; + toolNames.erase(toolNames.begin()); + while (toolNames.size() > 1) + { + tools += ", " + toolNames[0]; + toolNames.erase(toolNames.begin()); + } + if (toolNames.size() == 1) + { + tools += " and " + toolNames[0]; + } + std::string autogenComment = "Automatic " + tools + " for target "; + autogenComment += target->GetName(); + +#if defined(_WIN32) && !defined(__CYGWIN__) + bool usePRE_BUILD = false; + cmGlobalGenerator* gg = lg->GetGlobalGenerator(); + if(gg->GetName().find("Visual Studio") != std::string::npos) + { + cmGlobalVisualStudioGenerator* vsgg = + static_cast<cmGlobalVisualStudioGenerator*>(gg); + // Under VS >= 7 use a PRE_BUILD event instead of a separate target to + // reduce the number of targets loaded into the IDE. + // This also works around a VS 11 bug that may skip updating the target: + // https://connect.microsoft.com/VisualStudio/feedback/details/769495 + usePRE_BUILD = vsgg->GetVersion() >= cmGlobalVisualStudioGenerator::VS7; + if(usePRE_BUILD) + { + for (std::vector<std::string>::iterator it = depends.begin(); + it != depends.end(); ++it) + { + if(!makefile->FindTargetToUse(it->c_str())) + { + usePRE_BUILD = false; + break; + } + } + } + } +#endif + + std::vector<std::string> rcc_output; + bool const isNinja = + lg->GetGlobalGenerator()->GetName() == "Ninja"; + if(isNinja +#if defined(_WIN32) && !defined(__CYGWIN__) + || usePRE_BUILD +#endif + ) + { + std::vector<cmSourceFile*> srcFiles; + target->GetConfigCommonSourceFiles(srcFiles); + for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath()); + + std::string ext = sf->GetExtension(); + + if (target->GetPropertyAsBool("AUTORCC")) + { + if (ext == "qrc" + && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) + { + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFile); + + std::string rcc_output_dir = target->GetSupportDirectory(); + cmSystemTools::MakeDirectory(rcc_output_dir.c_str()); + std::string rcc_output_file = rcc_output_dir; + rcc_output_file += "/qrc_" + basename + ".cpp"; + rcc_output.push_back(rcc_output_file); + + if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) + { + if (qtMajorVersion == "5") + { + ListQt5RccInputs(sf, target, depends); + } + else + { + ListQt4RccInputs(sf, depends); + } +#if defined(_WIN32) && !defined(__CYGWIN__) + // Cannot use PRE_BUILD because the resource files themselves + // may not be sources within the target so VS may not know the + // target needs to re-build at all. + usePRE_BUILD = false; +#endif + } + } + } + } + } + +#if defined(_WIN32) && !defined(__CYGWIN__) + if(usePRE_BUILD) + { + // Add the pre-build command directly to bypass the OBJECT_LIBRARY + // rejection in cmMakefile::AddCustomCommandToTarget because we know + // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case. + std::vector<std::string> no_output; + std::vector<std::string> no_byproducts; + cmCustomCommand cc(makefile, no_output, no_byproducts, depends, + commandLines, autogenComment.c_str(), + workingDirectory.c_str()); + cc.SetEscapeOldStyle(false); + cc.SetEscapeAllowMakeVars(true); + target->Target->AddPreBuildCommand(cc); + } + else +#endif + { + cmTarget* autogenTarget = makefile->AddUtilityCommand( + autogenTargetName, true, + workingDirectory.c_str(), + /*byproducts=*/rcc_output, depends, + commandLines, false, autogenComment.c_str()); + + cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); + lg->AddGeneratorTarget(autogenTarget, gt); + lg->GetGlobalGenerator()->AddGeneratorTarget(autogenTarget, gt); + + // Set target folder + const char* autogenFolder = makefile->GetState() + ->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER"); + if (!autogenFolder) + { + autogenFolder = makefile->GetState() + ->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER"); + } + if (autogenFolder && *autogenFolder) + { + autogenTarget->SetProperty("FOLDER", autogenFolder); + } + else + { + // inherit FOLDER property from target (#13688) + copyTargetProperty(gt->Target, target->Target, "FOLDER"); + } + + target->Target->AddUtility(autogenTargetName); + } +} + +void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( + cmGeneratorTarget const* target) +{ + cmMakefile* makefile = target->Target->GetMakefile(); + + // forget the variables added here afterwards again: + cmMakefile::ScopePushPop varScope(makefile); + static_cast<void>(varScope); + + // create a custom target for running generators at buildtime: + std::string autogenTargetName = GetAutogenTargetName(target); + + makefile->AddDefinition("_moc_target_name", + cmOutputConverter::EscapeForCMake(autogenTargetName).c_str()); + makefile->AddDefinition("_origin_target_name", + cmOutputConverter::EscapeForCMake(target->GetName()).c_str()); + + std::string targetDir = GetAutogenTargetDir(target); + + const char *qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR"); + if (!qtVersion) + { + qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); + } + if (const char *targetQtVersion = + target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) + { + qtVersion = targetQtVersion; + } + if (qtVersion) + { + makefile->AddDefinition("_target_qt_version", qtVersion); + } + + std::vector<std::string> skipUic; + std::vector<std::string> skipMoc; + std::vector<std::string> mocSources; + std::vector<std::string> mocHeaders; + std::map<std::string, std::string> configIncludes; + std::map<std::string, std::string> configDefines; + std::map<std::string, std::string> configUicOptions; + + if (target->GetPropertyAsBool("AUTOMOC") + || target->GetPropertyAsBool("AUTOUIC") + || target->GetPropertyAsBool("AUTORCC")) + { + SetupSourceFiles(target, skipMoc, mocSources, mocHeaders, skipUic); + } + makefile->AddDefinition("_cpp_files", + cmOutputConverter::EscapeForCMake(cmJoin(mocSources, ";")).c_str()); + if (target->GetPropertyAsBool("AUTOMOC")) + { + SetupAutoMocTarget(target, autogenTargetName, + skipMoc, mocHeaders, + configIncludes, configDefines); + } + if (target->GetPropertyAsBool("AUTOUIC")) + { + SetupAutoUicTarget(target, skipUic, configUicOptions); + } + if (target->GetPropertyAsBool("AUTORCC")) + { + SetupAutoRccTarget(target); + } + + const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT"); + std::string inputFile = cmakeRoot; + inputFile += "/Modules/AutogenInfo.cmake.in"; + std::string outputFile = targetDir; + outputFile += "/AutogenInfo.cmake"; + makefile->AddDefinition("_qt_rcc_inputs", + makefile->GetDefinition("_qt_rcc_inputs_" + target->GetName())); + makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), + false, true, false); + + // Ensure we have write permission in case .in was read-only. + mode_t perm = 0; +#if defined(_WIN32) && !defined(__CYGWIN__) + mode_t mode_write = S_IWRITE; +#else + mode_t mode_write = S_IWUSR; +#endif + cmSystemTools::GetPermissions(outputFile, perm); + if (!(perm & mode_write)) + { + cmSystemTools::SetPermissions(outputFile, perm | mode_write); + } + if (!configDefines.empty() + || !configIncludes.empty() + || !configUicOptions.empty()) + { + cmsys::ofstream infoFile(outputFile.c_str(), std::ios::app); + if ( !infoFile ) + { + std::string error = "Internal CMake error when trying to open file: "; + error += outputFile.c_str(); + error += " for writing."; + cmSystemTools::Error(error.c_str()); + return; + } + if (!configDefines.empty()) + { + for (std::map<std::string, std::string>::iterator + it = configDefines.begin(), end = configDefines.end(); + it != end; ++it) + { + infoFile << "set(AM_MOC_COMPILE_DEFINITIONS_" << it->first << + " " << it->second << ")\n"; + } + } + if (!configIncludes.empty()) + { + for (std::map<std::string, std::string>::iterator + it = configIncludes.begin(), end = configIncludes.end(); + it != end; ++it) + { + infoFile << "set(AM_MOC_INCLUDES_" << it->first << + " " << it->second << ")\n"; + } + } + if (!configUicOptions.empty()) + { + for (std::map<std::string, std::string>::iterator + it = configUicOptions.begin(), end = configUicOptions.end(); + it != end; ++it) + { + infoFile << "set(AM_UIC_TARGET_OPTIONS_" << it->first << + " " << it->second << ")\n"; + } + } + } +} diff --git a/Source/cmQtAutoGeneratorInitializer.h b/Source/cmQtAutoGeneratorInitializer.h new file mode 100644 index 0000000..eaf140d --- /dev/null +++ b/Source/cmQtAutoGeneratorInitializer.h @@ -0,0 +1,36 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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 cmQtAutoGeneratorInitializer_h +#define cmQtAutoGeneratorInitializer_h + +#include "cmStandardIncludes.h" + +#include <string> +#include <vector> +#include <map> + +class cmSourceFile; +class cmGeneratorTarget; +class cmLocalGenerator; + +class cmQtAutoGeneratorInitializer +{ +public: + static void InitializeAutogenSources(cmGeneratorTarget* target); + static void InitializeAutogenTarget(cmLocalGenerator* lg, + cmGeneratorTarget* target); + static void SetupAutoGenerateTarget(cmGeneratorTarget const* target); +}; + +#endif diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index becfeba..fc690f8 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -12,17 +12,12 @@ ============================================================================*/ #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" +#include "cmOutputConverter.h" #include "cmMakefile.h" -#include "cmSourceFile.h" #include "cmSystemTools.h" #include "cmState.h" #include "cmAlgorithms.h" -#if defined(_WIN32) && !defined(__CYGWIN__) -# include "cmGlobalVisualStudioGenerator.h" -#endif - #include <sys/stat.h> #include <cmsys/Terminal.h> @@ -36,7 +31,6 @@ #include "cmQtAutoGenerators.h" - static bool requiresMocing(const std::string& text, std::string ¯oName) { // this simple check is much much faster than the regexp @@ -105,28 +99,6 @@ static std::string extractSubDir(const std::string& absPath, return subDir; } - -static void copyTargetProperty(cmTarget* destinationTarget, - cmTarget* sourceTarget, - const std::string& propertyName) -{ - const char* propertyValue = sourceTarget->GetProperty(propertyName); - if (propertyValue) - { - destinationTarget->SetProperty(propertyName, propertyValue); - } -} - - -static std::string ReadAll(const std::string& filename) -{ - cmsys::ifstream file(filename.c_str()); - std::stringstream stream; - stream << file.rdbuf(); - file.close(); - return stream.str(); -} - cmQtAutoGenerators::cmQtAutoGenerators() :Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0) ,ColorOutput(true) @@ -151,692 +123,6 @@ cmQtAutoGenerators::cmQtAutoGenerators() } } -static std::string getAutogenTargetName(cmTarget const* target) -{ - std::string autogenTargetName = target->GetName(); - autogenTargetName += "_automoc"; - return autogenTargetName; -} - -static std::string getAutogenTargetDir(cmTarget const* target) -{ - cmMakefile* makefile = target->GetMakefile(); - std::string targetDir = makefile->GetCurrentBinaryDirectory(); - targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory(); - targetDir += "/"; - targetDir += getAutogenTargetName(target); - targetDir += ".dir/"; - return targetDir; -} - -static std::string cmQtAutoGeneratorsStripCR(std::string const& line) -{ - // Strip CR characters rcc may have printed (possibly more than one!). - std::string::size_type cr = line.find('\r'); - if (cr != line.npos) - { - return line.substr(0, cr); - } - return line; -} - -std::string cmQtAutoGenerators::ListQt5RccInputs(cmSourceFile* sf, - cmTarget const* target, - std::vector<std::string>& depends) -{ - std::string rccCommand = this->GetRccExecutable(target); - std::vector<std::string> qrcEntries; - - std::vector<std::string> command; - command.push_back(rccCommand); - command.push_back("-list"); - - std::string absFile = cmsys::SystemTools::GetRealPath( - sf->GetFullPath()); - - command.push_back(absFile); - - std::string rccStdOut; - std::string rccStdErr; - int retVal = 0; - bool result = cmSystemTools::RunSingleCommand( - command, &rccStdOut, &rccStdErr, - &retVal, 0, cmSystemTools::OUTPUT_NONE); - if (!result || retVal) - { - std::cerr << "AUTOGEN: error: Rcc list process for " << sf->GetFullPath() - << " failed:\n" << rccStdOut << "\n" << rccStdErr << std::endl; - return std::string(); - } - - { - std::istringstream ostr(rccStdOut); - std::string oline; - while(std::getline(ostr, oline)) - { - oline = cmQtAutoGeneratorsStripCR(oline); - if(!oline.empty()) - { - qrcEntries.push_back(oline); - } - } - } - - { - std::istringstream estr(rccStdErr); - std::string eline; - while(std::getline(estr, eline)) - { - eline = cmQtAutoGeneratorsStripCR(eline); - if (cmHasLiteralPrefix(eline, "RCC: Error in")) - { - static std::string searchString = "Cannot find file '"; - - std::string::size_type pos = eline.find(searchString); - if (pos == std::string::npos) - { - std::cerr << "AUTOGEN: error: Rcc lists unparsable output " - << eline << std::endl; - return std::string(); - } - pos += searchString.length(); - std::string::size_type sz = eline.size() - pos - 1; - qrcEntries.push_back(eline.substr(pos, sz)); - } - } - } - - depends.insert(depends.end(), qrcEntries.begin(), qrcEntries.end()); - return cmJoin(qrcEntries, "@list_sep@"); -} - -std::string cmQtAutoGenerators::ListQt4RccInputs(cmSourceFile* sf, - std::vector<std::string>& depends) -{ - const std::string qrcContents = ReadAll(sf->GetFullPath()); - - cmsys::RegularExpression fileMatchRegex("(<file[^<]+)"); - - std::string entriesList; - const char* sep = ""; - - size_t offset = 0; - while (fileMatchRegex.find(qrcContents.c_str() + offset)) - { - std::string qrcEntry = fileMatchRegex.match(1); - - offset += qrcEntry.size(); - - cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)"); - fileReplaceRegex.find(qrcEntry); - std::string tag = fileReplaceRegex.match(1); - - qrcEntry = qrcEntry.substr(tag.size()); - - if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str())) - { - qrcEntry = sf->GetLocation().GetDirectory() + "/" + qrcEntry; - } - - entriesList += sep; - entriesList += qrcEntry; - sep = "@list_sep@"; - depends.push_back(qrcEntry); - } - return entriesList; -} - -bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, - cmTarget* target) -{ - cmMakefile* makefile = target->GetMakefile(); - // don't do anything if there is no Qt4 or Qt5Core (which contains moc): - std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); - if (qtMajorVersion == "") - { - qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); - } - if (qtMajorVersion != "4" && qtMajorVersion != "5") - { - return false; - } - - if (target->GetPropertyAsBool("AUTOMOC")) - { - std::string automocTargetName = getAutogenTargetName(target); - std::string mocCppFile = makefile->GetCurrentBinaryDirectory(); - mocCppFile += "/"; - mocCppFile += automocTargetName; - mocCppFile += ".cpp"; - makefile->GetOrCreateSource(mocCppFile, true); - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - mocCppFile.c_str(), false); - - target->AddSource(mocCppFile); - } - // create a custom target for running generators at buildtime: - std::string autogenTargetName = getAutogenTargetName(target); - - std::string targetDir = getAutogenTargetDir(target); - - cmCustomCommandLine currentLine; - currentLine.push_back(cmSystemTools::GetCMakeCommand()); - currentLine.push_back("-E"); - currentLine.push_back("cmake_autogen"); - currentLine.push_back(targetDir); - currentLine.push_back("$<CONFIGURATION>"); - - cmCustomCommandLines commandLines; - commandLines.push_back(currentLine); - - std::string workingDirectory = cmSystemTools::CollapseFullPath( - "", makefile->GetCurrentBinaryDirectory()); - - std::vector<std::string> depends; - if (const char *autogenDepends = - target->GetProperty("AUTOGEN_TARGET_DEPENDS")) - { - cmSystemTools::ExpandListArgument(autogenDepends, depends); - } - std::vector<std::string> toolNames; - if (target->GetPropertyAsBool("AUTOMOC")) - { - toolNames.push_back("moc"); - } - if (target->GetPropertyAsBool("AUTOUIC")) - { - toolNames.push_back("uic"); - } - if (target->GetPropertyAsBool("AUTORCC")) - { - toolNames.push_back("rcc"); - } - - std::string tools = toolNames[0]; - toolNames.erase(toolNames.begin()); - while (toolNames.size() > 1) - { - tools += ", " + toolNames[0]; - toolNames.erase(toolNames.begin()); - } - if (toolNames.size() == 1) - { - tools += " and " + toolNames[0]; - } - std::string autogenComment = "Automatic " + tools + " for target "; - autogenComment += target->GetName(); - -#if defined(_WIN32) && !defined(__CYGWIN__) - bool usePRE_BUILD = false; - cmGlobalGenerator* gg = lg->GetGlobalGenerator(); - if(gg->GetName().find("Visual Studio") != std::string::npos) - { - cmGlobalVisualStudioGenerator* vsgg = - static_cast<cmGlobalVisualStudioGenerator*>(gg); - // Under VS >= 7 use a PRE_BUILD event instead of a separate target to - // reduce the number of targets loaded into the IDE. - // This also works around a VS 11 bug that may skip updating the target: - // https://connect.microsoft.com/VisualStudio/feedback/details/769495 - usePRE_BUILD = vsgg->GetVersion() >= cmGlobalVisualStudioGenerator::VS7; - if(usePRE_BUILD) - { - for (std::vector<std::string>::iterator it = depends.begin(); - it != depends.end(); ++it) - { - if(!makefile->FindTargetToUse(it->c_str())) - { - usePRE_BUILD = false; - break; - } - } - } - } -#endif - - std::vector<std::string> rcc_output; - bool const isNinja = - lg->GetGlobalGenerator()->GetName() == "Ninja"; - if(isNinja -#if defined(_WIN32) && !defined(__CYGWIN__) - || usePRE_BUILD -#endif - ) - { - std::vector<cmSourceFile*> srcFiles; - cmGeneratorTarget* gtgt = - lg->GetGlobalGenerator()->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); - for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); - fileIt != srcFiles.end(); - ++fileIt) - { - cmSourceFile* sf = *fileIt; - std::string absFile = cmsys::SystemTools::GetRealPath( - sf->GetFullPath()); - - std::string ext = sf->GetExtension(); - - if (target->GetPropertyAsBool("AUTORCC")) - { - if (ext == "qrc" - && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) - { - std::string basename = cmsys::SystemTools:: - GetFilenameWithoutLastExtension(absFile); - - std::string rcc_output_dir = target->GetSupportDirectory(); - cmSystemTools::MakeDirectory(rcc_output_dir.c_str()); - std::string rcc_output_file = rcc_output_dir; - rcc_output_file += "/qrc_" + basename + ".cpp"; - rcc_output.push_back(rcc_output_file); - - if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) - { - if (qtMajorVersion == "5") - { - this->ListQt5RccInputs(sf, target, depends); - } - else - { - this->ListQt4RccInputs(sf, depends); - } -#if defined(_WIN32) && !defined(__CYGWIN__) - // Cannot use PRE_BUILD because the resource files themselves - // may not be sources within the target so VS may not know the - // target needs to re-build at all. - usePRE_BUILD = false; -#endif - } - } - } - } - } - -#if defined(_WIN32) && !defined(__CYGWIN__) - if(usePRE_BUILD) - { - // Add the pre-build command directly to bypass the OBJECT_LIBRARY - // rejection in cmMakefile::AddCustomCommandToTarget because we know - // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case. - std::vector<std::string> no_output; - std::vector<std::string> no_byproducts; - cmCustomCommand cc(makefile, no_output, no_byproducts, depends, - commandLines, autogenComment.c_str(), - workingDirectory.c_str()); - cc.SetEscapeOldStyle(false); - cc.SetEscapeAllowMakeVars(true); - target->AddPreBuildCommand(cc); - } - else -#endif - { - cmTarget* autogenTarget = makefile->AddUtilityCommand( - autogenTargetName, true, - workingDirectory.c_str(), - /*byproducts=*/rcc_output, depends, - commandLines, false, autogenComment.c_str()); - - cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); - makefile->AddGeneratorTarget(autogenTarget, gt); - - // Set target folder - const char* autogenFolder = makefile->GetState() - ->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER"); - if (!autogenFolder) - { - autogenFolder = makefile->GetState() - ->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER"); - } - if (autogenFolder && *autogenFolder) - { - autogenTarget->SetProperty("FOLDER", autogenFolder); - } - else - { - // inherit FOLDER property from target (#13688) - copyTargetProperty(autogenTarget, target, "FOLDER"); - } - - target->AddUtility(autogenTargetName); - } - - return true; -} - -static void GetCompileDefinitionsAndDirectories(cmTarget const* target, - const std::string& config, - std::string &incs, - std::string &defs) -{ - cmMakefile* makefile = target->GetMakefile(); - cmGlobalGenerator* globalGen = makefile->GetGlobalGenerator(); - std::vector<std::string> includeDirs; - cmGeneratorTarget *gtgt = globalGen->GetGeneratorTarget(target); - cmLocalGenerator *localGen = gtgt->GetLocalGenerator(); - // Get the include dirs for this target, without stripping the implicit - // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667 - localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false); - - incs = cmJoin(includeDirs, ";"); - - std::set<std::string> defines; - localGen->AddCompileDefinitions(defines, target, config, "CXX"); - - defs += cmJoin(defines, ";"); -} - -void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) -{ - cmMakefile* makefile = target->GetMakefile(); - - // forget the variables added here afterwards again: - cmMakefile::ScopePushPop varScope(makefile); - static_cast<void>(varScope); - - // create a custom target for running generators at buildtime: - std::string autogenTargetName = getAutogenTargetName(target); - - makefile->AddDefinition("_moc_target_name", - cmOutputConverter::EscapeForCMake(autogenTargetName).c_str()); - makefile->AddDefinition("_origin_target_name", - cmOutputConverter::EscapeForCMake(target->GetName()).c_str()); - - std::string targetDir = getAutogenTargetDir(target); - - const char *qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR"); - if (!qtVersion) - { - qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); - } - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - if (const char *targetQtVersion = - gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) - { - qtVersion = targetQtVersion; - } - if (qtVersion) - { - makefile->AddDefinition("_target_qt_version", qtVersion); - } - - std::map<std::string, std::string> configIncludes; - std::map<std::string, std::string> configDefines; - std::map<std::string, std::string> configUicOptions; - - if (target->GetPropertyAsBool("AUTOMOC") - || target->GetPropertyAsBool("AUTOUIC") - || target->GetPropertyAsBool("AUTORCC")) - { - this->SetupSourceFiles(target); - } - makefile->AddDefinition("_cpp_files", - cmOutputConverter::EscapeForCMake(this->Sources).c_str()); - if (target->GetPropertyAsBool("AUTOMOC")) - { - this->SetupAutoMocTarget(target, autogenTargetName, - configIncludes, configDefines); - } - if (target->GetPropertyAsBool("AUTOUIC")) - { - this->SetupAutoUicTarget(target, configUicOptions); - } - if (target->GetPropertyAsBool("AUTORCC")) - { - this->SetupAutoRccTarget(target); - } - - const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT"); - std::string inputFile = cmakeRoot; - inputFile += "/Modules/AutogenInfo.cmake.in"; - std::string outputFile = targetDir; - outputFile += "/AutogenInfo.cmake"; - makefile->AddDefinition("_qt_rcc_inputs", - makefile->GetDefinition("_qt_rcc_inputs_" + target->GetName())); - makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), - false, true, false); - - // Ensure we have write permission in case .in was read-only. - mode_t perm = 0; -#if defined(_WIN32) && !defined(__CYGWIN__) - mode_t mode_write = S_IWRITE; -#else - mode_t mode_write = S_IWUSR; -#endif - cmSystemTools::GetPermissions(outputFile, perm); - if (!(perm & mode_write)) - { - cmSystemTools::SetPermissions(outputFile, perm | mode_write); - } - if (!configDefines.empty() - || !configIncludes.empty() - || !configUicOptions.empty()) - { - cmsys::ofstream infoFile(outputFile.c_str(), std::ios::app); - if ( !infoFile ) - { - std::string error = "Internal CMake error when trying to open file: "; - error += outputFile.c_str(); - error += " for writing."; - cmSystemTools::Error(error.c_str()); - return; - } - if (!configDefines.empty()) - { - for (std::map<std::string, std::string>::iterator - it = configDefines.begin(), end = configDefines.end(); - it != end; ++it) - { - infoFile << "set(AM_MOC_COMPILE_DEFINITIONS_" << it->first << - " " << it->second << ")\n"; - } - } - if (!configIncludes.empty()) - { - for (std::map<std::string, std::string>::iterator - it = configIncludes.begin(), end = configIncludes.end(); - it != end; ++it) - { - infoFile << "set(AM_MOC_INCLUDES_" << it->first << - " " << it->second << ")\n"; - } - } - if (!configUicOptions.empty()) - { - for (std::map<std::string, std::string>::iterator - it = configUicOptions.begin(), end = configUicOptions.end(); - it != end; ++it) - { - infoFile << "set(AM_UIC_TARGET_OPTIONS_" << it->first << - " " << it->second << ")\n"; - } - } - } -} - -void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) -{ - cmMakefile* makefile = target->GetMakefile(); - - const char* sepFiles = ""; - const char* sepHeaders = ""; - - std::vector<cmSourceFile*> srcFiles; - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); - - const char *skipMocSep = ""; - const char *skipUicSep = ""; - - std::vector<std::string> newRccFiles; - - for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); - fileIt != srcFiles.end(); - ++fileIt) - { - cmSourceFile* sf = *fileIt; - std::string absFile = cmsys::SystemTools::GetRealPath( - sf->GetFullPath()); - bool skipMoc = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); - bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")); - - if(cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC"))) - { - this->SkipUic += skipUicSep; - this->SkipUic += absFile; - skipUicSep = ";"; - } - - std::string ext = sf->GetExtension(); - - if (target->GetPropertyAsBool("AUTORCC")) - { - if (ext == "qrc" - && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) - { - std::string basename = cmsys::SystemTools:: - GetFilenameWithoutLastExtension(absFile); - - std::string rcc_output_dir = target->GetSupportDirectory(); - cmSystemTools::MakeDirectory(rcc_output_dir.c_str()); - std::string rcc_output_file = rcc_output_dir; - rcc_output_file += "/qrc_" + basename + ".cpp"; - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - rcc_output_file.c_str(), false); - makefile->GetOrCreateSource(rcc_output_file, true); - newRccFiles.push_back(rcc_output_file); - } - } - - if (!generated) - { - if (skipMoc) - { - this->SkipMoc += skipMocSep; - this->SkipMoc += absFile; - skipMocSep = ";"; - } - else - { - cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat( - ext.c_str()); - if (fileType == cmSystemTools::CXX_FILE_FORMAT) - { - this->Sources += sepFiles; - this->Sources += absFile; - sepFiles = ";"; - } - else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) - { - this->Headers += sepHeaders; - this->Headers += absFile; - sepHeaders = ";"; - } - } - } - } - - for(std::vector<std::string>::const_iterator fileIt = newRccFiles.begin(); - fileIt != newRccFiles.end(); - ++fileIt) - { - const_cast<cmTarget*>(target)->AddSource(*fileIt); - } -} - -void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, - const std::string &autogenTargetName, - std::map<std::string, std::string> &configIncludes, - std::map<std::string, std::string> &configDefines) -{ - cmMakefile* makefile = target->GetMakefile(); - - const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS"); - std::string _moc_options = (tmp!=0 ? tmp : ""); - makefile->AddDefinition("_moc_options", - cmOutputConverter::EscapeForCMake(_moc_options).c_str()); - makefile->AddDefinition("_skip_moc", - cmOutputConverter::EscapeForCMake(this->SkipMoc).c_str()); - makefile->AddDefinition("_moc_headers", - cmOutputConverter::EscapeForCMake(this->Headers).c_str()); - bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); - makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE"); - - std::string _moc_incs; - std::string _moc_compile_defs; - std::vector<std::string> configs; - const std::string& config = makefile->GetConfigurations(configs); - GetCompileDefinitionsAndDirectories(target, config, - _moc_incs, _moc_compile_defs); - - makefile->AddDefinition("_moc_incs", - cmOutputConverter::EscapeForCMake(_moc_incs).c_str()); - makefile->AddDefinition("_moc_compile_defs", - cmOutputConverter::EscapeForCMake(_moc_compile_defs).c_str()); - - for (std::vector<std::string>::const_iterator li = configs.begin(); - li != configs.end(); ++li) - { - std::string config_moc_incs; - std::string config_moc_compile_defs; - GetCompileDefinitionsAndDirectories(target, *li, - config_moc_incs, - config_moc_compile_defs); - if (config_moc_incs != _moc_incs) - { - configIncludes[*li] = - cmOutputConverter::EscapeForCMake(config_moc_incs); - if(_moc_incs.empty()) - { - _moc_incs = config_moc_incs; - } - } - if (config_moc_compile_defs != _moc_compile_defs) - { - configDefines[*li] = - cmOutputConverter::EscapeForCMake(config_moc_compile_defs); - if(_moc_compile_defs.empty()) - { - _moc_compile_defs = config_moc_compile_defs; - } - } - } - - const char *qtVersion = makefile->GetDefinition("_target_qt_version"); - if (strcmp(qtVersion, "5") == 0) - { - cmTarget *qt5Moc = makefile->FindTargetToUse("Qt5::moc"); - if (!qt5Moc) - { - cmSystemTools::Error("Qt5::moc target not found ", - autogenTargetName.c_str()); - return; - } - makefile->AddDefinition("_qt_moc_executable", - qt5Moc->ImportedGetLocation("")); - } - else if (strcmp(qtVersion, "4") == 0) - { - cmTarget *qt4Moc = makefile->FindTargetToUse("Qt4::moc"); - if (!qt4Moc) - { - cmSystemTools::Error("Qt4::moc target not found ", - autogenTargetName.c_str()); - return; - } - makefile->AddDefinition("_qt_moc_executable", - qt4Moc->ImportedGetLocation("")); - } - else - { - cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and " - "Qt 5 ", autogenTargetName.c_str()); - } -} - void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts, const std::vector<std::string> &fileOpts, bool isQt5) @@ -882,332 +168,6 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -static void GetUicOpts(cmTarget const* target, const std::string& config, - std::string &optString) -{ - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - std::vector<std::string> opts; - gtgt->GetAutoUicOptions(opts, config); - optString = cmJoin(opts, ";"); -} - -void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, - std::map<std::string, std::string> &configUicOptions) -{ - cmMakefile *makefile = target->GetMakefile(); - - std::set<std::string> skipped; - std::vector<std::string> skipVec; - cmSystemTools::ExpandListArgument(this->SkipUic, skipVec); - skipped.insert(skipVec.begin(), skipVec.end()); - - makefile->AddDefinition("_skip_uic", - cmOutputConverter::EscapeForCMake(this->SkipUic).c_str()); - - std::vector<cmSourceFile*> uiFilesWithOptions - = makefile->GetQtUiFilesWithOptions(); - - const char *qtVersion = makefile->GetDefinition("_target_qt_version"); - - std::string _uic_opts; - std::vector<std::string> configs; - const std::string& config = makefile->GetConfigurations(configs); - GetUicOpts(target, config, _uic_opts); - - if (!_uic_opts.empty()) - { - _uic_opts = cmOutputConverter::EscapeForCMake(_uic_opts); - makefile->AddDefinition("_uic_target_options", _uic_opts.c_str()); - } - for (std::vector<std::string>::const_iterator li = configs.begin(); - li != configs.end(); ++li) - { - std::string config_uic_opts; - GetUicOpts(target, *li, config_uic_opts); - if (config_uic_opts != _uic_opts) - { - configUicOptions[*li] = - cmOutputConverter::EscapeForCMake(config_uic_opts); - if(_uic_opts.empty()) - { - _uic_opts = config_uic_opts; - } - } - } - - std::string uiFileFiles; - std::string uiFileOptions; - const char* sep = ""; - - for(std::vector<cmSourceFile*>::const_iterator fileIt = - uiFilesWithOptions.begin(); - fileIt != uiFilesWithOptions.end(); - ++fileIt) - { - cmSourceFile* sf = *fileIt; - std::string absFile = cmsys::SystemTools::GetRealPath( - sf->GetFullPath()); - - if (!skipped.insert(absFile).second) - { - continue; - } - uiFileFiles += sep; - uiFileFiles += absFile; - uiFileOptions += sep; - std::string opts = sf->GetProperty("AUTOUIC_OPTIONS"); - cmSystemTools::ReplaceString(opts, ";", "@list_sep@"); - uiFileOptions += opts; - sep = ";"; - } - - makefile->AddDefinition("_qt_uic_options_files", - cmOutputConverter::EscapeForCMake(uiFileFiles).c_str()); - makefile->AddDefinition("_qt_uic_options_options", - cmOutputConverter::EscapeForCMake(uiFileOptions).c_str()); - - std::string targetName = target->GetName(); - if (strcmp(qtVersion, "5") == 0) - { - cmTarget *qt5Uic = makefile->FindTargetToUse("Qt5::uic"); - if (!qt5Uic) - { - // Project does not use Qt5Widgets, but has AUTOUIC ON anyway - } - else - { - makefile->AddDefinition("_qt_uic_executable", - qt5Uic->ImportedGetLocation("")); - } - } - else if (strcmp(qtVersion, "4") == 0) - { - cmTarget *qt4Uic = makefile->FindTargetToUse("Qt4::uic"); - if (!qt4Uic) - { - cmSystemTools::Error("Qt4::uic target not found ", - targetName.c_str()); - return; - } - makefile->AddDefinition("_qt_uic_executable", - qt4Uic->ImportedGetLocation("")); - } - else - { - cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and " - "Qt 5 ", targetName.c_str()); - } -} - -void cmQtAutoGenerators::MergeRccOptions(std::vector<std::string> &opts, - const std::vector<std::string> &fileOpts, - bool isQt5) -{ - static const char* valueOptions[] = { - "name", - "root", - "compress", - "threshold" - }; - std::vector<std::string> extraOpts; - for(std::vector<std::string>::const_iterator it = fileOpts.begin(); - it != fileOpts.end(); ++it) - { - std::vector<std::string>::iterator existingIt - = std::find(opts.begin(), opts.end(), *it); - if (existingIt != opts.end()) - { - const char *o = it->c_str(); - if (*o == '-') - { - ++o; - } - if (isQt5 && *o == '-') - { - ++o; - } - if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions), - cmStrCmp(*it)) != cmArrayEnd(valueOptions)) - { - assert(existingIt + 1 != opts.end()); - *(existingIt + 1) = *(it + 1); - ++it; - } - } - else - { - extraOpts.push_back(*it); - } - } - opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); -} - -void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) -{ - std::string _rcc_files; - const char* sepRccFiles = ""; - cmMakefile *makefile = target->GetMakefile(); - - std::vector<cmSourceFile*> srcFiles; - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); - - std::string qrcInputs; - const char* qrcInputsSep = ""; - - std::string rccFileFiles; - std::string rccFileOptions; - const char *optionSep = ""; - - const char *qtVersion = makefile->GetDefinition("_target_qt_version"); - - std::vector<std::string> rccOptions; - if (const char* opts = target->GetProperty("AUTORCC_OPTIONS")) - { - cmSystemTools::ExpandListArgument(opts, rccOptions); - } - std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); - if (qtMajorVersion == "") - { - qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); - } - - for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); - fileIt != srcFiles.end(); - ++fileIt) - { - cmSourceFile* sf = *fileIt; - std::string ext = sf->GetExtension(); - if (ext == "qrc") - { - std::string absFile = cmsys::SystemTools::GetRealPath( - sf->GetFullPath()); - bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); - - if (!skip) - { - _rcc_files += sepRccFiles; - _rcc_files += absFile; - sepRccFiles = ";"; - - if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS")) - { - std::vector<std::string> optsVec; - cmSystemTools::ExpandListArgument(prop, optsVec); - this->MergeRccOptions(rccOptions, optsVec, - strcmp(qtVersion, "5") == 0); - } - - if (!rccOptions.empty()) - { - rccFileFiles += optionSep; - rccFileFiles += absFile; - rccFileOptions += optionSep; - } - const char *listSep = ""; - for(std::vector<std::string>::const_iterator it = rccOptions.begin(); - it != rccOptions.end(); - ++it) - { - rccFileOptions += listSep; - rccFileOptions += *it; - listSep = "@list_sep@"; - } - optionSep = ";"; - - std::vector<std::string> depends; - - std::string entriesList; - if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) - { - if (qtMajorVersion == "5") - { - entriesList = this->ListQt5RccInputs(sf, target, depends); - } - else - { - entriesList = this->ListQt4RccInputs(sf, depends); - } - if (entriesList.empty()) - { - return; - } - } - qrcInputs += qrcInputsSep; - qrcInputs += entriesList; - qrcInputsSep = ";"; - } - } - } - makefile->AddDefinition("_qt_rcc_inputs_" + target->GetName(), - cmOutputConverter::EscapeForCMake(qrcInputs).c_str()); - - makefile->AddDefinition("_rcc_files", - cmOutputConverter::EscapeForCMake(_rcc_files).c_str()); - - makefile->AddDefinition("_qt_rcc_options_files", - cmOutputConverter::EscapeForCMake(rccFileFiles).c_str()); - makefile->AddDefinition("_qt_rcc_options_options", - cmOutputConverter::EscapeForCMake(rccFileOptions).c_str()); - - makefile->AddDefinition("_qt_rcc_executable", - this->GetRccExecutable(target).c_str()); -} - -std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) -{ - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - cmMakefile *makefile = target->GetMakefile(); - const char *qtVersion = makefile->GetDefinition("_target_qt_version"); - if (!qtVersion) - { - qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR"); - if (!qtVersion) - { - qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); - } - if (const char *targetQtVersion = - gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) - { - qtVersion = targetQtVersion; - } - } - - std::string targetName = target->GetName(); - if (strcmp(qtVersion, "5") == 0) - { - cmTarget *qt5Rcc = makefile->FindTargetToUse("Qt5::rcc"); - if (!qt5Rcc) - { - cmSystemTools::Error("Qt5::rcc target not found ", - targetName.c_str()); - return std::string(); - } - return qt5Rcc->ImportedGetLocation(""); - } - else if (strcmp(qtVersion, "4") == 0) - { - cmTarget *qt4Rcc = makefile->FindTargetToUse("Qt4::rcc"); - if (!qt4Rcc) - { - cmSystemTools::Error("Qt4::rcc target not found ", - targetName.c_str()); - return std::string(); - } - return qt4Rcc->ImportedGetLocation(""); - } - - cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and " - "Qt 5 ", targetName.c_str()); - return std::string(); -} - bool cmQtAutoGenerators::Run(const std::string& targetDirectory, const std::string& config) { @@ -1215,23 +175,24 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cmake cm; cm.SetHomeOutputDirectory(targetDirectory); cm.SetHomeDirectory(targetDirectory); + cm.GetCurrentSnapshot().SetDefaultDefinitions(); cmGlobalGenerator gg(&cm); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); + snapshot.GetDirectory().SetCurrentBinary(targetDirectory); + snapshot.GetDirectory().SetCurrentSource(targetDirectory); + cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, snapshot)); - cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator(mf.get())); - lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); - lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); - gg.SetCurrentMakefile(lg->GetMakefile()); + gg.SetCurrentMakefile(mf.get()); - this->ReadAutogenInfoFile(lg->GetMakefile(), targetDirectory, config); - this->ReadOldMocDefinitionsFile(lg->GetMakefile(), targetDirectory); + this->ReadAutogenInfoFile(mf.get(), targetDirectory, config); + this->ReadOldMocDefinitionsFile(mf.get(), targetDirectory); this->Init(); if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") { - success = this->RunAutogen(lg->GetMakefile()); + success = this->RunAutogen(mf.get()); } this->WriteOldMocDefinitionsFile(targetDirectory); @@ -1533,6 +494,14 @@ void cmQtAutoGenerators::Init() } +static std::string ReadAll(const std::string& filename) +{ + cmsys::ifstream file(filename.c_str()); + std::stringstream stream; + stream << file.rdbuf(); + file.close(); + return stream.str(); +} bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) { @@ -2251,7 +1220,8 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, { std::vector<std::string> fileOpts; cmSystemTools::ExpandListArgument(optionIt->second, fileOpts); - this->MergeUicOptions(opts, fileOpts, this->QtMajorVersion == "5"); + cmQtAutoGenerators::MergeUicOptions(opts, fileOpts, + this->QtMajorVersion == "5"); } command.insert(command.end(), opts.begin(), opts.end()); diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 4f03348..ab7b6ed 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -15,10 +15,11 @@ #define cmQtAutoGenerators_h #include <list> +#include <vector> +#include <string> +#include <map> -class cmGlobalGenerator; class cmMakefile; -class cmLocalGenerator; class cmQtAutoGenerators { @@ -26,18 +27,7 @@ public: cmQtAutoGenerators(); bool Run(const std::string& targetDirectory, const std::string& config); - bool InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target); - void SetupAutoGenerateTarget(cmTarget const* target); - void SetupSourceFiles(cmTarget const* target); - private: - void SetupAutoMocTarget(cmTarget const* target, - const std::string &autogenTargetName, - std::map<std::string, std::string> &configIncludes, - std::map<std::string, std::string> &configDefines); - void SetupAutoUicTarget(cmTarget const* target, - std::map<std::string, std::string> &configUicOptions); - void SetupAutoRccTarget(cmTarget const* target); bool ReadAutogenInfoFile(cmMakefile* makefile, const std::string& targetDirectory, @@ -83,20 +73,9 @@ private: bool EndsWith(const std::string& str, const std::string& with); bool StartsWith(const std::string& str, const std::string& with); - void MergeUicOptions(std::vector<std::string> &opts, - const std::vector<std::string> &fileOpts, bool isQt5); - - void MergeRccOptions(std::vector<std::string> &opts, + static void MergeUicOptions(std::vector<std::string> &opts, const std::vector<std::string> &fileOpts, bool isQt5); - std::string GetRccExecutable(cmTarget const* target); - - std::string ListQt5RccInputs(cmSourceFile* sf, cmTarget const* target, - std::vector<std::string>& depends); - - std::string ListQt4RccInputs(cmSourceFile* sf, - std::vector<std::string>& depends); - bool InputFilesNewerThanQrc(const std::string& qrcFile, const std::string& rccOutput); diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h index 94161f8..410b370 100644 --- a/Source/cmRemoveCommand.h +++ b/Source/cmRemoveCommand.h @@ -47,12 +47,6 @@ public: */ virtual std::string GetName() const {return "remove";} - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - cmTypeMacro(cmRemoveCommand, cmCommand); }; diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 306276b..1d70ad6 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -48,7 +48,7 @@ bool cmSetCommand return true; } - // if it will be cleared, then clear it if it isn;t already clear + // if it will be cleared, then clear it if it isn't already clear if (currValue) { cmSystemTools::PutEnv(putEnvArg); @@ -59,7 +59,7 @@ bool cmSetCommand // SET (VAR) // Removes the definition of VAR. if (args.size() == 1) { - this->Makefile->RemoveDefinition(args[0]); + this->Makefile->RemoveDefinition(variable); return true; } // SET (VAR PARENT_SCOPE) // Removes the definition of VAR diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index 06217bb..b1c13ac 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -10,7 +10,6 @@ See the License for more information. ============================================================================*/ #include "cmSetTargetPropertiesCommand.h" -#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" // cmSetTargetPropertiesCommand diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 86f0a7a..37383be 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -12,7 +12,6 @@ #include "cmSourceFile.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSystemTools.h" #include "cmake.h" diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 4a87cc2..b8d5c02 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -12,7 +12,6 @@ #include "cmSourceFileLocation.h" #include "cmMakefile.h" -#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmSystemTools.h" #include "cmAlgorithms.h" diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index 468a589..dd8fa9c 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -123,4 +123,10 @@ static thisClass* SafeDownCast(cmObject *c) \ } \ class cmTypeMacro_UseTrailingSemicolon +enum cmTargetLinkLibraryType { + GENERAL_LibraryType, + DEBUG_LibraryType, + OPTIMIZED_LibraryType +}; + #endif diff --git a/Source/cmState.cxx b/Source/cmState.cxx index b30c10b..c491c7d 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -12,6 +12,7 @@ #include "cmState.h" #include "cmake.h" +#include "cmVersion.h" #include "cmCacheManager.h" #include "cmCommand.h" #include "cmAlgorithms.h" @@ -82,9 +83,8 @@ struct cmState::BuildsystemDirectoryStateType std::vector<cmState::Snapshot> Children; }; -cmState::cmState(cmake* cm) - : CMakeInstance(cm), - IsInTryCompile(false), +cmState::cmState() + : IsInTryCompile(false), WindowsShell(false), WindowsVSIDE(false), WatcomWMake(false), @@ -92,13 +92,42 @@ cmState::cmState(cmake* cm) NMake(false), MSYSShell(false) { + this->CacheManager = new cmCacheManager; } cmState::~cmState() { + delete this->CacheManager; cmDeleteAll(this->Commands); } +const char* cmState::GetTargetTypeName(cmState::TargetType targetType) +{ + switch( targetType ) + { + case cmState::STATIC_LIBRARY: + return "STATIC_LIBRARY"; + case cmState::MODULE_LIBRARY: + return "MODULE_LIBRARY"; + case cmState::SHARED_LIBRARY: + return "SHARED_LIBRARY"; + case cmState::OBJECT_LIBRARY: + return "OBJECT_LIBRARY"; + case cmState::EXECUTABLE: + return "EXECUTABLE"; + case cmState::UTILITY: + return "UTILITY"; + case cmState::GLOBAL_TARGET: + return "GLOBAL_TARGET"; + case cmState::INTERFACE_LIBRARY: + return "INTERFACE_LIBRARY"; + case cmState::UNKNOWN_LIBRARY: + return "UNKNOWN_LIBRARY"; + } + assert(0 && "Unexpected target type"); + return 0; +} + const char* cmCacheEntryTypes[] = { "BOOL", "PATH", @@ -147,12 +176,30 @@ bool cmState::IsCacheEntryType(std::string const& key) return false; } +bool cmState::LoadCache(const std::string& path, bool internal, + std::set<std::string>& excludes, + std::set<std::string>& includes) +{ + return this->CacheManager->LoadCache(path, internal, + excludes, includes); +} + +bool cmState::SaveCache(const std::string& path) +{ + return this->CacheManager->SaveCache(path); +} + +bool cmState::DeleteCache(const std::string& path) +{ + return this->CacheManager->DeleteCache(path); +} + std::vector<std::string> cmState::GetCacheEntryKeys() const { std::vector<std::string> definitions; - definitions.reserve(this->CMakeInstance->GetCacheManager()->GetSize()); + definitions.reserve(this->CacheManager->GetSize()); cmCacheManager::CacheIterator cit = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(); + this->CacheManager->GetCacheIterator(); for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() ) { definitions.push_back(cit.GetName()); @@ -162,7 +209,7 @@ std::vector<std::string> cmState::GetCacheEntryKeys() const const char* cmState::GetCacheEntryValue(std::string const& key) const { - cmCacheManager::CacheEntry* e = this->CMakeInstance->GetCacheManager() + cmCacheManager::CacheEntry* e = this->CacheManager ->GetCacheEntry(key); if (!e) { @@ -174,21 +221,21 @@ const char* cmState::GetCacheEntryValue(std::string const& key) const const char* cmState::GetInitializedCacheValue(std::string const& key) const { - return this->CMakeInstance->GetCacheManager()->GetInitializedCacheValue(key); + return this->CacheManager->GetInitializedCacheValue(key); } cmState::CacheEntryType cmState::GetCacheEntryType(std::string const& key) const { cmCacheManager::CacheIterator it = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str()); + this->CacheManager->GetCacheIterator(key.c_str()); return it.GetType(); } void cmState::SetCacheEntryValue(std::string const& key, std::string const& value) { - this->CMakeInstance->GetCacheManager()->SetCacheEntryValue(key, value); + this->CacheManager->SetCacheEntryValue(key, value); } void cmState::SetCacheEntryProperty(std::string const& key, @@ -196,7 +243,7 @@ void cmState::SetCacheEntryProperty(std::string const& key, std::string const& value) { cmCacheManager::CacheIterator it = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str()); + this->CacheManager->GetCacheIterator(key.c_str()); it.SetProperty(propertyName, value.c_str()); } @@ -205,14 +252,14 @@ void cmState::SetCacheEntryBoolProperty(std::string const& key, bool value) { cmCacheManager::CacheIterator it = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str()); + this->CacheManager->GetCacheIterator(key.c_str()); it.SetProperty(propertyName, value); } const char* cmState::GetCacheEntryProperty(std::string const& key, std::string const& propertyName) { - cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager() + cmCacheManager::CacheIterator it = this->CacheManager ->GetCacheIterator(key.c_str()); if (!it.PropertyExists(propertyName)) { @@ -224,7 +271,7 @@ const char* cmState::GetCacheEntryProperty(std::string const& key, bool cmState::GetCacheEntryPropertyAsBool(std::string const& key, std::string const& propertyName) { - return this->CMakeInstance->GetCacheManager() + return this->CacheManager ->GetCacheIterator(key.c_str()).GetPropertyAsBool(propertyName); } @@ -232,13 +279,13 @@ void cmState::AddCacheEntry(const std::string& key, const char* value, const char* helpString, cmState::CacheEntryType type) { - this->CMakeInstance->GetCacheManager()->AddCacheEntry(key, value, + this->CacheManager->AddCacheEntry(key, value, helpString, type); } void cmState::RemoveCacheEntry(std::string const& key) { - this->CMakeInstance->GetCacheManager()->RemoveCacheEntry(key); + this->CacheManager->RemoveCacheEntry(key); } void cmState::AppendCacheEntryProperty(const std::string& key, @@ -246,7 +293,7 @@ void cmState::AppendCacheEntryProperty(const std::string& key, const std::string& value, bool asString) { - this->CMakeInstance->GetCacheManager() + this->CacheManager ->GetCacheIterator(key.c_str()).AppendProperty(property, value.c_str(), asString); @@ -255,7 +302,7 @@ void cmState::AppendCacheEntryProperty(const std::string& key, void cmState::RemoveCacheEntryProperty(std::string const& key, std::string const& propertyName) { - this->CMakeInstance->GetCacheManager() + this->CacheManager ->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0); } @@ -287,11 +334,21 @@ cmState::Snapshot cmState::Reset() pos->PolicyScope = this->PolicyStack.Root(); assert(pos->Policies.IsValid()); assert(pos->PolicyRoot.IsValid()); + + { + std::string srcDir = + cmDefinitions::Get("CMAKE_SOURCE_DIR", pos->Vars, pos->Root); + std::string binDir = + cmDefinitions::Get("CMAKE_BINARY_DIR", pos->Vars, pos->Root); this->VarTree.Clear(); pos->Vars = this->VarTree.Extend(this->VarTree.Root()); pos->Parent = this->VarTree.Root(); pos->Root = this->VarTree.Root(); + pos->Vars->Set("CMAKE_SOURCE_DIR", srcDir.c_str()); + pos->Vars->Set("CMAKE_BINARY_DIR", binDir.c_str()); + } + this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, "", "", true); @@ -659,6 +716,16 @@ bool cmState::UseMSYSShell() const return this->MSYSShell; } +unsigned int cmState::GetCacheMajorVersion() const +{ + return this->CacheManager->GetCacheMajorVersion(); +} + +unsigned int cmState::GetCacheMinorVersion() const +{ + return this->CacheManager->GetCacheMinorVersion(); +} + const char* cmState::GetBinaryDirectory() const { return this->BinaryDirectory.c_str(); @@ -805,8 +872,12 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->Parent = origin; pos->Root = origin; pos->Vars = this->VarTree.Extend(origin); + cmState::Snapshot snapshot = cmState::Snapshot(this, pos); originSnapshot.Position->BuildSystemDirectory->Children.push_back(snapshot); + snapshot.SetDefaultDefinitions(); + snapshot.InitializeFromParent(); + snapshot.SetDirectoryDefinitions(); return snapshot; } @@ -978,6 +1049,8 @@ void cmState::Directory::SetCurrentSource(std::string const& dir) loc, this->DirectoryState->CurrentSourceDirectoryComponents); this->ComputeRelativePathTopSource(); + + this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc.c_str()); } const char* cmState::Directory::GetCurrentBinary() const @@ -996,6 +1069,8 @@ void cmState::Directory::SetCurrentBinary(std::string const& dir) loc, this->DirectoryState->CurrentBinaryDirectoryComponents); this->ComputeRelativePathTopBinary(); + + this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc.c_str()); } void cmState::Snapshot::SetListFile(const std::string& listfile) @@ -1067,7 +1142,8 @@ cmState::Snapshot cmState::Snapshot::GetBuildsystemDirectoryParent() const PositionType parentPos = this->Position->DirectoryParent; if (parentPos != this->State->SnapshotData.Root()) { - snapshot = Snapshot(this->State, parentPos); + snapshot = Snapshot(this->State, + parentPos->BuildSystemDirectory->DirectoryEnd); } return snapshot; @@ -1286,6 +1362,70 @@ void InitializeContentFromParent(T& parentContent, contentEndPosition = thisContent.size(); } +void cmState::Snapshot::SetDefaultDefinitions() +{ + /* Up to CMake 2.4 here only WIN32, UNIX and APPLE were set. + With CMake must separate between target and host platform. In most cases + the tests for WIN32, UNIX and APPLE will be for the target system, so an + additional set of variables for the host system is required -> + CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE. + WIN32, UNIX and APPLE are now set in the platform files in + Modules/Platforms/. + To keep cmake scripts (-P) and custom language and compiler modules + working, these variables are still also set here in this place, but they + will be reset in CMakeSystemSpecificInformation.cmake before the platform + files are executed. */ + #if defined(_WIN32) + this->SetDefinition("WIN32", "1"); + this->SetDefinition("CMAKE_HOST_WIN32", "1"); + #else + this->SetDefinition("UNIX", "1"); + this->SetDefinition("CMAKE_HOST_UNIX", "1"); + #endif + #if defined(__CYGWIN__) + if(cmSystemTools::IsOn(cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32"))) + { + this->SetDefinition("WIN32", "1"); + this->SetDefinition("CMAKE_HOST_WIN32", "1"); + } + #endif + #if defined(__APPLE__) + this->SetDefinition("APPLE", "1"); + this->SetDefinition("CMAKE_HOST_APPLE", "1"); + #endif + + char temp[1024]; + sprintf(temp, "%d", cmVersion::GetMinorVersion()); + this->SetDefinition("CMAKE_MINOR_VERSION", temp); + sprintf(temp, "%d", cmVersion::GetMajorVersion()); + this->SetDefinition("CMAKE_MAJOR_VERSION", temp); + sprintf(temp, "%d", cmVersion::GetPatchVersion()); + this->SetDefinition("CMAKE_PATCH_VERSION", temp); + sprintf(temp, "%d", cmVersion::GetTweakVersion()); + this->SetDefinition("CMAKE_TWEAK_VERSION", temp); + this->SetDefinition("CMAKE_VERSION", + cmVersion::GetCMakeVersion()); + + this->SetDefinition("CMAKE_FILES_DIRECTORY", + cmake::GetCMakeFilesDirectory()); + + // Setup the default include file regular expression (match everything). + this->Position->BuildSystemDirectory + ->Properties.SetProperty("INCLUDE_REGULAR_EXPRESSION", "^.*$"); +} + +void cmState::Snapshot::SetDirectoryDefinitions() +{ + this->SetDefinition("CMAKE_SOURCE_DIR", + this->State->GetSourceDirectory()); + this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", + this->State->GetSourceDirectory()); + this->SetDefinition("CMAKE_BINARY_DIR", + this->State->GetBinaryDirectory()); + this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", + this->State->GetBinaryDirectory()); +} + void cmState::Snapshot::InitializeFromParent() { PositionType parent = this->Position->DirectoryParent; @@ -1334,6 +1474,20 @@ std::string cmState::Snapshot::GetProjectName() const return this->Position->BuildSystemDirectory->ProjectName; } +void cmState::Snapshot::InitializeFromParent_ForSubdirsCommand() +{ + std::string currentSrcDir = this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR"); + std::string currentBinDir = this->GetDefinition("CMAKE_CURRENT_BINARY_DIR"); + this->InitializeFromParent(); + this->SetDefinition("CMAKE_SOURCE_DIR", + this->State->GetSourceDirectory()); + this->SetDefinition("CMAKE_BINARY_DIR", + this->State->GetBinaryDirectory()); + + this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", currentSrcDir.c_str()); + this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", currentBinDir.c_str()); +} + cmState::Directory::Directory( cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter, const cmState::Snapshot& snapshot) @@ -1376,11 +1530,16 @@ cmBacktraceRange GetPropertyBacktraces(T const& content, template <typename T, typename U, typename V> void AppendEntry(T& content, U& backtraces, V& endContentPosition, - const std::string& vec, const cmListFileBacktrace& lfbt) + const std::string& value, const cmListFileBacktrace& lfbt) { + if (value.empty()) + { + return; + } + assert(endContentPosition == content.size()); - content.push_back(vec); + content.push_back(value); backtraces.push_back(lfbt); endContentPosition = content.size(); @@ -1733,3 +1892,87 @@ bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) { return lhs.Position != rhs.Position; } + +static bool ParseEntryWithoutType(const std::string& entry, + std::string& var, + std::string& value) +{ + // input line is: key=value + static cmsys::RegularExpression reg( + "^([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + // input line is: "key"=value + static cmsys::RegularExpression regQuoted( + "^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + bool flag = false; + if(regQuoted.find(entry)) + { + var = regQuoted.match(1); + value = regQuoted.match(2); + flag = true; + } + else if (reg.find(entry)) + { + var = reg.match(1); + value = reg.match(2); + flag = true; + } + + // if value is enclosed in single quotes ('foo') then remove them + // it is used to enclose trailing space or tab + if (flag && + value.size() >= 2 && + value[0] == '\'' && + value[value.size() - 1] == '\'') + { + value = value.substr(1, + value.size() - 2); + } + + return flag; +} + +bool cmState::ParseCacheEntry(const std::string& entry, + std::string& var, + std::string& value, + CacheEntryType& type) +{ + // input line is: key:type=value + static cmsys::RegularExpression reg( + "^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + // input line is: "key":type=value + static cmsys::RegularExpression regQuoted( + "^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + bool flag = false; + if(regQuoted.find(entry)) + { + var = regQuoted.match(1); + type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str()); + value = regQuoted.match(3); + flag = true; + } + else if (reg.find(entry)) + { + var = reg.match(1); + type = cmState::StringToCacheEntryType(reg.match(2).c_str()); + value = reg.match(3); + flag = true; + } + + // if value is enclosed in single quotes ('foo') then remove them + // it is used to enclose trailing space or tab + if (flag && + value.size() >= 2 && + value[0] == '\'' && + value[value.size() - 1] == '\'') + { + value = value.substr(1, + value.size() - 2); + } + + if (!flag) + { + return ParseEntryWithoutType(entry, var, value); + } + + return flag; +} diff --git a/Source/cmState.h b/Source/cmState.h index 99e537c..7d1fc80 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -23,6 +23,7 @@ class cmake; class cmCommand; class cmDefinitions; class cmListFileBacktrace; +class cmCacheManager; class cmState { @@ -32,7 +33,7 @@ class cmState typedef cmLinkedTree<SnapshotDataType>::iterator PositionType; friend class Snapshot; public: - cmState(cmake* cm); + cmState(); ~cmState(); enum SnapshotType @@ -75,8 +76,6 @@ public: Snapshot GetCallStackParent() const; SnapshotType GetType() const; - void InitializeFromParent(); - void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id) const; bool HasDefinedPolicyCMP0011(); @@ -91,12 +90,17 @@ public: void SetProjectName(std::string const& name); std::string GetProjectName() const; + void InitializeFromParent_ForSubdirsCommand(); + struct StrictWeakOrder { bool operator()(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) const; }; + void SetDirectoryDefinitions(); + void SetDefaultDefinitions(); + private: friend bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs); @@ -105,6 +109,9 @@ public: friend class cmState; friend class Directory; friend struct StrictWeakOrder; + + void InitializeFromParent(); + cmState* State; cmState::PositionType Position; }; @@ -174,6 +181,14 @@ public: friend class Snapshot; }; + enum TargetType { EXECUTABLE, STATIC_LIBRARY, + SHARED_LIBRARY, MODULE_LIBRARY, + OBJECT_LIBRARY, UTILITY, GLOBAL_TARGET, + INTERFACE_LIBRARY, + UNKNOWN_LIBRARY}; + + static const char* GetTargetTypeName(cmState::TargetType targetType); + Snapshot CreateBaseSnapshot(); Snapshot CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, @@ -207,6 +222,14 @@ public: static const char* CacheEntryTypeToString(CacheEntryType); static bool IsCacheEntryType(std::string const& key); + bool LoadCache(const std::string& path, bool internal, + std::set<std::string>& excludes, + std::set<std::string>& includes); + + bool SaveCache(const std::string& path) ; + + bool DeleteCache(const std::string& path); + std::vector<std::string> GetCacheEntryKeys() const; const char* GetCacheEntryValue(std::string const& key) const; const char* GetInitializedCacheValue(std::string const& key) const; @@ -214,8 +237,6 @@ public: void SetCacheEntryValue(std::string const& key, std::string const& value); void SetCacheValue(std::string const& key, std::string const& value); - void AddCacheEntry(const std::string& key, const char* value, - const char* helpString, CacheEntryType type); void RemoveCacheEntry(std::string const& key); void SetCacheEntryProperty(std::string const& key, @@ -235,6 +256,12 @@ public: void RemoveCacheEntryProperty(std::string const& key, std::string const& propertyName); + ///! Break up a line like VAR:type="value" into var, type and value + static bool ParseCacheEntry(const std::string& entry, + std::string& var, + std::string& value, + CacheEntryType& type); + Snapshot Reset(); // Define a property void DefineProperty(const std::string& name, cmProperty::ScopeType scope, @@ -295,12 +322,19 @@ public: void SetMSYSShell(bool mSYSShell); bool UseMSYSShell() const; + unsigned int GetCacheMajorVersion() const; + unsigned int GetCacheMinorVersion() const; + private: + friend class cmake; + void AddCacheEntry(const std::string& key, const char* value, + const char* helpString, CacheEntryType type); + std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions; std::vector<std::string> EnabledLanguages; std::map<std::string, cmCommand*> Commands; cmPropertyMap GlobalProperties; - cmake* CMakeInstance; + cmCacheManager* CacheManager; cmLinkedTree<BuildsystemDirectoryStateType> BuildsystemDirectory; diff --git a/Source/cmSubdirCommand.h b/Source/cmSubdirCommand.h index 6addd8f..bcefd2c 100644 --- a/Source/cmSubdirCommand.h +++ b/Source/cmSubdirCommand.h @@ -44,12 +44,6 @@ public: */ virtual std::string GetName() const { return "subdirs";} - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - cmTypeMacro(cmSubdirCommand, cmCommand); }; diff --git a/Source/cmSubdirDependsCommand.h b/Source/cmSubdirDependsCommand.h index 75a5685..3f3507e 100644 --- a/Source/cmSubdirDependsCommand.h +++ b/Source/cmSubdirDependsCommand.h @@ -21,7 +21,6 @@ public: virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); virtual std::string GetName() const { return "subdir_depends";} - virtual bool IsDiscouraged() const { return true; } cmTypeMacro(cmSubdirDependsCommand, cmCommand); }; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 005a803..2c5aa8a 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2045,10 +2045,11 @@ bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile) cmSystemToolsWindowsHandle hFrom = CreateFileW(SystemTools::ConvertToWindowsExtendedPath(fromFile).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, - OPEN_EXISTING, 0, 0); + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); cmSystemToolsWindowsHandle hTo = CreateFileW(SystemTools::ConvertToWindowsExtendedPath(toFile).c_str(), - GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); + FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, 0); if(!hFrom || !hTo) { return false; @@ -2100,7 +2101,8 @@ bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t) #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle h = CreateFileW(SystemTools::ConvertToWindowsExtendedPath(fname).c_str(), - GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); + GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, 0); if(!h) { return false; @@ -2127,7 +2129,8 @@ bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t) #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle h = CreateFileW(SystemTools::ConvertToWindowsExtendedPath(fname).c_str(), - GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); + FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, 0); if(!h) { return false; @@ -2216,6 +2219,7 @@ static std::string cmSystemToolsCTestCommand; static std::string cmSystemToolsCPackCommand; static std::string cmSystemToolsCMakeCursesCommand; static std::string cmSystemToolsCMakeGUICommand; +static std::string cmSystemToolsCMClDepsCommand; static std::string cmSystemToolsCMakeRoot; void cmSystemTools::FindCMakeResources(const char* argv0) { @@ -2308,6 +2312,13 @@ void cmSystemTools::FindCMakeResources(const char* argv0) { cmSystemToolsCMakeCursesCommand = ""; } + cmSystemToolsCMClDepsCommand = exe_dir; + cmSystemToolsCMClDepsCommand += "/cmcldeps"; + cmSystemToolsCMClDepsCommand += cmSystemTools::GetExecutableExtension(); + if(!cmSystemTools::FileExists(cmSystemToolsCMClDepsCommand.c_str())) + { + cmSystemToolsCMClDepsCommand = ""; + } #ifdef CMAKE_BUILD_WITH_CMAKE // Install tree has "<prefix>/bin/cmake" and "<prefix><CMAKE_DATA_DIR>". @@ -2375,6 +2386,12 @@ std::string const& cmSystemTools::GetCMakeGUICommand() } //---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCMClDepsCommand() +{ + return cmSystemToolsCMClDepsCommand; +} + +//---------------------------------------------------------------------------- std::string const& cmSystemTools::GetCMakeRoot() { return cmSystemToolsCMakeRoot; @@ -2760,6 +2777,14 @@ bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op, } //---------------------------------------------------------------------------- +bool cmSystemTools::VersionCompareGreater(std::string const& lhs, + std::string const& rhs) +{ + return cmSystemTools::VersionCompare( + cmSystemTools::OP_GREATER, lhs.c_str(), rhs.c_str()); +} + +//---------------------------------------------------------------------------- bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg, bool* removed) { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index d14897f..b6b0978 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -294,6 +294,8 @@ public: * Compare versions */ static bool VersionCompare(CompareOp op, const char* lhs, const char* rhs); + static bool VersionCompareGreater(std::string const& lhs, + std::string const& rhs); /** * Determine the file type based on the extension @@ -426,6 +428,7 @@ public: static std::string const& GetCMakeCommand(); static std::string const& GetCMakeGUICommand(); static std::string const& GetCMakeCursesCommand(); + static std::string const& GetCMClDepsCommand(); static std::string const& GetCMakeRoot(); /** Echo a message in color using KWSys's Terminal cprintf. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3425f34..e056469 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -33,91 +33,10 @@ #define UNORDERED_SET std::set #endif -const char* cmTarget::GetTargetTypeName(TargetType targetType) -{ - switch( targetType ) - { - case cmTarget::STATIC_LIBRARY: - return "STATIC_LIBRARY"; - case cmTarget::MODULE_LIBRARY: - return "MODULE_LIBRARY"; - case cmTarget::SHARED_LIBRARY: - return "SHARED_LIBRARY"; - case cmTarget::OBJECT_LIBRARY: - return "OBJECT_LIBRARY"; - case cmTarget::EXECUTABLE: - return "EXECUTABLE"; - case cmTarget::UTILITY: - return "UTILITY"; - case cmTarget::GLOBAL_TARGET: - return "GLOBAL_TARGET"; - case cmTarget::INTERFACE_LIBRARY: - return "INTERFACE_LIBRARY"; - case cmTarget::UNKNOWN_LIBRARY: - return "UNKNOWN_LIBRARY"; - } - assert(0 && "Unexpected target type"); - return 0; -} - -//---------------------------------------------------------------------------- -struct cmTarget::OutputInfo -{ - std::string OutDir; - std::string ImpDir; - std::string PdbDir; - bool empty() const - { return OutDir.empty() && ImpDir.empty() && PdbDir.empty(); } -}; - //---------------------------------------------------------------------------- class cmTargetInternals { public: - cmTargetInternals() - : Backtrace() - { - this->UtilityItemsDone = false; - } - cmTargetInternals(cmTargetInternals const&) - : Backtrace() - { - this->UtilityItemsDone = false; - } - ~cmTargetInternals(); - - // The backtrace when the target was created. - cmListFileBacktrace Backtrace; - - typedef std::map<std::string, cmTarget::OutputInfo> OutputInfoMapType; - OutputInfoMapType OutputInfoMap; - - typedef std::map<std::string, cmTarget::ImportInfo> ImportInfoMapType; - ImportInfoMapType ImportInfoMap; - - struct HeadToLinkImplementationMap: - public std::map<cmTarget const*, cmOptionalLinkImplementation> {}; - typedef std::map<std::string, - HeadToLinkImplementationMap> LinkImplMapType; - LinkImplMapType LinkImplMap; - - typedef std::map<std::string, std::vector<cmSourceFile*> > - SourceFilesMapType; - SourceFilesMapType SourceFilesMap; - - std::set<cmLinkItem> UtilityItems; - bool UtilityItemsDone; - - class TargetPropertyEntry { - static cmLinkImplItem NoLinkImplItem; - public: - TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge, - cmLinkImplItem const& item = NoLinkImplItem) - : ge(cge), LinkImplItem(item) - {} - const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge; - cmLinkImplItem const& LinkImplItem; - }; std::vector<std::string> IncludeDirectoriesEntries; std::vector<cmListFileBacktrace> IncludeDirectoriesBacktraces; std::vector<std::string> CompileOptionsEntries; @@ -126,21 +45,12 @@ public: std::vector<cmListFileBacktrace> CompileFeaturesBacktraces; std::vector<std::string> CompileDefinitionsEntries; std::vector<cmListFileBacktrace> CompileDefinitionsBacktraces; - std::vector<TargetPropertyEntry*> SourceEntries; - std::vector<cmValueWithOrigin> LinkImplementationPropertyEntries; - - void AddInterfaceEntries( - cmTarget const* thisTarget, std::string const& config, - std::string const& prop, std::vector<TargetPropertyEntry*>& entries); + std::vector<std::string> SourceEntries; + std::vector<cmListFileBacktrace> SourceBacktraces; + std::vector<std::string> LinkImplementationPropertyEntries; + std::vector<cmListFileBacktrace> LinkImplementationPropertyBacktraces; }; -cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem; - -//---------------------------------------------------------------------------- -cmTargetInternals::~cmTargetInternals() -{ -} - //---------------------------------------------------------------------------- cmTarget::cmTarget() { @@ -154,17 +64,15 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugSourcesDone = false; - this->LinkImplementationLanguageIsContextDependent = true; } -void cmTarget::SetType(TargetType type, const std::string& name) +void cmTarget::SetType(cmState::TargetType type, const std::string& name) { this->Name = name; // only add dependency information for library targets this->TargetTypeValue = type; - if(this->TargetTypeValue >= STATIC_LIBRARY - && this->TargetTypeValue <= MODULE_LIBRARY) + if(this->TargetTypeValue >= cmState::STATIC_LIBRARY + && this->TargetTypeValue <= cmState::MODULE_LIBRARY) { this->RecordDependencies = true; } @@ -194,7 +102,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->IsApple = this->Makefile->IsOn("APPLE"); // Setup default property values. - if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) + if (this->GetType() != cmState::INTERFACE_LIBRARY + && this->GetType() != cmState::UTILITY) { this->SetPropertyDefault("ANDROID_API", 0); this->SetPropertyDefault("ANDROID_API_MIN", 0); @@ -257,7 +166,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) mf->GetConfigurations(configNames); // Setup per-configuration property default values. - if (this->GetType() != UTILITY) + if (this->GetType() != cmState::UTILITY) { const char* configProps[] = { "ARCHIVE_OUTPUT_DIRECTORY_", @@ -273,7 +182,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) std::string configUpper = cmSystemTools::UpperCase(*ci); for(const char** p = configProps; *p; ++p) { - if (this->TargetTypeValue == INTERFACE_LIBRARY + if (this->TargetTypeValue == cmState::INTERFACE_LIBRARY && strcmp(*p, "MAP_IMPORTED_CONFIG_") != 0) { continue; @@ -288,8 +197,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) // compatibility with previous CMake versions in which executables // did not support this variable. Projects may still specify the // property directly. - if(this->TargetTypeValue != cmTarget::EXECUTABLE - && this->TargetTypeValue != cmTarget::INTERFACE_LIBRARY) + if(this->TargetTypeValue != cmState::EXECUTABLE + && this->TargetTypeValue != cmState::INTERFACE_LIBRARY) { std::string property = cmSystemTools::UpperCase(*ci); property += "_POSTFIX"; @@ -299,7 +208,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) } // Save the backtrace of target construction. - this->Internal->Backtrace = this->Makefile->GetBacktrace(); + this->Backtrace = this->Makefile->GetBacktrace(); if (!this->IsImported()) { @@ -336,29 +245,32 @@ void cmTarget::SetMakefile(cmMakefile* mf) parentOptionsBts.begin(), parentOptionsBts.end()); } - if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) + if (this->GetType() != cmState::INTERFACE_LIBRARY + && this->GetType() != cmState::UTILITY) { this->SetPropertyDefault("C_VISIBILITY_PRESET", 0); this->SetPropertyDefault("CXX_VISIBILITY_PRESET", 0); this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", 0); } - if(this->TargetTypeValue == cmTarget::EXECUTABLE) + if(this->TargetTypeValue == cmState::EXECUTABLE) { this->SetPropertyDefault("ANDROID_GUI", 0); this->SetPropertyDefault("CROSSCOMPILING_EMULATOR", 0); + this->SetPropertyDefault("ENABLE_EXPORTS", 0); } - if(this->TargetTypeValue == cmTarget::SHARED_LIBRARY - || this->TargetTypeValue == cmTarget::MODULE_LIBRARY) + if(this->TargetTypeValue == cmState::SHARED_LIBRARY + || this->TargetTypeValue == cmState::MODULE_LIBRARY) { this->SetProperty("POSITION_INDEPENDENT_CODE", "True"); } - if(this->TargetTypeValue == cmTarget::SHARED_LIBRARY) + if(this->TargetTypeValue == cmState::SHARED_LIBRARY) { this->SetPropertyDefault("WINDOWS_EXPORT_ALL_SYMBOLS", 0); } - if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) + if (this->GetType() != cmState::INTERFACE_LIBRARY + && this->GetType() != cmState::UTILITY) { this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", 0); } @@ -366,36 +278,22 @@ void cmTarget::SetMakefile(cmMakefile* mf) // Record current policies for later use. this->Makefile->RecordPolicies(this->PolicyMap); - if (this->TargetTypeValue == INTERFACE_LIBRARY) + if (this->TargetTypeValue == cmState::INTERFACE_LIBRARY) { // This policy is checked in a few conditions. The properties relevant - // to the policy are always ignored for INTERFACE_LIBRARY targets, + // to the policy are always ignored for cmState::INTERFACE_LIBRARY targets, // so ensure that the conditions don't lead to nonsense. this->PolicyMap.Set(cmPolicies::CMP0022, cmPolicies::NEW); } - if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) + if (this->GetType() != cmState::INTERFACE_LIBRARY + && this->GetType() != cmState::UTILITY) { this->SetPropertyDefault("JOB_POOL_COMPILE", 0); this->SetPropertyDefault("JOB_POOL_LINK", 0); } } -void CreatePropertyGeneratorExpressions( - std::vector<std::string> const& entries, - std::vector<cmListFileBacktrace> const& backtraces, - std::vector<cmTargetInternals::TargetPropertyEntry*>& items) -{ - std::vector<cmListFileBacktrace>::const_iterator btIt = backtraces.begin(); - for (std::vector<std::string>::const_iterator it = entries.begin(); - it != entries.end(); ++it, ++btIt) - { - cmGeneratorExpression ge(*btIt); - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*it); - items.push_back(new cmTargetInternals::TargetPropertyEntry(cge)); - } -} - //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { @@ -417,29 +315,12 @@ cmListFileBacktrace const* cmTarget::GetUtilityBacktrace( } //---------------------------------------------------------------------------- -std::set<cmLinkItem> const& cmTarget::GetUtilityItems() const -{ - if(!this->Internal->UtilityItemsDone) - { - this->Internal->UtilityItemsDone = true; - for(std::set<std::string>::const_iterator i = this->Utilities.begin(); - i != this->Utilities.end(); ++i) - { - this->Internal->UtilityItems.insert( - cmLinkItem(*i, this->Makefile->FindTargetToUse(*i))); - } - } - return this->Internal->UtilityItems; -} - -//---------------------------------------------------------------------------- void cmTarget::FinishConfigure() { // Erase any cached link information that might have been comptued // on-demand during the configuration. This ensures that build // system generation uses up-to-date information even if other cache // invalidation code in this source file is buggy. - this->ClearLinkMaps(); #if defined(_WIN32) && !defined(__CYGWIN__) // Do old-style link dependency analysis only for CM_USE_OLD_VS6. @@ -451,64 +332,30 @@ void cmTarget::FinishConfigure() } //---------------------------------------------------------------------------- -void cmTarget::ClearLinkMaps() -{ - this->LinkImplementationLanguageIsContextDependent = true; - this->Internal->LinkImplMap.clear(); - this->Internal->SourceFilesMap.clear(); -} - -//---------------------------------------------------------------------------- cmListFileBacktrace const& cmTarget::GetBacktrace() const { - return this->Internal->Backtrace; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetSupportDirectory() const -{ - std::string dir = this->Makefile->GetCurrentBinaryDirectory(); - dir += cmake::GetCMakeFilesDirectory(); - dir += "/"; - dir += this->Name; -#if defined(__VMS) - dir += "_dir"; -#else - dir += ".dir"; -#endif - return dir; + return this->Backtrace; } //---------------------------------------------------------------------------- bool cmTarget::IsExecutableWithExports() const { - return (this->GetType() == cmTarget::EXECUTABLE && + return (this->GetType() == cmState::EXECUTABLE && this->GetPropertyAsBool("ENABLE_EXPORTS")); } //---------------------------------------------------------------------------- -bool cmTarget::IsLinkable() const -{ - return (this->GetType() == cmTarget::STATIC_LIBRARY || - this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || - this->GetType() == cmTarget::UNKNOWN_LIBRARY || - this->GetType() == cmTarget::INTERFACE_LIBRARY || - this->IsExecutableWithExports()); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasImportLibrary() const { return (this->DLLPlatform && - (this->GetType() == cmTarget::SHARED_LIBRARY || + (this->GetType() == cmState::SHARED_LIBRARY || this->IsExecutableWithExports())); } //---------------------------------------------------------------------------- bool cmTarget::IsFrameworkOnApple() const { - return (this->GetType() == cmTarget::SHARED_LIBRARY && + return (this->GetType() == cmState::SHARED_LIBRARY && this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("FRAMEWORK")); } @@ -516,268 +363,19 @@ bool cmTarget::IsFrameworkOnApple() const //---------------------------------------------------------------------------- bool cmTarget::IsAppBundleOnApple() const { - return (this->GetType() == cmTarget::EXECUTABLE && + return (this->GetType() == cmState::EXECUTABLE && this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("MACOSX_BUNDLE")); } //---------------------------------------------------------------------------- -bool cmTarget::IsCFBundleOnApple() const -{ - return (this->GetType() == cmTarget::MODULE_LIBRARY && - this->Makefile->IsOn("APPLE") && - this->GetPropertyAsBool("BUNDLE")); -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsXCTestOnApple() const -{ - return (this->IsCFBundleOnApple() && - this->GetPropertyAsBool("XCTEST")); -} - -//---------------------------------------------------------------------------- -static bool processSources(cmTarget const* tgt, - const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, - std::vector<std::string> &srcs, - UNORDERED_SET<std::string> &uniqueSrcs, - cmGeneratorExpressionDAGChecker *dagChecker, - std::string const& config, bool debugSources) -{ - cmMakefile *mf = tgt->GetMakefile(); - - bool contextDependent = false; - - for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - cmLinkImplItem const& item = (*it)->LinkImplItem; - std::string const& targetName = item; - std::vector<std::string> entrySources; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt, - tgt, - dagChecker), - entrySources); - - if ((*it)->ge->GetHadContextSensitiveCondition()) - { - contextDependent = true; - } - - for(std::vector<std::string>::iterator i = entrySources.begin(); - i != entrySources.end(); ++i) - { - std::string& src = *i; - cmSourceFile* sf = mf->GetOrCreateSource(src); - std::string e; - std::string fullPath = sf->GetFullPath(&e); - if(fullPath.empty()) - { - if(!e.empty()) - { - cmake* cm = mf->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e, - tgt->GetBacktrace()); - } - return contextDependent; - } - - if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src.c_str())) - { - std::ostringstream err; - if (!targetName.empty()) - { - err << "Target \"" << targetName << "\" contains relative " - "path in its INTERFACE_SOURCES:\n" - " \"" << src << "\""; - } - else - { - err << "Found relative path while evaluating sources of " - "\"" << tgt->GetName() << "\":\n \"" << src << "\"\n"; - } - tgt->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, err.str()); - return contextDependent; - } - src = fullPath; - } - std::string usedSources; - for(std::vector<std::string>::iterator - li = entrySources.begin(); li != entrySources.end(); ++li) - { - std::string src = *li; - - if(uniqueSrcs.insert(src).second) - { - srcs.push_back(src); - if (debugSources) - { - usedSources += " * " + src + "\n"; - } - } - } - if (!usedSources.empty()) - { - mf->GetCMakeInstance()->IssueMessage(cmake::LOG, - std::string("Used sources for target ") - + tgt->GetName() + ":\n" - + usedSources, (*it)->ge->GetBacktrace()); - } - } - return contextDependent; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetSourceFiles(std::vector<std::string> &files, - const std::string& config) const -{ - assert(this->GetType() != INTERFACE_LIBRARY); - - if (!this->Makefile->IsConfigured()) - { - // At configure-time, this method can be called as part of getting the - // LOCATION property or to export() a file to be include()d. However - // there is no cmGeneratorTarget at configure-time, so search the SOURCES - // for TARGET_OBJECTS instead for backwards compatibility with OLD - // behavior of CMP0024 and CMP0026 only. - - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector<TargetPropertyEntry*>::const_iterator - i = this->Internal->SourceEntries.begin(); - i != this->Internal->SourceEntries.end(); ++i) - { - std::string entry = (*i)->ge->GetInput(); - - std::vector<std::string> items; - cmSystemTools::ExpandListArgument(entry, items); - for (std::vector<std::string>::const_iterator - li = items.begin(); li != items.end(); ++li) - { - if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") && - (*li)[li->size() - 1] == '>') - { - continue; - } - files.push_back(*li); - } - } - return; - } - - std::vector<std::string> debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugSources = !this->DebugSourcesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "SOURCES") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugSourcesDone = true; - } - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "SOURCES", 0, 0); - - UNORDERED_SET<std::string> uniqueSrcs; - bool contextDependentDirectSources = processSources(this, - this->Internal->SourceEntries, - files, - uniqueSrcs, - &dagChecker, - config, - debugSources); - - std::vector<cmTargetInternals::TargetPropertyEntry*> - linkInterfaceSourcesEntries; - - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_SOURCES", - linkInterfaceSourcesEntries); - - std::vector<std::string>::size_type numFilesBefore = files.size(); - bool contextDependentInterfaceSources = processSources(this, - linkInterfaceSourcesEntries, - files, - uniqueSrcs, - &dagChecker, - config, - debugSources); - - if (!contextDependentDirectSources - && !(contextDependentInterfaceSources && numFilesBefore < files.size())) - { - this->LinkImplementationLanguageIsContextDependent = false; - } - - cmDeleteAll(linkInterfaceSourcesEntries); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files, - const std::string& config) const -{ - - // Lookup any existing link implementation for this configuration. - std::string key = cmSystemTools::UpperCase(config); - - if(!this->LinkImplementationLanguageIsContextDependent) - { - files = this->Internal->SourceFilesMap.begin()->second; - return; - } - - cmTargetInternals::SourceFilesMapType::iterator - it = this->Internal->SourceFilesMap.find(key); - if(it != this->Internal->SourceFilesMap.end()) - { - files = it->second; - } - else - { - std::vector<std::string> srcs; - this->GetSourceFiles(srcs, config); - - std::set<cmSourceFile*> emitted; - - for(std::vector<std::string>::const_iterator i = srcs.begin(); - i != srcs.end(); ++i) - { - cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i); - if (emitted.insert(sf).second) - { - files.push_back(sf); - } - } - this->Internal->SourceFilesMap[key] = files; - } -} - -//---------------------------------------------------------------------------- void cmTarget::AddTracedSources(std::vector<std::string> const& srcs) { - std::string srcFiles = cmJoin(srcs, ";"); - if (!srcFiles.empty()) + if (!srcs.empty()) { - this->Internal->SourceFilesMap.clear(); - this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(cmJoin(srcs, ";")); + this->Internal->SourceBacktraces.push_back(lfbt); } } @@ -810,14 +408,9 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs) } if (!srcFiles.empty()) { - this->Internal->SourceFilesMap.clear(); - this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(srcFiles); + this->Internal->SourceBacktraces.push_back(lfbt); } } @@ -921,10 +514,10 @@ public: } - bool operator()(cmTargetInternals::TargetPropertyEntry* entry) + bool operator()(std::string const& entry) { std::vector<std::string> files; - cmSystemTools::ExpandListArgument(entry->ge->GetInput(), files); + cmSystemTools::ExpandListArgument(entry, files); std::vector<cmSourceFileLocation> locations(files.size()); std::transform(files.begin(), files.end(), locations.begin(), CreateLocation(this->Needle.GetMakefile())); @@ -943,14 +536,9 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) TargetPropertyEntryFinder(sfl)) == this->Internal->SourceEntries.end()) { - this->Internal->SourceFilesMap.clear(); - this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(src); + this->Internal->SourceBacktraces.push_back(lfbt); } if (cmGeneratorExpression::Find(src) != std::string::npos) { @@ -995,31 +583,6 @@ const std::vector<std::string>& cmTarget::GetLinkDirectories() const } //---------------------------------------------------------------------------- -cmTarget::LinkLibraryType cmTarget::ComputeLinkType( - const std::string& config) const -{ - // No configuration is always optimized. - if(config.empty()) - { - return cmTarget::OPTIMIZED; - } - - // Get the list of configurations considered to be DEBUG. - std::vector<std::string> debugConfigs = - this->Makefile->GetCMakeInstance()->GetDebugConfigs(); - - // Check if any entry in the list matches this configuration. - std::string configUpper = cmSystemTools::UpperCase(config); - if (std::find(debugConfigs.begin(), debugConfigs.end(), configUpper) != - debugConfigs.end()) - { - return cmTarget::DEBUG; - } - // The current configuration is not a debug configuration. - return cmTarget::OPTIMIZED; -} - -//---------------------------------------------------------------------------- void cmTarget::ClearDependencyInformation( cmMakefile& mf, const std::string& target ) { @@ -1048,17 +611,10 @@ void cmTarget::ClearDependencyInformation( cmMakefile& mf, } //---------------------------------------------------------------------------- -bool cmTarget::NameResolvesToFramework(const std::string& libname) const -{ - return this->Makefile->GetGlobalGenerator()-> - NameResolvesToFramework(libname); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value, - cmTarget::LinkLibraryType llt) const + cmTargetLinkLibraryType llt) const { - if (llt == GENERAL) + if (llt == GENERAL_LibraryType) { return value; } @@ -1079,7 +635,7 @@ std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value, configString = "$<OR:" + configString + ">"; } - if (llt == OPTIMIZED) + if (llt == OPTIMIZED_LibraryType) { configString = "$<NOT:" + configString + ">"; } @@ -1136,22 +692,23 @@ void cmTarget::GetTllSignatureTraces(std::ostringstream &s, void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& target, const std::string& lib, - LinkLibraryType llt) + cmTargetLinkLibraryType llt) { cmTarget *tgt = this->Makefile->FindTargetToUse(lib); { const bool isNonImportedTarget = tgt && !tgt->IsImported(); - const std::string libName = (isNonImportedTarget && llt != GENERAL) - ? targetNameGenex(lib) - : lib; + const std::string libName = + (isNonImportedTarget && llt != GENERAL_LibraryType) + ? targetNameGenex(lib) + : lib; this->AppendProperty("LINK_LIBRARIES", this->GetDebugGeneratorExpressions(libName, llt).c_str()); } if (cmGeneratorExpression::Find(lib) != std::string::npos - || (tgt && tgt->GetType() == INTERFACE_LIBRARY) + || (tgt && tgt->GetType() == cmState::INTERFACE_LIBRARY) || (target == lib )) { return; @@ -1164,7 +721,6 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, this->LinkLibrariesForVS6.push_back( tmp ); #endif this->OriginalLinkLibraries.push_back(tmp); - this->ClearLinkMaps(); // Add the explicit dependency information for this target. This is // simply a set of libraries separated by ";". There should always @@ -1186,13 +742,13 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, } switch (llt) { - case cmTarget::GENERAL: + case GENERAL_LibraryType: dependencies += "general"; break; - case cmTarget::DEBUG: + case DEBUG_LibraryType: dependencies += "debug"; break; - case cmTarget::OPTIMIZED: + case OPTIMIZED_LibraryType: dependencies += "optimized"; break; } @@ -1253,6 +809,26 @@ cmBacktraceRange cmTarget::GetCompileDefinitionsBacktraces() const return cmMakeRange(this->Internal->CompileDefinitionsBacktraces); } +cmStringRange cmTarget::GetSourceEntries() const +{ + return cmMakeRange(this->Internal->SourceEntries); +} + +cmBacktraceRange cmTarget::GetSourceBacktraces() const +{ + return cmMakeRange(this->Internal->SourceBacktraces); +} + +cmStringRange cmTarget::GetLinkImplementationEntries() const +{ + return cmMakeRange(this->Internal->LinkImplementationPropertyEntries); +} + +cmBacktraceRange cmTarget::GetLinkImplementationBacktraces() const +{ + return cmMakeRange(this->Internal->LinkImplementationPropertyBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1506,7 +1082,7 @@ void cmTarget::GatherDependenciesForVS6( const cmMakefile& mf, // Parse the dependency information, which is a set of // type, library pairs separated by ";". There is always a trailing ";". - cmTarget::LinkLibraryType llt = cmTarget::GENERAL; + cmTargetLinkLibraryType llt = GENERAL_LibraryType; std::string depline = deps; std::string::size_type start = 0; std::string::size_type end; @@ -1518,22 +1094,22 @@ void cmTarget::GatherDependenciesForVS6( const cmMakefile& mf, { if (l == "debug") { - llt = cmTarget::DEBUG; + llt = DEBUG_LibraryType; } else if (l == "optimized") { - llt = cmTarget::OPTIMIZED; + llt = OPTIMIZED_LibraryType; } else if (l == "general") { - llt = cmTarget::GENERAL; + llt = GENERAL_LibraryType; } else { LibraryID lib2(l,llt); this->InsertDependencyForVS6( dep_map, lib, lib2); this->GatherDependenciesForVS6( mf, lib2, dep_map); - llt = cmTarget::GENERAL; + llt = GENERAL_LibraryType; } } start = end+1; // skip the ; @@ -1581,7 +1157,7 @@ static bool whiteListedInterfaceProperty(const std::string& prop) //---------------------------------------------------------------------------- void cmTarget::SetProperty(const std::string& prop, const char* value) { - if (this->GetType() == INTERFACE_LIBRARY + if (this->GetType() == cmState::INTERFACE_LIBRARY && !whiteListedInterfaceProperty(prop)) { std::ostringstream e; @@ -1651,11 +1227,12 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) else if (prop == "LINK_LIBRARIES") { this->Internal->LinkImplementationPropertyEntries.clear(); + this->Internal->LinkImplementationPropertyBacktraces.clear(); if (value) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmValueWithOrigin entry(value, lfbt); - this->Internal->LinkImplementationPropertyEntries.push_back(entry); + this->Internal->LinkImplementationPropertyEntries.push_back(value); + this->Internal->LinkImplementationPropertyBacktraces.push_back(lfbt); } } else if (prop == "SOURCES") @@ -1668,19 +1245,19 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - this->Internal->SourceFilesMap.clear(); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmDeleteAll(this->Internal->SourceEntries); + this->Internal->SourceEntries.clear(); - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceBacktraces.clear(); + if (value) + { + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + this->Internal->SourceEntries.push_back(value); + this->Internal->SourceBacktraces.push_back(lfbt); + } } else { this->Properties.SetProperty(prop, value); - this->MaybeInvalidatePropertyCache(prop); } } @@ -1688,7 +1265,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) void cmTarget::AppendProperty(const std::string& prop, const char* value, bool asString) { - if (this->GetType() == INTERFACE_LIBRARY + if (this->GetType() == cmState::INTERFACE_LIBRARY && !whiteListedInterfaceProperty(prop)) { std::ostringstream e; @@ -1706,7 +1283,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "INCLUDE_DIRECTORIES") { - if (value) + if (value && *value) { this->Internal->IncludeDirectoriesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); @@ -1715,7 +1292,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_OPTIONS") { - if (value) + if (value && *value) { this->Internal->CompileOptionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); @@ -1724,7 +1301,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_FEATURES") { - if (value) + if (value && *value) { this->Internal->CompileFeaturesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); @@ -1733,7 +1310,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_DEFINITIONS") { - if (value) + if (value && *value) { this->Internal->CompileDefinitionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); @@ -1749,11 +1326,11 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if (prop == "LINK_LIBRARIES") { - if (value) + if (value && *value) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmValueWithOrigin entry(value, lfbt); - this->Internal->LinkImplementationPropertyEntries.push_back(entry); + this->Internal->LinkImplementationPropertyEntries.push_back(value); + this->Internal->LinkImplementationPropertyBacktraces.push_back(lfbt); } } else if (prop == "SOURCES") @@ -1766,47 +1343,23 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(value); + this->Internal->SourceBacktraces.push_back(lfbt); } else { this->Properties.AppendProperty(prop, value, asString); - this->MaybeInvalidatePropertyCache(prop); - } -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetExportName() const -{ - const char *exportName = this->GetProperty("EXPORT_NAME"); - - if (exportName && *exportName) - { - if (!cmGeneratorExpression::IsValidTargetName(exportName)) - { - std::ostringstream e; - e << "EXPORT_NAME property \"" << exportName << "\" for \"" - << this->GetName() << "\": is not valid."; - cmSystemTools::Error(e.str().c_str()); - return ""; - } - return exportName; } - return this->GetName(); } //---------------------------------------------------------------------------- void cmTarget::AppendBuildInterfaceIncludes() { - if(this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::STATIC_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::INTERFACE_LIBRARY && + if(this->GetType() != cmState::SHARED_LIBRARY && + this->GetType() != cmState::STATIC_LIBRARY && + this->GetType() != cmState::MODULE_LIBRARY && + this->GetType() != cmState::INTERFACE_LIBRARY && !this->IsExecutableWithExports()) { return; @@ -1875,20 +1428,6 @@ void cmTarget::InsertCompileDefinition(std::string const& entry, } //---------------------------------------------------------------------------- -void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) -{ - // Wipe out maps caching information affected by this property. - if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED")) - { - this->Internal->ImportInfoMap.clear(); - } - if(!this->IsImported() && cmHasLiteralPrefix(prop, "LINK_INTERFACE_")) - { - this->ClearLinkMaps(); - } -} - -//---------------------------------------------------------------------------- static void cmTargetCheckLINK_INTERFACE_LIBRARIES( const std::string& prop, const char* value, cmMakefile* context, bool imported) @@ -1989,154 +1528,6 @@ void cmTarget::MarkAsImported() } //---------------------------------------------------------------------------- -bool cmTarget::HaveWellDefinedOutputFiles() const -{ - return - this->GetType() == cmTarget::STATIC_LIBRARY || - this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || - this->GetType() == cmTarget::EXECUTABLE; -} - -//---------------------------------------------------------------------------- -cmTarget::OutputInfo const* cmTarget::GetOutputInfo( - const std::string& config) const -{ - // There is no output information for imported targets. - if(this->IsImported()) - { - return 0; - } - - // Only libraries and executables have well-defined output files. - if(!this->HaveWellDefinedOutputFiles()) - { - std::string msg = "cmTarget::GetOutputInfo called for "; - msg += this->GetName(); - msg += " which has type "; - msg += cmTarget::GetTargetTypeName(this->GetType()); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - return 0; - } - - // Lookup/compute/cache the output information for this configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - typedef cmTargetInternals::OutputInfoMapType OutputInfoMapType; - OutputInfoMapType::iterator i = - this->Internal->OutputInfoMap.find(config_upper); - if(i == this->Internal->OutputInfoMap.end()) - { - // Add empty info in map to detect potential recursion. - OutputInfo info; - OutputInfoMapType::value_type entry(config_upper, info); - i = this->Internal->OutputInfoMap.insert(entry).first; - - // Compute output directories. - this->ComputeOutputDir(config, false, info.OutDir); - this->ComputeOutputDir(config, true, info.ImpDir); - if(!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) - { - info.PdbDir = info.OutDir; - } - - // Now update the previously-prepared map entry. - i->second = info; - } - else if(i->second.empty()) - { - // An empty map entry indicates we have been called recursively - // from the above block. - this->Makefile->GetCMakeInstance()->IssueMessage( - cmake::FATAL_ERROR, - "Target '" + this->GetName() + "' OUTPUT_DIRECTORY depends on itself.", - this->GetBacktrace()); - return 0; - } - return &i->second; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetDirectory(const std::string& config, - bool implib) const -{ - if (this->IsImported()) - { - // Return the directory from which the target is imported. - return - cmSystemTools::GetFilenamePath( - this->ImportedGetFullPath(config, implib)); - } - else if(OutputInfo const* info = this->GetOutputInfo(config)) - { - // Return the directory in which the target will be built. - return implib? info->ImpDir : info->OutDir; - } - return ""; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetPDBDirectory(const std::string& config) const -{ - if(OutputInfo const* info = this->GetOutputInfo(config)) - { - // Return the directory in which the target will be built. - return info->PdbDir; - } - return ""; -} - -//---------------------------------------------------------------------------- -const char* cmTarget::ImportedGetLocation(const std::string& config) const -{ - static std::string location; - assert(this->IsImported()); - location = this->ImportedGetFullPath(config, false); - return location.c_str(); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetTargetVersion(int& major, int& minor) const -{ - int patch; - this->GetTargetVersion(false, major, minor, patch); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetTargetVersion(bool soversion, - int& major, int& minor, int& patch) const -{ - // Set the default values. - major = 0; - minor = 0; - patch = 0; - - assert(this->GetType() != INTERFACE_LIBRARY); - - // Look for a VERSION or SOVERSION property. - const char* prop = soversion? "SOVERSION" : "VERSION"; - if(const char* version = this->GetProperty(prop)) - { - // Try to parse the version number and store the results that were - // successfully parsed. - int parsed_major; - int parsed_minor; - int parsed_patch; - switch(sscanf(version, "%d.%d.%d", - &parsed_major, &parsed_minor, &parsed_patch)) - { - case 3: patch = parsed_patch; // no break! - case 2: minor = parsed_minor; // no break! - case 1: major = parsed_major; // no break! - default: break; - } - } -} - -//---------------------------------------------------------------------------- bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const { if (this->IsImported()) @@ -2182,7 +1573,7 @@ const char *cmTarget::GetProperty(const std::string& prop) const const char *cmTarget::GetProperty(const std::string& prop, cmMakefile* context) const { - if (this->GetType() == INTERFACE_LIBRARY + if (this->GetType() == cmState::INTERFACE_LIBRARY && !whiteListedInterfaceProperty(prop)) { std::ostringstream e; @@ -2194,11 +1585,11 @@ const char *cmTarget::GetProperty(const std::string& prop, // Watch for special "computed" properties that are dependent on // other properties or variables. Always recompute them. - if(this->GetType() == cmTarget::EXECUTABLE || - this->GetType() == cmTarget::STATIC_LIBRARY || - this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || - this->GetType() == cmTarget::UNKNOWN_LIBRARY) + if(this->GetType() == cmState::EXECUTABLE || + this->GetType() == cmState::STATIC_LIBRARY || + this->GetType() == cmState::SHARED_LIBRARY || + this->GetType() == cmState::MODULE_LIBRARY || + this->GetType() == cmState::UNKNOWN_LIBRARY) { static const std::string propLOCATION = "LOCATION"; if(prop == propLOCATION) @@ -2321,23 +1712,13 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - output = ""; - std::string sep; - for (std::vector<cmValueWithOrigin>::const_iterator - it = this->Internal->LinkImplementationPropertyEntries.begin(), - end = this->Internal->LinkImplementationPropertyEntries.end(); - it != end; ++it) - { - output += sep; - output += it->Value; - sep = ";"; - } + output = cmJoin(this->Internal->LinkImplementationPropertyEntries, ";"); return output.c_str(); } // the type property returns what type the target is else if (prop == propTYPE) { - return cmTarget::GetTargetTypeName(this->GetType()); + return cmState::GetTargetTypeName(this->GetType()); } else if(prop == propINCLUDE_DIRECTORIES) { @@ -2408,13 +1789,11 @@ const char *cmTarget::GetProperty(const std::string& prop, std::ostringstream ss; const char* sep = ""; - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector<TargetPropertyEntry*>::const_iterator + for(std::vector<std::string>::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string entry = (*i)->ge->GetInput(); + std::string const& entry = *i; std::vector<std::string> files; cmSystemTools::ExpandListArgument(entry, files); @@ -2520,17 +1899,17 @@ const char* cmTarget::GetSuffixVariableInternal(bool implib) const { switch(this->GetType()) { - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: return "CMAKE_STATIC_LIBRARY_SUFFIX"; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" : "CMAKE_SHARED_LIBRARY_SUFFIX"); - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" : "CMAKE_SHARED_MODULE_SUFFIX"); - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" // Android GUI application packages store the native @@ -2549,17 +1928,17 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const { switch(this->GetType()) { - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: return "CMAKE_STATIC_LIBRARY_PREFIX"; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" : "CMAKE_SHARED_LIBRARY_PREFIX"); - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" : "CMAKE_SHARED_MODULE_PREFIX"); - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" // Android GUI application packages store the native @@ -2573,148 +1952,76 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const } //---------------------------------------------------------------------------- -bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const +std::string +cmTarget::ImportedGetFullPath(const std::string& config, bool pimplib) const { - bool install_name_is_rpath = false; - bool macosx_rpath = false; + assert(this->IsImported()); - if(!this->IsImportedTarget) + // Lookup/compute/cache the import information for this + // configuration. + std::string config_upper; + if(!config.empty()) { - if(this->GetType() != cmTarget::SHARED_LIBRARY) - { - return false; - } - const char* install_name = this->GetProperty("INSTALL_NAME_DIR"); - bool use_install_name = - this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"); - if(install_name && use_install_name && - std::string(install_name) == "@rpath") - { - install_name_is_rpath = true; - } - else if(install_name && use_install_name) - { - return false; - } - if(!install_name_is_rpath) - { - macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); - } + config_upper = cmSystemTools::UpperCase(config); } else { - // Lookup the imported soname. - if(cmTarget::ImportInfo const* info = this->GetImportInfo(config)) + config_upper = "NOCONFIG"; + } + + std::string result; + + const char* loc = 0; + const char* imp = 0; + std::string suffix; + + if(this->GetType() != cmState::INTERFACE_LIBRARY + && this->GetMappedConfig(config_upper, &loc, &imp, suffix)) + { + if (!pimplib) { - if(!info->NoSOName && !info->SOName.empty()) + if(loc) { - if(info->SOName.find("@rpath/") == 0) - { - install_name_is_rpath = true; - } + result = loc; } else { - std::string install_name; - cmSystemTools::GuessLibraryInstallName(info->Location, install_name); - if(install_name.find("@rpath") != std::string::npos) + std::string impProp = "IMPORTED_LOCATION"; + impProp += suffix; + if(const char* config_location = this->GetProperty(impProp)) { - install_name_is_rpath = true; + result = config_location; + } + else if(const char* location = + this->GetProperty("IMPORTED_LOCATION")) + { + result = location; } } } - } - - if(!install_name_is_rpath && !macosx_rpath) - { - return false; - } - - if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG")) - { - std::ostringstream w; - w << "Attempting to use"; - if(macosx_rpath) - { - w << " MACOSX_RPATH"; - } else { - w << " @rpath"; - } - w << " without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being set."; - w << " This could be because you are using a Mac OS X version"; - w << " less than 10.5 or because CMake's platform configuration is"; - w << " corrupt."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, w.str(), this->GetBacktrace()); - } - - return true; -} - -//---------------------------------------------------------------------------- -bool cmTarget::MacOSXRpathInstallNameDirDefault() const -{ - // we can't do rpaths when unsupported - if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG")) - { - return false; - } - - const char* macosx_rpath_str = this->GetProperty("MACOSX_RPATH"); - if(macosx_rpath_str) - { - return this->GetPropertyAsBool("MACOSX_RPATH"); - } - - cmPolicies::PolicyStatus cmp0042 = this->GetPolicyStatusCMP0042(); - - if(cmp0042 == cmPolicies::WARN) - { - this->Makefile->GetGlobalGenerator()-> - AddCMP0042WarnTarget(this->GetName()); - } - - if(cmp0042 == cmPolicies::NEW) - { - return true; - } - - return false; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsImportedSharedLibWithoutSOName( - const std::string& config) const -{ - if(this->IsImported() && this->GetType() == cmTarget::SHARED_LIBRARY) - { - if(cmTarget::ImportInfo const* info = this->GetImportInfo(config)) - { - return info->NoSOName; + if(imp) + { + result = imp; + } + else if(this->GetType() == cmState::SHARED_LIBRARY || + this->IsExecutableWithExports()) + { + std::string impProp = "IMPORTED_IMPLIB"; + impProp += suffix; + if(const char* config_implib = this->GetProperty(impProp)) + { + result = config_implib; + } + else if(const char* implib = this->GetProperty("IMPORTED_IMPLIB")) + { + result = implib; + } + } } } - return false; -} - -//---------------------------------------------------------------------------- -std::string -cmTarget::GetFullNameImported(const std::string& config, bool implib) const -{ - return cmSystemTools::GetFilenameName( - this->ImportedGetFullPath(config, implib)); -} -//---------------------------------------------------------------------------- -std::string -cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const -{ - std::string result; - if(cmTarget::ImportInfo const* info = this->GetImportInfo(config)) - { - result = implib? info->ImportLibrary : info->Location; - } if(result.empty()) { result = this->GetName(); @@ -2724,43 +2031,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -void cmTarget::ComputeVersionedName(std::string& vName, - std::string const& prefix, - std::string const& base, - std::string const& suffix, - std::string const& name, - const char* version) const -{ - vName = this->IsApple? (prefix+base) : name; - if(version) - { - vName += "."; - vName += version; - } - vName += this->IsApple? suffix : std::string(); -} - -//---------------------------------------------------------------------------- -bool cmTarget::HasImplibGNUtoMS() const -{ - return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); -} - -//---------------------------------------------------------------------------- -bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName, - std::string& out, const char* newExt) const -{ - if(this->HasImplibGNUtoMS() && - gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a") - { - out = gnuName.substr(0, gnuName.size()-6); - out += newExt? newExt : ".lib"; - return true; - } - return false; -} - -//---------------------------------------------------------------------------- void cmTarget::SetPropertyDefault(const std::string& property, const char* default_value) { @@ -2779,236 +2049,9 @@ void cmTarget::SetPropertyDefault(const std::string& property, } //---------------------------------------------------------------------------- -bool cmTarget::HaveInstallTreeRPATH() const -{ - const char* install_rpath = this->GetProperty("INSTALL_RPATH"); - return (install_rpath && *install_rpath) && - !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH"); -} - -//---------------------------------------------------------------------------- -const char* cmTarget::GetOutputTargetType(bool implib) const -{ - switch(this->GetType()) - { - case cmTarget::SHARED_LIBRARY: - if(this->DLLPlatform) - { - if(implib) - { - // A DLL import library is treated as an archive target. - return "ARCHIVE"; - } - else - { - // A DLL shared library is treated as a runtime target. - return "RUNTIME"; - } - } - else - { - // For non-DLL platforms shared libraries are treated as - // library targets. - return "LIBRARY"; - } - case cmTarget::STATIC_LIBRARY: - // Static libraries are always treated as archive targets. - return "ARCHIVE"; - case cmTarget::MODULE_LIBRARY: - if(implib) - { - // Module libraries are always treated as library targets. - return "ARCHIVE"; - } - else - { - // Module import libraries are treated as archive targets. - return "LIBRARY"; - } - case cmTarget::EXECUTABLE: - if(implib) - { - // Executable import libraries are treated as archive targets. - return "ARCHIVE"; - } - else - { - // Executables are always treated as runtime targets. - return "RUNTIME"; - } - default: - break; - } - return ""; -} - -//---------------------------------------------------------------------------- -bool cmTarget::ComputeOutputDir(const std::string& config, - bool implib, std::string& out) const -{ - bool usesDefaultOutputDir = false; - std::string conf = config; - - // Look for a target property defining the target output directory - // based on the target type. - std::string targetTypeName = this->GetOutputTargetType(implib); - const char* propertyName = 0; - std::string propertyNameStr = targetTypeName; - if(!propertyNameStr.empty()) - { - propertyNameStr += "_OUTPUT_DIRECTORY"; - propertyName = propertyNameStr.c_str(); - } - - // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(conf); - const char* configProp = 0; - std::string configPropStr = targetTypeName; - if(!configPropStr.empty()) - { - configPropStr += "_OUTPUT_DIRECTORY_"; - configPropStr += configUpper; - configProp = configPropStr.c_str(); - } - - // Select an output directory. - if(const char* config_outdir = this->GetProperty(configProp)) - { - // Use the user-specified per-configuration output directory. - cmGeneratorExpression ge; - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = - ge.Parse(config_outdir); - out = cge->Evaluate(this->Makefile, config); - - // Skip per-configuration subdirectory. - conf = ""; - } - else if(const char* outdir = this->GetProperty(propertyName)) - { - // Use the user-specified output directory. - cmGeneratorExpression ge; - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = - ge.Parse(outdir); - out = cge->Evaluate(this->Makefile, config); - - // Skip per-configuration subdirectory if the value contained a - // generator expression. - if (out != outdir) - { - conf = ""; - } - } - else if(this->GetType() == cmTarget::EXECUTABLE) - { - // Lookup the output path for executables. - out = this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); - } - else if(this->GetType() == cmTarget::STATIC_LIBRARY || - this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) - { - // Lookup the output path for libraries. - out = this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH"); - } - if(out.empty()) - { - // Default to the current output directory. - usesDefaultOutputDir = true; - out = "."; - } - - // Convert the output path to a full path in case it is - // specified as a relative path. Treat a relative path as - // relative to the current output directory for this makefile. - out = (cmSystemTools::CollapseFullPath - (out, this->Makefile->GetCurrentBinaryDirectory())); - - // The generator may add the configuration's subdirectory. - if(!conf.empty()) - { - bool iosPlatform = this->Makefile->PlatformIsAppleIos(); - std::string suffix = - usesDefaultOutputDir && iosPlatform ? "${EFFECTIVE_PLATFORM_NAME}" : ""; - this->Makefile->GetGlobalGenerator()-> - AppendDirectoryForConfig("/", conf, suffix, out); - } - - return usesDefaultOutputDir; -} - -//---------------------------------------------------------------------------- -bool cmTarget::ComputePDBOutputDir(const std::string& kind, - const std::string& config, - std::string& out) const -{ - // Look for a target property defining the target output directory - // based on the target type. - const char* propertyName = 0; - std::string propertyNameStr = kind; - if(!propertyNameStr.empty()) - { - propertyNameStr += "_OUTPUT_DIRECTORY"; - propertyName = propertyNameStr.c_str(); - } - std::string conf = config; - - // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(conf); - const char* configProp = 0; - std::string configPropStr = kind; - if(!configPropStr.empty()) - { - configPropStr += "_OUTPUT_DIRECTORY_"; - configPropStr += configUpper; - configProp = configPropStr.c_str(); - } - - // Select an output directory. - if(const char* config_outdir = this->GetProperty(configProp)) - { - // Use the user-specified per-configuration output directory. - out = config_outdir; - - // Skip per-configuration subdirectory. - conf = ""; - } - else if(const char* outdir = this->GetProperty(propertyName)) - { - // Use the user-specified output directory. - out = outdir; - } - if(out.empty()) - { - return false; - } - - // Convert the output path to a full path in case it is - // specified as a relative path. Treat a relative path as - // relative to the current output directory for this makefile. - out = (cmSystemTools::CollapseFullPath - (out, this->Makefile->GetCurrentBinaryDirectory())); - - // The generator may add the configuration's subdirectory. - if(!conf.empty()) - { - this->Makefile->GetGlobalGenerator()-> - AppendDirectoryForConfig("/", conf, "", out); - } - return true; -} - -//---------------------------------------------------------------------------- -bool cmTarget::UsesDefaultOutputDir(const std::string& config, - bool implib) const -{ - std::string dir; - return this->ComputeOutputDir(config, implib, dir); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkVersion() const { - assert(this->GetType() != INTERFACE_LIBRARY); + assert(this->GetType() != cmState::INTERFACE_LIBRARY); if(const char* fversion = this->GetProperty("FRAMEWORK_VERSION")) { @@ -3024,137 +2067,15 @@ std::string cmTarget::GetFrameworkVersion() const } } -//---------------------------------------------------------------------------- -const char* cmTarget::GetExportMacro() const -{ - // Define the symbol for targets that export symbols. - if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || - this->IsExecutableWithExports()) - { - if(const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL")) - { - this->ExportMacro = custom_export_name; - } - else - { - std::string in = this->GetName(); - in += "_EXPORTS"; - this->ExportMacro = cmSystemTools::MakeCindentifier(in); - } - return this->ExportMacro.c_str(); - } - else - { - return 0; - } -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const -{ - return this->LinkImplicitNullProperties.find(p) - != this->LinkImplicitNullProperties.end(); -} - -//---------------------------------------------------------------------------- -void -cmTarget::GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const -{ - // At configure-time, this method can be called as part of getting the - // LOCATION property or to export() a file to be include()d. However - // there is no cmGeneratorTarget at configure-time, so search the SOURCES - // for TARGET_OBJECTS instead for backwards compatibility with OLD - // behavior of CMP0024 and CMP0026 only. - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector<TargetPropertyEntry*>::const_iterator - i = this->Internal->SourceEntries.begin(); - i != this->Internal->SourceEntries.end(); ++i) - { - std::string entry = (*i)->ge->GetInput(); - - std::vector<std::string> files; - cmSystemTools::ExpandListArgument(entry, files); - for (std::vector<std::string>::const_iterator - li = files.begin(); li != files.end(); ++li) - { - if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") && - (*li)[li->size() - 1] == '>') - { - std::string objLibName = li->substr(17, li->size()-18); - - if (cmGeneratorExpression::Find(objLibName) != std::string::npos) - { - continue; - } - cmTarget *objLib = this->Makefile->FindTargetToUse(objLibName); - if(objLib) - { - objlibs.push_back(objLib); - } - } - } - } -} - -//---------------------------------------------------------------------------- -cmTarget::ImportInfo const* -cmTarget::GetImportInfo(const std::string& config) const -{ - // There is no imported information for non-imported targets. - if(!this->IsImported()) - { - return 0; - } - - // Lookup/compute/cache the import information for this - // configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - else - { - config_upper = "NOCONFIG"; - } - typedef cmTargetInternals::ImportInfoMapType ImportInfoMapType; - - ImportInfoMapType::const_iterator i = - this->Internal->ImportInfoMap.find(config_upper); - if(i == this->Internal->ImportInfoMap.end()) - { - ImportInfo info; - this->ComputeImportInfo(config_upper, info); - ImportInfoMapType::value_type entry(config_upper, info); - i = this->Internal->ImportInfoMap.insert(entry).first; - } - - if(this->GetType() == INTERFACE_LIBRARY) - { - return &i->second; - } - // If the location is empty then the target is not available for - // this configuration. - if(i->second.Location.empty() && i->second.ImportLibrary.empty()) - { - return 0; - } - - // Return the import information. - return &i->second; -} - bool cmTarget::GetMappedConfig(std::string const& desired_config, const char** loc, const char** imp, std::string& suffix) const { - if (this->GetType() == INTERFACE_LIBRARY) + if (this->GetType() == cmState::INTERFACE_LIBRARY) { // This method attempts to find a config-specific LOCATION for the - // IMPORTED library. In the case of INTERFACE_LIBRARY, there is no + // IMPORTED library. In the case of cmState::INTERFACE_LIBRARY, there is no // LOCATION at all, so leaving *loc and *imp unchanged is the appropriate // and valid response. return true; @@ -3278,445 +2199,6 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, } //---------------------------------------------------------------------------- -void cmTarget::ComputeImportInfo(std::string const& desired_config, - ImportInfo& info) const -{ - // This method finds information about an imported target from its - // properties. The "IMPORTED_" namespace is reserved for properties - // defined by the project exporting the target. - - // Initialize members. - info.NoSOName = false; - - const char* loc = 0; - const char* imp = 0; - std::string suffix; - if (!this->GetMappedConfig(desired_config, &loc, &imp, suffix)) - { - return; - } - - // Get the link interface. - { - std::string linkProp = "INTERFACE_LINK_LIBRARIES"; - const char *propertyLibs = this->GetProperty(linkProp); - - if (this->GetType() != INTERFACE_LIBRARY) - { - if(!propertyLibs) - { - linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; - linkProp += suffix; - propertyLibs = this->GetProperty(linkProp); - } - - if(!propertyLibs) - { - linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; - propertyLibs = this->GetProperty(linkProp); - } - } - if(propertyLibs) - { - info.LibrariesProp = linkProp; - info.Libraries = propertyLibs; - } - } - if(this->GetType() == INTERFACE_LIBRARY) - { - return; - } - - // A provided configuration has been chosen. Load the - // configuration's properties. - - // Get the location. - if(loc) - { - info.Location = loc; - } - else - { - std::string impProp = "IMPORTED_LOCATION"; - impProp += suffix; - if(const char* config_location = this->GetProperty(impProp)) - { - info.Location = config_location; - } - else if(const char* location = this->GetProperty("IMPORTED_LOCATION")) - { - info.Location = location; - } - } - - // Get the soname. - if(this->GetType() == cmTarget::SHARED_LIBRARY) - { - std::string soProp = "IMPORTED_SONAME"; - soProp += suffix; - if(const char* config_soname = this->GetProperty(soProp)) - { - info.SOName = config_soname; - } - else if(const char* soname = this->GetProperty("IMPORTED_SONAME")) - { - info.SOName = soname; - } - } - - // Get the "no-soname" mark. - if(this->GetType() == cmTarget::SHARED_LIBRARY) - { - std::string soProp = "IMPORTED_NO_SONAME"; - soProp += suffix; - if(const char* config_no_soname = this->GetProperty(soProp)) - { - info.NoSOName = cmSystemTools::IsOn(config_no_soname); - } - else if(const char* no_soname = this->GetProperty("IMPORTED_NO_SONAME")) - { - info.NoSOName = cmSystemTools::IsOn(no_soname); - } - } - - // Get the import library. - if(imp) - { - info.ImportLibrary = imp; - } - else if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->IsExecutableWithExports()) - { - std::string impProp = "IMPORTED_IMPLIB"; - impProp += suffix; - if(const char* config_implib = this->GetProperty(impProp)) - { - info.ImportLibrary = config_implib; - } - else if(const char* implib = this->GetProperty("IMPORTED_IMPLIB")) - { - info.ImportLibrary = implib; - } - } - - // Get the link dependencies. - { - std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES"; - linkProp += suffix; - if(const char* config_libs = this->GetProperty(linkProp)) - { - info.SharedDeps = config_libs; - } - else if(const char* libs = - this->GetProperty("IMPORTED_LINK_DEPENDENT_LIBRARIES")) - { - info.SharedDeps = libs; - } - } - - // Get the link languages. - if(this->LinkLanguagePropagatesToDependents()) - { - std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES"; - linkProp += suffix; - if(const char* config_libs = this->GetProperty(linkProp)) - { - info.Languages = config_libs; - } - else if(const char* libs = - this->GetProperty("IMPORTED_LINK_INTERFACE_LANGUAGES")) - { - info.Languages = libs; - } - } - - // Get the cyclic repetition count. - if(this->GetType() == cmTarget::STATIC_LIBRARY) - { - std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY"; - linkProp += suffix; - if(const char* config_reps = this->GetProperty(linkProp)) - { - sscanf(config_reps, "%u", &info.Multiplicity); - } - else if(const char* reps = - this->GetProperty("IMPORTED_LINK_INTERFACE_MULTIPLICITY")) - { - sscanf(reps, "%u", &info.Multiplicity); - } - } -} - -//---------------------------------------------------------------------------- -void cmTargetInternals::AddInterfaceEntries( - cmTarget const* thisTarget, std::string const& config, - std::string const& prop, std::vector<TargetPropertyEntry*>& entries) -{ - if(cmLinkImplementationLibraries const* impl = - thisTarget->GetLinkImplementationLibraries(config)) - { - for (std::vector<cmLinkImplItem>::const_iterator - it = impl->Libraries.begin(), end = impl->Libraries.end(); - it != end; ++it) - { - if(it->Target) - { - std::string genex = - "$<TARGET_PROPERTY:" + *it + "," + prop + ">"; - cmGeneratorExpression ge(it->Backtrace); - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex); - cge->SetEvaluateForBuildsystem(true); - entries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge, *it)); - } - } - } -} - -cmOptionalLinkImplementation& -cmTarget::GetLinkImplMap(std::string const& config) const -{ - // Populate the link implementation for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - return Internal->LinkImplMap[CONFIG][this]; -} - -//---------------------------------------------------------------------------- -cmLinkImplementationLibraries const* -cmTarget::GetLinkImplementationLibraries(const std::string& config) const -{ - return this->GetLinkImplementationLibrariesInternal(config, this); -} - -//---------------------------------------------------------------------------- -cmLinkImplementationLibraries const* -cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config, - cmTarget const* head) const -{ - // There is no link implementation for imported targets. - if(this->IsImported()) - { - return 0; - } - - // Populate the link implementation libraries for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::HeadToLinkImplementationMap& hm = - this->Internal->LinkImplMap[CONFIG]; - - // If the link implementation does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - cmOptionalLinkImplementation& impl = hm[head]; - if(!impl.LibrariesDone) - { - impl.LibrariesDone = true; - this->ComputeLinkImplementationLibraries(config, impl, head); - } - return &impl; -} - -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkImplementationLibraries( - const std::string& config, - cmOptionalLinkImplementation& impl, - cmTarget const* head) const -{ - // Collect libraries directly linked in this configuration. - for (std::vector<cmValueWithOrigin>::const_iterator - le = this->Internal->LinkImplementationPropertyEntries.begin(), - end = this->Internal->LinkImplementationPropertyEntries.end(); - le != end; ++le) - { - std::vector<std::string> llibs; - cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), - "LINK_LIBRARIES", 0, 0); - cmGeneratorExpression ge(le->Backtrace); - cmsys::auto_ptr<cmCompiledGeneratorExpression> const cge = - ge.Parse(le->Value); - std::string const evaluated = - cge->Evaluate(this->Makefile, config, false, head, &dagChecker); - cmSystemTools::ExpandListArgument(evaluated, llibs); - if(cge->GetHadHeadSensitiveCondition()) - { - impl.HadHeadSensitiveCondition = true; - } - - for(std::vector<std::string>::const_iterator li = llibs.begin(); - li != llibs.end(); ++li) - { - // Skip entries that resolve to the target itself or are empty. - std::string name = this->CheckCMP0004(*li); - if(name == this->GetName() || name.empty()) - { - if(name == this->GetName()) - { - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - std::ostringstream e; - switch(this->GetPolicyStatusCMP0038()) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0038) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - - if(!noMessage) - { - e << "Target \"" << this->GetName() << "\" links to itself."; - this->Makefile->GetCMakeInstance()->IssueMessage( - messageType, e.str(), this->GetBacktrace()); - if (messageType == cmake::FATAL_ERROR) - { - return; - } - } - } - continue; - } - - // The entry is meant for this configuration. - impl.Libraries.push_back( - cmLinkImplItem(name, this->FindTargetToLink(name), - le->Backtrace, evaluated != le->Value)); - } - - std::set<std::string> const& seenProps = cge->GetSeenTargetProperties(); - for (std::set<std::string>::const_iterator it = seenProps.begin(); - it != seenProps.end(); ++it) - { - if (!this->GetProperty(*it)) - { - this->LinkImplicitNullProperties.insert(*it); - } - } - cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards); - } - - cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config); - cmTarget::LinkLibraryVectorType const& oldllibs = - this->GetOriginalLinkLibraries(); - for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin(); - li != oldllibs.end(); ++li) - { - if(li->second != cmTarget::GENERAL && li->second != linkType) - { - std::string name = this->CheckCMP0004(li->first); - if(name == this->GetName() || name.empty()) - { - continue; - } - // Support OLD behavior for CMP0003. - impl.WrongConfigLibraries.push_back( - cmLinkItem(name, this->FindTargetToLink(name))); - } - } -} - -//---------------------------------------------------------------------------- -cmTarget const* cmTarget::FindTargetToLink(std::string const& name) const -{ - cmTarget const* tgt = this->Makefile->FindTargetToUse(name); - - // Skip targets that will not really be linked. This is probably a - // name conflict between an external library and an executable - // within the project. - if(tgt && tgt->GetType() == cmTarget::EXECUTABLE && - !tgt->IsExecutableWithExports()) - { - tgt = 0; - } - - if(tgt && tgt->GetType() == cmTarget::OBJECT_LIBRARY) - { - std::ostringstream e; - e << "Target \"" << this->GetName() << "\" links to " - "OBJECT library \"" << tgt->GetName() << "\" but this is not " - "allowed. " - "One may link only to STATIC or SHARED libraries, or to executables " - "with the ENABLE_EXPORTS property set."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace()); - tgt = 0; - } - - // Return the target found, if any. - return tgt; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::CheckCMP0004(std::string const& item) const -{ - // Strip whitespace off the library names because we used to do this - // in case variables were expanded at generate time. We no longer - // do the expansion but users link to libraries like " ${VAR} ". - std::string lib = item; - std::string::size_type pos = lib.find_first_not_of(" \t\r\n"); - if(pos != lib.npos) - { - lib = lib.substr(pos, lib.npos); - } - pos = lib.find_last_not_of(" \t\r\n"); - if(pos != lib.npos) - { - lib = lib.substr(0, pos+1); - } - if(lib != item) - { - cmake* cm = this->Makefile->GetCMakeInstance(); - switch(this->GetPolicyStatusCMP0004()) - { - case cmPolicies::WARN: - { - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0004) << "\n" - << "Target \"" << this->GetName() << "\" links to item \"" - << item << "\" which has leading or trailing whitespace."; - cm->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->GetBacktrace()); - } - case cmPolicies::OLD: - break; - case cmPolicies::NEW: - { - std::ostringstream e; - e << "Target \"" << this->GetName() << "\" links to item \"" - << item << "\" which has leading or trailing whitespace. " - << "This is now an error according to policy CMP0004."; - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace()); - } - break; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - { - std::ostringstream e; - e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0004) << "\n" - << "Target \"" << this->GetName() << "\" links to item \"" - << item << "\" which has leading or trailing whitespace."; - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace()); - } - break; - } - } - return lib; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; @@ -3735,7 +2217,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c86ec24..e8c05da 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -16,7 +16,6 @@ #include "cmPropertyMap.h" #include "cmPolicies.h" #include "cmListFileCache.h" -#include "cmLinkItem.h" #include <cmsys/auto_ptr.hxx> #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -27,22 +26,6 @@ # endif #endif -#define CM_FOR_EACH_TARGET_POLICY(F) \ - F(CMP0003) \ - F(CMP0004) \ - F(CMP0008) \ - F(CMP0020) \ - F(CMP0021) \ - F(CMP0022) \ - F(CMP0027) \ - F(CMP0038) \ - F(CMP0041) \ - F(CMP0042) \ - F(CMP0046) \ - F(CMP0052) \ - F(CMP0060) \ - F(CMP0063) - class cmake; class cmMakefile; class cmSourceFile; @@ -77,18 +60,12 @@ class cmTarget { public: cmTarget(); - enum TargetType { EXECUTABLE, STATIC_LIBRARY, - SHARED_LIBRARY, MODULE_LIBRARY, - OBJECT_LIBRARY, UTILITY, GLOBAL_TARGET, - INTERFACE_LIBRARY, - UNKNOWN_LIBRARY}; - static const char* GetTargetTypeName(TargetType targetType); enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD }; /** * Return the type of target. */ - TargetType GetType() const + cmState::TargetType GetType() const { return this->TargetTypeValue; } @@ -96,13 +73,12 @@ public: /** * Set the target type */ - void SetType(TargetType f, const std::string& name); + void SetType(cmState::TargetType f, const std::string& name); void MarkAsImported(); ///! Set/Get the name of the target const std::string& GetName() const {return this->Name;} - std::string GetExportName() const; ///! Set the cmMakefile that owns this target void SetMakefile(cmMakefile *mf); @@ -133,11 +109,6 @@ public: {this->PostBuildCommands.push_back(cmd);} /** - * Get the list of the source files used by this target - */ - void GetSourceFiles(std::vector<cmSourceFile*> &files, - const std::string& config) const; - /** * Add sources to the target. */ void AddSources(std::vector<std::string> const& srcs); @@ -145,28 +116,21 @@ public: cmSourceFile* AddSourceCMP0049(const std::string& src); cmSourceFile* AddSource(const std::string& src); - enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED}; - //* how we identify a library, by name and type - typedef std::pair<std::string, LinkLibraryType> LibraryID; + typedef std::pair<std::string, cmTargetLinkLibraryType> LibraryID; typedef std::vector<LibraryID > LinkLibraryVectorType; const LinkLibraryVectorType &GetOriginalLinkLibraries() const {return this->OriginalLinkLibraries;} - /** Compute the link type to use for the given configuration. */ - LinkLibraryType ComputeLinkType(const std::string& config) const; - /** * Clear the dependency information recorded for this target, if any. */ void ClearDependencyInformation(cmMakefile& mf, const std::string& target); - // Check to see if a library is a framework and treat it different on Mac - bool NameResolvesToFramework(const std::string& libname) const; void AddLinkLibrary(cmMakefile& mf, const std::string& target, const std::string& lib, - LinkLibraryType llt); + cmTargetLinkLibraryType llt); enum TLLSignature { KeywordTLLSignature, PlainTLLSignature @@ -210,7 +174,6 @@ public: void AddUtility(const std::string& u, cmMakefile *makefile = 0); ///! Get the utilities used by this target std::set<std::string>const& GetUtilities() const { return this->Utilities; } - std::set<cmLinkItem>const& GetUtilityItems() const; cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const; /** Finalize the target at the end of the Configure step. */ @@ -227,70 +190,6 @@ public: bool IsImported() const {return this->IsImportedTarget;} - void GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const; - - cmLinkImplementationLibraries const* - GetLinkImplementationLibraries(const std::string& config) const; - - void ComputeLinkImplementationLibraries(const std::string& config, - cmOptionalLinkImplementation& impl, - cmTarget const* head) const; - - cmOptionalLinkImplementation& - GetLinkImplMap(std::string const& config) const; - - cmTarget const* FindTargetToLink(std::string const& name) const; - - /** Strip off leading and trailing whitespace from an item named in - the link dependencies of this target. */ - std::string CheckCMP0004(std::string const& item) const; - - /** Get the directory in which this target will be built. If the - configuration name is given then the generator will add its - subdirectory for that configuration. Otherwise just the canonical - output directory is given. */ - std::string GetDirectory(const std::string& config = "", - bool implib = false) const; - - /** Get the directory in which this targets .pdb files will be placed. - If the configuration name is given then the generator will add its - subdirectory for that configuration. Otherwise just the canonical - pdb output directory is given. */ - std::string GetPDBDirectory(const std::string& config) const; - - const char* ImportedGetLocation(const std::string& config) const; - - /** Get the target major and minor version numbers interpreted from - the VERSION property. Version 0 is returned if the property is - not set or cannot be parsed. */ - void GetTargetVersion(int& major, int& minor) const; - - /** Get the target major, minor, and patch version numbers - interpreted from the VERSION or SOVERSION property. Version 0 - is returned if the property is not set or cannot be parsed. */ - void - GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - - /** Whether this library has \@rpath and platform supports it. */ - bool HasMacOSXRpathInstallNameDir(const std::string& config) const; - - /** Whether this library defaults to \@rpath. */ - bool MacOSXRpathInstallNameDirDefault() const; - - /** Test for special case of a third-party shared library that has - no soname at all. */ - bool IsImportedSharedLibWithoutSOName(const std::string& config) const; - - /** Does this target have a GNU implib to convert to MS format? */ - bool HasImplibGNUtoMS() const; - - /** Convert the given GNU import library name (.dll.a) to a name with a new - extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */ - bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, - const char* newExt = 0) const; - - bool HaveInstallTreeRPATH() const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } @@ -299,33 +198,14 @@ public: const char** imp, std::string& suffix) const; - /** Get the macro to define when building sources in this target. - If no macro should be defined null is returned. */ - const char* GetExportMacro() const; - /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports() const; - /** Return whether this target may be used to link another target. */ - bool IsLinkable() const; - - /** Return whether or not the target is for a DLL platform. */ - bool IsDLLPlatform() const { return this->DLLPlatform; } - - /** Return whether or not the target has a DLL import library. */ - bool HasImportLibrary() const; - /** Return whether this target is a shared library Framework on Apple. */ bool IsFrameworkOnApple() const; - /** Return whether this target is a CFBundle (plugin) on Apple. */ - bool IsCFBundleOnApple() const; - - /** Return whether this target is a XCTest on Apple. */ - bool IsXCTestOnApple() const; - /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; @@ -336,16 +216,6 @@ public: /** Get a backtrace from the creation of the target. */ cmListFileBacktrace const& GetBacktrace() const; - /** Get a build-tree directory in which to place target support files. */ - std::string GetSupportDirectory() const; - - /** Return whether this target uses the default value for its output - directory. */ - bool UsesDefaultOutputDir(const std::string& config, bool implib) const; - - /** @return whether this target have a well defined output file name. */ - bool HaveWellDefinedOutputFiles() const; - void InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before = false); @@ -357,23 +227,15 @@ public: void AppendBuildInterfaceIncludes(); - bool IsNullImpliedByLinkLibraries(const std::string &p) const; - std::string GetDebugGeneratorExpressions(const std::string &value, - cmTarget::LinkLibraryType llt) const; + cmTargetLinkLibraryType llt) const; void AddSystemIncludeDirectories(const std::set<std::string> &incs); std::set<std::string> const & GetSystemIncludeDirectories() const { return this->SystemIncludeDirectories; } bool LinkLanguagePropagatesToDependents() const - { return this->TargetTypeValue == STATIC_LIBRARY; } - - std::map<std::string, std::string> const& - GetMaxLanguageStandards() const - { - return this->MaxLanguageStandards; - } + { return this->TargetTypeValue == cmState::STATIC_LIBRARY; } cmStringRange GetIncludeDirectoriesEntries() const; cmBacktraceRange GetIncludeDirectoriesBacktraces() const; @@ -387,6 +249,12 @@ public: cmStringRange GetCompileDefinitionsEntries() const; cmBacktraceRange GetCompileDefinitionsBacktraces() const; + cmStringRange GetSourceEntries() const; + cmBacktraceRange GetSourceBacktraces() const; + cmStringRange GetLinkImplementationEntries() const; + cmBacktraceRange GetLinkImplementationBacktraces() const; + + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -456,31 +324,19 @@ private: void SetPropertyDefault(const std::string& property, const char* default_value); - // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. - const char* GetOutputTargetType(bool implib) const; - - std::string GetFullNameImported(const std::string& config, - bool implib) const; - std::string ImportedGetFullPath(const std::string& config, bool implib) const; - - void GetSourceFiles(std::vector<std::string> &files, - const std::string& config) const; private: mutable cmPropertyMap Properties; std::set<std::string> SystemIncludeDirectories; std::set<std::string> LinkDirectoriesEmmitted; std::set<std::string> Utilities; - mutable std::set<std::string> LinkImplicitNullProperties; std::map<std::string, cmListFileBacktrace> UtilityBacktraces; - mutable std::map<std::string, std::string> MaxLanguageStandards; cmPolicies::PolicyMap PolicyMap; std::string Name; std::string InstallPath; std::string RuntimeInstallPath; - mutable std::string ExportMacro; std::vector<std::string> LinkDirectories; std::vector<cmCustomCommand> PreBuildCommands; std::vector<cmCustomCommand> PreLinkCommands; @@ -493,7 +349,7 @@ private: #endif cmMakefile* Makefile; cmTargetInternalPointer Internal; - TargetType TargetTypeValue; + cmState::TargetType TargetTypeValue; bool HaveInstallRule; bool RecordDependencies; bool DLLPlatform; @@ -501,61 +357,21 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugSourcesDone; - mutable bool LinkImplementationLanguageIsContextDependent; #if defined(_WIN32) && !defined(__CYGWIN__) bool LinkLibrariesForVS6Analyzed; #endif - // Cache target output paths for each configuration. - struct OutputInfo; - OutputInfo const* GetOutputInfo(const std::string& config) const; - bool - ComputeOutputDir(const std::string& config, - bool implib, std::string& out) const; - bool ComputePDBOutputDir(const std::string& kind, const std::string& config, - std::string& out) const; - - // Cache import information from properties for each configuration. - struct ImportInfo - { - ImportInfo(): NoSOName(false), Multiplicity(0) {} - bool NoSOName; - int Multiplicity; - std::string Location; - std::string SOName; - std::string ImportLibrary; - std::string Languages; - std::string Libraries; - std::string LibrariesProp; - std::string SharedDeps; - }; - - ImportInfo const* GetImportInfo(const std::string& config) const; - void ComputeImportInfo(std::string const& desired_config, - ImportInfo& info) const; - - cmLinkImplementationLibraries const* - GetLinkImplementationLibrariesInternal(const std::string& config, - cmTarget const* head) const; - std::string ProcessSourceItemCMP0049(const std::string& s); - void ClearLinkMaps(); - - void MaybeInvalidatePropertyCache(const std::string& prop); + /** Return whether or not the target has a DLL import library. */ + bool HasImportLibrary() const; // Internal representation details. friend class cmTargetInternals; friend class cmGeneratorTarget; friend class cmTargetTraceDependencies; - void ComputeVersionedName(std::string& vName, - std::string const& prefix, - std::string const& base, - std::string const& suffix, - std::string const& name, - const char* version) const; + cmListFileBacktrace Backtrace; }; #ifdef CMAKE_BUILD_WITH_CMAKE diff --git a/Source/cmTargetExport.h b/Source/cmTargetExport.h index 7665888..2781337 100644 --- a/Source/cmTargetExport.h +++ b/Source/cmTargetExport.h @@ -14,7 +14,7 @@ #include "cmStandardIncludes.h" -class cmTarget; +class cmGeneratorTarget; class cmInstallTargetGenerator; class cmInstallFilesGenerator; @@ -25,7 +25,8 @@ class cmInstallFilesGenerator; class cmTargetExport { public: - cmTarget* Target; ///< The target + std::string TargetName; + cmGeneratorTarget* Target; ///@name Generators ///@{ diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index b57b921..435346a 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -88,7 +88,7 @@ bool cmTargetLinkLibrariesCommand return true; } - if(this->Target->GetType() == cmTarget::OBJECT_LIBRARY) + if(this->Target->GetType() == cmState::OBJECT_LIBRARY) { std::ostringstream e; e << "Object library target \"" << args[0] << "\" " @@ -98,7 +98,7 @@ bool cmTargetLinkLibrariesCommand return true; } - if (this->Target->GetType() == cmTarget::UTILITY) + if (this->Target->GetType() == cmState::UTILITY) { std::ostringstream e; const char *modal = 0; @@ -136,7 +136,7 @@ bool cmTargetLinkLibrariesCommand } // Keep track of link configuration specifiers. - cmTarget::LinkLibraryType llt = cmTarget::GENERAL; + cmTargetLinkLibraryType llt = GENERAL_LibraryType; bool haveLLT = false; // Start with primary linking and switch to link interface @@ -242,27 +242,27 @@ bool cmTargetLinkLibrariesCommand { if(haveLLT) { - this->LinkLibraryTypeSpecifierWarning(llt, cmTarget::DEBUG); + this->LinkLibraryTypeSpecifierWarning(llt, DEBUG_LibraryType); } - llt = cmTarget::DEBUG; + llt = DEBUG_LibraryType; haveLLT = true; } else if(args[i] == "optimized") { if(haveLLT) { - this->LinkLibraryTypeSpecifierWarning(llt, cmTarget::OPTIMIZED); + this->LinkLibraryTypeSpecifierWarning(llt, OPTIMIZED_LibraryType); } - llt = cmTarget::OPTIMIZED; + llt = OPTIMIZED_LibraryType; haveLLT = true; } else if(args[i] == "general") { if(haveLLT) { - this->LinkLibraryTypeSpecifierWarning(llt, cmTarget::GENERAL); + this->LinkLibraryTypeSpecifierWarning(llt, GENERAL_LibraryType); } - llt = cmTarget::GENERAL; + llt = GENERAL_LibraryType; haveLLT = true; } else if(haveLLT) @@ -282,7 +282,7 @@ bool cmTargetLinkLibrariesCommand // specifed that a library is both debug and optimized. (this check is // only there for backwards compatibility when mixing projects built // with old versions of CMake and new) - llt = cmTarget::GENERAL; + llt = GENERAL_LibraryType; std::string linkType = args[0]; linkType += "_LINK_TYPE"; const char* linkTypeString = @@ -291,11 +291,11 @@ bool cmTargetLinkLibrariesCommand { if(strcmp(linkTypeString, "debug") == 0) { - llt = cmTarget::DEBUG; + llt = DEBUG_LibraryType; } if(strcmp(linkTypeString, "optimized") == 0) { - llt = cmTarget::OPTIMIZED; + llt = OPTIMIZED_LibraryType; } } if (!this->HandleLibrary(args[i], llt)) @@ -350,9 +350,9 @@ cmTargetLinkLibrariesCommand //---------------------------------------------------------------------------- bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, - cmTarget::LinkLibraryType llt) + cmTargetLinkLibraryType llt) { - if(this->Target->GetType() == cmTarget::INTERFACE_LIBRARY + if(this->Target->GetType() == cmState::INTERFACE_LIBRARY && this->CurrentProcessingState != ProcessingKeywordLinkInterface) { this->Makefile->IssueMessage(cmake::FATAL_ERROR, @@ -428,7 +428,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, else if(this->CurrentProcessingState != ProcessingKeywordPublicInterface && this->CurrentProcessingState != ProcessingPlainPublicInterface) { - if (this->Target->GetType() == cmTarget::STATIC_LIBRARY) + if (this->Target->GetType() == cmState::STATIC_LIBRARY) { std::string configLib = this->Target ->GetDebugGeneratorExpressions(lib, llt); @@ -458,7 +458,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, return true; } - if (this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + if (this->Target->GetType() == cmState::INTERFACE_LIBRARY) { return true; } @@ -469,7 +469,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, std::string prop; // Include this library in the link interface for the target. - if(llt == cmTarget::DEBUG || llt == cmTarget::GENERAL) + if(llt == DEBUG_LibraryType || llt == GENERAL_LibraryType) { // Put in the DEBUG configuration interfaces. for(std::vector<std::string>::const_iterator i = debugConfigs.begin(); @@ -480,7 +480,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, this->Target->AppendProperty(prop, lib.c_str()); } } - if(llt == cmTarget::OPTIMIZED || llt == cmTarget::GENERAL) + if(llt == OPTIMIZED_LibraryType || llt == GENERAL_LibraryType) { // Put in the non-DEBUG configuration interfaces. this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib.c_str()); diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 47dd8bd..f061e6d 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -62,7 +62,7 @@ private: ProcessingState CurrentProcessingState; - bool HandleLibrary(const std::string& lib, cmTarget::LinkLibraryType llt); + bool HandleLibrary(const std::string& lib, cmTargetLinkLibraryType llt); }; diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 4696de4..bfc19a4 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -44,12 +44,12 @@ bool cmTargetPropCommandBase this->HandleMissingTarget(args[0]); return false; } - if ((this->Target->GetType() != cmTarget::SHARED_LIBRARY) - && (this->Target->GetType() != cmTarget::STATIC_LIBRARY) - && (this->Target->GetType() != cmTarget::OBJECT_LIBRARY) - && (this->Target->GetType() != cmTarget::MODULE_LIBRARY) - && (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) - && (this->Target->GetType() != cmTarget::EXECUTABLE)) + if ((this->Target->GetType() != cmState::SHARED_LIBRARY) + && (this->Target->GetType() != cmState::STATIC_LIBRARY) + && (this->Target->GetType() != cmState::OBJECT_LIBRARY) + && (this->Target->GetType() != cmState::MODULE_LIBRARY) + && (this->Target->GetType() != cmState::INTERFACE_LIBRARY) + && (this->Target->GetType() != cmState::EXECUTABLE)) { this->SetError("called with non-compilable target type"); return false; @@ -114,7 +114,7 @@ bool cmTargetPropCommandBase return false; } - if (this->Target->GetType() == cmTarget::INTERFACE_LIBRARY + if (this->Target->GetType() == cmState::INTERFACE_LIBRARY && scope != "INTERFACE") { this->SetError("may only be set INTERFACE properties on INTERFACE " diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 9d85f5a..d997596 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -89,8 +89,8 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // be translated. std::string exe = command[0]; cmGeneratorTarget* target = - this->LG->GetMakefile()->FindGeneratorTargetToUse(exe); - if(target && target->GetType() == cmTarget::EXECUTABLE) + this->LG->FindGeneratorTargetToUse(exe); + if(target && target->GetType() == cmState::EXECUTABLE) { // Use the target file on disk. exe = target->GetFullPath(config); @@ -117,7 +117,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, else { // Use the command name given. - exe = ge.Parse(exe.c_str())->Evaluate(this->LG->GetMakefile(), config); + exe = ge.Parse(exe.c_str())->Evaluate(this->LG, config); cmSystemTools::ConvertToUnixSlashes(exe); } @@ -128,7 +128,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, { os << " " << cmOutputConverter::EscapeForCMake( ge.Parse(*ci)->Evaluate( - this->LG->GetMakefile(), config)); + this->LG, config)); } // Finish the test command. @@ -145,7 +145,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, { os << " " << i->first << " " << cmOutputConverter::EscapeForCMake( - ge.Parse(i->second.GetValue())->Evaluate(this->LG->GetMakefile(), + ge.Parse(i->second.GetValue())->Evaluate(this->LG, config)); } os << ")" << std::endl; diff --git a/Source/cmUseMangledMesaCommand.h b/Source/cmUseMangledMesaCommand.h index da927c7..1af2bfe 100644 --- a/Source/cmUseMangledMesaCommand.h +++ b/Source/cmUseMangledMesaCommand.h @@ -23,7 +23,6 @@ public: cmExecutionStatus &status); virtual std::string GetName() const { return "use_mangled_mesa";} virtual bool IsScriptable() const { return true; } - virtual bool IsDiscouraged() const { return true; } protected: void CopyAndFullPathMesaHeader(const char* source, const char* outdir); diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 486328f..3f1e333 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -11,8 +11,6 @@ ============================================================================*/ #include "cmUtilitySourceCommand.h" -#include "cmCacheManager.h" - // cmUtilitySourceCommand bool cmUtilitySourceCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) @@ -54,13 +52,13 @@ bool cmUtilitySourceCommand } else { - cmCacheManager *manager = - this->Makefile->GetCMakeInstance()->GetCacheManager(); + cmState *state = + this->Makefile->GetState(); haveCacheValue = (cacheValue && (strstr(cacheValue, "(IntDir)") == 0 || (intDir && strcmp(intDir, "$(IntDir)") == 0)) && - (manager->GetCacheMajorVersion() != 0 && - manager->GetCacheMinorVersion() != 0 )); + (state->GetCacheMajorVersion() != 0 && + state->GetCacheMinorVersion() != 0 )); } if(haveCacheValue) diff --git a/Source/cmUtilitySourceCommand.h b/Source/cmUtilitySourceCommand.h index 23afdbe..8863ff5 100644 --- a/Source/cmUtilitySourceCommand.h +++ b/Source/cmUtilitySourceCommand.h @@ -22,7 +22,6 @@ public: virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); virtual std::string GetName() const { return "utility_source";} - virtual bool IsDiscouraged() const { return true; } }; #endif diff --git a/Source/cmVariableRequiresCommand.h b/Source/cmVariableRequiresCommand.h index 7e68de1..5b0477f 100644 --- a/Source/cmVariableRequiresCommand.h +++ b/Source/cmVariableRequiresCommand.h @@ -22,7 +22,6 @@ public: virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); virtual std::string GetName() const { return "variable_requires";} - virtual bool IsDiscouraged() const { return true; } }; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 4c380f7..f4c632d 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -9,6 +9,7 @@ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more information. ============================================================================*/ +#include "windows.h" #include "cmVisualStudio10TargetGenerator.h" #include "cmGlobalVisualStudio10Generator.h" #include "cmGeneratorTarget.h" @@ -177,7 +178,7 @@ cmVisualStudio10TargetGenerator(cmTarget* target, this->LocalGenerator = (cmLocalVisualStudio7Generator*) this->GeneratorTarget->GetLocalGenerator(); - this->Name = this->Target->GetName(); + this->Name = this->GeneratorTarget->GetName(); this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str()); this->Platform = gg->GetPlatformName(); this->NsightTegra = gg->IsNsightTegra(); @@ -194,8 +195,8 @@ cmVisualStudio10TargetGenerator(cmTarget* target, this->BuildFileStream = 0; this->IsMissingFiles = false; this->DefaultArtifactDir = - this->Makefile->GetCurrentBinaryDirectory() + std::string("/") + - this->LocalGenerator->GetTargetDirectory(*this->Target); + this->LocalGenerator->GetCurrentBinaryDirectory() + std::string("/") + + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); } cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator() @@ -268,8 +269,8 @@ void cmVisualStudio10TargetGenerator::WriteString(const char* line, void cmVisualStudio10TargetGenerator::Generate() { // do not generate external ms projects - if(this->Target->GetType() == cmTarget::INTERFACE_LIBRARY - || this->Target->GetProperty("EXTERNAL_MSPROJECT")) + if(this->GeneratorTarget->GetType() == cmState::INTERFACE_LIBRARY + || this->GeneratorTarget->GetProperty("EXTERNAL_MSPROJECT")) { return; } @@ -277,7 +278,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->Target->SetProperty("GENERATOR_FILE_NAME",this->Name.c_str()); this->Target->SetProperty("GENERATOR_FILE_NAME_EXT", ".vcxproj"); - if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) + if(this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) { if(!this->ComputeClOptions()) { @@ -296,8 +297,7 @@ void cmVisualStudio10TargetGenerator::Generate() return; } } - cmMakefile* mf = this->Target->GetMakefile(); - std::string path = mf->GetCurrentBinaryDirectory(); + std::string path = this->LocalGenerator->GetCurrentBinaryDirectory(); path += "/"; path += this->Name; path += ".vcxproj"; @@ -360,14 +360,15 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("<ProjectGUID>", 2); (*this->BuildFileStream) << "{" << this->GUID << "}</ProjectGUID>\n"; - if(this->MSTools && this->Target->GetType() <= cmTarget::GLOBAL_TARGET) + if(this->MSTools + && this->GeneratorTarget->GetType() <= cmState::GLOBAL_TARGET) { this->WriteApplicationTypeSettings(); this->VerifyNecessaryFiles(); } const char* vsProjectTypes = - this->Target->GetProperty("VS_GLOBAL_PROJECT_TYPES"); + this->GeneratorTarget->GetProperty("VS_GLOBAL_PROJECT_TYPES"); if(vsProjectTypes) { this->WriteString("<ProjectTypes>", 2); @@ -375,9 +376,12 @@ void cmVisualStudio10TargetGenerator::Generate() "</ProjectTypes>\n"; } - const char* vsProjectName = this->Target->GetProperty("VS_SCC_PROJECTNAME"); - const char* vsLocalPath = this->Target->GetProperty("VS_SCC_LOCALPATH"); - const char* vsProvider = this->Target->GetProperty("VS_SCC_PROVIDER"); + const char* vsProjectName = + this->GeneratorTarget->GetProperty("VS_SCC_PROJECTNAME"); + const char* vsLocalPath = + this->GeneratorTarget->GetProperty("VS_SCC_LOCALPATH"); + const char* vsProvider = + this->GeneratorTarget->GetProperty("VS_SCC_PROVIDER"); if( vsProjectName && vsLocalPath && vsProvider ) { @@ -391,7 +395,8 @@ void cmVisualStudio10TargetGenerator::Generate() (*this->BuildFileStream) << cmVS10EscapeXML(vsProvider) << "</SccProvider>\n"; - const char* vsAuxPath = this->Target->GetProperty("VS_SCC_AUXPATH"); + const char* vsAuxPath = + this->GeneratorTarget->GetProperty("VS_SCC_AUXPATH"); if( vsAuxPath ) { this->WriteString("<SccAuxPath>", 2); @@ -400,13 +405,13 @@ void cmVisualStudio10TargetGenerator::Generate() } } - if(this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT")) + if(this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) { this->WriteString("<WinMDAssembly>true</WinMDAssembly>\n", 2); } const char* vsGlobalKeyword = - this->Target->GetProperty("VS_GLOBAL_KEYWORD"); + this->GeneratorTarget->GetProperty("VS_GLOBAL_KEYWORD"); if(!vsGlobalKeyword) { this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2); @@ -419,7 +424,7 @@ void cmVisualStudio10TargetGenerator::Generate() } const char* vsGlobalRootNamespace = - this->Target->GetProperty("VS_GLOBAL_ROOTNAMESPACE"); + this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE"); if(vsGlobalRootNamespace) { this->WriteString("<RootNamespace>", 2); @@ -430,14 +435,14 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("<Platform>", 2); (*this->BuildFileStream) << cmVS10EscapeXML(this->Platform) << "</Platform>\n"; - const char* projLabel = this->Target->GetProperty("PROJECT_LABEL"); + const char* projLabel = this->GeneratorTarget->GetProperty("PROJECT_LABEL"); if(!projLabel) { projLabel = this->Name.c_str(); } this->WriteString("<ProjectName>", 2); (*this->BuildFileStream) << cmVS10EscapeXML(projLabel) << "</ProjectName>\n"; - if(const char* targetFrameworkVersion = this->Target->GetProperty( + if(const char* targetFrameworkVersion = this->GeneratorTarget->GetProperty( "VS_DOTNET_TARGET_FRAMEWORK_VERSION")) { this->WriteString("<TargetFrameworkVersion>", 2); @@ -462,6 +467,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("<Import Project=\"" VS10_USER_PROPS "\"" " Condition=\"exists('" VS10_USER_PROPS "')\"" " Label=\"LocalAppDataPlatform\" />\n", 2); + this->WritePlatformExtensions(); this->WriteString("</ImportGroup>\n", 1); this->WriteString("<PropertyGroup Label=\"UserMacros\" />\n", 1); this->WriteWinRTPackageCertificateKeyFile(); @@ -474,6 +480,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteXamlFilesGroup(); this->WriteWinRTReferences(); this->WriteProjectReferences(); + this->WriteSDKReferences(); this->WriteString( "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\"" " />\n", 1); @@ -494,7 +501,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() { std::vector<std::string> references; if(const char* vsDotNetReferences = - this->Target->GetProperty("VS_DOTNET_REFERENCES")) + this->GeneratorTarget->GetProperty("VS_DOTNET_REFERENCES")) { cmSystemTools::ExpandListArgument(vsDotNetReferences, references); } @@ -540,7 +547,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() i != this->Configurations.end(); ++i) { this->WritePlatformConfigTag("LogicalName", i->c_str(), 3); - if(this->Target->GetProperty("VS_GLOBAL_ROOTNAMESPACE")) + if(this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE")) { (*this->BuildFileStream ) << "$(RootNamespace)."; } @@ -607,7 +614,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTReferences() { std::vector<std::string> references; if(const char* vsWinRTReferences = - this->Target->GetProperty("VS_WINRT_REFERENCES")) + this->GeneratorTarget->GetProperty("VS_WINRT_REFERENCES")) { cmSystemTools::ExpandListArgument(vsWinRTReferences, references); } @@ -664,19 +671,19 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() i->c_str(), 1, " Label=\"Configuration\"", "\n"); std::string configType = "<ConfigurationType>"; - switch(this->Target->GetType()) + switch(this->GeneratorTarget->GetType()) { - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: configType += "DynamicLibrary"; break; - case cmTarget::OBJECT_LIBRARY: - case cmTarget::STATIC_LIBRARY: + case cmState::OBJECT_LIBRARY: + case cmState::STATIC_LIBRARY: configType += "StaticLibrary"; break; - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: if(this->NsightTegra && - !this->Target->GetPropertyAsBool("ANDROID_GUI")) + !this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) { // Android executables are .so too. configType += "DynamicLibrary"; @@ -686,8 +693,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() configType += "Application"; } break; - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: + case cmState::UTILITY: + case cmState::GLOBAL_TARGET: if(this->NsightTegra) { // Tegra-Android platform does not understand "Utility". @@ -698,8 +705,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() configType += "Utility"; } break; - case cmTarget::UNKNOWN_LIBRARY: - case cmTarget::INTERFACE_LIBRARY: + case cmState::UNKNOWN_LIBRARY: + case cmState::INTERFACE_LIBRARY: break; } configType += "</ConfigurationType>\n"; @@ -741,16 +748,16 @@ void cmVisualStudio10TargetGenerator mfcLine += useOfMfcValue + "</UseOfMfc>\n"; this->WriteString(mfcLine.c_str(), 2); - if((this->Target->GetType() <= cmTarget::OBJECT_LIBRARY && + if((this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY && this->ClOptions[config]->UsingUnicode()) || - this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT") || + this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") || this->GlobalGenerator->TargetsWindowsPhone() || this->GlobalGenerator->TargetsWindowsStore() || - this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) + this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) { this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2); } - else if (this->Target->GetType() <= cmTarget::MODULE_LIBRARY && + else if (this->GeneratorTarget->GetType() <= cmState::MODULE_LIBRARY && this->ClOptions[config]->UsingSBCS()) { this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2); @@ -766,8 +773,8 @@ void cmVisualStudio10TargetGenerator pts += "</PlatformToolset>\n"; this->WriteString(pts.c_str(), 2); } - if(this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT") || - this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) + if(this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") || + this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) { this->WriteString("<WindowsAppContainer>true" "</WindowsAppContainer>\n", 2); @@ -785,27 +792,29 @@ void cmVisualStudio10TargetGenerator ntv += toolset? toolset : "Default"; ntv += "</NdkToolchainVersion>\n"; this->WriteString(ntv.c_str(), 2); - if(const char* minApi = this->Target->GetProperty("ANDROID_API_MIN")) + if(const char* minApi = + this->GeneratorTarget->GetProperty("ANDROID_API_MIN")) { this->WriteString("<AndroidMinAPI>", 2); (*this->BuildFileStream ) << "android-" << cmVS10EscapeXML(minApi) << "</AndroidMinAPI>\n"; } - if(const char* api = this->Target->GetProperty("ANDROID_API")) + if(const char* api = this->GeneratorTarget->GetProperty("ANDROID_API")) { this->WriteString("<AndroidTargetAPI>", 2); (*this->BuildFileStream ) << "android-" << cmVS10EscapeXML(api) << "</AndroidTargetAPI>\n"; } - if(const char* cpuArch = this->Target->GetProperty("ANDROID_ARCH")) + if(const char* cpuArch = this->GeneratorTarget->GetProperty("ANDROID_ARCH")) { this->WriteString("<AndroidArch>", 2); (*this->BuildFileStream) << cmVS10EscapeXML(cpuArch) << "</AndroidArch>\n"; } - if(const char* stlType = this->Target->GetProperty("ANDROID_STL_TYPE")) + if(const char* stlType = + this->GeneratorTarget->GetProperty("ANDROID_STL_TYPE")) { this->WriteString("<AndroidStlType>", 2); (*this->BuildFileStream) << cmVS10EscapeXML(stlType) << @@ -871,6 +880,9 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source, fout << "# generated from CMake\n"; fout.flush(); fout.close(); + // Force given file to have a very old timestamp, thus + // preventing dependent rebuilds. + this->ForceOld(sourcePath); } else { @@ -945,7 +957,7 @@ cmVisualStudio10TargetGenerator::ConvertPath(std::string const& path, { return forceRelative ? cmSystemTools::RelativePath( - this->Makefile->GetCurrentBinaryDirectory(), path.c_str()) + this->LocalGenerator->GetCurrentBinaryDirectory(), path.c_str()) : path.c_str(); } @@ -984,7 +996,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->AddMissingSourceGroups(groupsUsed, sourceGroups); // Write out group file - std::string path = this->Makefile->GetCurrentBinaryDirectory(); + std::string path = this->LocalGenerator->GetCurrentBinaryDirectory(); path += "/"; path += this->Name; path += ".vcxproj.filters"; @@ -1303,6 +1315,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) { tool = "XML"; } + if(this->NsightTegra) { // Nsight Tegra needs specific file types to check up-to-dateness. @@ -1364,7 +1377,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) } for(size_t i = 0; i != this->Configurations.size(); ++i) { - if(0 == strcmp(cge->Evaluate(this->Makefile, + if(0 == strcmp(cge->Evaluate(this->LocalGenerator, this->Configurations[i]), "1")) { this->WriteString("<DeploymentContent Condition=\"" @@ -1441,7 +1454,7 @@ void cmVisualStudio10TargetGenerator::WriteSource( std::string sourceRel = this->ConvertPath(sf->GetFullPath(), true); size_t const maxLen = 250; if(sf->GetCustomCommand() || - ((strlen(this->Makefile->GetCurrentBinaryDirectory()) + 1 + + ((strlen(this->LocalGenerator->GetCurrentBinaryDirectory()) + 1 + sourceRel.length()) <= maxLen)) { forceRelative = true; @@ -1474,7 +1487,7 @@ void cmVisualStudio10TargetGenerator::WriteSources( void cmVisualStudio10TargetGenerator::WriteAllSources() { - if(this->Target->GetType() > cmTarget::UTILITY) + if(this->GeneratorTarget->GetType() > cmState::UTILITY) { return; } @@ -1736,8 +1749,8 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() { - cmTarget::TargetType ttype = this->Target->GetType(); - if(ttype > cmTarget::GLOBAL_TARGET) + cmState::TargetType ttype = this->GeneratorTarget->GetType(); + if(ttype > cmState::GLOBAL_TARGET) { return; } @@ -1749,7 +1762,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() config = this->Configurations.begin(); config != this->Configurations.end(); ++config) { - if(ttype >= cmTarget::UTILITY) + if(ttype >= cmState::UTILITY) { this->WritePlatformConfigTag("IntDir", config->c_str(), 3); *this->BuildFileStream @@ -1759,21 +1772,21 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() else { std::string intermediateDir = this->LocalGenerator-> - GetTargetDirectory(*this->Target); + GetTargetDirectory(this->GeneratorTarget); intermediateDir += "/"; intermediateDir += *config; intermediateDir += "/"; std::string outDir; std::string targetNameFull; - if(ttype == cmTarget::OBJECT_LIBRARY) + if(ttype == cmState::OBJECT_LIBRARY) { outDir = intermediateDir; - targetNameFull = this->Target->GetName(); + targetNameFull = this->GeneratorTarget->GetName(); targetNameFull += ".lib"; } else { - outDir = this->Target->GetDirectory(config->c_str()) + "/"; + outDir = this->GeneratorTarget->GetDirectory(config->c_str()) + "/"; targetNameFull = this->GeneratorTarget->GetFullName(config->c_str()); } this->ConvertToWindowsSlash(intermediateDir); @@ -1821,8 +1834,8 @@ OutputLinkIncremental(std::string const& configName) } // static libraries and things greater than modules do not need // to set this option - if(this->Target->GetType() == cmTarget::STATIC_LIBRARY - || this->Target->GetType() > cmTarget::MODULE_LIBRARY) + if(this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY + || this->GeneratorTarget->GetType() > cmState::MODULE_LIBRARY) { return; } @@ -1919,7 +1932,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( { clOptions.AddFlag("CompileAs", "CompileAsCpp"); } - this->LocalGenerator->AddCompileOptions(flags, this->Target, + this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, linkLanguage, configName.c_str()); // Get preprocessor definitions for this directory. @@ -1948,7 +1961,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( configDefine += configName; configDefine += "\""; clOptions.AddDefine(configDefine); - if(const char* exportMacro = this->Target->GetExportMacro()) + if(const char* exportMacro = + this->GeneratorTarget->GetExportMacro()) { clOptions.AddDefine(exportMacro); } @@ -1956,12 +1970,12 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( if (this->MSTools) { // If we have the VS_WINRT_COMPONENT set then force Compile as WinRT. - if (this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT")) + if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) { clOptions.AddFlag("CompileAsWinRT", "true"); // For WinRT components, add the _WINRT_DLL define to produce a lib - if (this->Target->GetType() == cmTarget::SHARED_LIBRARY || - this->Target->GetType() == cmTarget::MODULE_LIBRARY ) + if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || + this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY ) { clOptions.AddDefine("_WINRT_DLL"); } @@ -2005,7 +2019,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( if(this->NsightTegra) { if(const char* processMax = - this->Target->GetProperty("ANDROID_PROCESS_MAX")) + this->GeneratorTarget->GetProperty("ANDROID_PROCESS_MAX")) { this->WriteString("<ProcessMax>", 3); *this->BuildFileStream << cmVS10EscapeXML(processMax) << @@ -2169,14 +2183,14 @@ WriteMasmOptions(std::string const& configName, void cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config) { - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY && - this->Target->GetType() != cmTarget::OBJECT_LIBRARY) + if(this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY && + this->GeneratorTarget->GetType() != cmState::OBJECT_LIBRARY) { return; } std::string libflags; this->LocalGenerator->GetStaticLibraryFlags(libflags, - cmSystemTools::UpperCase(config), this->Target); + cmSystemTools::UpperCase(config), this->GeneratorTarget); if(!libflags.empty()) { this->WriteString("<Lib>\n", 2); @@ -2203,6 +2217,33 @@ cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config) } } +void cmVisualStudio10TargetGenerator::WriteManifestOptions( + std::string const& config) +{ + if (this->GeneratorTarget->GetType() != cmState::EXECUTABLE && + this->GeneratorTarget->GetType() != cmState::SHARED_LIBRARY && + this->GeneratorTarget->GetType() != cmState::MODULE_LIBRARY) + { + return; + } + + std::vector<cmSourceFile const*> manifest_srcs; + this->GeneratorTarget->GetManifests(manifest_srcs, config); + if (!manifest_srcs.empty()) + { + this->WriteString("<Manifest>\n", 2); + this->WriteString("<AdditionalManifestFiles>", 3); + for (std::vector<cmSourceFile const*>::const_iterator + mi = manifest_srcs.begin(); mi != manifest_srcs.end(); ++mi) + { + std::string m = this->ConvertPath((*mi)->GetFullPath(), false); + this->ConvertToWindowsSlash(m); + (*this->BuildFileStream) << m << ";"; + } + (*this->BuildFileStream) << "</AdditionalManifestFiles>\n"; + this->WriteString("</Manifest>\n", 2); + } +} //---------------------------------------------------------------------------- void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( @@ -2210,7 +2251,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( { // Look through the sources for AndroidManifest.xml and use // its location as the root source directory. - std::string rootDir = this->Makefile->GetCurrentSourceDirectory(); + std::string rootDir = this->LocalGenerator->GetCurrentSourceDirectory(); { std::vector<cmSourceFile const*> extraSources; this->GeneratorTarget->GetExtraSources(extraSources, ""); @@ -2236,18 +2277,18 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( cmVS10EscapeXML(antBuildPath) << "</AntBuildPath>\n"; } - if (this->Target->GetPropertyAsBool("ANDROID_SKIP_ANT_STEP")) + if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_SKIP_ANT_STEP")) { this->WriteString("<SkipAntStep>true</SkipAntStep>\n", 3); } - if (this->Target->GetPropertyAsBool("ANDROID_PROGUARD")) + if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_PROGUARD")) { this->WriteString("<EnableProGuard>true</EnableProGuard>\n", 3); } if (const char* proGuardConfigLocation = - this->Target->GetProperty("ANDROID_PROGUARD_CONFIG_PATH")) + this->GeneratorTarget->GetProperty("ANDROID_PROGUARD_CONFIG_PATH")) { this->WriteString("<ProGuardConfigLocation>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(proGuardConfigLocation) << @@ -2255,7 +2296,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } if (const char* securePropertiesLocation = - this->Target->GetProperty("ANDROID_SECURE_PROPS_PATH")) + this->GeneratorTarget->GetProperty("ANDROID_SECURE_PROPS_PATH")) { this->WriteString("<SecurePropertiesLocation>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(securePropertiesLocation) << @@ -2263,31 +2304,33 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } if (const char* nativeLibDirectoriesExpression = - this->Target->GetProperty("ANDROID_NATIVE_LIB_DIRECTORIES")) + this->GeneratorTarget->GetProperty("ANDROID_NATIVE_LIB_DIRECTORIES")) { cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(nativeLibDirectoriesExpression); - std::string nativeLibDirs = cge->Evaluate(this->Makefile, configName); + std::string nativeLibDirs = cge->Evaluate(this->LocalGenerator, + configName); this->WriteString("<NativeLibDirectories>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(nativeLibDirs) << "</NativeLibDirectories>\n"; } if (const char* nativeLibDependenciesExpression = - this->Target->GetProperty("ANDROID_NATIVE_LIB_DEPENDENCIES")) + this->GeneratorTarget->GetProperty("ANDROID_NATIVE_LIB_DEPENDENCIES")) { cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(nativeLibDependenciesExpression); - std::string nativeLibDeps = cge->Evaluate(this->Makefile, configName); + std::string nativeLibDeps = cge->Evaluate(this->LocalGenerator, + configName); this->WriteString("<NativeLibDependencies>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(nativeLibDeps) << "</NativeLibDependencies>\n"; } if (const char* javaSourceDir = - this->Target->GetProperty("ANDROID_JAVA_SOURCE_DIR")) + this->GeneratorTarget->GetProperty("ANDROID_JAVA_SOURCE_DIR")) { this->WriteString("<JavaSourceDir>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(javaSourceDir) << @@ -2295,19 +2338,20 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } if (const char* jarDirectoriesExpression = - this->Target->GetProperty("ANDROID_JAR_DIRECTORIES")) + this->GeneratorTarget->GetProperty("ANDROID_JAR_DIRECTORIES")) { cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(jarDirectoriesExpression); - std::string jarDirectories = cge->Evaluate(this->Makefile, configName); + std::string jarDirectories = cge->Evaluate(this->LocalGenerator, + configName); this->WriteString("<JarDirectories>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(jarDirectories) << "</JarDirectories>\n"; } if (const char* jarDeps = - this->Target->GetProperty("ANDROID_JAR_DEPENDENCIES")) + this->GeneratorTarget->GetProperty("ANDROID_JAR_DEPENDENCIES")) { this->WriteString("<JarDependencies>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(jarDeps) << @@ -2315,7 +2359,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } if (const char* assetsDirectories = - this->Target->GetProperty("ANDROID_ASSETS_DIRECTORIES")) + this->GeneratorTarget->GetProperty("ANDROID_ASSETS_DIRECTORIES")) { this->WriteString("<AssetsDirectories>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(assetsDirectories) << @@ -2331,7 +2375,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } if (const char* antAdditionalOptions = - this->Target->GetProperty("ANDROID_ANT_ADDITIONAL_OPTIONS")) + this->GeneratorTarget->GetProperty("ANDROID_ANT_ADDITIONAL_OPTIONS")) { this->WriteString("<AdditionalOptions>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(antAdditionalOptions) << @@ -2344,9 +2388,9 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( //---------------------------------------------------------------------------- bool cmVisualStudio10TargetGenerator::ComputeLinkOptions() { - if(this->Target->GetType() == cmTarget::EXECUTABLE || - this->Target->GetType() == cmTarget::SHARED_LIBRARY || - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + if(this->GeneratorTarget->GetType() == cmState::EXECUTABLE || + this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || + this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) { for(std::vector<std::string>::const_iterator i = this->Configurations.begin(); @@ -2383,11 +2427,11 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) std::string CONFIG = cmSystemTools::UpperCase(config); const char* linkType = "SHARED"; - if(this->Target->GetType() == cmTarget::MODULE_LIBRARY) + if(this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) { linkType = "MODULE"; } - if(this->Target->GetType() == cmTarget::EXECUTABLE) + if(this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { linkType = "EXE"; } @@ -2402,7 +2446,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) flags += " "; flags += this-> Target->GetMakefile()->GetRequiredDefinition(linkFlagVar.c_str()); - const char* targetLinkFlags = this->Target->GetProperty("LINK_FLAGS"); + const char* targetLinkFlags = + this->GeneratorTarget->GetProperty("LINK_FLAGS"); if(targetLinkFlags) { flags += " "; @@ -2410,7 +2455,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) } std::string flagsProp = "LINK_FLAGS_"; flagsProp += CONFIG; - if(const char* flagsConfig = this->Target->GetProperty(flagsProp.c_str())) + if(const char* flagsConfig = + this->GeneratorTarget->GetProperty(flagsProp.c_str())) { flags += " "; flags += flagsConfig; @@ -2470,7 +2516,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - if(this->Target->GetType() == cmTarget::EXECUTABLE) + if(this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, @@ -2488,12 +2534,12 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) { linkOptions.AddFlag("Version", ""); - if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") ) + if ( this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE") ) { if (this->GlobalGenerator->TargetsWindowsCE()) { linkOptions.AddFlag("SubSystem", "WindowsCE"); - if (this->Target->GetType() == cmTarget::EXECUTABLE) + if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { if (this->ClOptions[config]->UsingUnicode()) { @@ -2515,7 +2561,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) if (this->GlobalGenerator->TargetsWindowsCE()) { linkOptions.AddFlag("SubSystem", "WindowsCE"); - if (this->Target->GetType() == cmTarget::EXECUTABLE) + if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { if (this->ClOptions[config]->UsingUnicode()) { @@ -2547,10 +2593,11 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) { linkOptions.AddFlag("GenerateDebugInformation", "false"); } - std::string pdb = this->Target->GetPDBDirectory(config.c_str()); + std::string pdb = this->GeneratorTarget->GetPDBDirectory(config.c_str()); pdb += "/"; pdb += targetNamePDB; - std::string imLib = this->Target->GetDirectory(config.c_str(), true); + std::string imLib = + this->GeneratorTarget->GetDirectory(config.c_str(), true); imLib += "/"; imLib += targetNameImport; @@ -2559,7 +2606,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) // A Windows Runtime component uses internal .NET metadata, // so does not have an import library. - if(this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT")) + if(this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") && + this->GeneratorTarget->GetType() != cmState::EXECUTABLE) { linkOptions.AddFlag("GenerateWindowsMetadata", "true"); } @@ -2597,10 +2645,10 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) "%(IgnoreSpecificDefaultLibraries)"); } - if (this->Target->GetType() == cmTarget::SHARED_LIBRARY && + if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { - if (this->Target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) + if (this->GeneratorTarget->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { linkOptions.AddFlag("ModuleDefinitionFile", "$(IntDir)exportall.def"); } @@ -2614,8 +2662,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& config) { - if(this->Target->GetType() == cmTarget::STATIC_LIBRARY - || this->Target->GetType() > cmTarget::MODULE_LIBRARY) + if(this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY + || this->GeneratorTarget->GetType() > cmState::MODULE_LIBRARY) { return; } @@ -2630,7 +2678,7 @@ cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& config) { this->WriteString("<ProjectReference>\n", 2); this->WriteString( - " <LinkLibraryDependencies>false</LinkLibraryDependencies>\n", 2); + "<LinkLibraryDependencies>false</LinkLibraryDependencies>\n", 3); this->WriteString("</ProjectReference>\n", 2); } } @@ -2653,7 +2701,7 @@ void cmVisualStudio10TargetGenerator::AddLibraries( libVec.push_back(path); } else if (!l->Target - || l->Target->GetType() != cmTarget::INTERFACE_LIBRARY) + || l->Target->GetType() != cmState::INTERFACE_LIBRARY) { libVec.push_back(l->Value); } @@ -2725,7 +2773,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1); *this->BuildFileStream << "\n"; // output cl compile flags <ClCompile></ClCompile> - if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) + if(this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) { this->WriteClOptions(*i, includes); // output rc compile flags <ResourceCompile></ResourceCompile> @@ -2740,9 +2788,11 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() this->WriteLinkOptions(*i); // output lib flags <Lib></Lib> this->WriteLibOptions(*i); + // output manifest flags <Manifest></Manifest> + this->WriteManifestOptions(*i); if(this->NsightTegra && - this->Target->GetType() == cmTarget::EXECUTABLE && - this->Target->GetPropertyAsBool("ANDROID_GUI")) + this->GeneratorTarget->GetType() == cmState::EXECUTABLE && + this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) { this->WriteAntBuildOptions(*i); } @@ -2754,10 +2804,10 @@ void cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName) { bool addedPrelink = false; - if (this->Target->GetType() == cmTarget::SHARED_LIBRARY && + if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { - if (this->Target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) + if (this->GeneratorTarget->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { addedPrelink = true; std::vector<cmCustomCommand> commands = @@ -2820,13 +2870,13 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() = this->GlobalGenerator->GetTargetDirectDepends(this->GeneratorTarget); typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet OrderedTargetDependSet; - OrderedTargetDependSet depends(unordered); + OrderedTargetDependSet depends(unordered, CMAKE_CHECK_BUILD_SYSTEM_TARGET); this->WriteString("<ItemGroup>\n", 1); for( OrderedTargetDependSet::const_iterator i = depends.begin(); i != depends.end(); ++i) { cmTarget const* dt = (*i)->Target; - if(dt->GetType() == cmTarget::INTERFACE_LIBRARY) + if(dt->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -2863,11 +2913,106 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() this->WriteString("</ItemGroup>\n", 1); } +void cmVisualStudio10TargetGenerator::WritePlatformExtensions() +{ + // This only applies to Windows 10 apps + if (this->GlobalGenerator->TargetsWindowsStore() && + cmHasLiteralPrefix(this->GlobalGenerator->GetSystemVersion(), "10.0")) + { + const char* desktopExtensionsVersion = + this->GeneratorTarget->GetProperty("VS_DESKTOP_EXTENSIONS_VERSION"); + if (desktopExtensionsVersion) + { + this->WriteSinglePlatformExtension("WindowsDesktop", + desktopExtensionsVersion); + } + const char* mobileExtensionsVersion = + this->GeneratorTarget->GetProperty("VS_MOBILE_EXTENSIONS_VERSION"); + if (mobileExtensionsVersion) + { + this->WriteSinglePlatformExtension("WindowsMobile", + mobileExtensionsVersion); + } + } +} + +void cmVisualStudio10TargetGenerator::WriteSinglePlatformExtension( + std::string const& extension, + std::string const& version + ) +{ + this->WriteString("<Import Project=", 2); + (*this->BuildFileStream) + << "\"$([Microsoft.Build.Utilities.ToolLocationHelper]" + << "::GetPlatformExtensionSDKLocation(`" + << extension <<", Version=" << version + << "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, " + << "$(ExtensionSDKDirectoryRoot), null))" + << "\\DesignTime\\CommonConfiguration\\Neutral\\" + << extension << ".props\" " + << "Condition=\"exists('$(" + << "[Microsoft.Build.Utilities.ToolLocationHelper]" + << "::GetPlatformExtensionSDKLocation(`" + << extension << ", Version=" << version + << "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, " + << "$(ExtensionSDKDirectoryRoot), null))" + << "\\DesignTime\\CommonConfiguration\\Neutral\\" + << extension << ".props')\" />\n"; +} + +void cmVisualStudio10TargetGenerator::WriteSDKReferences() +{ + // This only applies to Windows 10 apps + if (this->GlobalGenerator->TargetsWindowsStore() && + cmHasLiteralPrefix(this->GlobalGenerator->GetSystemVersion(), "10.0")) + { + const char* desktopExtensionsVersion = + this->GeneratorTarget->GetProperty("VS_DESKTOP_EXTENSIONS_VERSION"); + const char* mobileExtensionsVersion = + this->GeneratorTarget->GetProperty("VS_MOBILE_EXTENSIONS_VERSION"); + const char* iotExtensionsVersion = + this->GeneratorTarget->GetProperty("VS_IOT_EXTENSIONS_VERSION"); + + if(desktopExtensionsVersion || mobileExtensionsVersion || + iotExtensionsVersion) + { + this->WriteString("<ItemGroup>\n", 1); + if(desktopExtensionsVersion) + { + this->WriteSingleSDKReference("WindowsDesktop", + desktopExtensionsVersion); + } + if(mobileExtensionsVersion) + { + this->WriteSingleSDKReference("WindowsMobile", + mobileExtensionsVersion); + } + if(iotExtensionsVersion) + { + this->WriteSingleSDKReference("WindowsIoT", + iotExtensionsVersion); + } + this->WriteString("</ItemGroup>\n", 1); + } + } +} + +void cmVisualStudio10TargetGenerator::WriteSingleSDKReference( + std::string const& extension, + std::string const& version + ) +{ + this->WriteString("<SDKReference Include=\"", 2); + (*this->BuildFileStream) << extension + << ", Version=" << version << "\" />\n"; +} + + void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() { if((this->GlobalGenerator->TargetsWindowsStore() || this->GlobalGenerator->TargetsWindowsPhone()) - && (cmTarget::EXECUTABLE == this->Target->GetType())) + && (cmState::EXECUTABLE == this->GeneratorTarget->GetType())) { std::string pfxFile; std::vector<cmSourceFile const*> certificates; @@ -2886,7 +3031,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() { // Move the manifest to a project directory to avoid clashes std::string artifactDir = - this->LocalGenerator->GetTargetDirectory(*this->Target); + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->ConvertToWindowsSlash(artifactDir); this->WriteString("<PropertyGroup>\n", 1); this->WriteString("<AppxPackageArtifactsDir>", 2); @@ -2973,6 +3118,8 @@ IsXamlSource(const std::string& sourceFile) void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings() { + cmGlobalVisualStudio10Generator* gg = + static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); bool isAppContainer = false; bool const isWindowsPhone = this->GlobalGenerator->TargetsWindowsPhone(); bool const isWindowsStore = this->GlobalGenerator->TargetsWindowsStore(); @@ -2983,34 +3130,52 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings() (*this->BuildFileStream) << (isWindowsPhone ? "Windows Phone" : "Windows Store") << "</ApplicationType>\n"; - this->WriteString("<ApplicationTypeRevision>", 2); - (*this->BuildFileStream) << cmVS10EscapeXML(v) - << "</ApplicationTypeRevision>\n"; this->WriteString("<DefaultLanguage>en-US" "</DefaultLanguage>\n", 2); - if(v == "8.1") + if (cmHasLiteralPrefix(v, "10.0")) { + this->WriteString("<ApplicationTypeRevision>", 2); + (*this->BuildFileStream) << cmVS10EscapeXML("10.0") + << "</ApplicationTypeRevision>\n"; + // Visual Studio 14.0 is necessary for building 10.0 apps + this->WriteString("<MinimumVisualStudioVersion>14.0" + "</MinimumVisualStudioVersion>\n", 2); + + if(this->GeneratorTarget->GetType() < cmState::UTILITY) + { + isAppContainer = true; + } + } + else if(v == "8.1") + { + this->WriteString("<ApplicationTypeRevision>", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(v) + << "</ApplicationTypeRevision>\n"; // Visual Studio 12.0 is necessary for building 8.1 apps this->WriteString("<MinimumVisualStudioVersion>12.0" "</MinimumVisualStudioVersion>\n", 2); - if (this->Target->GetType() < cmTarget::UTILITY) + if (this->GeneratorTarget->GetType() < cmState::UTILITY) { isAppContainer = true; } } else if (v == "8.0") { + this->WriteString("<ApplicationTypeRevision>", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(v) + << "</ApplicationTypeRevision>\n"; // Visual Studio 11.0 is necessary for building 8.0 apps this->WriteString("<MinimumVisualStudioVersion>11.0" "</MinimumVisualStudioVersion>\n", 2); - if (isWindowsStore && this->Target->GetType() < cmTarget::UTILITY) + if (isWindowsStore + && this->GeneratorTarget->GetType() < cmState::UTILITY) { isAppContainer = true; } else if (isWindowsPhone && - this->Target->GetType() == cmTarget::EXECUTABLE) + this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { this->WriteString("<XapOutputs>true</XapOutputs>\n", 2); this->WriteString("<XapFilename>", 2); @@ -3029,13 +3194,46 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings() this->WriteString("<WindowsSDKDesktopARMSupport>true" "</WindowsSDKDesktopARMSupport>\n", 2); } + std::string const& targetPlatformVersion = + gg->GetWindowsTargetPlatformVersion(); + if (!targetPlatformVersion.empty()) + { + this->WriteString("<WindowsTargetPlatformVersion>", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion) << + "</WindowsTargetPlatformVersion>\n"; + } + const char* targetPlatformMinVersion = + this->GeneratorTarget + ->GetProperty("VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION"); + if(targetPlatformMinVersion) + { + this->WriteString("<WindowsTargetPlatformMinVersion>", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformMinVersion) << + "</WindowsTargetPlatformMinVersion>\n"; + } + else if (isWindowsStore && cmHasLiteralPrefix(v, "10.0")) + { + // If the min version is not set, then use the TargetPlatformVersion + if (!targetPlatformVersion.empty()) + { + this->WriteString("<WindowsTargetPlatformMinVersion>", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion) << + "</WindowsTargetPlatformMinVersion>\n"; + } + } + + // Added IoT Startup Task support + if(this->GeneratorTarget->GetPropertyAsBool("VS_IOT_STARTUP_TASK")) + { + this->WriteString("<ContainsStartupTask>true</ContainsStartupTask>\n", 2); + } } void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles() { // For Windows and Windows Phone executables, we will assume that if a // manifest is not present that we need to add all the necessary files - if (this->Target->GetType() == cmTarget::EXECUTABLE) + if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { std::vector<cmSourceFile const*> manifestSources; this->GeneratorTarget->GetAppManifest(manifestSources, ""); @@ -3081,7 +3279,7 @@ void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles() { this->IsMissingFiles = true; } - else if (v == "8.1") + else if (v == "8.1" || cmHasLiteralPrefix(v, "10.0")) { this->IsMissingFiles = true; } @@ -3115,6 +3313,10 @@ void cmVisualStudio10TargetGenerator::WriteMissingFiles() { this->WriteMissingFilesWS81(); } + else if (cmHasLiteralPrefix(v, "10.0")) + { + this->WriteMissingFilesWS10_0(); + } } } @@ -3126,13 +3328,15 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80() // For WP80, the manifest needs to be in the same folder as the project // this can cause an overwrite problem if projects aren't organized in // folders - std::string manifestFile = this->Makefile->GetCurrentBinaryDirectory() + + std::string manifestFile = + this->LocalGenerator->GetCurrentBinaryDirectory() + std::string("/WMAppManifest.xml"); std::string artifactDir = - this->LocalGenerator->GetTargetDirectory(*this->Target); + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName()); + std::string targetNameXML = + cmVS10EscapeXML(this->GeneratorTarget->GetName()); cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); @@ -3212,10 +3416,11 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81() std::string manifestFile = this->DefaultArtifactDir + "/package.appxManifest"; std::string artifactDir = - this->LocalGenerator->GetTargetDirectory(*this->Target); + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName()); + std::string targetNameXML = + cmVS10EscapeXML(this->GeneratorTarget->GetName()); cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); @@ -3272,10 +3477,11 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80() std::string manifestFile = this->DefaultArtifactDir + "/package.appxManifest"; std::string artifactDir = - this->LocalGenerator->GetTargetDirectory(*this->Target); + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName()); + std::string targetNameXML = + cmVS10EscapeXML(this->GeneratorTarget->GetName()); cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); @@ -3324,10 +3530,11 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81() std::string manifestFile = this->DefaultArtifactDir + "/package.appxManifest"; std::string artifactDir = - this->LocalGenerator->GetTargetDirectory(*this->Target); + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName()); + std::string targetNameXML = + cmVS10EscapeXML(this->GeneratorTarget->GetName()); cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); @@ -3376,6 +3583,65 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81() this->WriteCommonMissingFiles(manifestFile); } +void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0() +{ + std::string manifestFile = + this->DefaultArtifactDir + "/package.appxManifest"; + std::string artifactDir = + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); + this->ConvertToWindowsSlash(artifactDir); + std::string artifactDirXML = cmVS10EscapeXML(artifactDir); + std::string targetNameXML = + cmVS10EscapeXML(this->GeneratorTarget->GetName()); + + cmGeneratedFileStream fout(manifestFile.c_str()); + fout.SetCopyIfDifferent(true); + + fout << + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<Package\n\t" + "xmlns=\"http://schemas.microsoft.com/appx/manifest/foundation/windows10\"" + "\txmlns:mp=\"http://schemas.microsoft.com/appx/2014/phone/manifest\"\n" + "\txmlns:uap=\"http://schemas.microsoft.com/appx/manifest/uap/windows10\"" + "\n\tIgnorableNamespaces=\"uap mp\">\n\n" + "\t<Identity Name=\"" << this->GUID << "\" Publisher=\"CN=CMake\"" + " Version=\"1.0.0.0\" />\n" + "\t<mp:PhoneIdentity PhoneProductId=\"" << this->GUID << + "\" PhonePublisherId=\"00000000-0000-0000-0000-000000000000\"/>\n" + "\t<Properties>\n" + "\t\t<DisplayName>" << targetNameXML << "</DisplayName>\n" + "\t\t<PublisherDisplayName>CMake</PublisherDisplayName>\n" + "\t\t<Logo>" << artifactDirXML << "\\StoreLogo.png</Logo>\n" + "\t</Properties>\n" + "\t<Dependencies>\n" + "\t\t<TargetDeviceFamily Name=\"Windows.Universal\" " + "MinVersion=\"10.0.0.0\" MaxVersionTested=\"10.0.0.0\" />\n" + "\t</Dependencies>\n" + + "\t<Resources>\n" + "\t\t<Resource Language=\"x-generate\" />\n" + "\t</Resources>\n" + "\t<Applications>\n" + "\t\t<Application Id=\"App\"" + " Executable=\"" << targetNameXML << ".exe\"" + " EntryPoint=\"" << targetNameXML << ".App\">\n" + "\t\t\t<uap:VisualElements\n" + "\t\t\t\tDisplayName=\"" << targetNameXML << "\"\n" + "\t\t\t\tDescription=\"" << targetNameXML << "\"\n" + "\t\t\t\tBackgroundColor=\"#336699\"\n" + "\t\t\t\tSquare150x150Logo=\"" << artifactDirXML << "\\Logo.png\"\n" + "\t\t\t\tSquare44x44Logo=\"" << artifactDirXML << + "\\SmallLogo44x44.png\">\n" + "\t\t\t\t<uap:SplashScreen" + " Image=\"" << artifactDirXML << "\\SplashScreen.png\" />\n" + "\t\t\t</uap:VisualElements>\n" + "\t\t</Application>\n" + "\t</Applications>\n" + "</Package>\n"; + + this->WriteCommonMissingFiles(manifestFile); +} + void cmVisualStudio10TargetGenerator ::WriteCommonMissingFiles(const std::string& manifestFile) @@ -3399,6 +3665,14 @@ cmVisualStudio10TargetGenerator (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo) << "\" />\n"; this->AddedFiles.push_back(smallLogo); + std::string smallLogo44 = this->DefaultArtifactDir + "/SmallLogo44x44.png"; + cmSystemTools::CopyAFile(templateFolder + "/SmallLogo44x44.png", + smallLogo44, false); + this->ConvertToWindowsSlash(smallLogo44); + this->WriteString("<Image Include=\"", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo44) << "\" />\n"; + this->AddedFiles.push_back(smallLogo44); + std::string logo = this->DefaultArtifactDir + "/Logo.png"; cmSystemTools::CopyAFile(templateFolder + "/Logo.png", logo, false); @@ -3429,3 +3703,26 @@ cmVisualStudio10TargetGenerator this->WriteString("<None Include=\"", 2); (*this->BuildFileStream) << cmVS10EscapeXML(keyFile) << "\" />\n"; } + +bool cmVisualStudio10TargetGenerator::ForceOld(const std::string& source) const +{ + HANDLE h = CreateFileW( + cmSystemTools::ConvertToWindowsExtendedPath(source).c_str(), + FILE_WRITE_ATTRIBUTES, + FILE_SHARE_WRITE, 0, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, 0); + if (!h) + { + return false; + } + + FILETIME const ftime_20010101 = { 3365781504u, 29389701u }; + if (!SetFileTime(h, &ftime_20010101, &ftime_20010101, &ftime_20010101)) + { + CloseHandle(h); + return false; + } + + CloseHandle(h); + return true; +} diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 451f8b2..15ed9f2 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -78,6 +78,13 @@ private: void WriteMissingFilesWP81(); void WriteMissingFilesWS80(); void WriteMissingFilesWS81(); + void WriteMissingFilesWS10_0(); + void WritePlatformExtensions(); + void WriteSinglePlatformExtension(std::string const& extension, + std::string const& version); + void WriteSDKReferences(); + void WriteSingleSDKReference(std::string const& extension, + std::string const& version); void WriteCommonMissingFiles(const std::string& manifestFile); void WriteTargetSpecificReferences(); @@ -111,6 +118,7 @@ private: void AddLibraries(cmComputeLinkInformation& cli, std::vector<std::string>& libVec); void WriteLibOptions(std::string const& config); + void WriteManifestOptions(std::string const& config); void WriteEvents(std::string const& configName); void WriteEvent(const char* name, std::vector<cmCustomCommand> const& commands, @@ -129,6 +137,8 @@ private: cmIDEFlagTable const* GetLinkFlagTable() const; cmIDEFlagTable const* GetMasmFlagTable() const; + bool ForceOld(const std::string& source) const; + private: typedef cmVisualStudioGeneratorOptions Options; typedef std::map<std::string, Options*> OptionsMap; diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 012c580..4b7afd8 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -49,7 +49,20 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, mf.ExpandArguments(this->Args, expandedArguments); cmake::MessageType messageType; - cmConditionEvaluator conditionEvaluator(mf); + cmListFileContext execContext = this->GetStartingContext(); + + cmCommandContext commandContext; + commandContext.Line = execContext.Line; + commandContext.Name = execContext.Name; + + cmListFileContext conditionContext = + cmConditionEvaluator::GetConditionContext( + &mf, commandContext, + this->GetStartingContext().FilePath); + + cmConditionEvaluator conditionEvaluator( + mf, conditionContext, + mf.GetBacktrace(commandContext)); bool isTrue = conditionEvaluator.IsTrue( expandedArguments, errorString, messageType); diff --git a/Source/cmWriteFileCommand.h b/Source/cmWriteFileCommand.h index 0d06878..89dc9ff 100644 --- a/Source/cmWriteFileCommand.h +++ b/Source/cmWriteFileCommand.h @@ -46,12 +46,6 @@ public: */ virtual std::string GetName() const { return "write_file";} - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - cmTypeMacro(cmWriteFileCommand, cmCommand); }; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index f069481..7268241 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -10,7 +10,6 @@ See the License for more information. ============================================================================*/ #include "cmake.h" -#include "cmCacheManager.h" #include "cmMakefile.h" #include "cmLocalGenerator.h" #include "cmExternalMakefileProjectGenerator.h" @@ -128,12 +127,14 @@ cmake::cmake() this->WarnUnused = false; this->WarnUnusedCli = true; this->CheckSystemVars = false; + this->SuppressDevWarnings = false; + this->DoSuppressDevWarnings = false; this->DebugOutput = false; this->DebugTryCompile = false; this->ClearBuildSystem = false; this->FileComparison = new cmFileTimeComparison; - this->State = new cmState(this); + this->State = new cmState; this->CurrentSnapshot = this->State->CreateBaseSnapshot(); #ifdef __APPLE__ @@ -149,7 +150,6 @@ cmake::cmake() #endif this->Verbose = false; - this->CacheManager = new cmCacheManager(this); this->GlobalGenerator = 0; this->ProgressCallback = 0; this->ProgressCallbackClientData = 0; @@ -169,7 +169,6 @@ cmake::cmake() cmake::~cmake() { - delete this->CacheManager; delete this->State; if (this->GlobalGenerator) { @@ -187,6 +186,7 @@ void cmake::CleanupCommandsAndMacros() { this->CurrentSnapshot = this->State->Reset(); this->State->RemoveUserDefinedCommands(); + this->CurrentSnapshot.SetDefaultDefinitions(); } // Parse the args @@ -214,7 +214,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) } std::string var, value; cmState::CacheEntryType type = cmState::UNINITIALIZED; - if(cmCacheManager::ParseEntry(entry, var, value, type)) + if(cmState::ParseCacheEntry(entry, var, value, type)) { // The value is transformed if it is a filepath for example, so // we can't compare whether the value is already in the cache until @@ -230,7 +230,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) } } - this->State->AddCacheEntry(var, value.c_str(), + this->AddCacheEntry(var, value.c_str(), "No help, variable specified on the command line.", type); if(this->WarnUnusedCli) @@ -250,70 +250,15 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) return false; } } - else if(cmHasLiteralPrefix(arg, "-W")) + else if(arg.find("-Wno-dev",0) == 0) { - std::string entry = arg.substr(2); - if (entry.empty()) - { - ++i; - if (i < args.size()) - { - entry = args[i]; - } - else - { - cmSystemTools::Error( - "-W must be followed with [no-][error=]<name>."); - return false; - } + this->SuppressDevWarnings = true; + this->DoSuppressDevWarnings = true; } - - std::string name; - bool foundNo = false; - bool foundError = false; - unsigned int nameStartPosition = 0; - - if (entry.find("no-", nameStartPosition) == 0) - { - foundNo = true; - nameStartPosition += 3; - } - - if (entry.find("error=", nameStartPosition) == 0) - { - foundError = true; - nameStartPosition += 6; - } - - name = entry.substr(nameStartPosition); - if (name.empty()) - { - cmSystemTools::Error("No warning name provided."); - return false; - } - - if (!foundNo && !foundError) - { - // -W<name> - this->WarningLevels[name] = std::max(this->WarningLevels[name], - WARNING_LEVEL); - } - else if (foundNo && !foundError) - { - // -Wno<name> - this->WarningLevels[name] = IGNORE_LEVEL; - } - else if (!foundNo && foundError) - { - // -Werror=<name> - this->WarningLevels[name] = ERROR_LEVEL; - } - else - { - // -Wno-error=<name> - this->WarningLevels[name] = std::min(this->WarningLevels[name], - WARNING_LEVEL); - } + else if(arg.find("-Wdev",0) == 0) + { + this->SuppressDevWarnings = false; + this->DoSuppressDevWarnings = true; } else if(arg.find("-U",0) == 0) { @@ -430,21 +375,21 @@ void cmake::ReadListFile(const std::vector<std::string>& args, this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); cmState::Snapshot snapshot = this->GetCurrentSnapshot(); - cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot)); - cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator(mf.get())); - lg->GetMakefile()->SetCurrentBinaryDirectory + snapshot.GetDirectory().SetCurrentBinary (cmSystemTools::GetCurrentWorkingDirectory()); - lg->GetMakefile()->SetCurrentSourceDirectory + snapshot.GetDirectory().SetCurrentSource (cmSystemTools::GetCurrentWorkingDirectory()); + snapshot.SetDefaultDefinitions(); + cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot)); if (this->GetWorkingMode() != NORMAL_MODE) { std::string file(cmSystemTools::CollapseFullPath(path)); cmSystemTools::ConvertToUnixSlashes(file); - lg->GetMakefile()->SetScriptModeFile(file.c_str()); + mf->SetScriptModeFile(file.c_str()); - lg->GetMakefile()->SetArgcArgv(args); + mf->SetArgcArgv(args); } - if (!lg->GetMakefile()->ReadListFile(path)) + if (!mf->ReadListFile(path)) { cmSystemTools::Error("Error processing file: ", path); } @@ -472,13 +417,14 @@ bool cmake::FindPackage(const std::vector<std::string>& args) this->SetGlobalGenerator(gg); cmState::Snapshot snapshot = this->GetCurrentSnapshot(); + snapshot.GetDirectory().SetCurrentBinary + (cmSystemTools::GetCurrentWorkingDirectory()); + snapshot.GetDirectory().SetCurrentSource + (cmSystemTools::GetCurrentWorkingDirectory()); // read in the list file to fill the cache + snapshot.SetDefaultDefinitions(); cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot)); cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator(mf.get())); - mf->SetCurrentBinaryDirectory - (cmSystemTools::GetCurrentWorkingDirectory()); - mf->SetCurrentSourceDirectory - (cmSystemTools::GetCurrentWorkingDirectory()); mf->SetArgcArgv(args); @@ -531,7 +477,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args) ++libIt) { mf->AddLinkLibraryForTarget(targetName, *libIt, - cmTarget::GENERAL); + GENERAL_LibraryType); } @@ -645,7 +591,11 @@ void cmake::SetArgs(const std::vector<std::string>& args, // skip for now i++; } - else if(arg.find("-W",0) == 0) + else if(arg.find("-Wno-dev",0) == 0) + { + // skip for now + } + else if(arg.find("-Wdev",0) == 0) { // skip for now } @@ -898,14 +848,14 @@ void cmake::SetDirectoriesFromFile(const char* arg) int cmake::AddCMakePaths() { // Save the value in the cache - this->CacheManager->AddCacheEntry + this->AddCacheEntry ("CMAKE_COMMAND", cmSystemTools::GetCMakeCommand().c_str(), "Path to CMake executable.", cmState::INTERNAL); #ifdef CMAKE_BUILD_WITH_CMAKE - this->CacheManager->AddCacheEntry + this->AddCacheEntry ("CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(), "Path to ctest program executable.", cmState::INTERNAL); - this->CacheManager->AddCacheEntry + this->AddCacheEntry ("CMAKE_CPACK_COMMAND", cmSystemTools::GetCPackCommand().c_str(), "Path to cpack program executable.", cmState::INTERNAL); #endif @@ -919,7 +869,7 @@ int cmake::AddCMakePaths() cmSystemTools::GetCMakeRoot().c_str()); return 0; } - this->CacheManager->AddCacheEntry + this->AddCacheEntry ("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(), "Path to CMake installation.", cmState::INTERNAL); @@ -1033,6 +983,10 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname) void cmake::SetHomeDirectory(const std::string& dir) { this->State->SetSourceDirectory(dir); + if (this->CurrentSnapshot.IsValid()) + { + this->CurrentSnapshot.SetDefinition("CMAKE_SOURCE_DIR", dir); + } } const char* cmake::GetHomeDirectory() const @@ -1043,6 +997,10 @@ const char* cmake::GetHomeDirectory() const void cmake::SetHomeOutputDirectory(const std::string& dir) { this->State->SetBinaryDirectory(dir); + if (this->CurrentSnapshot.IsValid()) + { + this->CurrentSnapshot.SetDefinition("CMAKE_BINARY_DIR", dir); + } } const char* cmake::GetHomeOutputDirectory() const @@ -1136,10 +1094,10 @@ int cmake::DoPreConfigureChecks() } // do a sanity check on some values - if(this->CacheManager->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) + if(this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) { std::string cacheStart = - this->CacheManager->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"); + this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"); cacheStart += "/CMakeLists.txt"; std::string currentStart = this->GetHomeDirectory(); currentStart += "/CMakeLists.txt"; @@ -1196,12 +1154,12 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) save.value = *i; warning << *i << "\n"; const char* existingValue = - this->CacheManager->GetCacheEntryValue(save.key); + this->State->GetCacheEntryValue(save.key); if(existingValue) { - save.type = this->CacheManager->GetCacheEntryType(save.key); + save.type = this->State->GetCacheEntryType(save.key); if(const char* help = - this->CacheManager->GetCacheEntryProperty(save.key, "HELPSTRING")) + this->State->GetCacheEntryProperty(save.key, "HELPSTRING")) { save.help = help; } @@ -1210,7 +1168,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) } // remove the cache - this->CacheManager->DeleteCache(this->GetHomeOutputDirectory()); + this->DeleteCache(this->GetHomeOutputDirectory()); // load the empty cache this->LoadCache(); // restore the changed compilers @@ -1232,121 +1190,25 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) int cmake::Configure() { - WarningLevel warningLevel; - - if (this->WarningLevels.count("deprecated") == 1) + if(this->DoSuppressDevWarnings) { - warningLevel = this->WarningLevels["deprecated"]; - if (warningLevel == IGNORE_LEVEL) + if(this->SuppressDevWarnings) { - this->CacheManager-> - AddCacheEntry("CMAKE_WARN_DEPRECATED", "FALSE", - "Whether to issue deprecation warnings for" - " macros and functions.", - cmState::BOOL); - this->CacheManager-> - AddCacheEntry("CMAKE_ERROR_DEPRECATED", "FALSE", - "Whether to issue deprecation errors for macros" - " and functions.", - cmState::BOOL); - } - if (warningLevel == WARNING_LEVEL) - { - this->CacheManager-> - AddCacheEntry("CMAKE_WARN_DEPRECATED", "TRUE", - "Whether to issue deprecation warnings for" - " macros and functions.", - cmState::BOOL); - } - else if (warningLevel == ERROR_LEVEL) - { - this->CacheManager-> - AddCacheEntry("CMAKE_ERROR_DEPRECATED", "TRUE", - "Whether to issue deprecation errors for macros" - " and functions.", - cmState::BOOL); - } - } - - if (this->WarningLevels.count("dev") == 1) - { - bool setDeprecatedVariables = false; - - const char* cachedWarnDeprecated = - this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED"); - const char* cachedErrorDeprecated = - this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED"); - - // don't overwrite deprecated warning setting from a previous invocation - if (!cachedWarnDeprecated && !cachedErrorDeprecated) - { - setDeprecatedVariables = true; - } - - warningLevel = this->WarningLevels["dev"]; - if (warningLevel == IGNORE_LEVEL) - { - this->CacheManager-> + this-> AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE", "Suppress Warnings that are meant for" " the author of the CMakeLists.txt files.", cmState::INTERNAL); - this->CacheManager-> - AddCacheEntry("CMAKE_ERROR_DEVELOPER_WARNINGS", "FALSE", - "Suppress errors that are meant for" - " the author of the CMakeLists.txt files.", - cmState::INTERNAL); - - if (setDeprecatedVariables) - { - this->CacheManager-> - AddCacheEntry("CMAKE_WARN_DEPRECATED", "FALSE", - "Whether to issue deprecation warnings for" - " macros and functions.", - cmState::BOOL); - this->CacheManager-> - AddCacheEntry("CMAKE_ERROR_DEPRECATED", "FALSE", - "Whether to issue deprecation errors for macros" - " and functions.", - cmState::BOOL); - } } - else if (warningLevel == WARNING_LEVEL) + else { - this->CacheManager-> + this-> AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE", "Suppress Warnings that are meant for" " the author of the CMakeLists.txt files.", cmState::INTERNAL); - - if (setDeprecatedVariables) - { - this->CacheManager-> - AddCacheEntry("CMAKE_WARN_DEPRECATED", "TRUE", - "Whether to issue deprecation warnings for" - " macros and functions.", - cmState::BOOL); - } - } - else if (warningLevel == ERROR_LEVEL) - { - this->CacheManager-> - AddCacheEntry("CMAKE_ERROR_DEVELOPER_WARNINGS", "TRUE", - "Suppress errors that are meant for" - " the author of the CMakeLists.txt files.", - cmState::INTERNAL); - - if (setDeprecatedVariables) - { - this->CacheManager-> - AddCacheEntry("CMAKE_ERROR_DEPRECATED", "TRUE", - "Whether to issue deprecation errors for macros" - " and functions.", - cmState::BOOL); - } } } - int ret = this->ActualConfigure(); const char* delCacheVars = this->State ->GetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_"); @@ -1375,7 +1237,7 @@ int cmake::ActualConfigure() } if ( !res ) { - this->CacheManager->AddCacheEntry + this->AddCacheEntry ("CMAKE_HOME_DIRECTORY", this->GetHomeDirectory(), "Source directory with the top level CMakeLists.txt file for this " @@ -1387,9 +1249,9 @@ int cmake::ActualConfigure() if(!this->GlobalGenerator) { const char* genName = - this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR"); + this->State->GetInitializedCacheValue("CMAKE_GENERATOR"); const char* extraGenName = - this->CacheManager->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); + this->State->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); if(genName) { std::string fullName = cmExternalMakefileProjectGenerator:: @@ -1467,7 +1329,7 @@ int cmake::ActualConfigure() } } - const char* genName = this->CacheManager + const char* genName = this->State ->GetInitializedCacheValue("CMAKE_GENERATOR"); if(genName) { @@ -1484,20 +1346,20 @@ int cmake::ActualConfigure() return -2; } } - if(!this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR")) + if(!this->State->GetInitializedCacheValue("CMAKE_GENERATOR")) { - this->CacheManager->AddCacheEntry("CMAKE_GENERATOR", + this->AddCacheEntry("CMAKE_GENERATOR", this->GlobalGenerator->GetName().c_str(), "Name of generator.", cmState::INTERNAL); - this->CacheManager->AddCacheEntry("CMAKE_EXTRA_GENERATOR", + this->AddCacheEntry("CMAKE_EXTRA_GENERATOR", this->GlobalGenerator->GetExtraGeneratorName().c_str(), "Name of external makefile project generator.", cmState::INTERNAL); } if(const char* platformName = - this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM")) + this->State->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM")) { if(this->GeneratorPlatform.empty()) { @@ -1518,14 +1380,14 @@ int cmake::ActualConfigure() } else { - this->CacheManager->AddCacheEntry("CMAKE_GENERATOR_PLATFORM", + this->AddCacheEntry("CMAKE_GENERATOR_PLATFORM", this->GeneratorPlatform.c_str(), "Name of generator platform.", cmState::INTERNAL); } if(const char* tsName = - this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET")) + this->State->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET")) { if(this->GeneratorToolset.empty()) { @@ -1546,7 +1408,7 @@ int cmake::ActualConfigure() } else { - this->CacheManager->AddCacheEntry("CMAKE_GENERATOR_TOOLSET", + this->AddCacheEntry("CMAKE_GENERATOR_TOOLSET", this->GeneratorToolset.c_str(), "Name of generator toolset.", cmState::INTERNAL); @@ -1580,7 +1442,7 @@ int cmake::ActualConfigure() { if(!this->State->GetInitializedCacheValue("LIBRARY_OUTPUT_PATH")) { - this->State->AddCacheEntry + this->AddCacheEntry ("LIBRARY_OUTPUT_PATH", "", "Single output directory for building all libraries.", cmState::PATH); @@ -1588,7 +1450,7 @@ int cmake::ActualConfigure() if(!this->State ->GetInitializedCacheValue("EXECUTABLE_OUTPUT_PATH")) { - this->State->AddCacheEntry + this->AddCacheEntry ("EXECUTABLE_OUTPUT_PATH", "", "Single output directory for building all executables.", cmState::PATH); @@ -1608,7 +1470,7 @@ int cmake::ActualConfigure() // only save the cache if there were no fatal errors if ( this->GetWorkingMode() == NORMAL_MODE ) { - this->CacheManager->SaveCache(this->GetHomeOutputDirectory()); + this->SaveCache(this->GetHomeOutputDirectory()); } if(cmSystemTools::GetErrorOccuredFlag()) { @@ -1677,18 +1539,6 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) { this->AddCMakePaths(); } - - // don't turn dev warnings into errors by default, if no value has been - // specified for the flag, disable it - if (!this->State->GetCacheEntryValue("CMAKE_ERROR_DEVELOPER_WARNINGS")) - { - this->CacheManager-> - AddCacheEntry("CMAKE_ERROR_DEVELOPER_WARNINGS", "FALSE", - "Suppress errors that are meant for" - " the author of the CMakeLists.txt files.", - cmState::INTERNAL); - } - // Add any cache args if ( !this->SetCacheArgs(args) ) { @@ -1790,7 +1640,7 @@ int cmake::Generate() // for the Visual Studio and Xcode generators.) if ( this->GetWorkingMode() == NORMAL_MODE ) { - this->CacheManager->SaveCache(this->GetHomeOutputDirectory()); + this->SaveCache(this->GetHomeOutputDirectory()); } return 0; } @@ -1799,14 +1649,15 @@ void cmake::AddCacheEntry(const std::string& key, const char* value, const char* helpString, int type) { - this->CacheManager->AddCacheEntry(key, value, + this->State->AddCacheEntry(key, value, helpString, cmState::CacheEntryType(type)); + this->UnwatchUnusedCli(key); } const char* cmake::GetCacheDefinition(const std::string& name) const { - return this->CacheManager->GetInitializedCacheValue(name); + return this->State->GetInitializedCacheValue(name); } void cmake::AddDefaultCommands() @@ -1879,7 +1730,7 @@ bool cmake::ParseCacheEntry(const std::string& entry, std::string& value, cmState::CacheEntryType& type) { - return cmCacheManager::ParseEntry(entry, var, value, type); + return cmState::ParseCacheEntry(entry, var, value, type); } int cmake::LoadCache() @@ -1910,24 +1761,43 @@ int cmake::LoadCache() bool cmake::LoadCache(const std::string& path) { - return this->CacheManager->LoadCache(path); + std::set<std::string> emptySet; + return this->LoadCache(path, true, emptySet, emptySet); } bool cmake::LoadCache(const std::string& path, bool internal, std::set<std::string>& excludes, std::set<std::string>& includes) { - return this->CacheManager->LoadCache(path, internal, excludes, includes); + bool result = this->State->LoadCache(path, internal, excludes, includes); + static const char* entries[] = {"CMAKE_CACHE_MAJOR_VERSION", + "CMAKE_CACHE_MINOR_VERSION"}; + for (const char* const* nameIt = cmArrayBegin(entries); + nameIt != cmArrayEnd(entries); ++nameIt) + { + this->UnwatchUnusedCli(*nameIt); + } + return result; } bool cmake::SaveCache(const std::string& path) { - return this->CacheManager->SaveCache(path); + bool result = this->State->SaveCache(path); + static const char* entries[] = {"CMAKE_CACHE_MAJOR_VERSION", + "CMAKE_CACHE_MINOR_VERSION", + "CMAKE_CACHE_PATCH_VERSION", + "CMAKE_CACHEFILE_DIR"}; + for (const char* const* nameIt = cmArrayBegin(entries); + nameIt != cmArrayEnd(entries); ++nameIt) + { + this->UnwatchUnusedCli(*nameIt); + } + return result; } bool cmake::DeleteCache(const std::string& path) { - return this->CacheManager->DeleteCache(path); + return this->State->DeleteCache(path); } void cmake::SetProgressCallback(ProgressCallbackType f, void *cd) @@ -1992,7 +1862,7 @@ void cmake::UpdateConversionPathTable() { // Update the path conversion table with any specified file: const char* tablepath = - this->CacheManager + this->State ->GetInitializedCacheValue("CMAKE_PATH_TRANSLATION_FILE"); if(tablepath) @@ -2061,9 +1931,9 @@ int cmake::CheckBuildSystem() cmake cm; cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); + cm.GetCurrentSnapshot().SetDefaultDefinitions(); cmGlobalGenerator gg(&cm); cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); - cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator(mf.get())); if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || cmSystemTools::GetErrorOccuredFlag()) { @@ -2092,6 +1962,7 @@ int cmake::CheckBuildSystem() ggd(this->CreateGlobalGenerator(genName)); if(ggd.get()) { + cm.GetCurrentSnapshot().SetDefaultDefinitions(); cmsys::auto_ptr<cmMakefile> mfd(new cmMakefile(ggd.get(), cm.GetCurrentSnapshot())); cmsys::auto_ptr<cmLocalGenerator> lgd( @@ -2596,17 +2467,20 @@ bool cmake::PrintMessagePreamble(cmake::MessageType t, std::ostream& msg) { msg << "CMake Deprecation Warning"; } - else if (t == cmake::AUTHOR_WARNING) - { - msg << "CMake Warning (dev)"; - } - else if (t == cmake::AUTHOR_ERROR) - { - msg << "CMake Error (dev)"; - } else { msg << "CMake Warning"; + if(t == cmake::AUTHOR_WARNING) + { + // Allow suppression of these warnings. + const char* suppress = this->State->GetCacheEntryValue( + "CMAKE_SUPPRESS_DEVELOPER_WARNINGS"); + if(suppress && cmSystemTools::IsOn(suppress)) + { + return false; + } + msg << " (dev)"; + } } return true; } @@ -2628,12 +2502,6 @@ void displayMessage(cmake::MessageType t, std::ostringstream& msg) msg << "This warning is for project developers. Use -Wno-dev to suppress it."; } - else if (t == cmake::AUTHOR_ERROR) - { - msg << - "This error is for project developers. Use -Wno-error=dev to suppress " - "it."; - } // Add a terminating blank line. msg << "\n"; @@ -2657,8 +2525,7 @@ void displayMessage(cmake::MessageType t, std::ostringstream& msg) // Output the message. if(t == cmake::FATAL_ERROR || t == cmake::INTERNAL_ERROR - || t == cmake::DEPRECATION_ERROR - || t == cmake::AUTHOR_ERROR) + || t == cmake::DEPRECATION_ERROR) { cmSystemTools::SetErrorOccured(); cmSystemTools::Message(msg.str().c_str(), "Error"); @@ -2855,18 +2722,3 @@ void cmake::RunCheckForUnusedVariables() } #endif } - -void cmake::SetSuppressDevWarnings(bool b) -{ - // equivalent to -Wno-dev - if (b) - { - this->WarningLevels["dev"] = IGNORE_LEVEL; - } - // equivalent to -Wdev - else - { - this->WarningLevels["dev"] = std::max(this->WarningLevels["dev"], - WARNING_LEVEL); - } -} diff --git a/Source/cmake.h b/Source/cmake.h index 8ac8897..9d28cba 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -59,7 +59,6 @@ class cmake public: enum MessageType { AUTHOR_WARNING, - AUTHOR_ERROR, FATAL_ERROR, INTERNAL_ERROR, MESSAGE, @@ -69,12 +68,6 @@ class cmake DEPRECATION_WARNING }; - enum WarningLevel - { - IGNORE_LEVEL, - WARNING_LEVEL, - ERROR_LEVEL - }; /** \brief Describes the working modes of cmake */ enum WorkingMode @@ -278,7 +271,6 @@ class cmake void SetTrace(bool b) { this->Trace = b;} bool GetTraceExpand() { return this->TraceExpand;} void SetTraceExpand(bool b) { this->TraceExpand = b;} - void SetSuppressDevWarnings(bool b); bool GetWarnUninitialized() { return this->WarnUninitialized;} void SetWarnUninitialized(bool b) { this->WarnUninitialized = b;} bool GetWarnUnused() { return this->WarnUnused;} @@ -299,6 +291,12 @@ class cmake std::string const& GetCMakeEditCommand() const { return this->CMakeEditCommand; } + void SetSuppressDevWarnings(bool v) + { + this->SuppressDevWarnings = v; + this->DoSuppressDevWarnings = true; + } + /** Display a message to the user. */ void IssueMessage(cmake::MessageType t, std::string const& text, cmListFileBacktrace const& backtrace = cmListFileBacktrace()); @@ -341,7 +339,8 @@ protected: cmGlobalGenerator *GlobalGenerator; cmCacheManager *CacheManager; - std::map<std::string, WarningLevel> WarningLevels; + bool SuppressDevWarnings; + bool DoSuppressDevWarnings; std::string GeneratorPlatform; std::string GeneratorToolset; @@ -417,15 +416,7 @@ private: {"-T <toolset-name>", "Specify toolset name if supported by generator."}, \ {"-A <platform-name>", "Specify platform name if supported by generator."}, \ {"-Wno-dev", "Suppress developer warnings."},\ - {"-Wdev", "Enable developer warnings."},\ - {"-Werror=dev", "Make developer warnings errors."},\ - {"-Wno-error=dev", "Make developer warnings not errors."},\ - {"-Wdeprecated", "Enable deprecated macro and function warnings."},\ - {"-Wno-deprecated", "Suppress deprecated macro and function warnings."},\ - {"-Werror=deprecated", "Make deprecated macro and function warnings " \ - "errors."},\ - {"-Wno-error=deprecated", "Make deprecated macro and function warnings " \ - "not errors."} + {"-Wdev", "Enable developer warnings."} #define FOR_EACH_C_FEATURE(F) \ F(c_function_prototypes) \ diff --git a/Source/cmake.version.manifest b/Source/cmake.version.manifest new file mode 100644 index 0000000..e7010c9 --- /dev/null +++ b/Source/cmake.version.manifest @@ -0,0 +1,18 @@ +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" + manifestVersion="1.0" + xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" > + <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> + <application> + <!-- Windows Vista --> + <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> + <!-- Windows 7 --> + <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> + <!-- Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + <!-- Windows 8.1 --> + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> + <!-- Windows 10 --> + <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> + </application> + </compatibility> +</assembly> diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index aa70aa0..be492ed 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -765,15 +765,18 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) startOutDir = cmSystemTools::CollapseFullPath(startOutDir); cm.SetHomeDirectory(homeDir); cm.SetHomeOutputDirectory(homeOutDir); + cm.GetCurrentSnapshot().SetDefaultDefinitions(); if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen)) { cm.SetGlobalGenerator(ggd); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); + snapshot.GetDirectory().SetCurrentBinary + (cmSystemTools::GetCurrentWorkingDirectory()); + snapshot.GetDirectory().SetCurrentSource + (cmSystemTools::GetCurrentWorkingDirectory()); cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(ggd, snapshot)); cmsys::auto_ptr<cmLocalGenerator> lgd( ggd->CreateLocalGenerator(mf.get())); - lgd->GetMakefile()->SetCurrentSourceDirectory(startDir); - lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir); // Actually scan dependencies. return lgd->UpdateDependencies(depInfo.c_str(), @@ -1355,6 +1358,35 @@ int cmcmd::WindowsCEEnvironment(const char* version, const std::string& name) return -1; } +class cmVSLink +{ + int Type; + bool Verbose; + bool Incremental; + bool LinkGeneratesManifest; + std::vector<std::string> LinkCommand; + std::vector<std::string> UserManifests; + std::string LinkerManifestFile; + std::string ManifestFile; + std::string ManifestFileRC; + std::string ManifestFileRes; + std::string TargetFile; +public: + cmVSLink(int type, bool verbose) + : Type(type) + , Verbose(verbose) + , Incremental(false) + , LinkGeneratesManifest(true) + {} + bool Parse(std::vector<std::string>::const_iterator argBeg, + std::vector<std::string>::const_iterator argEnd); + int Link(); +private: + int LinkIncremental(); + int LinkNonIncremental(); + int RunMT(std::string const& out, bool notify); +}; + // For visual studio 2005 and newer manifest files need to be embedded into // exe and dll's. This code does that in such a way that incremental linking // still works. @@ -1364,11 +1396,7 @@ int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type) { return -1; } - bool verbose = false; - if(cmSystemTools::GetEnv("VERBOSE")) - { - verbose = true; - } + bool verbose = cmSystemTools::GetEnv("VERBOSE")? true:false; std::vector<std::string> expandedArgs; for(std::vector<std::string>::iterator i = args.begin(); i != args.end(); ++i) @@ -1389,79 +1417,19 @@ int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type) expandedArgs.push_back(*i); } } - bool hasIncremental = false; - bool hasManifest = true; - for(std::vector<std::string>::iterator i = expandedArgs.begin(); - i != expandedArgs.end(); ++i) - { - if(cmSystemTools::Strucmp(i->c_str(), "/INCREMENTAL:YES") == 0) - { - hasIncremental = true; - } - if(cmSystemTools::Strucmp(i->c_str(), "/INCREMENTAL") == 0) - { - hasIncremental = true; - } - if(cmSystemTools::Strucmp(i->c_str(), "/MANIFEST:NO") == 0) - { - hasManifest = false; - } - } - if(hasIncremental && hasManifest) - { - if(verbose) - { - std::cout << "Visual Studio Incremental Link with embedded manifests\n"; - } - return cmcmd::VisualStudioLinkIncremental(expandedArgs, type, verbose); - } - if(verbose) - { - if(!hasIncremental) - { - std::cout << "Visual Studio Non-Incremental Link\n"; - } - else - { - std::cout << "Visual Studio Incremental Link without manifests\n"; - } - } - return cmcmd::VisualStudioLinkNonIncremental(expandedArgs, - type, hasManifest, verbose); -} -int cmcmd::ParseVisualStudioLinkCommand(std::vector<std::string>& args, - std::vector<std::string>& command, - std::string& targetName) -{ - std::vector<std::string>::iterator i = args.begin(); - i++; // skip -E - i++; // skip vs_link_dll or vs_link_exe - command.push_back(*i); - i++; // move past link command - for(; i != args.end(); ++i) - { - command.push_back(*i); - if(i->find("/Fe") == 0) - { - targetName = i->substr(3); - } - if(i->find("/out:") == 0) - { - targetName = i->substr(5); - } - } - if(targetName.empty() || command.empty()) + cmVSLink vsLink(type, verbose); + if (!vsLink.Parse(expandedArgs.begin()+2, expandedArgs.end())) { return -1; } - return 0; + return vsLink.Link(); } -bool cmcmd::RunCommand(const char* comment, +static bool RunCommand(const char* comment, std::vector<std::string>& command, bool verbose, - int* retCodeOut) + int* retCodeOut = 0) { if(verbose) { @@ -1503,8 +1471,134 @@ bool cmcmd::RunCommand(const char* comment, return retCode == 0; } -int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args, - int type, bool verbose) +bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg, + std::vector<std::string>::const_iterator argEnd) +{ + // Parse our own arguments. + std::string intDir; + std::vector<std::string>::const_iterator arg = argBeg; + while (arg != argEnd && cmHasLiteralPrefix(*arg, "-")) + { + if (*arg == "--") + { + ++arg; + break; + } + else if (*arg == "--manifests") + { + for (++arg; arg != argEnd && !cmHasLiteralPrefix(*arg, "-"); ++arg) + { + this->UserManifests.push_back(*arg); + } + } + else if (cmHasLiteralPrefix(*arg, "--intdir=")) + { + intDir = arg->substr(9); + ++arg; + } + else + { + std::cerr << "unknown argument '" << *arg << "'\n"; + return false; + } + } + if (intDir.empty()) + { + return false; + } + + // The rest of the arguments form the link command. + if (arg == argEnd) + { + return false; + } + this->LinkCommand.insert(this->LinkCommand.begin(), arg, argEnd); + + // Parse the link command to extract information we need. + for (; arg != argEnd; ++arg) + { + if (cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL:YES") == 0) + { + this->Incremental = true; + } + else if (cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL") == 0) + { + this->Incremental = true; + } + else if (cmSystemTools::Strucmp(arg->c_str(), "/MANIFEST:NO") == 0) + { + this->LinkGeneratesManifest = false; + } + else if (cmHasLiteralPrefix(*arg, "/Fe")) + { + this->TargetFile = arg->substr(3); + } + else if (cmHasLiteralPrefix(*arg, "/out:")) + { + this->TargetFile = arg->substr(5); + } + } + + if (this->TargetFile.empty()) + { + return false; + } + + this->ManifestFile = intDir + "/embed.manifest"; + this->LinkerManifestFile = intDir + "/intermediate.manifest"; + + if (this->Incremental) + { + // We will compile a resource containing the manifest and + // pass it to the link command. + this->ManifestFileRC = intDir + "/manifest.rc"; + this->ManifestFileRes = intDir + "/manifest.res"; + this->LinkCommand.push_back(this->ManifestFileRes); + } + else if (this->UserManifests.empty()) + { + // Prior to support for user-specified manifests CMake placed the + // linker-generated manifest next to the binary (as if it were not to be + // embedded) when not linking incrementally. Preserve this behavior. + this->ManifestFile = this->TargetFile + ".manifest"; + this->LinkerManifestFile = this->ManifestFile; + } + + if (this->LinkGeneratesManifest) + { + this->LinkCommand.push_back("/MANIFEST"); + this->LinkCommand.push_back("/MANIFESTFILE:" + this->LinkerManifestFile); + } + + return true; +} + +int cmVSLink::Link() +{ + if (this->Incremental && + (this->LinkGeneratesManifest || !this->UserManifests.empty())) + { + if (this->Verbose) + { + std::cout << "Visual Studio Incremental Link with embedded manifests\n"; + } + return LinkIncremental(); + } + if (this->Verbose) + { + if (!this->Incremental) + { + std::cout << "Visual Studio Non-Incremental Link\n"; + } + else + { + std::cout << "Visual Studio Incremental Link without manifests\n"; + } + } + return LinkNonIncremental(); +} + +int cmVSLink::LinkIncremental() { // This follows the steps listed here: // http://blogs.msdn.com/zakramer/archive/2006/05/22/603558.aspx @@ -1528,161 +1622,118 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args, // 7. Finally, the Linker does another incremental link, but since the // only thing that has changed is the *.res file that contains the // manifest it is a short link. - std::vector<std::string> linkCommand; - std::string targetName; - if(cmcmd::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1) - { - return -1; - } - std::string manifestArg = "/MANIFESTFILE:"; - std::vector<std::string> rcCommand; - rcCommand.push_back(cmSystemTools::FindProgram("rc.exe")); - std::vector<std::string> mtCommand; - mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); - std::string tempManifest; - tempManifest = targetName; - tempManifest += ".intermediate.manifest"; - std::string resourceInputFile = targetName; - resourceInputFile += ".resource.txt"; - if(verbose) + + // Create a resource file referencing the manifest. + std::string absManifestFile = + cmSystemTools::CollapseFullPath(this->ManifestFile); + if (this->Verbose) { - std::cout << "Create " << resourceInputFile << "\n"; + std::cout << "Create " << this->ManifestFileRC << "\n"; } - // Create input file for rc command - cmsys::ofstream fout(resourceInputFile.c_str()); - if(!fout) + { + cmsys::ofstream fout(this->ManifestFileRC.c_str()); + if (!fout) { return -1; } - std::string manifestFile = targetName; - manifestFile += ".embed.manifest"; - std::string fullPath= cmSystemTools::CollapseFullPath(manifestFile); - fout << type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID " - "*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath << "\""; - fout.close(); - manifestArg += tempManifest; - // add the manifest arg to the linkCommand - linkCommand.push_back("/MANIFEST"); - linkCommand.push_back(manifestArg); - // if manifestFile is not yet created, create an - // empty one - if(!cmSystemTools::FileExists(manifestFile.c_str())) + fout << this->Type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ " + "24 /* RT_MANIFEST */ \"" << absManifestFile << "\""; + } + + // If we have not previously generated a manifest file, + // generate an empty one so the resource compiler succeeds. + if (!cmSystemTools::FileExists(this->ManifestFile)) { - if(verbose) + if (this->Verbose) { - std::cout << "Create empty: " << manifestFile << "\n"; + std::cout << "Create empty: " << this->ManifestFile << "\n"; } - cmsys::ofstream foutTmp(manifestFile.c_str()); + cmsys::ofstream foutTmp(this->ManifestFile.c_str()); } - std::string resourceFile = manifestFile; - resourceFile += ".res"; - // add the resource file to the end of the link command - linkCommand.push_back(resourceFile); - std::string outputOpt = "/fo"; - outputOpt += resourceFile; - rcCommand.push_back(outputOpt); - rcCommand.push_back(resourceInputFile); - // Run rc command to create resource - if(!cmcmd::RunCommand("RC Pass 1", rcCommand, verbose)) - { - return -1; - } - // Now run the link command to link and create manifest - if(!cmcmd::RunCommand("LINK Pass 1", linkCommand, verbose)) + + // Compile the resource file. + std::vector<std::string> rcCommand; + rcCommand.push_back(cmSystemTools::FindProgram("rc.exe")); + rcCommand.push_back("/fo" + this->ManifestFileRes); + rcCommand.push_back(this->ManifestFileRC); + if (!RunCommand("RC Pass 1", rcCommand, this->Verbose)) { return -1; } - // create mt command - std::string outArg("/out:"); - outArg+= manifestFile; - mtCommand.push_back("/nologo"); - mtCommand.push_back(outArg); - mtCommand.push_back("/notify_update"); - mtCommand.push_back("/manifest"); - mtCommand.push_back(tempManifest); - // now run mt.exe to create the final manifest file - int mtRet =0; - if(!cmcmd::RunCommand("MT", mtCommand, verbose, &mtRet)) + + // Run the link command (possibly generates intermediate manifest). + if (!RunCommand("LINK Pass 1", this->LinkCommand, this->Verbose)) { return -1; } - // if mt returns 0, then the manifest was not changed and - // we do not need to do another link step - if(mtRet == 0) - { - return 0; - } - // check for magic mt return value if mt returns the magic number - // 1090650113 then it means that it updated the manifest file and we need - // to do the final link. If mt has any value other than 0 or 1090650113 - // then there was some problem with the command itself and there was an - // error so return the error code back out of cmake so make can report it. - // (when hosted on a posix system the value is 187) - if(mtRet != 1090650113 && mtRet != 187) + + // Run the manifest tool to create the final manifest. + int mtRet = this->RunMT("/out:" + this->ManifestFile, true); + + // If mt returns 1090650113 (or 187 on a posix host) then it updated the + // manifest file so we need to embed it again. Otherwise we are done. + if (mtRet != 1090650113 && mtRet != 187) { return mtRet; } - // update the resource file with the new manifest from the mt command. - if(!cmcmd::RunCommand("RC Pass 2", rcCommand, verbose)) + + // Compile the resource file again. + if (!RunCommand("RC Pass 2", rcCommand, this->Verbose)) { return -1; } - // Run the final incremental link that will put the new manifest resource - // into the file incrementally. - if(!cmcmd::RunCommand("FINAL LINK", linkCommand, verbose)) + + // Link incrementally again to use the updated resource. + if (!RunCommand("FINAL LINK", this->LinkCommand, this->Verbose)) { return -1; } return 0; } -int cmcmd::VisualStudioLinkNonIncremental(std::vector<std::string>& args, - int type, - bool hasManifest, - bool verbose) +int cmVSLink::LinkNonIncremental() { - std::vector<std::string> linkCommand; - std::string targetName; - if(cmcmd::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1) - { - return -1; - } - // Run the link command as given - if (hasManifest) - { - linkCommand.push_back("/MANIFEST"); - } - if(!cmcmd::RunCommand("LINK", linkCommand, verbose)) + // Run the link command (possibly generates intermediate manifest). + if (!RunCommand("LINK", this->LinkCommand, this->Verbose)) { return -1; } - if(!hasManifest) + + // If we have no manifest files we are done. + if (!this->LinkGeneratesManifest && this->UserManifests.empty()) { return 0; } + + // Run the manifest tool to embed the final manifest in the binary. + std::string mtOut = + "/outputresource:" + this->TargetFile + (this->Type == 1? ";#1" : ";#2"); + return this->RunMT(mtOut, false); +} + +int cmVSLink::RunMT(std::string const& out, bool notify) +{ std::vector<std::string> mtCommand; mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); mtCommand.push_back("/nologo"); mtCommand.push_back("/manifest"); - std::string manifestFile = targetName; - manifestFile += ".manifest"; - mtCommand.push_back(manifestFile); - std::string outresource = "/outputresource:"; - outresource += targetName; - outresource += ";#"; - if(type == 1) + if (this->LinkGeneratesManifest) { - outresource += "1"; + mtCommand.push_back(this->LinkerManifestFile); } - else if(type == 2) + mtCommand.insert(mtCommand.end(), + this->UserManifests.begin(), this->UserManifests.end()); + mtCommand.push_back(out); + if (notify) { - outresource += "2"; + // Add an undocumented option that enables a special return + // code to notify us when the manifest is modified. + mtCommand.push_back("/notify_update"); } - mtCommand.push_back(outresource); - // Now use the mt tool to embed the manifest into the exe or dll - if(!cmcmd::RunCommand("MT", mtCommand, verbose)) + int mtRet = 0; + if (!RunCommand("MT", mtCommand, this->Verbose, &mtRet)) { return -1; } - return 0; + return mtRet; } diff --git a/Source/cmcmd.h b/Source/cmcmd.h index 2bfbae7..64b2406 100644 --- a/Source/cmcmd.h +++ b/Source/cmcmd.h @@ -35,20 +35,6 @@ protected: static int WindowsCEEnvironment(const char* version, const std::string& name); static int VisualStudioLink(std::vector<std::string>& args, int type); - static int VisualStudioLinkIncremental(std::vector<std::string>& args, - int type, - bool verbose); - static int VisualStudioLinkNonIncremental(std::vector<std::string>& args, - int type, - bool hasManifest, - bool verbose); - static int ParseVisualStudioLinkCommand(std::vector<std::string>& args, - std::vector<std::string>& command, - std::string& targetName); - static bool RunCommand(const char* comment, - std::vector<std::string>& command, - bool verbose, - int* retCodeOut = 0); }; #endif diff --git a/Source/ctest.cxx b/Source/ctest.cxx index afcbd61..7fa6aed 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -46,6 +46,10 @@ static const char * cmDocumentationOptions[][2] = {"--debug", "Displaying more verbose internals of CTest."}, {"--output-on-failure", "Output anything outputted by the test program " "if the test should fail."}, + {"--test-output-size-passed <size>", "Limit the output for passed tests " + "to <size> bytes"}, + {"--test-output-size-failed <size>", "Limit the output for failed tests " + "to <size> bytes"}, {"-F", "Enable failover."}, {"-j <jobs>, --parallel <jobs>", "Run the tests in parallel using the " "given number of jobs."}, diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 84010d8..ce7f563 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -342,11 +342,6 @@ ENDIF() # capabilities and parent project's request. Enforce 0/1 as only # possible values for configuration into Configure.hxx. -IF(UNIX) - KWSYS_PLATFORM_CXX_TEST(KWSYS_STAT_HAS_ST_MTIM - "Checking whether struct stat has st_mtim member" DIRECT) -ENDIF() - # Check existence and uniqueness of long long and __int64. KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG "Checking whether C++ compiler has 'long long'" DIRECT) @@ -511,12 +506,18 @@ IF(KWSYS_USE_SystemTools) "Checking whether CXX compiler has utimes" DIRECT) KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UTIMENSAT "Checking whether CXX compiler has utimensat" DIRECT) + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_STAT_HAS_ST_MTIM + "Checking whether CXX compiler struct stat has st_mtim member" DIRECT) + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_STAT_HAS_ST_MTIMESPEC + "Checking whether CXX compiler struct stat has st_mtimespec member" DIRECT) SET_PROPERTY(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS KWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV} KWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV} KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H} KWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES} KWSYS_CXX_HAS_UTIMENSAT=${KWSYS_CXX_HAS_UTIMENSAT} + KWSYS_CXX_STAT_HAS_ST_MTIM=${KWSYS_CXX_STAT_HAS_ST_MTIM} + KWSYS_CXX_STAT_HAS_ST_MTIMESPEC=${KWSYS_CXX_STAT_HAS_ST_MTIMESPEC} ) ENDIF() diff --git a/Source/kwsys/CTestCustom.cmake.in b/Source/kwsys/CTestCustom.cmake.in index d6f802e..760221b 100644 --- a/Source/kwsys/CTestCustom.cmake.in +++ b/Source/kwsys/CTestCustom.cmake.in @@ -9,7 +9,6 @@ # resulting memory leaks are not logged by valgrind anyway. Therefore, we # don't have to exclude it. -set(CTEST_CUSTOM_MEMCHECK_IGNORE - ${CTEST_CUSTOM_MEMCHECK_IGNORE} +list(APPEND CTEST_CUSTOM_MEMCHECK_IGNORE kwsys.testProcess-10 ) diff --git a/Source/kwsys/Configure.hxx.in b/Source/kwsys/Configure.hxx.in index 3faf862..ff8e49d 100644 --- a/Source/kwsys/Configure.hxx.in +++ b/Source/kwsys/Configure.hxx.in @@ -18,9 +18,6 @@ /* Whether wstring is available. */ #define @KWSYS_NAMESPACE@_STL_HAS_WSTRING @KWSYS_STL_HAS_WSTRING@ -/* Whether struct stat has the st_mtim member for high resolution times. */ -#define @KWSYS_NAMESPACE@_STAT_HAS_ST_MTIM @KWSYS_STAT_HAS_ST_MTIM@ - /* If building a C++ file in kwsys itself, give the source file access to the macros without a configured namespace. */ #if defined(KWSYS_NAMESPACE) @@ -28,7 +25,6 @@ # define kwsys @KWSYS_NAMESPACE@ # endif # define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS -# define KWSYS_STAT_HAS_ST_MTIM @KWSYS_NAMESPACE@_STAT_HAS_ST_MTIM # define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING #endif diff --git a/Source/kwsys/EncodingCXX.cxx b/Source/kwsys/EncodingCXX.cxx index 7d9b3e4..597d4bd 100644 --- a/Source/kwsys/EncodingCXX.cxx +++ b/Source/kwsys/EncodingCXX.cxx @@ -38,6 +38,7 @@ // Windows API. #if defined(_WIN32) # include <windows.h> +# include <shellapi.h> #endif namespace KWSYS_NAMESPACE diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 97a1df8..da34eb9 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -408,6 +408,7 @@ class SystemToolsPathCaseMap: // adds the elements of the env variable path to the arg passed in void SystemTools::GetPath(std::vector<std::string>& path, const char* env) { + size_t const old_size = path.size(); #if defined(_WIN32) && !defined(__CYGWIN__) const char pathSep = ';'; #else @@ -445,7 +446,7 @@ void SystemTools::GetPath(std::vector<std::string>& path, const char* env) done = true; } } - for(std::vector<std::string>::iterator i = path.begin(); + for(std::vector<std::string>::iterator i = path.begin() + old_size; i != path.end(); ++i) { SystemTools::ConvertToUnixSlashes(*i); @@ -1365,15 +1366,18 @@ bool SystemTools::Touch(const std::string& filename, bool create) struct timeval mtime; gettimeofday(&mtime, 0); # if KWSYS_CXX_HAS_UTIMES - struct timeval times[2] = - { -# if KWSYS_STAT_HAS_ST_MTIM - {st.st_atim.tv_sec, st.st_atim.tv_nsec/1000}, /* tv_sec, tv_usec */ + struct timeval atime; +# if KWSYS_CXX_STAT_HAS_ST_MTIM + atime.tv_sec = st.st_atim.tv_sec; + atime.tv_usec = st.st_atim.tv_nsec/1000; +# elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC + atime.tv_sec = st.st_atimespec.tv_sec; + atime.tv_usec = st.st_atimespec.tv_nsec/1000; # else - {st.st_atime, 0}, + atime.tv_sec = st.st_atime; + atime.tv_usec = 0; # endif - mtime - }; + struct timeval times[2] = { atime, mtime }; if(utimes(filename.c_str(), times) < 0) { return false; @@ -1407,7 +1411,7 @@ bool SystemTools::FileTimeCompare(const std::string& f1, { return false; } -# if KWSYS_STAT_HAS_ST_MTIM +# if KWSYS_CXX_STAT_HAS_ST_MTIM // Compare using nanosecond resolution. if(s1.st_mtim.tv_sec < s2.st_mtim.tv_sec) { @@ -1425,6 +1429,24 @@ bool SystemTools::FileTimeCompare(const std::string& f1, { *result = 1; } +# elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC + // Compare using nanosecond resolution. + if(s1.st_mtimespec.tv_sec < s2.st_mtimespec.tv_sec) + { + *result = -1; + } + else if(s1.st_mtimespec.tv_sec > s2.st_mtimespec.tv_sec) + { + *result = 1; + } + else if(s1.st_mtimespec.tv_nsec < s2.st_mtimespec.tv_nsec) + { + *result = -1; + } + else if(s1.st_mtimespec.tv_nsec > s2.st_mtimespec.tv_nsec) + { + *result = 1; + } # else // Compare using 1 second resolution. if(s1.st_mtime < s2.st_mtime) @@ -2365,95 +2387,102 @@ bool SystemTools::CopyFileAlways(const std::string& source, const std::string& d } mode_t perm = 0; bool perms = SystemTools::GetPermissions(source, perm); - - const int bufferSize = 4096; - char buffer[bufferSize]; - - // If destination is a directory, try to create a file with the same - // name as the source in that directory. - std::string real_destination = destination; - std::string destination_dir; - if(SystemTools::FileExists(destination) && - SystemTools::FileIsDirectory(destination)) + + if(SystemTools::FileIsDirectory(source)) { - destination_dir = real_destination; - SystemTools::ConvertToUnixSlashes(real_destination); - real_destination += '/'; - std::string source_name = source; - real_destination += SystemTools::GetFilenameName(source_name); + SystemTools::MakeDirectory(destination); } else { - destination_dir = SystemTools::GetFilenamePath(destination); - } + const int bufferSize = 4096; + char buffer[bufferSize]; - // Create destination directory + // If destination is a directory, try to create a file with the same + // name as the source in that directory. - SystemTools::MakeDirectory(destination_dir); + std::string destination_dir; + if(SystemTools::FileExists(destination) && + SystemTools::FileIsDirectory(destination)) + { + destination_dir = real_destination; + SystemTools::ConvertToUnixSlashes(real_destination); + real_destination += '/'; + std::string source_name = source; + real_destination += SystemTools::GetFilenameName(source_name); + } + else + { + destination_dir = SystemTools::GetFilenamePath(destination); + } + + // Create destination directory - // Open files + SystemTools::MakeDirectory(destination_dir); + + // Open files #if defined(_WIN32) - kwsys::ifstream fin(Encoding::ToNarrow( - SystemTools::ConvertToWindowsExtendedPath(source)).c_str(), - std::ios::in | std::ios::binary); + kwsys::ifstream fin(Encoding::ToNarrow( + SystemTools::ConvertToWindowsExtendedPath(source)).c_str(), + std::ios::in | std::ios::binary); #else - kwsys::ifstream fin(source.c_str(), - std::ios::in | std::ios::binary); + kwsys::ifstream fin(source.c_str(), + std::ios::in | std::ios::binary); #endif - if(!fin) - { - return false; - } + if(!fin) + { + return false; + } - // try and remove the destination file so that read only destination files - // can be written to. - // If the remove fails continue so that files in read only directories - // that do not allow file removal can be modified. - SystemTools::RemoveFile(real_destination); + // try and remove the destination file so that read only destination files + // can be written to. + // If the remove fails continue so that files in read only directories + // that do not allow file removal can be modified. + SystemTools::RemoveFile(real_destination); #if defined(_WIN32) - kwsys::ofstream fout(Encoding::ToNarrow( - SystemTools::ConvertToWindowsExtendedPath(real_destination)).c_str(), + kwsys::ofstream fout(Encoding::ToNarrow( + SystemTools::ConvertToWindowsExtendedPath(real_destination)).c_str(), std::ios::out | std::ios::trunc | std::ios::binary); #else - kwsys::ofstream fout(real_destination.c_str(), + kwsys::ofstream fout(real_destination.c_str(), std::ios::out | std::ios::trunc | std::ios::binary); #endif - if(!fout) - { - return false; - } - - // This copy loop is very sensitive on certain platforms with - // slightly broken stream libraries (like HPUX). Normally, it is - // incorrect to not check the error condition on the fin.read() - // before using the data, but the fin.gcount() will be zero if an - // error occurred. Therefore, the loop should be safe everywhere. - while(fin) - { - fin.read(buffer, bufferSize); - if(fin.gcount()) + if(!fout) { - fout.write(buffer, fin.gcount()); + return false; } - else + + // This copy loop is very sensitive on certain platforms with + // slightly broken stream libraries (like HPUX). Normally, it is + // incorrect to not check the error condition on the fin.read() + // before using the data, but the fin.gcount() will be zero if an + // error occurred. Therefore, the loop should be safe everywhere. + while(fin) { - break; + fin.read(buffer, bufferSize); + if(fin.gcount()) + { + fout.write(buffer, fin.gcount()); + } + else + { + break; + } } - } - // Make sure the operating system has finished writing the file - // before closing it. This will ensure the file is finished before - // the check below. - fout.flush(); + // Make sure the operating system has finished writing the file + // before closing it. This will ensure the file is finished before + // the check below. + fout.flush(); - fin.close(); - fout.close(); + fin.close(); + fout.close(); - if(!fout) - { - return false; + if(!fout) + { + return false; + } } if ( perms ) { @@ -4879,11 +4908,8 @@ std::string SystemTools::GetOperatingSystemNameAndVersion() OSVERSIONINFOEXA osvi; BOOL bOsVersionInfoEx; - // Try calling GetVersionEx using the OSVERSIONINFOEX structure. - // If that fails, try using the OSVERSIONINFO structure. - - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEXA)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); + ZeroMemory(&osvi, sizeof(osvi)); + osvi.dwOSVersionInfoSize = sizeof(osvi); #ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx # pragma warning (push) @@ -4893,14 +4919,10 @@ std::string SystemTools::GetOperatingSystemNameAndVersion() # pragma warning (disable:4996) # endif #endif - bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *)&osvi); + bOsVersionInfoEx = GetVersionExA((OSVERSIONINFOA *)&osvi); if (!bOsVersionInfoEx) { - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (!GetVersionEx((OSVERSIONINFO *)&osvi)) - { - return 0; - } + return 0; } #ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx # pragma warning (pop) @@ -4913,10 +4935,56 @@ std::string SystemTools::GetOperatingSystemNameAndVersion() case VER_PLATFORM_WIN32_NT: // Test for the specific product family. + if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0) + { + if (osvi.wProductType == VER_NT_WORKSTATION) + { + res += "Microsoft Windows 10"; + } + else + { + res += "Microsoft Windows Server 2016 family"; + } + } + + if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 3) + { + if (osvi.wProductType == VER_NT_WORKSTATION) + { + res += "Microsoft Windows 8.1"; + } + else + { + res += "Microsoft Windows Server 2012 R2 family"; + } + } + + if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 2) + { + if (osvi.wProductType == VER_NT_WORKSTATION) + { + res += "Microsoft Windows 8"; + } + else + { + res += "Microsoft Windows Server 2012 family"; + } + } + + if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1) + { + if (osvi.wProductType == VER_NT_WORKSTATION) + { + res += "Microsoft Windows 7"; + } + else + { + res += "Microsoft Windows Server 2008 R2 family"; + } + } if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) { -#if (_MSC_VER >= 1300) if (osvi.wProductType == VER_NT_WORKSTATION) { res += "Microsoft Windows Vista"; @@ -4925,9 +4993,6 @@ std::string SystemTools::GetOperatingSystemNameAndVersion() { res += "Microsoft Windows Server 2008 family"; } -#else - res += "Microsoft Windows Vista or Windows Server 2008"; -#endif } if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) @@ -4956,7 +5021,6 @@ std::string SystemTools::GetOperatingSystemNameAndVersion() { // Test for the workstation type. -#if (_MSC_VER >= 1300) if (osvi.wProductType == VER_NT_WORKSTATION) { if (osvi.dwMajorVersion == 4) @@ -5028,7 +5092,6 @@ std::string SystemTools::GetOperatingSystemNameAndVersion() } } } -#endif // Visual Studio 7 and up } // Test for specific product on Windows NT 4.0 SP5 and earlier diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index d2d1d40..bba5a5c 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -703,13 +703,13 @@ public: /** * Create a symbolic link if the platform supports it. Returns whether - * creation succeded. + * creation succeeded. */ static bool CreateSymlink(const std::string& origName, const std::string& newName); /** * Read the contents of a symbolic link. Returns whether reading - * succeded. + * succeeded. */ static bool ReadSymlink(const std::string& newName, std::string& origName); diff --git a/Source/kwsys/Terminal.c b/Source/kwsys/Terminal.c index d13f79a..a8abb6c 100644 --- a/Source/kwsys/Terminal.c +++ b/Source/kwsys/Terminal.c @@ -184,14 +184,25 @@ static const char* kwsysTerminalVT100Names[] = static int kwsysTerminalStreamIsVT100(FILE* stream, int default_vt100, int default_tty) { + /* Force color according to http://bixense.com/clicolors/ convention. */ + { + const char* clicolor_force = getenv("CLICOLOR_FORCE"); + if (clicolor_force && *clicolor_force && strcmp(clicolor_force, "0") != 0) + { + return 1; + } + } + /* If running inside emacs the terminal is not VT100. Some emacs seem to claim the TERM is xterm even though they do not support VT100 escapes. */ + { const char* emacs = getenv("EMACS"); if(emacs && *emacs == 't') { return 0; } + } /* Check for a valid terminal. */ if(!default_vt100) diff --git a/Source/kwsys/kwsysPlatformTestsCXX.cxx b/Source/kwsys/kwsysPlatformTestsCXX.cxx index 94579b3..9626937 100644 --- a/Source/kwsys/kwsysPlatformTestsCXX.cxx +++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx @@ -32,7 +32,7 @@ int main() } #endif -#ifdef TEST_KWSYS_STAT_HAS_ST_MTIM +#ifdef TEST_KWSYS_CXX_STAT_HAS_ST_MTIM #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> @@ -45,6 +45,19 @@ int main() } #endif +#ifdef TEST_KWSYS_CXX_STAT_HAS_ST_MTIMESPEC +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +int main() +{ + struct stat stat1; + (void)stat1.st_mtimespec.tv_sec; + (void)stat1.st_mtimespec.tv_nsec; + return 0; +} +#endif + #ifdef TEST_KWSYS_CXX_SAME_LONG_AND___INT64 void function(long**) {} int main() diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index e14d2fc..a0f904f 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -28,6 +28,7 @@ #include <testSystemTools.h> #include <iostream> +#include <sstream> #include <string.h> /* strcmp */ #if defined(_WIN32) && !defined(__CYGWIN__) # include <io.h> /* _umask (MSVC) / umask (Borland) */ @@ -790,6 +791,66 @@ static bool CheckCollapsePath() return res; } +static std::string StringVectorToString(const std::vector<std::string>& vec) +{ + std::stringstream ss; + ss << "vector("; + for (std::vector<std::string>::const_iterator i = vec.begin(); + i != vec.end(); ++i) + { + if (i != vec.begin()) + { + ss << ", "; + } + ss << *i; + } + ss << ")"; + return ss.str(); +} + +static bool CheckGetPath() +{ + const char* envName = "S"; +#ifdef _WIN32 + const char* envValue = "C:\\Somewhere\\something;D:\\Temp"; +#else + const char* envValue = "/Somewhere/something:/tmp"; +#endif + const char* registryPath = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MyApp; MyKey]"; + + std::vector<std::string> originalPathes; + originalPathes.push_back(registryPath); + + std::vector<std::string> expectedPathes; + expectedPathes.push_back(registryPath); +#ifdef _WIN32 + expectedPathes.push_back("C:/Somewhere/something"); + expectedPathes.push_back("D:/Temp"); +#else + expectedPathes.push_back("/Somewhere/something"); + expectedPathes.push_back("/tmp"); +#endif + + bool res = true; + res &= CheckPutEnv(std::string(envName) + "=" + envValue, envName, envValue); + + std::vector<std::string> pathes = originalPathes; + kwsys::SystemTools::GetPath(pathes, envName); + + if (pathes != expectedPathes) + { + std::cerr << + "GetPath(" << StringVectorToString(originalPathes) << + ", " << envName << ") yielded " << StringVectorToString(pathes) << + " instead of " << StringVectorToString(expectedPathes) << + std::endl; + res = false; + } + + res &= CheckUnPutEnv(envName, envName); + return res; +} + //---------------------------------------------------------------------------- int testSystemTools(int, char*[]) { @@ -825,5 +886,7 @@ int testSystemTools(int, char*[]) res &= CheckCollapsePath(); + res &= CheckGetPath(); + return res ? 0 : 1; } |