Hi It's a long time since I said I might do this feature. But with the supplied patch it's now possible to use the option '--cmakelists-file-name' to specify another filename to look for instead of 'CMakeLists.txt'. I have a very good reason for needing this for a ambitios project, which however is not ready yet for releases. But bottom line is that I would like to have the possibility of to seperate sets of CMakeFiles in the same source directory completely independant of each other (For the very courious some little old info is here: http://cpaf.sourceforge.net).
Anyway to apply the patch: - Put 'alternate_cmakelists_name.diff' in parent dir of CMake source dir. - run patch -p1 -i ../alternate_cmakelists_name.diff Diff file is made from cvs source of today january 13th around 3 pm GMT. Hope someone with write access to the cvs will apply it! -Regards Martin Lütken -----Original Message----- From: [EMAIL PROTECTED] on behalf of Dizzy Sent: Tue 8/28/2007 11:27 AM To: cmake@cmake.org Subject: Re: [CMake] Changing the default name "CMakeLists.txt" On Tuesday 28 August 2007 12:05:49 Martin Lütken wrote: > If not, then does anyone have an idea how hard it would be to add a > possiblity (command line option I guess) like that to the cmake source code > ? >From a simple grep in the cmake CVS sources I think that to add such an option first would require to have a unified place with the "CMakeLists.txt" string value because currently there are about 15 different places in code where the string is hardcoded, about 30 places where it appears in messages generated from the code and A LOT of code comments and cmake module comments where it's used (tho the comments can be left in place since they still make sense talking about a CMakeLists.txt file even if that is configurable). All in all I don't think it's very hard to do it, would result in a better cmake code organization too (not having scattered "CMakeLists.txt" magic value all over the code). -- Mihai RUSU Email: [EMAIL PROTECTED] "Linux is obsolete" -- AST _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
diff -cr CMake/Source/cmake.cxx CMakeNew/Source/cmake.cxx *** CMake/Source/cmake.cxx 2008-01-03 13:28:12.000000000 +0100 --- CMakeNew/Source/cmake.cxx 2008-01-13 17:25:32.000000000 +0100 *************** *** 110,115 **** --- 110,117 ---- #include <memory> // auto_ptr + const char* cmake::CMAKELISTS_FILE_NAME = "CMakeLists.txt"; + static bool cmakeCheckStampFile(const char* stampName); void cmNeedBackwardsCompatibility(const std::string& variable, *************** *** 644,650 **** std::string cacheFile = path; cacheFile += "/CMakeCache.txt"; std::string listFile = path; ! listFile += "/CMakeLists.txt"; if(cmSystemTools::FileExists(cacheFile.c_str())) { cachePath = path; --- 646,652 ---- std::string cacheFile = path; cacheFile += "/CMakeCache.txt"; std::string listFile = path; ! listFile += std::string("/") + cmake::CMAKELISTS_FILE_NAME; if(cmSystemTools::FileExists(cacheFile.c_str())) { cachePath = path; *************** *** 1723,1736 **** { // Make sure the Start directory contains a CMakeLists.txt file. std::string srcList = this->GetHomeDirectory(); ! srcList += "/CMakeLists.txt"; if(!cmSystemTools::FileExists(srcList.c_str())) { cmOStringStream err; if(cmSystemTools::FileIsDirectory(this->GetHomeDirectory())) { err << "The source directory \"" << this->GetHomeDirectory() ! << "\" does not appear to contain CMakeLists.txt.\n"; } else if(cmSystemTools::FileExists(this->GetHomeDirectory())) { --- 1725,1738 ---- { // Make sure the Start directory contains a CMakeLists.txt file. std::string srcList = this->GetHomeDirectory(); ! srcList += std::string("/") + cmake::CMAKELISTS_FILE_NAME; if(!cmSystemTools::FileExists(srcList.c_str())) { cmOStringStream err; if(cmSystemTools::FileIsDirectory(this->GetHomeDirectory())) { err << "The source directory \"" << this->GetHomeDirectory() ! << "\" does not appear to contain " << cmake::CMAKELISTS_FILE_NAME << "\n"; } else if(cmSystemTools::FileExists(this->GetHomeDirectory())) { *************** *** 1753,1761 **** { std::string cacheStart = this->CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY"); ! cacheStart += "/CMakeLists.txt"; std::string currentStart = this->GetHomeDirectory(); ! currentStart += "/CMakeLists.txt"; if(!cmSystemTools::SameFile(cacheStart.c_str(), currentStart.c_str())) { std::string message = "The source \""; --- 1755,1763 ---- { std::string cacheStart = this->CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY"); ! cacheStart += std::string("/") + cmake::CMAKELISTS_FILE_NAME; std::string currentStart = this->GetHomeDirectory(); ! currentStart += std::string("/") + cmake::CMAKELISTS_FILE_NAME; if(!cmSystemTools::SameFile(cacheStart.c_str(), currentStart.c_str())) { std::string message = "The source \""; *************** *** 3533,3539 **** std::string inFile = modulesPath; inFile += "/SystemInformation.cmake"; std::string outFile = destPath; ! outFile += "/CMakeLists.txt"; // Copy file if(!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str())) --- 3535,3541 ---- std::string inFile = modulesPath; inFile += "/SystemInformation.cmake"; std::string outFile = destPath; ! outFile += std::string("/") + cmake::CMAKELISTS_FILE_NAME; // Copy file if(!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str())) diff -cr CMake/Source/cmake.h CMakeNew/Source/cmake.h *** CMake/Source/cmake.h 2008-01-01 21:13:41.000000000 +0100 --- CMakeNew/Source/cmake.h 2008-01-13 17:10:29.000000000 +0100 *************** *** 59,64 **** --- 59,66 ---- public: typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap; + static const char* CMAKELISTS_FILE_NAME; ///< The actual name used as "CMakeLists.txt" + ///! construct an instance of cmake cmake(); ///! destruct an instance of cmake diff -cr CMake/Source/cmakemain.cxx CMakeNew/Source/cmakemain.cxx *** CMake/Source/cmakemain.cxx 2007-12-13 23:56:49.000000000 +0100 --- CMakeNew/Source/cmakemain.cxx 2008-01-13 17:32:18.000000000 +0100 *************** *** 88,93 **** --- 88,96 ---- "No configure or generate step is performed and the cache is not" " modified. If variables are defined using -D, this must be done " "before the -P argument."}, + {"--cmakelists-file-name [name]", "Use 'name' as default instead of 'CMakeLists.txt'.", + "CMake will look for this filename in all source directories instead of the " + "default 'CMakeLists.txt'."}, {"--graphviz=[file]", "Generate graphviz of dependencies.", "Generate a graphviz input file that will contain all the library and " "executable dependencies in the project."}, *************** *** 417,422 **** --- 420,443 ---- list_all_cached = true; list_help = true; } + // TODO: [EMAIL PROTECTED]: This it not a perfect way to do this, but I am not sure + // where to put processing of this new argument. Also if you specify + // fx. '--cmakelists-file-name -N' you will not get the intended error message. + else if (strcmp(av[i], "--cmakelists-file-name") == 0) + { + if ( i < ac -1 ) + { + i++; + cmake::CMAKELISTS_FILE_NAME = av[i]; + } + else + { + cmSystemTools::Error("No filename specified for argument --cmakelists-file-name"); + } + // TODO: Is this a good way and place to print this info out. And should we print it at all ? + std::string sMsg = std::string("Using CmakeLists filename: ") + cmake::CMAKELISTS_FILE_NAME; + cmSystemTools::Message( sMsg.c_str() ); + } else if (strncmp(av[i], "-P", strlen("-P")) == 0) { if ( i == ac -1 ) diff -cr CMake/Source/cmCoreTryCompile.cxx CMakeNew/Source/cmCoreTryCompile.cxx *** CMake/Source/cmCoreTryCompile.cxx 2007-12-06 15:56:02.000000000 +0100 --- CMakeNew/Source/cmCoreTryCompile.cxx 2008-01-13 17:16:50.000000000 +0100 *************** *** 148,154 **** return -1; } ! std::string outFileName = this->BinaryDirectory + "/CMakeLists.txt"; // which signature are we using? If we are using var srcfile bindir if (this->SrcFileSignature) { --- 148,154 ---- return -1; } ! std::string outFileName = this->BinaryDirectory + std::string("/") + cmake::CMAKELISTS_FILE_NAME; // which signature are we using? If we are using var srcfile bindir if (this->SrcFileSignature) { diff -cr CMake/Source/cmGlobalKdevelopGenerator.cxx CMakeNew/Source/cmGlobalKdevelopGenerator.cxx *** CMake/Source/cmGlobalKdevelopGenerator.cxx 2007-10-22 19:28:49.000000000 +0200 --- CMakeNew/Source/cmGlobalKdevelopGenerator.cxx 2008-01-13 17:14:10.000000000 +0100 *************** *** 148,154 **** tmp=cmSystemTools::GetFilenameName(tmp); //add all files which dont match the default // */CMakeLists.txt;*cmake; to the file pattern ! if ((tmp!="CMakeLists.txt") && (strstr(tmp.c_str(), ".cmake")==0)) { cmakeFilePattern+=tmp+";"; --- 148,154 ---- tmp=cmSystemTools::GetFilenameName(tmp); //add all files which dont match the default // */CMakeLists.txt;*cmake; to the file pattern ! if ((tmp!=cmake::CMAKELISTS_FILE_NAME) && (strstr(tmp.c_str(), ".cmake")==0)) { cmakeFilePattern+=tmp+";"; diff -cr CMake/Source/cmLocalGenerator.cxx CMakeNew/Source/cmLocalGenerator.cxx *** CMake/Source/cmLocalGenerator.cxx 2008-01-11 19:00:29.000000000 +0100 --- CMakeNew/Source/cmLocalGenerator.cxx 2008-01-13 17:16:47.000000000 +0100 *************** *** 78,84 **** // find & read the list file std::string currentStart = this->Makefile->GetStartDirectory(); ! currentStart += "/CMakeLists.txt"; this->Makefile->ReadListFile(currentStart.c_str()); // at the end of the ReadListFile handle any old style subdirs --- 78,84 ---- // find & read the list file std::string currentStart = this->Makefile->GetStartDirectory(); ! currentStart += std::string("/") + cmake::CMAKELISTS_FILE_NAME; this->Makefile->ReadListFile(currentStart.c_str()); // at the end of the ReadListFile handle any old style subdirs diff -cr CMake/Source/cmLocalVisualStudio6Generator.cxx CMakeNew/Source/cmLocalVisualStudio6Generator.cxx *** CMake/Source/cmLocalVisualStudio6Generator.cxx 2007-11-20 17:18:04.000000000 +0100 --- CMakeNew/Source/cmLocalVisualStudio6Generator.cxx 2008-01-13 17:14:12.000000000 +0100 *************** *** 203,209 **** commandLine.push_back(dsprule); std::string makefileIn = this->Makefile->GetStartDirectory(); makefileIn += "/"; ! makefileIn += "CMakeLists.txt"; std::string comment = "Building Custom Rule "; comment += makefileIn; std::string args; --- 203,209 ---- commandLine.push_back(dsprule); std::string makefileIn = this->Makefile->GetStartDirectory(); makefileIn += "/"; ! makefileIn += cmake::CMAKELISTS_FILE_NAME; std::string comment = "Building Custom Rule "; comment += makefileIn; std::string args; diff -cr CMake/Source/cmLocalVisualStudio7Generator.cxx CMakeNew/Source/cmLocalVisualStudio7Generator.cxx *** CMake/Source/cmLocalVisualStudio7Generator.cxx 2007-12-18 15:50:08.000000000 +0100 --- CMakeNew/Source/cmLocalVisualStudio7Generator.cxx 2008-01-13 17:14:13.000000000 +0100 *************** *** 216,222 **** commandLine.push_back(dsprule); std::string makefileIn = this->Makefile->GetStartDirectory(); makefileIn += "/"; ! makefileIn += "CMakeLists.txt"; makefileIn = cmSystemTools::CollapseFullPath(makefileIn.c_str()); std::string comment = "Building Custom Rule "; comment += makefileIn; --- 216,222 ---- commandLine.push_back(dsprule); std::string makefileIn = this->Makefile->GetStartDirectory(); makefileIn += "/"; ! makefileIn += cmake::CMAKELISTS_FILE_NAME; makefileIn = cmSystemTools::CollapseFullPath(makefileIn.c_str()); std::string comment = "Building Custom Rule "; comment += makefileIn; diff -cr CMake/Source/MFCDialog/CMakeSetupDialog.cpp CMakeNew/Source/MFCDialog/CMakeSetupDialog.cpp *** CMake/Source/MFCDialog/CMakeSetupDialog.cpp 2007-08-01 20:58:55.000000000 +0200 --- CMakeNew/Source/MFCDialog/CMakeSetupDialog.cpp 2008-01-13 17:16:49.000000000 +0100 *************** *** 1415,1421 **** std::string cacheFile = path; cacheFile += "/CMakeCache.txt"; std::string listFile = path; ! listFile += "/CMakeLists.txt"; if(cmSystemTools::FileExists(cacheFile.c_str())) { cachePath = path; --- 1415,1421 ---- std::string cacheFile = path; cacheFile += "/CMakeCache.txt"; std::string listFile = path; ! listFile += std::string("/") + cmake::CMAKELISTS_FILE_NAME; if(cmSystemTools::FileExists(cacheFile.c_str())) { cachePath = path; diff -cr CMake/Source/QtDialog/CMakeSetup.cxx CMakeNew/Source/QtDialog/CMakeSetup.cxx *** CMake/Source/QtDialog/CMakeSetup.cxx 2007-12-13 23:56:50.000000000 +0100 --- CMakeNew/Source/QtDialog/CMakeSetup.cxx 2008-01-13 17:14:15.000000000 +0100 *************** *** 107,113 **** if(args.count() == 2) { QFileInfo buildFileInfo(args[1], "CMakeCache.txt"); ! QFileInfo srcFileInfo(args[1], "CMakeLists.txt"); if(buildFileInfo.exists()) { dialog.setBinaryDirectory(buildFileInfo.absolutePath()); --- 107,113 ---- if(args.count() == 2) { QFileInfo buildFileInfo(args[1], "CMakeCache.txt"); ! QFileInfo srcFileInfo(args[1], cmake::CMAKELISTS_FILE_NAME); if(buildFileInfo.exists()) { dialog.setBinaryDirectory(buildFileInfo.absolutePath()); diff -cr CMake/Source/QtDialog/CMakeSetupDialog.cxx CMakeNew/Source/QtDialog/CMakeSetupDialog.cxx *** CMake/Source/QtDialog/CMakeSetupDialog.cxx 2007-12-12 19:25:24.000000000 +0100 --- CMakeNew/Source/QtDialog/CMakeSetupDialog.cxx 2008-01-13 17:14:14.000000000 +0100 *************** *** 592,598 **** QString file = urls.count() ? urls[0].toLocalFile() : QString(); if(!file.isEmpty() && (file.endsWith("CMakeCache.txt", Qt::CaseInsensitive) || ! file.endsWith("CMakeLists.txt", Qt::CaseInsensitive) ) ) { e->accept(); } --- 592,598 ---- QString file = urls.count() ? urls[0].toLocalFile() : QString(); if(!file.isEmpty() && (file.endsWith("CMakeCache.txt", Qt::CaseInsensitive) || ! file.endsWith(cmake::CMAKELISTS_FILE_NAME, Qt::CaseInsensitive) ) ) { e->accept(); } *************** *** 621,627 **** this->setBinaryDirectory(info.absolutePath()); } } ! else if(file.endsWith("CMakeLists.txt", Qt::CaseInsensitive)) { QFileInfo info(file); if(this->CMakeThread->cmakeInstance()->binaryDirectory() != info.absolutePath()) --- 621,627 ---- this->setBinaryDirectory(info.absolutePath()); } } ! else if(file.endsWith(cmake::CMAKELISTS_FILE_NAME, Qt::CaseInsensitive)) { QFileInfo info(file); if(this->CMakeThread->cmakeInstance()->binaryDirectory() != info.absolutePath())
_______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake