diff options
135 files changed, 1287 insertions, 1947 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 19d83f1..1b91ab8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,9 @@ if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD) set(CMAKE_CXX_STANDARD 11) endif() endif() +if(NOT CMake_TEST_EXTERNAL_CMAKE) + include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx11_unordered_map.cmake) +endif() # option to set the internal encoding of CMake to UTF-8 option(CMAKE_ENCODING_UTF8 "Use UTF-8 encoding internally." ON) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index cc2fbb8..7f20d10 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -37,6 +37,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "LINK : warning LNK4089: all references to.*SHELL32.dll.*discarded by /OPT:REF" "LINK : warning LNK4089: all references to.*USER32.dll.*discarded by /OPT:REF" "LINK : warning LNK4089: all references to.*ole32.dll.*discarded by /OPT:REF" + "Warning.*: .*/Utilities/KWIML/test/test_INT_format.h.* # Redundant preprocessing concatenation" "Warning: library was too large for page size.*" "Warning: public.*_archive_.*in module.*archive_*clashes with prior module.*archive_.*" "Warning: public.*BZ2_bz.*in module.*bzlib.*clashes with prior module.*bzlib.*" diff --git a/Help/generator/Qbs.rst b/Help/generator/Qbs.rst deleted file mode 100644 index e569b77..0000000 --- a/Help/generator/Qbs.rst +++ /dev/null @@ -1,25 +0,0 @@ -Qbs ---- - -Generates Qbs project files. - -Project files for Qbs will be created in the top directory and -in every subdirectory which features a CMakeLists.txt file containing -a PROJECT() call. Additionally a hierarchy of makefiles is generated -into the build tree. The appropriate make program can build the -project through the default make target. A "make install" target is -also provided. - -This "extra" generator may be specified as: - -``Qbs - MinGW Makefiles`` - Generate with :generator:`MinGW Makefiles`. - -``Qbs - NMake Makefiles`` - Generate with :generator:`NMake Makefiles`. - -``Qbs - Ninja`` - Generate with :generator:`Ninja`. - -``Qbs - Unix Makefiles`` - Generate with :generator:`Unix Makefiles`. diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt index e4c5873..4207db4 100644 --- a/Help/manual/OPTIONS_BUILD.txt +++ b/Help/manual/OPTIONS_BUILD.txt @@ -27,6 +27,9 @@ command in the project sets the type to ``PATH`` or ``FILEPATH`` then the ``<value>`` will be converted to an absolute path. + This option may also be given as a single argument: + ``-D<var>:<type>=<value>`` or ``-D<var>=<value>``. + ``-U <globbing_expr>`` Remove matching entries from CMake cache. diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst index c8525c2..c456590 100644 --- a/Help/manual/cmake-buildsystem.7.rst +++ b/Help/manual/cmake-buildsystem.7.rst @@ -886,9 +886,9 @@ It may specify usage requirements such as :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES`, :prop_tgt:`INTERFACE_COMPILE_DEFINITIONS`, :prop_tgt:`INTERFACE_COMPILE_OPTIONS`, -:prop_tgt:`INTERFACE_LINK_LIBRARIES`, and +:prop_tgt:`INTERFACE_LINK_LIBRARIES`, :prop_tgt:`INTERFACE_SOURCES`, -:prop_tgt:`INTERFACE_POSITION_INDEPENDENT_CODE`. +and :prop_tgt:`INTERFACE_POSITION_INDEPENDENT_CODE`. Only the ``INTERFACE`` modes of the :command:`target_include_directories`, :command:`target_compile_definitions`, :command:`target_compile_options`, :command:`target_sources`, and :command:`target_link_libraries` commands diff --git a/Help/manual/cmake-generators.7.rst b/Help/manual/cmake-generators.7.rst index 4482f95..cde8de8 100644 --- a/Help/manual/cmake-generators.7.rst +++ b/Help/manual/cmake-generators.7.rst @@ -110,4 +110,3 @@ The following extra generators are known to CMake. /generator/KDevelop3 /generator/Kate /generator/Sublime Text 2 - /generator/Qbs diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index b2f7e9d..4bd5a5e 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -9,7 +9,7 @@ Synopsis .. parsed-literal:: cmake [<options>] (<path-to-source> | <path-to-existing-build>) - cmake [(-D<var>=<value>)...] -P <cmake-script-file> + cmake [(-D <var>=<value>)...] -P <cmake-script-file> cmake --build <dir> [<options>] [-- <build-tool-options>...] cmake -E <command> [<options>...] cmake --find-package <options>... diff --git a/Help/release/dev/add-extra-qbs-generator.rst b/Help/release/dev/add-extra-qbs-generator.rst deleted file mode 100644 index edb441f..0000000 --- a/Help/release/dev/add-extra-qbs-generator.rst +++ /dev/null @@ -1,6 +0,0 @@ -add-extra-qbs-geneator ----------------------- - -* It is now possible to generate :generator:`Qbs` project files - for use with QtCreator IDE, matching make tool must be used - to build the project through the generated makefiles. diff --git a/Help/release/dev/cmake-gui-osx-install-command-line.rst b/Help/release/dev/cmake-gui-osx-install-command-line.rst new file mode 100644 index 0000000..e0f0369 --- /dev/null +++ b/Help/release/dev/cmake-gui-osx-install-command-line.rst @@ -0,0 +1,10 @@ +cmake-gui-osx-install-command-line +---------------------------------- + +* On OS X the :manual:`cmake-gui(1)` no longer has the + ``Install For Command Line Use`` menu item. Instead there + is a ``How to Install For Command Line Use`` menu item + that shows an informational dialog box explaining how to + make the command line tools available. For example:: + + /Applications/CMake.app/Contents/bin/cmake-gui --install diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 73ad86e..5938d6c 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -82,7 +82,7 @@ include(CheckIncludeFile) include(CheckIncludeFileCXX) cmake_policy(PUSH) -cmake_policy(VERSION 3.0) +cmake_policy(SET CMP0054 NEW) get_filename_component(__check_type_size_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) @@ -112,9 +112,9 @@ function(__check_type_size_impl type var map builtin language) # Perform the check. - if("${language}" STREQUAL "C") + if(language STREQUAL "C") set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.c) - elseif("${language}" STREQUAL "CXX") + elseif(language STREQUAL "CXX") set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.cpp) else() message(FATAL_ERROR "Unknown language:\n ${language}\nSupported languages: C, CXX.\n") @@ -229,11 +229,11 @@ macro(CHECK_TYPE_SIZE TYPE VARIABLE) set(_builtin 0) else() set(_builtin 1) - if("${_language}" STREQUAL "C") + if(_language STREQUAL "C") check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(stdint.h HAVE_STDINT_H) check_include_file(stddef.h HAVE_STDDEF_H) - elseif("${_language}" STREQUAL "CXX") + elseif(_language STREQUAL "CXX") check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H) check_include_file_cxx(stdint.h HAVE_STDINT_H) check_include_file_cxx(stddef.h HAVE_STDDEF_H) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 7cf9d79..11a24b8 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1282,7 +1282,7 @@ endif() # Wrap multiple 'COMMAND' lines up into a second-level wrapper # script so all output can be sent to one log file. - if(command MATCHES ";COMMAND;") + if(command MATCHES "(^|;)COMMAND;") set(code_execute_process " ${code_cygpath_make} execute_process(COMMAND \${command} RESULT_VARIABLE result) @@ -1299,7 +1299,9 @@ endif() set(sep "") foreach(arg IN LISTS command) if("x${arg}" STREQUAL "xCOMMAND") - set(code "${code}set(command \"${cmd}\")${code_execute_process}") + if(NOT "x${cmd}" STREQUAL "x") + set(code "${code}set(command \"${cmd}\")${code_execute_process}") + endif() set(cmd "") set(sep "") else() diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index 27f8a82..70c3fd7 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -144,9 +144,8 @@ if(FortranCInterface_SOURCE_DIR) return() endif() -# Use CMake 2.8.0 behavior for this module regardless of including context. cmake_policy(PUSH) -cmake_policy(VERSION 2.8.0) +cmake_policy(SET CMP0007 NEW) #----------------------------------------------------------------------------- # Verify that C and Fortran are available. diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 6f12785..9624401 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -233,8 +233,6 @@ set(SRCS cmExtraKateGenerator.h cmExtraSublimeTextGenerator.cxx cmExtraSublimeTextGenerator.h - cmExtraQbsGenerator.cxx - cmExtraQbsGenerator.h cmFileLock.cxx cmFileLock.h cmFileLockPool.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 8f90e00..d988249 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 2) -set(CMake_VERSION_PATCH 20150518) +set(CMake_VERSION_PATCH 20150526) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 0137374..5049a3f 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -283,8 +283,6 @@ int cmCPackDebGenerator::PackageFiles() int cmCPackDebGenerator::createDeb() { - const char* cmakeExecutable = this->GetOption("CMAKE_COMMAND"); - // debian-binary file std::string dbfilename; dbfilename += this->GetOption("GEN_WDIR"); @@ -420,15 +418,15 @@ int cmCPackDebGenerator::createDeb() } else if(!strcmp(debian_compression_type, "bzip2")) { compression_suffix = ".bz2"; compression_modifier = "j"; - cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E "; + cmake_tar += "\"" + cmSystemTools::GetCMakeCommand() + "\" -E "; } else if(!strcmp(debian_compression_type, "gzip")) { compression_suffix = ".gz"; compression_modifier = "z"; - cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E "; + cmake_tar += "\"" + cmSystemTools::GetCMakeCommand() + "\" -E "; } else if(!strcmp(debian_compression_type, "none")) { compression_suffix = ""; compression_modifier = ""; - cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E "; + cmake_tar += "\"" + cmSystemTools::GetCMakeCommand() + "\" -E "; } else { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error unrecognized compression type: " @@ -501,7 +499,7 @@ int cmCPackDebGenerator::createDeb() fileIt != packageFiles.end(); ++ fileIt ) { cmd = "\""; - cmd += cmakeExecutable; + cmd += cmSystemTools::GetCMakeCommand(); cmd += "\" -E md5sum \""; cmd += *fileIt; cmd += "\""; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index e254e9a..41614ca 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -711,11 +711,13 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( } cmake cm; + cm.SetHomeDirectory(""); + cm.SetHomeOutputDirectory(""); cm.AddCMakePaths(); cm.SetProgressCallback(cmCPackGeneratorProgress, this); cmGlobalGenerator gg; gg.SetCMakeInstance(&cm); - cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator()); cmMakefile *mf = lg->GetMakefile(); std::string realInstallDirectory = tempInstallDirectory; if ( !installSubDirectory.empty() && installSubDirectory != "/" ) diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 2207873..a5109e0 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -198,10 +198,12 @@ int main (int argc, char const* const* argv) "Read CPack config file: " << cpackConfigFile << std::endl); cmake cminst; + cminst.SetHomeDirectory(""); + cminst.SetHomeOutputDirectory(""); cminst.GetState()->RemoveUnscriptableCommands(); cmGlobalGenerator cmgg; cmgg.SetCMakeInstance(&cminst); - cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.MakeLocalGenerator()); cmMakefile* globalMF = cmlg->GetMakefile(); #if defined(__CYGWIN__) globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 586070b..20d303d 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -204,6 +204,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) } cmake cm; + cm.SetHomeDirectory(""); + cm.SetHomeOutputDirectory(""); std::string cmakeOutString; cmCTestBuildAndTestCaptureRAII captureRAII(cm, cmakeOutString); static_cast<void>(captureRAII); diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index de6ecde..6f43a1e 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -750,9 +750,11 @@ int cmCTestLaunch::Main(int argc, const char* const argv[]) void cmCTestLaunch::LoadConfig() { cmake cm; + cm.SetHomeDirectory(""); + cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg; gg.SetCMakeInstance(&cm); - cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator()); cmMakefile* mf = lg->GetMakefile(); std::string fname = this->LogDir; fname += "CTestLaunchConfig.cmake"; diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 0a34be8..62c6b46 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -336,11 +336,13 @@ void cmCTestScriptHandler::CreateCMake() delete this->LocalGenerator; } this->CMake = new cmake; + this->CMake->SetHomeDirectory(""); + this->CMake->SetHomeOutputDirectory(""); this->CMake->AddCMakePaths(); this->GlobalGenerator = new cmGlobalGenerator; this->GlobalGenerator->SetCMakeInstance(this->CMake); - this->LocalGenerator = this->GlobalGenerator->CreateLocalGenerator(); + this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator(); this->Makefile = this->LocalGenerator->GetMakefile(); this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 95cdf3b..b1c479e 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1571,9 +1571,11 @@ void cmCTestTestHandler::GetListOfTests() cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Constructing a list of tests" << std::endl, this->Quiet); cmake cm; + cm.SetHomeDirectory(""); + cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg; gg.SetCMakeInstance(&cm); - cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator()); cmMakefile *mf = lg->GetMakefile(); mf->AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType().c_str()); diff --git a/Source/Checks/cm_cxx11_unordered_map.cmake b/Source/Checks/cm_cxx11_unordered_map.cmake new file mode 100644 index 0000000..80fe391 --- /dev/null +++ b/Source/Checks/cm_cxx11_unordered_map.cmake @@ -0,0 +1,25 @@ + +if(CMAKE_CXX_STANDARD AND NOT DEFINED CMake_HAVE_CXX11_UNORDERED_MAP) + message(STATUS "Checking if compiler supports C++11 unordered_map") + try_compile(CMake_HAVE_CXX11_UNORDERED_MAP + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_LIST_DIR}/cm_cxx11_unordered_map.cpp + CMAKE_FLAGS -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + OUTPUT_VARIABLE OUTPUT + ) + if(CMake_HAVE_CXX11_UNORDERED_MAP) + message(STATUS "Checking if compiler supports C++11 unordered_map - yes") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if compiler supports C++11 unordered_map passed with the following output:\n" + "${OUTPUT}\n" + "\n" + ) + else() + message(STATUS "Checking if compiler supports C++11 unordered_map - no") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if compiler supports C++11 unordered_map failed with the following output:\n" + "${OUTPUT}\n" + "\n" + ) + endif() +endif() diff --git a/Source/Checks/cm_cxx11_unordered_map.cpp b/Source/Checks/cm_cxx11_unordered_map.cpp new file mode 100644 index 0000000..beeb31b --- /dev/null +++ b/Source/Checks/cm_cxx11_unordered_map.cpp @@ -0,0 +1,6 @@ +#include <unordered_map> +int main() { + std::unordered_map<int, int> map; + map[0] = 0; + return 0; +} diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index e013f81..5236e57 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -104,6 +104,8 @@ int main(int argc, char const* const* argv) if(doc.CheckOptions(argc, argv)) { cmake hcm; + hcm.SetHomeDirectory(""); + hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); std::vector<cmDocumentationEntry> generators; hcm.GetGeneratorDocumentation(generators); diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 9cc993a..168f57d 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -99,15 +99,12 @@ set(SRCS QCMakeCacheView.h QCMakeWidgets.cxx QCMakeWidgets.h - QMacInstallDialog.cxx - QMacInstallDialog.h ) QT4_WRAP_UI(UI_SRCS CMakeSetupDialog.ui Compilers.ui CrossCompiler.ui AddCacheEntry.ui - MacInstallDialog.ui ) QT4_WRAP_CPP(MOC_SRCS AddCacheEntry.h @@ -117,7 +114,6 @@ QT4_WRAP_CPP(MOC_SRCS QCMake.h QCMakeCacheView.h QCMakeWidgets.h - QMacInstallDialog.h ) QT4_ADD_RESOURCES(RC_SRCS CMakeSetup.qrc) diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 8a72a24..38d6d44 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -15,11 +15,11 @@ #include <QTranslator> #include <QLocale> #include <QTextCodec> -#include "QMacInstallDialog.h" #include "CMakeSetupDialog.h" #include "cmDocumentation.h" #include "cmake.h" #include "cmVersion.h" +#include "cmAlgorithms.h" #include <cmsys/CommandLineArguments.hxx> #include <cmsys/SystemTools.hxx> #include <cmsys/Encoding.hxx> @@ -48,6 +48,10 @@ static const char * cmDocumentationOptions[][2] = {0,0} }; +#if defined(Q_OS_MAC) +static int cmOSXInstall(std::string dir); +#endif + int main(int argc, char** argv) { cmsys::Encoding::CommandLineArguments encoding_args = @@ -64,6 +68,8 @@ int main(int argc, char** argv) { // Construct and print requested documentation. cmake hcm; + hcm.SetHomeDirectory(""); + hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); std::vector<cmDocumentationEntry> generators; @@ -77,6 +83,17 @@ int main(int argc, char** argv) return (doc.PrintRequestedDocumentation(std::cout)? 0:1); } +#if defined(Q_OS_MAC) + if (argc2 == 2 && strcmp(argv2[1], "--install") == 0) + { + return cmOSXInstall("/usr/bin"); + } + if (argc2 == 2 && cmHasLiteralPrefix(argv2[1], "--install=")) + { + return cmOSXInstall(argv2[1]+10); + } +#endif + QApplication app(argc, argv); #if defined(CMAKE_ENCODING_UTF8) @@ -91,16 +108,6 @@ int main(int argc, char** argv) QApplication::removeLibraryPath(p); } - // if arg for install - for(int i =0; i < argc2; i++) - { - if(strcmp(argv2[i], "--mac-install") == 0) - { - QMacInstallDialog setupdialog(0); - setupdialog.exec(); - return 0; - } - } // tell the cmake library where cmake is QDir cmExecDir(QApplication::applicationDirPath()); #if defined(Q_OS_MAC) @@ -187,3 +194,54 @@ int main(int argc, char** argv) return app.exec(); } +#if defined(Q_OS_MAC) +# include <errno.h> +# include <string.h> +# include <sys/stat.h> +# include <unistd.h> +static bool cmOSXInstall(std::string const& dir, std::string const& tool) +{ + if (tool.empty()) + { + return true; + } + std::string link = dir + cmSystemTools::GetFilenameName(tool); + struct stat st; + if (lstat(link.c_str(), &st) == 0 && S_ISLNK(st.st_mode)) + { + char buf[4096]; + ssize_t s = readlink(link.c_str(), buf, sizeof(buf)-1); + if (s >= 0 && std::string(buf, s) == tool) + { + std::cerr << "Exists: '" << link << "' -> '" << tool << "'\n"; + return true; + } + } + if (symlink(tool.c_str(), link.c_str()) == 0) + { + std::cerr << "Linked: '" << link << "' -> '" << tool << "'\n"; + return true; + } + else + { + int err = errno; + std::cerr << "Failed: '" << link << "' -> '" << tool << "': " + << strerror(err) << "\n"; + return false; + } +} +static int cmOSXInstall(std::string dir) +{ + if (!cmHasLiteralSuffix(dir, "/")) + { + dir += "/"; + } + return ( + cmOSXInstall(dir, cmSystemTools::GetCMakeCommand()) && + cmOSXInstall(dir, cmSystemTools::GetCTestCommand()) && + cmOSXInstall(dir, cmSystemTools::GetCPackCommand()) && + cmOSXInstall(dir, cmSystemTools::GetCMakeGUICommand()) && + cmOSXInstall(dir, cmSystemTools::GetCMakeCursesCommand()) + ) ? 0 : 1; +} +#endif diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index b8077f2..426fa12 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -27,7 +27,6 @@ #include <QUrl> #include <QShortcut> #include <QKeySequence> -#include <QMacInstallDialog.h> #include <QInputDialog> #include "QCMake.h" @@ -121,7 +120,7 @@ CMakeSetupDialog::CMakeSetupDialog() this, SLOT(showUserChanges())); #if defined(Q_WS_MAC) || defined(Q_OS_MAC) this->InstallForCommandLineAction - = ToolsMenu->addAction(tr("&Install For Command Line Use")); + = ToolsMenu->addAction(tr("&How to Install For Command Line Use")); QObject::connect(this->InstallForCommandLineAction, SIGNAL(triggered(bool)), this, SLOT(doInstallForCommandLine())); #endif @@ -420,8 +419,37 @@ bool CMakeSetupDialog::doConfigureInternal() void CMakeSetupDialog::doInstallForCommandLine() { - QMacInstallDialog setupdialog(0); - setupdialog.exec(); + QString title = tr("How to Install For Command Line Use"); + QString msg = tr( + "One may add CMake to the PATH:\n" + "\n" + " PATH=\"%1\":\"$PATH\"\n" + "\n" + "Or, to install symlinks to '/usr/bin', run:\n" + "\n" + " sudo \"%2\" --install\n" + "\n" + "Or, to install symlinks to another directory, run:\n" + "\n" + " sudo \"%3\" --install=/path/to/bin\n" + ); + msg = msg.arg(cmSystemTools::GetFilenamePath( + cmSystemTools::GetCMakeCommand()).c_str()); + msg = msg.arg(cmSystemTools::GetCMakeGUICommand().c_str()); + msg = msg.arg(cmSystemTools::GetCMakeGUICommand().c_str()); + + QDialog dialog; + dialog.setWindowTitle(title); + QVBoxLayout* l = new QVBoxLayout(&dialog); + QLabel* lab = new QLabel(&dialog); + l->addWidget(lab); + lab->setText(msg); + lab->setWordWrap(false); + QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok, + Qt::Horizontal, &dialog); + QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept())); + l->addWidget(btns); + dialog.exec(); } bool CMakeSetupDialog::doGenerateInternal() diff --git a/Source/QtDialog/MacInstallDialog.ui b/Source/QtDialog/MacInstallDialog.ui deleted file mode 100644 index c7e31db..0000000 --- a/Source/QtDialog/MacInstallDialog.ui +++ /dev/null @@ -1,103 +0,0 @@ -<ui version="4.0" > - <class>Dialog</class> - <widget class="QDialog" name="Dialog" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>470</width> - <height>159</height> - </rect> - </property> - <property name="windowTitle" > - <string>Install Command Line Tools</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="3" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0" colspan="3" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="skipInstallButton" > - <property name="text" > - <string>Skip Install Command Line </string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="doInstallButton" > - <property name="text" > - <string>Install Command Line Links</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="0" column="2" > - <widget class="QPushButton" name="choosePathButton" > - <property name="text" > - <string>Choose...</string> - </property> - </widget> - </item> - <item row="0" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>Install Folder:</string> - </property> - </widget> - </item> - <item row="0" column="1" > - <widget class="QLineEdit" name="InstallPrefix" /> - </item> - <item row="1" column="0" colspan="3" > - <widget class="QLabel" name="label_2" > - <property name="text" > - <string>This will create symbolic links to the command line tools of cmake into the specified install folder.</string> - </property> - <property name="wordWrap" > - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/Source/QtDialog/QMacInstallDialog.cxx b/Source/QtDialog/QMacInstallDialog.cxx deleted file mode 100644 index fa7df43..0000000 --- a/Source/QtDialog/QMacInstallDialog.cxx +++ /dev/null @@ -1,121 +0,0 @@ -#include "QMacInstallDialog.h" -#include <QMessageBox> -#include "cmSystemTools.h" -#include <iostream> -#include <QFileDialog> -#include "ui_MacInstallDialog.h" - -class QMacInstallDialog::QMacInstallDialogInternals : public Ui::Dialog -{ -public: -}; - -QMacInstallDialog::QMacInstallDialog(QWidget*w) - :QDialog(w) -{ - this->Internals = new QMacInstallDialogInternals; - this->Internals->setupUi(this); - QObject::connect(this->Internals->choosePathButton, SIGNAL(clicked(bool)), - this, SLOT(ShowBrowser())); - QObject::connect(this->Internals->skipInstallButton, SIGNAL(clicked(bool)), - this, SLOT(SkipInstall())); - QObject::connect(this->Internals->doInstallButton, SIGNAL(clicked(bool)), - this, SLOT(DoInstall())); - this->Internals->InstallPrefix->setText("/usr/bin/"); - -} - -QMacInstallDialog::~QMacInstallDialog() -{ - delete this->Internals; -} - -void QMacInstallDialog::DoInstall() -{ - QDir installDir(this->Internals->InstallPrefix->text()); - QString installTo = installDir.path(); - if(!cmSystemTools::FileExists(installTo.toLocal8Bit().data())) - { - QString message = tr("Build install does not exist, " - "should I create it?\n\n" - "Directory: "); - message += installDir.path(); - QString title = tr("Create Directory"); - QMessageBox::StandardButton btn; - btn = QMessageBox::information(this, title, message, - QMessageBox::Yes | QMessageBox::No); - if(btn == QMessageBox::Yes) - { - cmSystemTools::MakeDirectory(installTo.toLocal8Bit().data()); - } - } - QDir cmExecDir(QApplication::applicationDirPath()); - cmExecDir.cd("../bin"); - QFileInfoList list = cmExecDir.entryInfoList(); - for (int i = 0; i < list.size(); ++i) - { - QFileInfo fileInfo = list.at(i); - QString filename = fileInfo.fileName(); - if(filename.size() && filename[0] == '.') - { - continue; - } - QString file = fileInfo.absoluteFilePath(); - QString newName = installTo; - newName += "/"; - newName += filename; - // Remove the old files - if(cmSystemTools::FileExists(newName.toLocal8Bit().data())) - { - std::cout << "rm [" << newName.toLocal8Bit().data() << "]\n"; - if(!cmSystemTools::RemoveFile(newName.toLocal8Bit().data())) - { - QString message = tr("Failed to remove file " - "installation may be incomplete: "); - message += newName; - QString title = tr("Error Removing file"); - QMessageBox::StandardButton btn = - QMessageBox::critical(this, title, message, - QMessageBox::Ok|QMessageBox::Abort); - if(btn == QMessageBox::Abort) - { - return; - } - } - } - std::cout << "ln -s [" << file.toLocal8Bit().data() << "] ["; - std::cout << newName.toLocal8Bit().data() << "]\n"; - if(!cmSystemTools::CreateSymlink(file.toLocal8Bit().data(), - newName.toLocal8Bit().data())) - { - QString message = tr("Failed create symlink " - "installation may be incomplete: "); - message += newName; - QString title = tr("Error Creating Symlink"); - QMessageBox::StandardButton btn = - QMessageBox::critical(this, title, message, - QMessageBox::Ok|QMessageBox::Abort); - if(btn == QMessageBox::Abort) - { - return; - } - } - } - this->done(0); -} - -void QMacInstallDialog::SkipInstall() -{ - this->done(0); -} - - -void QMacInstallDialog::ShowBrowser() -{ - QString dir = QFileDialog::getExistingDirectory(this, - tr("Enter Install Prefix"), this->Internals->InstallPrefix->text()); - if(!dir.isEmpty()) - { - this->Internals->InstallPrefix->setText(dir); - } -} diff --git a/Source/QtDialog/QMacInstallDialog.h b/Source/QtDialog/QMacInstallDialog.h deleted file mode 100644 index efe67df..0000000 --- a/Source/QtDialog/QMacInstallDialog.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef QMacInstallDialog_h -#define QMacInstallDialog_h -#include <QDialog> - -class QMacInstallDialog : public QDialog -{ - Q_OBJECT; -public: - QMacInstallDialog(QWidget*w); - ~QMacInstallDialog(); -private slots: - void ShowBrowser(); - void SkipInstall(); - void DoInstall(); -private: - class QMacInstallDialogInternals; - QMacInstallDialogInternals* Internals; -}; - -#endif diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 403a459..211c83c 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -510,9 +510,11 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) } cmake cm; + cm.SetHomeDirectory(""); + cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg; gg.SetCMakeInstance(&cm); - cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator()); cmMakefile *mf = lg->GetMakefile(); if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) ) { diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 289d0dc..108208e 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -407,14 +407,9 @@ bool cmCacheManager::SaveCache(const std::string& path) " was created", cmState::INTERNAL); fout << "# This is the CMakeCache file.\n" - << "# For build in directory: " << currentcwd << "\n"; - cmCacheManager::CacheEntry* cmakeCacheEntry - = this->GetCacheEntry("CMAKE_COMMAND"); - if ( cmakeCacheEntry ) - { - fout << "# It was generated by CMake: " << - cmakeCacheEntry->Value << std::endl; - } + << "# For build in directory: " << currentcwd << "\n" + << "# It was generated by CMake: " + << cmSystemTools::GetCMakeCommand() << std::endl; fout << "# You can edit this file to change values found and used by cmake." << std::endl diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index 0d1c86d..bd098a5 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -14,6 +14,7 @@ #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmState.h" +#include "cmLocalGenerator.h" #include "cmCommandArgumentLexer.h" @@ -139,14 +140,14 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) this->Makefile->GetHomeOutputDirectory())) { std::ostringstream msg; - cmListFileBacktrace bt(this->Makefile->GetLocalGenerator()); cmListFileContext lfc; - lfc.FilePath = this->FileName; + lfc.FilePath = this->Makefile->GetLocalGenerator() + ->Convert(this->FileName, cmLocalGenerator::HOME); + lfc.Line = this->FileLine; - bt.push_back(lfc); msg << "uninitialized variable \'" << var << "\'"; this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, - msg.str(), bt); + msg.str(), lfc); } } return 0; diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 73aface..61847d4 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -112,10 +112,7 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted( if(def && argument.WasQuoted() && this->Policy54Status == cmPolicies::WARN) { - bool hasBeenReported = this->Makefile.HasCMP0054AlreadyBeenReported( - this->Makefile.GetBacktrace()[0]); - - if(!hasBeenReported) + if(!this->Makefile.HasCMP0054AlreadyBeenReported()) { std::ostringstream e; e << (cmPolicies::GetPolicyWarning(cmPolicies::CMP0054)) << "\n"; @@ -161,10 +158,7 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword, if(isKeyword && argument.WasQuoted() && this->Policy54Status == cmPolicies::WARN) { - bool hasBeenReported = this->Makefile.HasCMP0054AlreadyBeenReported( - this->Makefile.GetBacktrace()[0]); - - if(!hasBeenReported) + if(!this->Makefile.HasCMP0054AlreadyBeenReported()) { std::ostringstream e; e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0054) << "\n"; diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index c0a1aa9..62128a7 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -14,4 +14,5 @@ #cmakedefine CMAKE_USE_ELF_PARSER #cmakedefine CMAKE_USE_MACH_PARSER #cmakedefine CMAKE_ENCODING_UTF8 +#cmakedefine CMake_HAVE_CXX11_UNORDERED_MAP #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index f54bc4d..2dab169 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -18,35 +18,57 @@ cmDefinitions::Def cmDefinitions::NoDef; //---------------------------------------------------------------------------- cmDefinitions::Def const& cmDefinitions::GetInternal( - const std::string& key, - std::list<cmDefinitions>::reverse_iterator rbegin, - std::list<cmDefinitions>::reverse_iterator rend) + const std::string& key, StackIter begin, StackIter end, bool raise) { - assert(rbegin != rend); - MapType::const_iterator i = rbegin->Map.find(key); - if (i != rbegin->Map.end()) + assert(begin != end); + MapType::iterator i = begin->Map.find(key); + if (i != begin->Map.end()) { + i->second.Used = true; return i->second; } - std::list<cmDefinitions>::reverse_iterator rit = rbegin; - ++rit; - if (rit == rend) + StackIter it = begin; + ++it; + if (it == end) { return cmDefinitions::NoDef; } - Def const& def = cmDefinitions::GetInternal(key, rit, rend); - return rbegin->Map.insert(MapType::value_type(key, def)).first->second; + Def const& def = cmDefinitions::GetInternal(key, it, end, raise); + if (!raise) + { + return def; + } + return begin->Map.insert(MapType::value_type(key, def)).first->second; } //---------------------------------------------------------------------------- const char* cmDefinitions::Get(const std::string& key, - std::list<cmDefinitions>::reverse_iterator rbegin, - std::list<cmDefinitions>::reverse_iterator rend) + StackIter begin, StackIter end) { - Def const& def = cmDefinitions::GetInternal(key, rbegin, rend); + Def const& def = cmDefinitions::GetInternal(key, begin, end, false); return def.Exists? def.c_str() : 0; } +void cmDefinitions::Raise(const std::string& key, + StackIter begin, StackIter end) +{ + cmDefinitions::GetInternal(key, begin, end, true); +} + +bool cmDefinitions::HasKey(const std::string& key, + StackConstIter begin, StackConstIter end) +{ + for (StackConstIter it = begin; it != end; ++it) + { + MapType::const_iterator i = it->Map.find(key); + if (i != it->Map.end()) + { + return true; + } + } + return false; +} + //---------------------------------------------------------------------------- void cmDefinitions::Set(const std::string& key, const char* value) { @@ -54,13 +76,8 @@ void cmDefinitions::Set(const std::string& key, const char* value) this->Map[key] = def; } -void cmDefinitions::Erase(const std::string& key) -{ - this->Map.erase(key); -} - //---------------------------------------------------------------------------- -std::vector<std::string> cmDefinitions::LocalKeys() const +std::vector<std::string> cmDefinitions::UnusedKeys() const { std::vector<std::string> keys; keys.reserve(this->Map.size()); @@ -68,7 +85,7 @@ std::vector<std::string> cmDefinitions::LocalKeys() const for(MapType::const_iterator mi = this->Map.begin(); mi != this->Map.end(); ++mi) { - if (mi->second.Exists) + if (!mi->second.Used) { keys.push_back(mi->first); } @@ -77,36 +94,24 @@ std::vector<std::string> cmDefinitions::LocalKeys() const } //---------------------------------------------------------------------------- -cmDefinitions cmDefinitions::MakeClosure( - std::list<cmDefinitions>::const_reverse_iterator rbegin, - std::list<cmDefinitions>::const_reverse_iterator rend) +cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin, + StackConstIter end) { - std::set<std::string> undefined; cmDefinitions closure; - closure.MakeClosure(undefined, rbegin, rend); - return closure; -} - -//---------------------------------------------------------------------------- -void -cmDefinitions::MakeClosure(std::set<std::string>& undefined, - std::list<cmDefinitions>::const_reverse_iterator rbegin, - std::list<cmDefinitions>::const_reverse_iterator rend) -{ - for (std::list<cmDefinitions>::const_reverse_iterator it = rbegin; - it != rend; ++it) + std::set<std::string> undefined; + for (StackConstIter it = begin; it != end; ++it) { // Consider local definitions. for(MapType::const_iterator mi = it->Map.begin(); mi != it->Map.end(); ++mi) { // Use this key if it is not already set or unset. - if(this->Map.find(mi->first) == this->Map.end() && + if(closure.Map.find(mi->first) == closure.Map.end() && undefined.find(mi->first) == undefined.end()) { if(mi->second.Exists) { - this->Map.insert(*mi); + closure.Map.insert(*mi); } else { @@ -115,22 +120,29 @@ cmDefinitions::MakeClosure(std::set<std::string>& undefined, } } } + return closure; } //---------------------------------------------------------------------------- std::vector<std::string> -cmDefinitions::ClosureKeys(std::set<std::string>& bound) const +cmDefinitions::ClosureKeys(StackConstIter begin, StackConstIter end) { + std::set<std::string> bound; std::vector<std::string> defined; - defined.reserve(this->Map.size()); - for(MapType::const_iterator mi = this->Map.begin(); - mi != this->Map.end(); ++mi) + + for (StackConstIter it = begin; it != end; ++it) { - // Use this key if it is not already set or unset. - if(bound.insert(mi->first).second && mi->second.Exists) + defined.reserve(defined.size() + it->Map.size()); + for(MapType::const_iterator mi = it->Map.begin(); + mi != it->Map.end(); ++mi) { - defined.push_back(mi->first); + // Use this key if it is not already set or unset. + if(bound.insert(mi->first).second && mi->second.Exists) + { + defined.push_back(mi->first); + } } } + return defined; } diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index b244793..5fdcaab 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -14,8 +14,12 @@ #include "cmStandardIncludes.h" #if defined(CMAKE_BUILD_WITH_CMAKE) +#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#include <unordered_map> +#else #include "cmsys/hash_map.hxx" #endif +#endif #include <list> @@ -28,27 +32,26 @@ */ class cmDefinitions { + typedef std::list<cmDefinitions>::reverse_iterator StackIter; + typedef std::list<cmDefinitions>::const_reverse_iterator StackConstIter; public: - /** Get the value associated with a key; null if none. - Store the result locally if it came from a parent. */ static const char* Get(const std::string& key, - std::list<cmDefinitions>::reverse_iterator rbegin, - std::list<cmDefinitions>::reverse_iterator rend); + StackIter begin, StackIter end); + + static void Raise(const std::string& key, StackIter begin, StackIter end); + + static bool HasKey(const std::string& key, + StackConstIter begin, StackConstIter end); /** Set (or unset if null) a value associated with a key. */ void Set(const std::string& key, const char* value); - void Erase(const std::string& key); + std::vector<std::string> UnusedKeys() const; - /** Get the set of all local keys. */ - std::vector<std::string> LocalKeys() const; + static std::vector<std::string> ClosureKeys(StackConstIter begin, + StackConstIter end); - std::vector<std::string> - ClosureKeys(std::set<std::string>& bound) const; - - static cmDefinitions MakeClosure( - std::list<cmDefinitions>::const_reverse_iterator rbegin, - std::list<cmDefinitions>::const_reverse_iterator rend); + static cmDefinitions MakeClosure(StackConstIter begin, StackConstIter end); private: // String with existence boolean. @@ -57,28 +60,32 @@ private: private: typedef std::string std_string; public: - Def(): std_string(), Exists(false) {} - Def(const char* v): std_string(v?v:""), Exists(v?true:false) {} - Def(const std_string& v): std_string(v), Exists(true) {} - Def(Def const& d): std_string(d), Exists(d.Exists) {} + Def(): std_string(), Exists(false), Used(false) {} + Def(const char* v) + : std_string(v ? v : ""), + Exists(v ? true : false), + Used(false) + {} + Def(const std_string& v): std_string(v), Exists(true), Used(false) {} + Def(Def const& d): std_string(d), Exists(d.Exists), Used(d.Used) {} bool Exists; + bool Used; }; static Def NoDef; - // Local definitions, set or unset. #if defined(CMAKE_BUILD_WITH_CMAKE) +#ifdef CMake_HAVE_CXX11_UNORDERED_MAP + typedef std::unordered_map<std::string, Def> MapType; +#else typedef cmsys::hash_map<std::string, Def> MapType; +#endif #else typedef std::map<std::string, Def> MapType; #endif MapType Map; static Def const& GetInternal(const std::string& key, - std::list<cmDefinitions>::reverse_iterator rbegin, - std::list<cmDefinitions>::reverse_iterator rend); - void MakeClosure(std::set<std::string>& undefined, - std::list<cmDefinitions>::const_reverse_iterator rbegin, - std::list<cmDefinitions>::const_reverse_iterator rend); + StackIter begin, StackIter end, bool raise); }; #endif diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h index d4da5a4..201465d 100644 --- a/Source/cmExecutionStatus.h +++ b/Source/cmExecutionStatus.h @@ -12,47 +12,44 @@ #ifndef cmExecutionStatus_h #define cmExecutionStatus_h -#include "cmObject.h" +#include "cmStandardIncludes.h" /** \class cmExecutionStatus * \brief Superclass for all command status classes * * when a command is involked it may set values on a command status instance */ -class cmExecutionStatus : public cmObject +class cmExecutionStatus { public: - cmTypeMacro(cmExecutionStatus, cmObject); + cmExecutionStatus() { this->Clear(); } - cmExecutionStatus() { this->Clear();} - - virtual void SetReturnInvoked(bool val) + void SetReturnInvoked(bool val) { this->ReturnInvoked = val; } - virtual bool GetReturnInvoked() + bool GetReturnInvoked() { return this->ReturnInvoked; } - virtual void SetBreakInvoked(bool val) + void SetBreakInvoked(bool val) { this->BreakInvoked = val; } - virtual bool GetBreakInvoked() + bool GetBreakInvoked() { return this->BreakInvoked; } - virtual void SetContinueInvoked(bool val) + void SetContinueInvoked(bool val) { this->ContinueInvoked = val; } - virtual bool GetContinueInvoked() + bool GetContinueInvoked() { return this->ContinueInvoked; } - virtual void Clear() + void Clear() { this->ReturnInvoked = false; this->BreakInvoked = false; this->ContinueInvoked = false; this->NestedError = false; } - virtual void SetNestedError(bool val) { this->NestedError = val; } - virtual bool GetNestedError() { return this->NestedError; } - + void SetNestedError(bool val) { this->NestedError = val; } + bool GetNestedError() { return this->NestedError; } -protected: +private: bool ReturnInvoked; bool BreakInvoked; bool ContinueInvoked; diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 72a6a30..a81e53c 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -1008,7 +1008,6 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); const std::string makeArgs = mf->GetSafeDefinition( "CMAKE_ECLIPSE_MAKE_ARGUMENTS"); - const std::string cmake = mf->GetRequiredDefinition("CMAKE_COMMAND"); cmGlobalGenerator* generator = const_cast<cmGlobalGenerator*>(this->GlobalGenerator); @@ -1096,11 +1095,12 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const std::string cleanArgs = "-E chdir \""; cleanArgs += makefile->GetCurrentBinaryDirectory(); cleanArgs += "\" \""; - cleanArgs += cmake; + cleanArgs += cmSystemTools::GetCMakeCommand(); cleanArgs += "\" -P \""; cleanArgs += (*it)->GetTargetDirectory(ti->second); cleanArgs += "/cmake_clean.cmake\""; - this->AppendTarget(fout, "Clean", cmake, cleanArgs, virtDir, "", ""); + this->AppendTarget(fout, "Clean", cmSystemTools::GetCMakeCommand(), + cleanArgs, virtDir, "", ""); } } break; diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index ec141a9..578e7d3 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -247,7 +247,7 @@ cmExtraKateGenerator::CreateDummyKateProjectFile(const cmMakefile* mf) const return; } - fout << "#Generated by " << mf->GetRequiredDefinition("CMAKE_COMMAND") + fout << "#Generated by " << cmSystemTools::GetCMakeCommand() << ", do not edit.\n"; } diff --git a/Source/cmExtraQbsGenerator.cxx b/Source/cmExtraQbsGenerator.cxx deleted file mode 100644 index 4cc4650..0000000 --- a/Source/cmExtraQbsGenerator.cxx +++ /dev/null @@ -1,260 +0,0 @@ -#include "cmExtraQbsGenerator.h" - -#include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" -#include "cmMakefile.h" -#include "cmGeneratedFileStream.h" -#include "cmSourceFile.h" - -cmExtraQbsGenerator::cmExtraQbsGenerator() -{ -#if defined(_WIN32) - this->SupportedGlobalGenerators.push_back("MinGW Makefiles"); - this->SupportedGlobalGenerators.push_back("NMake Makefiles"); -#endif - this->SupportedGlobalGenerators.push_back("Ninja"); - this->SupportedGlobalGenerators.push_back("Unix Makefiles"); -} - -cmExtraQbsGenerator::~cmExtraQbsGenerator() {} - -void cmExtraQbsGenerator::GetDocumentation(cmDocumentationEntry &entry, - const std::string &) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Qbs project files."; -} - -void cmExtraQbsGenerator::Generate() -{ - for (std::map<std::string, std::vector<cmLocalGenerator *> >::const_iterator - it = this->GlobalGenerator->GetProjectMap().begin(); - it != this->GlobalGenerator->GetProjectMap().end(); ++it) - { - // create a project file - this->CreateProjectFile(it->first, it->second); - } -} - -void cmExtraQbsGenerator::CreateProjectFile( - const std::string &name, - const std::vector<cmLocalGenerator *> &lgs) -{ - const cmMakefile *mf = lgs[0]->GetMakefile(); - std::string outputDir = mf->GetCurrentBinaryDirectory(); - - const std::string filename = outputDir + "/" + name + ".qbs"; - - this->CreateNewProjectFile(name, lgs, filename); -} - -void cmExtraQbsGenerator::CreateNewProjectFile( - const std::string &projectName, const std::vector<cmLocalGenerator *> &lgs, - const std::string &filename) -{ - cmGeneratedFileStream fout(filename.c_str()); - if (!fout) - { - return; - } - - fout << "import qbs\n" - << "import qbs.File\n\n" - << "Project {\n" - << "\tname:\"" << projectName << "\"\n"; - std::vector<cmLocalGenerator *>::const_iterator itr = lgs.begin(); - for (; itr != lgs.end(); ++itr) - { - cmLocalGenerator *lg = (*itr); - this->AppendSubProject(fout, lg); - } - fout << "}\n"; -} - -void cmExtraQbsGenerator::AppendSubProject(cmGeneratedFileStream &fout, - cmLocalGenerator *lg) -{ - const cmMakefile *mk = lg->GetMakefile(); - if (!mk || mk->GetTargets().size() == 0) - { - return; - } - - const std::string &relativePath = cmSystemTools::RelativePath( - mk->GetHomeDirectory(), mk->GetCurrentSourceDirectory()); - fout << "\tProject {\n" - << "\t\tname:\"" << relativePath << "\"\n"; - this->AppendProduct(fout, lg); - fout << "\t}\n"; -} - -void cmExtraQbsGenerator::AppendProduct(cmGeneratedFileStream &fout, - cmLocalGenerator *lg) -{ - const cmMakefile *mk = lg->GetMakefile(); - const cmTargets &ts = mk->GetTargets(); - std::string cfg = mk->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmTargets::const_iterator itr = ts.begin(); - for (; itr != ts.end(); ++itr) - { - const cmTarget &t = itr->second; - this->AppendTarget(fout, lg, t, cfg); - } -} - -void cmExtraQbsGenerator::AppendTarget(cmGeneratedFileStream &fout, - cmLocalGenerator *lg, const cmTarget &t, - const std::string &cfg) -{ - std::string type; - bool isBuildable = true; - switch (t.GetType()) - { - case cmTarget::EXECUTABLE: - type = "application"; - break; - case cmTarget::SHARED_LIBRARY: - type = "dynamiclibrary"; - break; - case cmTarget::STATIC_LIBRARY: - type = "staticlibrary"; - break; - default: - isBuildable = false; - break; - } - - if (type.empty()) - { - fout << "\t\tProject {\n"; - } - else - { - fout << "\t\tProduct {\n"; - fout << "\t\t\tdestinationDirectory: \"" << t.GetDirectory(cfg) << "\"\n"; - } - fout << "\t\t\tname:\"" << t.GetName() << "\"\n"; - - if (!type.empty()) - { - fout << "\t\t\ttype: \"" << type << "\"\n"; - fout << "\t\t\ttargetName: \"" << t.GetName() << "\"\n"; - } - - if (isBuildable) - { - fout << "\t\t\tDepends { name: \"cpp\" }\n"; - cmGeneratorTarget *gt = this->GlobalGenerator->GetGeneratorTarget(&t); - this->AppendSources(fout, gt, t, cfg); - - std::set<std::string> langs, incPaths, defs; - t.GetLanguages(langs, cfg); - for (std::set<std::string>::const_iterator lang = langs.begin(); - lang != langs.end(); - ++ lang) - { - const std::vector<std::string> &paths = - gt->GetIncludeDirectories(cfg, *lang); - std::copy(paths.begin(), paths.end(), - std::inserter(incPaths, incPaths.end())); - - lg->AddCompileDefinitions(defs, &t, cfg, *lang); - } - this->AppendIncludePaths(fout, incPaths); - this->AppendCompileDefinitions(fout, defs); - } - - fout << "\t\t}\n"; -} - -void cmExtraQbsGenerator::AppendSources(cmGeneratedFileStream &fout, - cmGeneratorTarget *gt, - const cmTarget &t, - const std::string &cfg) -{ - std::vector<cmSourceFile *> sources; - gt->GetSourceFiles(sources, cfg); - if (sources.empty()) - { - return; - } - - std::vector<cmSourceFile *> genSources; - std::vector<cmSourceFile *>::const_iterator itr = sources.begin(); - fout << "\t\t\tfiles: [\n" - << "\t\t\t\t\"" << t.GetMakefile()->GetCurrentListFile() << "\",\n"; - for (; itr != sources.end(); ++itr) - { - if (!(*itr)->GetPropertyAsBool("GENERATED")) - { - fout << "\t\t\t\t\"" << (*itr)->GetFullPath() << "\",\n"; - } - else - { - genSources.push_back(*itr); - } - } - fout << "\t\t\t]\n"; - - if (!genSources.empty()) - { - fout << "\t\t\tGroup {\n" - << "\t\t\t\tname:\"Generated\"\n" - << "\t\t\t\tfiles: [\n"; - itr = genSources.begin(); - std::string groupCondition; - bool initialCondition = true; - for (; itr != genSources.end(); ++itr) - { - const std::string &path = (*itr)->GetFullPath(); - fout << "\t\t\t\t\t\"" << path << "\",\n"; - if (initialCondition) - { - initialCondition = false; - } - else - { - groupCondition += "\t\t\t\t\t && "; - } - groupCondition += "File.exists(\"" + path + "\")\n"; - } - fout << "\t\t\t\t]\n" - << "\t\t\t\tcondition: " << groupCondition << "\t\t\t}\n"; - } -} - -void cmExtraQbsGenerator::AppendIncludePaths( - cmGeneratedFileStream &fout, - const std::set<std::string> &paths) -{ - if (paths.empty()) - { - return; - } - - std::set<std::string>::const_iterator itr = paths.begin(); - fout << "\t\t\tcpp.includePaths: [\n"; - for (; itr != paths.end(); ++ itr) - { - fout << "\t\t\t\t\"" << (*itr) << "\",\n"; - } - fout << "\t\t\t]\n"; -} - -void cmExtraQbsGenerator::AppendCompileDefinitions( - cmGeneratedFileStream &fout, - const std::set<std::string> &defs) -{ - if (defs.empty()) - { - return; - } - - std::set<std::string>::const_iterator itr = defs.begin(); - fout << "\t\t\tcpp.defines: [\n"; - for (; itr != defs.end(); ++ itr) - { - fout << "\t\t\t\t'" << (*itr) << "',\n"; - } - fout << "\t\t\t]\n"; -} diff --git a/Source/cmExtraQbsGenerator.h b/Source/cmExtraQbsGenerator.h deleted file mode 100644 index 531ccc9..0000000 --- a/Source/cmExtraQbsGenerator.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef CMEXTRAQBSGENERATOR_H -#define CMEXTRAQBSGENERATOR_H - -#include "cmExternalMakefileProjectGenerator.h" - -class cmGeneratorTarget; - -class cmExtraQbsGenerator : public cmExternalMakefileProjectGenerator -{ -public: - cmExtraQbsGenerator(); - ~cmExtraQbsGenerator(); - - virtual std::string GetName() const - { return cmExtraQbsGenerator::GetActualName(); } - static std::string GetActualName() { return "Qbs"; } - static cmExternalMakefileProjectGenerator *New() - { return new cmExtraQbsGenerator; } - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry &entry, - const std::string &fullName) const; - - virtual void Generate(); - -private: - void CreateProjectFile(const std::string &name, - const std::vector<cmLocalGenerator *> &lgs); - void CreateNewProjectFile(const std::string &projectName, - const std::vector<cmLocalGenerator *> &lgs, - const std::string &filename); - void AppendSubProject(cmGeneratedFileStream &fout, cmLocalGenerator *lg); - void AppendProduct(cmGeneratedFileStream &fout, cmLocalGenerator *lg); - void AppendTarget(cmGeneratedFileStream &fout, - cmLocalGenerator *lg, - const cmTarget &t, - const std::string &cfg); - void AppendSources(cmGeneratedFileStream &fout, - cmGeneratorTarget *gt, - const cmTarget &t, - const std::string &cfg); - void AppendIncludePaths(cmGeneratedFileStream &fout, - const std::set<std::string> &paths); - void AppendCompileDefinitions(cmGeneratedFileStream &fout, - const std::set<std::string> &defs); -}; - -#endif // CMEXTRAQBSGENERATOR_H diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx index 5727470..13e2a66 100644 --- a/Source/cmFileTimeComparison.cxx +++ b/Source/cmFileTimeComparison.cxx @@ -13,8 +13,12 @@ // Use a hash table to avoid duplicate file time checks from disk. #if defined(CMAKE_BUILD_WITH_CMAKE) +#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#include <unordered_map> +#else # include <cmsys/hash_map.hxx> #endif +#endif #include <cmsys/Encoding.hxx> @@ -47,9 +51,17 @@ private: { return h(s.c_str()); } +#ifdef CMake_HAVE_CXX11_UNORDERED_MAP + std::hash<const char*> h; +#else cmsys::hash<const char*> h; +#endif }; +#ifdef CMake_HAVE_CXX11_UNORDERED_MAP + typedef std::unordered_map<std::string, +#else typedef cmsys::hash_map<std::string, +#endif cmFileTimeComparison_Type, HashString> FileStatsMap; FileStatsMap Files; #endif diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index fdd1018..001adb1 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -94,8 +94,8 @@ bool cmFunctionHelperCommand::InvokeInitialPass } // we push a scope on the makefile - cmMakefile::LexicalPushPop lexScope(this->Makefile); cmMakefile::ScopePushPop varScope(this->Makefile); + cmMakefile::LexicalPushPop lexScope(this->Makefile); static_cast<void>(varScope); // Push a weak policy scope which restores the policies recorded at diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index d191056..0ee98a8 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -22,6 +22,10 @@ cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator() this->ToolSupportsColor = true; this->UseLinkScript = false; this->WindowsShell = true; + this->IncludeDirective = "!include"; + this->DefineWindowsNULL = true; + this->PassMakeflags = true; + this->UnixCD = false; } @@ -43,11 +47,7 @@ cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator( { cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3(this, parent); - lg->SetIncludeDirective("!include"); - lg->SetDefineWindowsNULL(true); lg->SetMakefileVariableSize(32); - lg->SetPassMakeflags(true); - lg->SetUnixCD(false); lg->SetMakeCommandEscapeTargetTwice(true); lg->SetBorlandMakeCurlyHack(true); return lg; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1c9c475..75d6186 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1099,7 +1099,7 @@ void cmGlobalGenerator::Configure() this->ClearGeneratorMembers(); // start with this directory - cmLocalGenerator *lg = this->CreateLocalGenerator(); + cmLocalGenerator *lg = this->MakeLocalGenerator(); this->LocalGenerators.push_back(lg); // set the Start directories @@ -1373,10 +1373,18 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) { cmTargets& targets = this->LocalGenerators[i]->GetMakefile()->GetTargets(); + std::vector<std::string> targetNames; + targetNames.reserve(targets.size()); for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) { - cmTarget& target = ti->second; + 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 || @@ -1882,6 +1890,12 @@ void cmGlobalGenerator::EnableInstallTarget() } cmLocalGenerator * +cmGlobalGenerator::MakeLocalGenerator(cmLocalGenerator *parent) +{ + return this->CreateLocalGenerator(parent); +} + +cmLocalGenerator * cmGlobalGenerator::CreateLocalGenerator(cmLocalGenerator *parent) { return new cmLocalGenerator(this, parent); @@ -2137,7 +2151,6 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) { cmMakefile* mf = this->LocalGenerators[0]->GetMakefile(); const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir(); - const char* cmakeCommand = mf->GetRequiredDefinition("CMAKE_COMMAND"); // CPack std::string workingDir = mf->GetCurrentBinaryDirectory(); @@ -2252,7 +2265,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) } else { - singleLine.push_back(cmakeCommand); + singleLine.push_back(cmSystemTools::GetCMakeCommand()); singleLine.push_back("-E"); singleLine.push_back("echo"); singleLine.push_back("No interactive CMake dialog available."); @@ -2273,7 +2286,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) cpackCommandLines.end()); singleLine.erase(singleLine.begin(), singleLine.end()); depends.erase(depends.begin(), depends.end()); - singleLine.push_back(cmakeCommand); + singleLine.push_back(cmSystemTools::GetCMakeCommand()); singleLine.push_back("-H$(CMAKE_SOURCE_DIR)"); singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); cpackCommandLines.push_back(singleLine); @@ -2315,7 +2328,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) ostr.str().c_str(), &cpackCommandLines, depends, 0, /*uses_terminal*/false); } - std::string cmd = cmakeCommand; + std::string cmd = cmSystemTools::GetCMakeCommand(); cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end()); singleLine.erase(singleLine.begin(), singleLine.end()); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 3b2a41f..f9ea449 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -24,7 +24,11 @@ #if defined(CMAKE_BUILD_WITH_CMAKE) # include "cmFileLockPool.h" -# include <cmsys/hash_map.hxx> +# ifdef CMake_HAVE_CXX11_UNORDERED_MAP +# include <unordered_map> +# else +# include <cmsys/hash_map.hxx> +# endif #endif class cmake; @@ -52,8 +56,7 @@ public: cmGlobalGenerator(); virtual ~cmGlobalGenerator(); - ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0); + cmLocalGenerator* MakeLocalGenerator(cmLocalGenerator* parent = 0); ///! Get the name for this generator virtual std::string GetName() const { return "Generic"; } @@ -354,6 +357,7 @@ public: cmFileLockPool& GetFileLockPool() { return FileLockPool; } #endif + std::string MakeSilentFlag; bool WindowsShell; bool WindowsVSIDE; bool WatcomWMake; @@ -429,7 +433,11 @@ protected: // All targets in the entire project. #if defined(CMAKE_BUILD_WITH_CMAKE) +#ifdef CMake_HAVE_CXX11_UNORDERED_MAP + typedef std::unordered_map<std::string, cmTarget*> TargetMap; +#else typedef cmsys::hash_map<std::string, cmTarget*> TargetMap; +#endif #else typedef std::map<std::string,cmTarget *> TargetMap; #endif @@ -442,6 +450,9 @@ protected: virtual bool UseFolderProperty(); private: + ///! Create a local generator appropriate to this Global Generator + virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent); + cmMakefile* TryCompileOuterMakefile; float FirstTimeProgress; // If you add a new map here, make sure it is copied diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx index 25613eb..3ddbeb6 100644 --- a/Source/cmGlobalJOMMakefileGenerator.cxx +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -21,6 +21,10 @@ cmGlobalJOMMakefileGenerator::cmGlobalJOMMakefileGenerator() this->UseLinkScript = false; this->WindowsShell = true; this->NMake = true; + this->DefineWindowsNULL = true; + this->PassMakeflags = true; + this->UnixCD = false; + this->MakeSilentFlag = "/nologo"; } void cmGlobalJOMMakefileGenerator @@ -46,20 +50,6 @@ void cmGlobalJOMMakefileGenerator this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } -///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalJOMMakefileGenerator::CreateLocalGenerator(cmLocalGenerator* parent) -{ - cmLocalUnixMakefileGenerator3* lg - = new cmLocalUnixMakefileGenerator3(this, parent); - lg->SetDefineWindowsNULL(true); - lg->SetMakeSilentFlag("/nologo"); - lg->SetIgnoreLibPrefix(true); - lg->SetPassMakeflags(true); - lg->SetUnixCD(false); - return lg; -} - //---------------------------------------------------------------------------- void cmGlobalJOMMakefileGenerator ::GetDocumentation(cmDocumentationEntry& entry) diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h index 4831309..fa596f6 100644 --- a/Source/cmGlobalJOMMakefileGenerator.h +++ b/Source/cmGlobalJOMMakefileGenerator.h @@ -36,9 +36,6 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); - ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0); - /** * Try to determine system information such as shared library * extension, pthreads, byte order etc. diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index b6adcbb..fe3321e 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -93,18 +93,6 @@ void cmGlobalMSYSMakefileGenerator } } -///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalMSYSMakefileGenerator::CreateLocalGenerator(cmLocalGenerator* parent) -{ - cmLocalUnixMakefileGenerator3* lg = - new cmLocalUnixMakefileGenerator3(this, parent); - lg->SetIgnoreLibPrefix(true); - lg->SetPassMakeflags(false); - lg->SetUnixCD(true); - return lg; -} - //---------------------------------------------------------------------------- void cmGlobalMSYSMakefileGenerator ::GetDocumentation(cmDocumentationEntry& entry) diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h index 1795d86..4d5ee1e 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.h +++ b/Source/cmGlobalMSYSMakefileGenerator.h @@ -35,9 +35,6 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); - ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0); - /** * Try to determine system information such as shared library * extension, pthreads, byte order etc. diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx index 5b92eeb..17a7301 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.cxx +++ b/Source/cmGlobalMinGWMakefileGenerator.cxx @@ -58,18 +58,6 @@ void cmGlobalMinGWMakefileGenerator this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } -///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalMinGWMakefileGenerator::CreateLocalGenerator(cmLocalGenerator* parent) -{ - cmLocalUnixMakefileGenerator3* lg = - new cmLocalUnixMakefileGenerator3(this, parent); - lg->SetIgnoreLibPrefix(true); - lg->SetPassMakeflags(false); - lg->SetUnixCD(true); - return lg; -} - //---------------------------------------------------------------------------- void cmGlobalMinGWMakefileGenerator ::GetDocumentation(cmDocumentationEntry& entry) diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h index 93f67be..5543d12 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.h +++ b/Source/cmGlobalMinGWMakefileGenerator.h @@ -34,9 +34,6 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); - ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0); - /** * Try to determine system information such as shared library * extension, pthreads, byte order etc. diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index 98d7fb4..6152b29 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -21,6 +21,10 @@ cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator() this->UseLinkScript = false; this->WindowsShell = true; this->NMake = true; + this->DefineWindowsNULL = true; + this->PassMakeflags = true; + this->UnixCD = false; + this->MakeSilentFlag = "/nologo"; } void cmGlobalNMakeMakefileGenerator @@ -46,20 +50,6 @@ void cmGlobalNMakeMakefileGenerator this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } -///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalNMakeMakefileGenerator::CreateLocalGenerator(cmLocalGenerator* parent) -{ - cmLocalUnixMakefileGenerator3* lg = - new cmLocalUnixMakefileGenerator3(this, parent); - lg->SetDefineWindowsNULL(true); - lg->SetMakeSilentFlag("/nologo"); - lg->SetIgnoreLibPrefix(true); - lg->SetPassMakeflags(true); - lg->SetUnixCD(false); - return lg; -} - //---------------------------------------------------------------------------- void cmGlobalNMakeMakefileGenerator ::GetDocumentation(cmDocumentationEntry& entry) diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index cb898ba..69e5084 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -34,9 +34,6 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); - ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0); - /** * Try to determine system information such as shared library * extension, pthreads, byte order etc. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index e064b84..24fe16e 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -330,12 +330,10 @@ void cmGlobalNinjaGenerator::AddMacOSXContentRule() { cmLocalGenerator *lg = this->LocalGenerators[0]; - cmMakefile* mfRoot = lg->GetMakefile(); std::ostringstream cmd; - cmd << lg->ConvertToOutputFormat( - mfRoot->GetRequiredDefinition("CMAKE_COMMAND"), - cmLocalGenerator::SHELL) + cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(), + cmLocalGenerator::SHELL) << " -E copy $in $out"; this->AddRule("COPY_OSX_CONTENT", @@ -1185,9 +1183,8 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) cmMakefile* mfRoot = lg->GetMakefile(); std::ostringstream cmd; - cmd << lg->ConvertToOutputFormat( - mfRoot->GetRequiredDefinition("CMAKE_COMMAND"), - cmLocalGenerator::SHELL) + cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(), + cmLocalGenerator::SHELL) << " -H" << lg->ConvertToOutputFormat(mfRoot->GetHomeDirectory(), cmLocalGenerator::SHELL) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index a4df493..a43a427 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -33,6 +33,11 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3() this->UseLinkScript = true; #endif this->CommandDatabase = NULL; + + this->IncludeDirective = "include"; + this->DefineWindowsNULL = false; + this->PassMakeflags = false; + this->UnixCD = true; } void cmGlobalUnixMakefileGenerator3 @@ -580,7 +585,7 @@ void cmGlobalUnixMakefileGenerator3 else { lg = static_cast<cmLocalUnixMakefileGenerator3 *> - (this->CreateLocalGenerator()); + (this->MakeLocalGenerator()); // set the Start directories lg->GetMakefile()->SetCurrentSourceDirectory (this->CMakeInstance->GetHomeDirectory()); diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 165a3c8..ac82287 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -132,6 +132,11 @@ public: virtual bool AllowDeleteOnError() const { return true; } virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; + + std::string IncludeDirective; + bool DefineWindowsNULL; + bool PassMakeflags; + bool UnixCD; protected: void WriteMainMakefile2(); void WriteMainCMakefile(); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 04bb6ce..d907de4 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -105,6 +105,7 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( this->SystemIsWindowsPhone = false; this->SystemIsWindowsStore = false; this->MSBuildCommandInitialized = false; + this->Version = VS10; } //---------------------------------------------------------------------------- @@ -311,8 +312,7 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) cmLocalGenerator * cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent) { - return new cmLocalVisualStudio10Generator( - cmLocalVisualStudioGenerator::VS10, this, parent); + return new cmLocalVisualStudio10Generator(this, parent); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 36ae0a4..c7ff1f6 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -117,6 +117,7 @@ cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\11.0\\Setup\\VC;" "ProductDir", vc11Express, cmSystemTools::KeyWOW64_32); this->DefaultPlatformToolset = "v110"; + this->Version = VS11; } //---------------------------------------------------------------------------- @@ -237,14 +238,6 @@ void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) } //---------------------------------------------------------------------------- -cmLocalGenerator * -cmGlobalVisualStudio11Generator::CreateLocalGenerator(cmLocalGenerator* parent) -{ - return new cmLocalVisualStudio10Generator( - cmLocalVisualStudioGenerator::VS11, this, parent); -} - -//---------------------------------------------------------------------------- bool cmGlobalVisualStudio11Generator::UseFolderProperty() { // Intentionally skip over the parent class implementation and call the diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index ae4b888..6a9032f 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -28,9 +28,6 @@ public: virtual void WriteSLNHeader(std::ostream& fout); - ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0); - protected: virtual bool InitializeWindowsPhone(cmMakefile* mf); virtual bool InitializeWindowsStore(cmMakefile* mf); diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 17b2fc7..4e89e57 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -97,6 +97,7 @@ cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\12.0\\Setup\\VC;" "ProductDir", vc12Express, cmSystemTools::KeyWOW64_32); this->DefaultPlatformToolset = "v120"; + this->Version = VS12; } //---------------------------------------------------------------------------- @@ -217,14 +218,6 @@ void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout) } //---------------------------------------------------------------------------- -cmLocalGenerator * -cmGlobalVisualStudio12Generator::CreateLocalGenerator(cmLocalGenerator* parent) -{ - return new cmLocalVisualStudio10Generator( - cmLocalVisualStudioGenerator::VS12, this, parent); -} - -//---------------------------------------------------------------------------- bool cmGlobalVisualStudio12Generator::IsWindowsDesktopToolsetInstalled() const { diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index d304bc1..797394f 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -28,9 +28,6 @@ public: virtual void WriteSLNHeader(std::ostream& fout); - ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0); - //in Visual Studio 2013 they detached the MSBuild tools version //from the .Net Framework version and instead made it have it's own //version number diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 90fcc7e..06ebe32 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -97,6 +97,7 @@ cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\14.0\\Setup\\VC;" "ProductDir", vc14Express, cmSystemTools::KeyWOW64_32); this->DefaultPlatformToolset = "v140"; + this->Version = VS14; } //---------------------------------------------------------------------------- @@ -126,11 +127,3 @@ void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout) fout << "# Visual Studio 14\n"; } } - -//---------------------------------------------------------------------------- -cmLocalGenerator * -cmGlobalVisualStudio14Generator::CreateLocalGenerator(cmLocalGenerator* parent) -{ - return new cmLocalVisualStudio10Generator( - cmLocalVisualStudioGenerator::VS14, this, parent); -} diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index 59f1e60..4d5612f 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -28,9 +28,6 @@ public: virtual void WriteSLNHeader(std::ostream& fout); - ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0); - virtual const char* GetToolsVersion() { return "14.0"; } protected: virtual const char* GetIDEVersion() { return "14.0"; } diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 570314e..66936b6 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -34,6 +34,7 @@ std::string GetVS6TargetName(const std::string& targetName) cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator() { this->MSDevCommandInitialized = false; + this->Version = VS6; } void cmGlobalVisualStudio6Generator diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 308e858..80858b4 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -21,18 +21,7 @@ cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator( : cmGlobalVisualStudio7Generator(platformName) { this->ProjectConfigurationSectionName = "ProjectConfiguration"; -} - -//---------------------------------------------------------------------------- -///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalVisualStudio71Generator::CreateLocalGenerator(cmLocalGenerator* parent) -{ - cmLocalVisualStudio7Generator *lg = - new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS71, - this, parent); - lg->SetExtraFlagTable(this->GetExtraFlagTableVS7()); - return lg; + this->Version = VS71; } //---------------------------------------------------------------------------- @@ -94,6 +83,9 @@ void cmGlobalVisualStudio71Generator cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators) { + std::vector<std::string> configs; + root->GetMakefile()->GetConfigurations(configs); + // Write out the header for a SLN file this->WriteSLNHeader(fout); @@ -115,11 +107,11 @@ void cmGlobalVisualStudio71Generator // Write out the configurations information for the solution fout << "Global\n"; // Write out the configurations for the solution - this->WriteSolutionConfigurations(fout); + this->WriteSolutionConfigurations(fout, configs); fout << "\tGlobalSection(" << this->ProjectConfigurationSectionName << ") = postSolution\n"; // Write out the configurations for all the targets in the project - this->WriteTargetConfigurations(fout, orderedProjectTargets); + this->WriteTargetConfigurations(fout, configs, orderedProjectTargets); fout << "\tEndGlobalSection\n"; if (useFolderProperty) @@ -140,11 +132,12 @@ void cmGlobalVisualStudio71Generator //---------------------------------------------------------------------------- void cmGlobalVisualStudio71Generator -::WriteSolutionConfigurations(std::ostream& fout) +::WriteSolutionConfigurations(std::ostream& fout, + std::vector<std::string> const& configs) { fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n"; - for(std::vector<std::string>::iterator i = this->Configurations.begin(); - i != this->Configurations.end(); ++i) + for(std::vector<std::string>::const_iterator i = configs.begin(); + i != configs.end(); ++i) { fout << "\t\t" << *i << " = " << *i << "\n"; } @@ -280,14 +273,15 @@ void cmGlobalVisualStudio71Generator void cmGlobalVisualStudio71Generator ::WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType, + std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, std::string const& platformMapping) { const std::string& platformName = !platformMapping.empty() ? platformMapping : this->GetPlatformName(); std::string guid = this->GetGUID(name); - for(std::vector<std::string>::iterator i = this->Configurations.begin(); - i != this->Configurations.end(); ++i) + for(std::vector<std::string>::const_iterator i = configs.begin(); + i != configs.end(); ++i) { fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|" << platformName << std::endl; diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index ad6c153..dbae43d 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -36,9 +36,6 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); - ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0); - /** * Where does this version of Visual Studio look for macros for the * current user? Returns the empty string if this version of Visual @@ -57,7 +54,8 @@ protected: virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); - virtual void WriteSolutionConfigurations(std::ostream& fout); + virtual void WriteSolutionConfigurations( + std::ostream& fout, std::vector<std::string> const& configs); virtual void WriteProject(std::ostream& fout, const std::string& name, const char* path, cmTarget const& t); @@ -66,6 +64,7 @@ protected: cmTarget const& t); virtual void WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType type, + std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping = ""); virtual void WriteExternalProject(std::ostream& fout, diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index a2faddd..08ed6ac 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -18,6 +18,32 @@ #include "cmake.h" #include <cmsys/Encoding.hxx> +//---------------------------------------------------------------------------- +static cmVS7FlagTable cmVS7ExtraFlagTable[] = +{ + // Precompiled header and related options. Note that the + // UsePrecompiledHeader entries are marked as "Continue" so that the + // corresponding PrecompiledHeaderThrough entry can be found. + {"UsePrecompiledHeader", "YX", "Automatically Generate", "2", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, + {"PrecompiledHeaderThrough", "YX", "Precompiled Header Name", "", + cmVS7FlagTable::UserValueRequired}, + {"UsePrecompiledHeader", "Yu", "Use Precompiled Header", "3", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, + {"PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "", + cmVS7FlagTable::UserValueRequired}, + {"WholeProgramOptimization", "LTCG", "WholeProgramOptimization", "true", 0}, + + // Exception handling mode. If no entries match, it will be FALSE. + {"ExceptionHandling", "GX", "enable c++ exceptions", "true", 0}, + {"ExceptionHandling", "EHsc", "enable c++ exceptions", "true", 0}, + // The EHa option does not have an IDE setting. Let it go to false, + // and have EHa passed on the command line by leaving out the table + // entry. + + {0,0,0,0,0} +}; + cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( const std::string& platformName) { @@ -33,6 +59,8 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( { this->DefaultPlatformName = platformName; } + this->ExtraFlagTable = cmVS7ExtraFlagTable; + this->Version = VS7; } cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator() @@ -94,7 +122,6 @@ void cmGlobalVisualStudio7Generator // Create list of configurations requested by user's cache, if any. this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); - this->GenerateConfigurations(mf); // if this environment variable is set, then copy it to // a static cache entry. It will be used by @@ -254,9 +281,7 @@ cmLocalGenerator * cmGlobalVisualStudio7Generator::CreateLocalGenerator(cmLocalGenerator* parent) { cmLocalVisualStudio7Generator *lg = - new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS7, - this, parent); - lg->SetExtraFlagTable(this->GetExtraFlagTableVS7()); + new cmLocalVisualStudio7Generator(this, parent); return lg; } @@ -295,50 +320,6 @@ bool cmGlobalVisualStudio7Generator::SetGeneratorPlatform(std::string const& p, return this->cmGlobalVisualStudioGenerator::SetGeneratorPlatform(p, mf); } -void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf) -{ - // process the configurations - const char* ct - = this->CMakeInstance->GetCacheDefinition("CMAKE_CONFIGURATION_TYPES"); - if ( ct ) - { - std::vector<std::string> argsOut; - cmSystemTools::ExpandListArgument(ct, argsOut); - for(std::vector<std::string>::iterator i = argsOut.begin(); - i != argsOut.end(); ++i) - { - if(std::find(this->Configurations.begin(), - this->Configurations.end(), - *i) == this->Configurations.end()) - { - this->Configurations.push_back(*i); - } - } - } - // default to at least Debug and Release - if(this->Configurations.size() == 0) - { - this->Configurations.push_back("Debug"); - this->Configurations.push_back("Release"); - } - - // Reset the entry to have a semi-colon separated list. - std::string configs = this->Configurations[0]; - for(unsigned int i=1; i < this->Configurations.size(); ++i) - { - configs += ";"; - configs += this->Configurations[i]; - } - - mf->AddCacheDefinition( - "CMAKE_CONFIGURATION_TYPES", - configs.c_str(), - "Semicolon separated list of supported configuration types, " - "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, " - "anything else will be ignored.", - cmState::STRING); -} - void cmGlobalVisualStudio7Generator::Generate() { // first do the superclass method @@ -410,6 +391,7 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile() void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( std::ostream& fout, + std::vector<std::string> const& configs, OrderedTargetDependSet const& projectTargets) { // loop over again and write out configurations for each target @@ -425,23 +407,22 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( const char* expath = target->GetProperty("EXTERNAL_MSPROJECT"); if(expath) { - std::set<std::string> allConfigurations(this->Configurations.begin(), - this->Configurations.end()); + std::set<std::string> allConfigurations(configs.begin(), configs.end()); const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING"); this->WriteProjectConfigurations( fout, target->GetName().c_str(), target->GetType(), - allConfigurations, mapping ? mapping : ""); + configs, allConfigurations, mapping ? mapping : ""); } else { const std::set<std::string>& configsPartOfDefaultBuild = - this->IsPartOfDefaultBuild(projectTargets, target); + this->IsPartOfDefaultBuild(configs, projectTargets, target); const char *vcprojName = target->GetProperty("GENERATOR_FILE_NAME"); if (vcprojName) { this->WriteProjectConfigurations(fout, vcprojName, target->GetType(), - configsPartOfDefaultBuild); + configs, configsPartOfDefaultBuild); } } } @@ -576,6 +557,9 @@ void cmGlobalVisualStudio7Generator cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators) { + std::vector<std::string> configs; + root->GetMakefile()->GetConfigurations(configs); + // Write out the header for a SLN file this->WriteSLNHeader(fout); @@ -599,8 +583,8 @@ void cmGlobalVisualStudio7Generator << "\tGlobalSection(SolutionConfiguration) = preSolution\n"; int c = 0; - for(std::vector<std::string>::iterator i = this->Configurations.begin(); - i != this->Configurations.end(); ++i) + for(std::vector<std::string>::iterator i = configs.begin(); + i != configs.end(); ++i) { fout << "\t\tConfigName." << c << " = " << *i << "\n"; c++; @@ -621,7 +605,7 @@ void cmGlobalVisualStudio7Generator // Write out the configurations for all the targets in the project fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n"; - this->WriteTargetConfigurations(fout, orderedProjectTargets); + this->WriteTargetConfigurations(fout, configs, orderedProjectTargets); fout << "\tEndGlobalSection\n"; // Write out global sections @@ -777,14 +761,15 @@ cmGlobalVisualStudio7Generator void cmGlobalVisualStudio7Generator ::WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType, + std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping) { const std::string& platformName = !platformMapping.empty() ? platformMapping : this->GetPlatformName(); std::string guid = this->GetGUID(name); - for(std::vector<std::string>::iterator i = this->Configurations.begin(); - i != this->Configurations.end(); ++i) + for(std::vector<std::string>::const_iterator i = configs.begin(); + i != configs.end(); ++i) { fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|" << platformName << "\n"; @@ -902,6 +887,8 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout) std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target) { + std::vector<std::string> configs; + target->GetMakefile()->GetConfigurations(configs); std::string pname = target->GetName(); pname += "_UTILITY"; std::string fname = target->GetMakefile()->GetCurrentBinaryDirectory(); @@ -925,8 +912,8 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target) "\t<Platforms><Platform Name=\"Win32\"/></Platforms>\n" "\t<Configurations>\n" ; - for(std::vector<std::string>::iterator i = this->Configurations.begin(); - i != this->Configurations.end(); ++i) + for(std::vector<std::string>::iterator i = configs.begin(); + i != configs.end(); ++i) { fout << "\t\t<Configuration\n" @@ -991,11 +978,6 @@ void cmGlobalVisualStudio7Generator::CreateGUID(const std::string& name) cmState::INTERNAL); } -std::vector<std::string> *cmGlobalVisualStudio7Generator::GetConfigurations() -{ - return &this->Configurations; -}; - //---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator ::GetDocumentation(cmDocumentationEntry& entry) @@ -1022,6 +1004,7 @@ cmGlobalVisualStudio7Generator std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( + std::vector<std::string> const& configs, OrderedTargetDependSet const& projectTargets, cmTarget const* target) { std::set<std::string> activeConfigs; @@ -1034,8 +1017,8 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( if(target->GetName() == "INSTALL") { // inspect CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD properties - for(std::vector<std::string>::iterator i = this->Configurations.begin(); - i != this->Configurations.end(); ++i) + for(std::vector<std::string>::const_iterator i = configs.begin(); + i != configs.end(); ++i) { const char* propertyValue = target->GetMakefile() ->GetDefinition("CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD"); @@ -1055,8 +1038,8 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( return activeConfigs; } // inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties - for(std::vector<std::string>::iterator i = this->Configurations.begin(); - i != this->Configurations.end(); ++i) + for(std::vector<std::string>::const_iterator i = configs.begin(); + i != configs.end(); ++i) { const char* propertyValue = target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str()); @@ -1086,36 +1069,6 @@ cmGlobalVisualStudio7Generator return false; } -//---------------------------------------------------------------------------- -static cmVS7FlagTable cmVS7ExtraFlagTable[] = -{ - // Precompiled header and related options. Note that the - // UsePrecompiledHeader entries are marked as "Continue" so that the - // corresponding PrecompiledHeaderThrough entry can be found. - {"UsePrecompiledHeader", "YX", "Automatically Generate", "2", - cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, - {"PrecompiledHeaderThrough", "YX", "Precompiled Header Name", "", - cmVS7FlagTable::UserValueRequired}, - {"UsePrecompiledHeader", "Yu", "Use Precompiled Header", "3", - cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, - {"PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "", - cmVS7FlagTable::UserValueRequired}, - {"WholeProgramOptimization", "LTCG", "WholeProgramOptimization", "true", 0}, - - // Exception handling mode. If no entries match, it will be FALSE. - {"ExceptionHandling", "GX", "enable c++ exceptions", "true", 0}, - {"ExceptionHandling", "EHsc", "enable c++ exceptions", "true", 0}, - // The EHa option does not have an IDE setting. Let it go to false, - // and have EHa passed on the command line by leaving out the table - // entry. - - {0,0,0,0,0} -}; -cmIDEFlagTable const* cmGlobalVisualStudio7Generator::GetExtraFlagTableVS7() -{ - return cmVS7ExtraFlagTable; -} - std::string cmGlobalVisualStudio7Generator::Encoding() { std::ostringstream encoding; diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 92c5f1a..901ecd6 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -78,11 +78,6 @@ public: */ virtual void OutputSLNFile(); - /** - * Get the list of configurations - */ - std::vector<std::string> *GetConfigurations(); - ///! Create a GUID or get an existing one. void CreateGUID(const std::string& name); std::string GetGUID(const std::string& name); @@ -111,6 +106,8 @@ public: // Encoding for Visual Studio files virtual std::string Encoding(); + cmIDEFlagTable const* ExtraFlagTable; + protected: virtual void Generate(); virtual const char* GetIDEVersion() { return "7.0"; } @@ -120,7 +117,6 @@ protected: static const char* ExternalProjectType(const char* location); - static cmIDEFlagTable const* GetExtraFlagTableVS7(); virtual void OutputSLNFile(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, @@ -133,6 +129,7 @@ protected: cmTarget const&t); virtual void WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType type, + std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping = ""); virtual void WriteSLNGlobalSections(std::ostream& fout, @@ -150,10 +147,9 @@ protected: OrderedTargetDependSet const& projectTargets); virtual void WriteTargetConfigurations( std::ostream& fout, + std::vector<std::string> const& configs, OrderedTargetDependSet const& projectTargets); - void GenerateConfigurations(cmMakefile* mf); - virtual void WriteExternalProject(std::ostream& fout, const std::string& name, const char* path, @@ -164,11 +160,11 @@ protected: std::string ConvertToSolutionPath(const char* path); std::set<std::string> - IsPartOfDefaultBuild(OrderedTargetDependSet const& projectTargets, + IsPartOfDefaultBuild(std::vector<std::string> const& configs, + OrderedTargetDependSet const& projectTargets, cmTarget const* target); bool IsDependedOn(OrderedTargetDependSet const& projectTargets, cmTarget const* target); - std::vector<std::string> Configurations; std::map<std::string, std::string> GUIDMap; virtual void WriteFolders(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index ff9ff10..9f02596 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -101,6 +101,8 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( { this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; this->Name = name; + this->ExtraFlagTable = this->GetExtraFlagTableVS8(); + this->Version = VS8; } //---------------------------------------------------------------------------- @@ -124,18 +126,6 @@ std::string cmGlobalVisualStudio8Generator::FindDevEnvCommand() } //---------------------------------------------------------------------------- -///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalVisualStudio8Generator::CreateLocalGenerator(cmLocalGenerator* parent) -{ - cmLocalVisualStudio7Generator *lg = - new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8, - this, parent); - lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); - return lg; -} - -//---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator ::EnableLanguage(std::vector<std::string>const & lang, cmMakefile *mf, bool optional) @@ -262,7 +252,6 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() return false; } - std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND"); cmCustomCommandLines noCommandLines; cmTarget* tgt = mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, @@ -320,9 +309,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // Create a rule to re-run CMake. std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash(); stampName += "generate.stamp"; - const char* dsprule = mf->GetRequiredDefinition("CMAKE_COMMAND"); cmCustomCommandLine commandLine; - commandLine.push_back(dsprule); + commandLine.push_back(cmSystemTools::GetCMakeCommand()); std::string argH = "-H"; argH += lg->Convert(mf->GetHomeDirectory(), cmLocalGenerator::START_OUTPUT, @@ -387,11 +375,12 @@ void cmGlobalVisualStudio8Generator::Generate() //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator -::WriteSolutionConfigurations(std::ostream& fout) +::WriteSolutionConfigurations(std::ostream& fout, + std::vector<std::string> const& configs) { fout << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n"; - for(std::vector<std::string>::iterator i = this->Configurations.begin(); - i != this->Configurations.end(); ++i) + for(std::vector<std::string>::const_iterator i = configs.begin(); + i != configs.end(); ++i) { fout << "\t\t" << *i << "|" << this->GetPlatformName() << " = " << *i << "|" << this->GetPlatformName() << "\n"; @@ -404,12 +393,13 @@ void cmGlobalVisualStudio8Generator ::WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType type, + std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, std::string const& platformMapping) { std::string guid = this->GetGUID(name); - for(std::vector<std::string>::iterator i = this->Configurations.begin(); - i != this->Configurations.end(); ++i) + for(std::vector<std::string>::const_iterator i = configs.begin(); + i != configs.end(); ++i) { fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|" diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index ee5ba9f..6d9d82e 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -33,9 +33,6 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); - ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0); - virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *, bool optional); virtual void AddPlatformDefinitions(cmMakefile* mf); @@ -84,9 +81,11 @@ protected: static cmIDEFlagTable const* GetExtraFlagTableVS8(); virtual void WriteSLNHeader(std::ostream& fout); - virtual void WriteSolutionConfigurations(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::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping = ""); virtual bool ComputeTargetDepends(); diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 8adde23..95e9fb9 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -104,6 +104,7 @@ cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator( const std::string& name, const std::string& platformName) : cmGlobalVisualStudio8Generator(name, platformName) { + this->Version = VS9; } //---------------------------------------------------------------------------- @@ -113,17 +114,6 @@ void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout) fout << "# Visual Studio 2008\n"; } -///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalVisualStudio9Generator::CreateLocalGenerator(cmLocalGenerator* parent) -{ - cmLocalVisualStudio7Generator *lg - = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9, - this, parent); - lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); - return lg; -} - //---------------------------------------------------------------------------- std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory() { diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h index 97b7804..bc4f773 100644 --- a/Source/cmGlobalVisualStudio9Generator.h +++ b/Source/cmGlobalVisualStudio9Generator.h @@ -28,9 +28,6 @@ public: const std::string& platformName); static cmGlobalGeneratorFactory* NewFactory(); - ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0); - /** * Try to determine system information such as shared library * extension, pthreads, byte order etc. diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index b74ba6f..05f0f01 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -33,6 +33,19 @@ cmGlobalVisualStudioGenerator::~cmGlobalVisualStudioGenerator() } //---------------------------------------------------------------------------- +cmGlobalVisualStudioGenerator::VSVersion +cmGlobalVisualStudioGenerator::GetVersion() const +{ + return this->Version; +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudioGenerator::SetVersion(VSVersion v) +{ + this->Version = v; +} + +//---------------------------------------------------------------------------- std::string cmGlobalVisualStudioGenerator::GetRegistryBase() { return cmGlobalVisualStudioGenerator::GetRegistryBase( diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index cb54132..ae83402 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -23,9 +23,27 @@ class cmGlobalVisualStudioGenerator : public cmGlobalGenerator { public: + /** Known versions of Visual Studio. */ + enum VSVersion + { + VS6 = 60, + VS7 = 70, + VS71 = 71, + VS8 = 80, + VS9 = 90, + VS10 = 100, + VS11 = 110, + VS12 = 120, + /* VS13 = 130 was skipped */ + VS14 = 140 + }; + cmGlobalVisualStudioGenerator(); virtual ~cmGlobalVisualStudioGenerator(); + VSVersion GetVersion() const; + void SetVersion(VSVersion v); + /** * Configure CMake's Visual Studio macros file into the user's Visual * Studio macros directory. @@ -107,6 +125,9 @@ protected: typedef std::map<cmTarget const*, std::string> UtilityDependsMap; UtilityDependsMap UtilityDepends; +protected: + VSVersion Version; + private: virtual std::string GetVSMakeProgram() = 0; void PrintCompilerAdvice(std::ostream&, std::string const&, diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 181178f..062091f 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -26,6 +26,10 @@ cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator() this->WindowsShell = true; #endif this->WatcomWMake = true; + this->IncludeDirective = "!include"; + this->DefineWindowsNULL = true; + this->UnixCD = false; + this->MakeSilentFlag = "-h"; } void cmGlobalWatcomWMakeGenerator @@ -44,21 +48,6 @@ void cmGlobalWatcomWMakeGenerator this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } -///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalWatcomWMakeGenerator::CreateLocalGenerator(cmLocalGenerator* parent) -{ - cmLocalUnixMakefileGenerator3* lg - = new cmLocalUnixMakefileGenerator3(this, parent); - lg->SetDefineWindowsNULL(true); - lg->SetMakeSilentFlag("-h"); - lg->SetIgnoreLibPrefix(true); - lg->SetPassMakeflags(false); - lg->SetUnixCD(false); - lg->SetIncludeDirective("!include"); - return lg; -} - //---------------------------------------------------------------------------- void cmGlobalWatcomWMakeGenerator ::GetDocumentation(cmDocumentationEntry& entry) diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index 3af2f9d..b733324 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -34,9 +34,6 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); - ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0); - /** * Try to determine system information such as shared library * extension, pthreads, byte order etc. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4a7411c..0753235 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -582,8 +582,8 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( { makefileStream << "\\\n" << this->ConvertToRelativeForMake(i->c_str()); } - std::string cmake = mf->GetRequiredDefinition("CMAKE_COMMAND"); - makefileStream << "\n\t" << this->ConvertToRelativeForMake(cmake.c_str()) + makefileStream << "\n\t" << + this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand().c_str()) << " -H" << this->ConvertToRelativeForMake( mf->GetHomeDirectory()) << " -B" << this->ConvertToRelativeForMake( @@ -1447,7 +1447,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, { cmCustomCommandLines cmd; cmd.resize(1); - cmd[0].push_back(this->CurrentMakefile->GetDefinition("CMAKE_COMMAND")); + cmd[0].push_back(cmSystemTools::GetCMakeCommand()); cmd[0].push_back("-E"); cmd[0].push_back("cmake_symlink_library"); std::string str_file = "$<TARGET_FILE:"; diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 99542a9..bbbfc24 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -65,9 +65,11 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, const char* fallbackSettingsFileName) { cmake cm; + cm.SetHomeDirectory(""); + cm.SetHomeOutputDirectory(""); cmGlobalGenerator ggi; ggi.SetCMakeInstance(&cm); - cmsys::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(ggi.MakeLocalGenerator()); cmMakefile *mf = lg->GetMakefile(); const char* inFileName = settingsFileName; diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index ddcea9b..2756cd2 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -400,6 +400,11 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token, } } +void cmListFileBacktrace::Append(cmListFileContext const& context) +{ + this->push_back(context); +} + //---------------------------------------------------------------------------- void cmListFileBacktrace::MakeRelative() { @@ -416,6 +421,31 @@ void cmListFileBacktrace::MakeRelative() this->Relative = true; } +void cmListFileBacktrace::PrintTitle(std::ostream& out) +{ + if (this->empty()) + { + return; + } + out << (this->front().Line ? " at " : " in ") << this->front(); +} + +void cmListFileBacktrace::PrintCallStack(std::ostream& out) +{ + if (size() <= 1) + { + return; + } + + const_iterator i = this->begin() + 1; + out << "Call Stack (most recent call first):\n"; + while(i != this->end()) + { + cmListFileContext const& lfc = *i; + out << " " << lfc << "\n"; + ++i; + } +} //---------------------------------------------------------------------------- std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc) @@ -431,3 +461,22 @@ std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc) } return os; } + +bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs) +{ + if(lhs.Line != rhs.Line) + { + return lhs.Line < rhs.Line; + } + return lhs.FilePath < rhs.FilePath; +} + +bool operator==(const cmListFileContext& lhs, const cmListFileContext& rhs) +{ + return lhs.Line == rhs.Line && lhs.FilePath == rhs.FilePath; +} + +bool operator!=(const cmListFileContext& lhs, const cmListFileContext& rhs) +{ + return !(lhs == rhs); +} diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index 544ff1b..4a1d181 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -62,13 +62,16 @@ struct cmListFileContext }; std::ostream& operator<<(std::ostream&, cmListFileContext const&); +bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs); +bool operator==(cmListFileContext const& lhs, cmListFileContext const& rhs); +bool operator!=(cmListFileContext const& lhs, cmListFileContext const& rhs); struct cmListFileFunction: public cmListFileContext { std::vector<cmListFileArgument> Arguments; }; -class cmListFileBacktrace: public std::vector<cmListFileContext> +class cmListFileBacktrace: private std::vector<cmListFileContext> { public: cmListFileBacktrace(cmLocalGenerator* localGen) @@ -77,7 +80,12 @@ class cmListFileBacktrace: public std::vector<cmListFileContext> { } + void Append(cmListFileContext const& context); + void MakeRelative(); + + void PrintTitle(std::ostream& out); + void PrintCallStack(std::ostream& out); private: cmLocalGenerator* LocalGenerator; bool Relative; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 74362ae..c2e996c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -62,12 +62,9 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, this->Makefile = new cmMakefile(this); this->LinkScriptShell = false; - this->IgnoreLibPrefix = false; this->UseRelativePaths = false; this->Configured = false; this->EmitUniversalBinaryFlags = true; - this->RelativePathsConfigured = false; - this->PathConversionsSetup = false; this->BackwardsCompatibility = 0; this->BackwardsCompatibilityFinal = false; } @@ -79,7 +76,7 @@ cmLocalGenerator::~cmLocalGenerator() bool cmLocalGenerator::IsRootMakefile() const { - return !this->GetParent(); + return !this->StateSnapshot.GetParent().IsValid(); } //---------------------------------------------------------------------------- @@ -118,8 +115,10 @@ void cmLocalGenerator::Configure() filesDir += cmake::GetCMakeFilesDirectory(); cmSystemTools::MakeDirectory(filesDir.c_str()); - // find & read the list file - this->ReadInputFile(); + std::string currentStart = this->StateSnapshot.GetCurrentSourceDirectory(); + currentStart += "/CMakeLists.txt"; + assert(cmSystemTools::FileExists(currentStart.c_str(), true)); + this->Makefile->ProcessBuildsystemFile(currentStart.c_str()); // at the end of the ReadListFile handle any old style subdirs // first get all the subdirectories @@ -186,39 +185,6 @@ void cmLocalGenerator::ComputeObjectMaxPath() this->ObjectMaxPathViolations.clear(); } -//---------------------------------------------------------------------------- -void cmLocalGenerator::ReadInputFile() -{ - // Look for the CMakeLists.txt file. - std::string currentStart = this->StateSnapshot.GetCurrentSourceDirectory(); - currentStart += "/CMakeLists.txt"; - assert(cmSystemTools::FileExists(currentStart.c_str(), true)); - this->Makefile->ProcessBuildsystemFile(currentStart.c_str()); -} - -void cmLocalGenerator::SetupPathConversions() -{ - // Setup the current output directory components for use by - // Convert - std::string outdir; - outdir = - cmSystemTools::CollapseFullPath(this->GetState()->GetSourceDirectory()); - cmSystemTools::SplitPath(outdir, this->HomeDirectoryComponents); - outdir = cmSystemTools::CollapseFullPath( - this->StateSnapshot.GetCurrentSourceDirectory()); - cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents); - - outdir = cmSystemTools::CollapseFullPath - (this->GetState()->GetBinaryDirectory()); - cmSystemTools::SplitPath(outdir, - this->HomeOutputDirectoryComponents); - - outdir = cmSystemTools::CollapseFullPath - (this->StateSnapshot.GetCurrentBinaryDirectory()); - cmSystemTools::SplitPath(outdir, - this->StartOutputDirectoryComponents); -} - void cmLocalGenerator::ConfigureFinalPass() { this->Makefile->ConfigureFinalPass(); @@ -390,12 +356,8 @@ void cmLocalGenerator::GenerateInstallRules() // Create the install script file. std::string file = this->StateSnapshot.GetCurrentBinaryDirectory(); std::string homedir = this->GetState()->GetBinaryDirectory(); - std::string currdir = this->StateSnapshot.GetCurrentBinaryDirectory(); - cmSystemTools::ConvertToUnixSlashes(file); - cmSystemTools::ConvertToUnixSlashes(homedir); - cmSystemTools::ConvertToUnixSlashes(currdir); int toplevel_install = 0; - if ( currdir == homedir ) + if (file == homedir) { toplevel_install = 1; } @@ -1031,12 +993,10 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } if(variable == "CMAKE_COMMAND") { - const char* cmcommand = - this->GetMakefile()->GetDefinition("CMAKE_COMMAND"); - return this->Convert(cmcommand, FULL, SHELL); + return this->Convert(cmSystemTools::GetCMakeCommand(), FULL, SHELL); } - std::vector<std::string> enabledLanguages; - this->GlobalGenerator->GetEnabledLanguages(enabledLanguages); + std::vector<std::string> enabledLanguages = + this->GetState()->GetEnabledLanguages(); // loop over language specific replace variables int pos = 0; while(ruleReplaceVars[pos]) @@ -1878,7 +1838,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, fdi != fwDirs.end(); ++fdi) { frameworkPath += fwSearchFlag; - frameworkPath += this->Convert(*fdi, NONE, shellFormat, false); + frameworkPath += this->Convert(*fdi, NONE, shellFormat); frameworkPath += " "; } } @@ -1932,7 +1892,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, ri != runtimeDirs.end(); ++ri) { rpath += cli.GetRuntimeFlag(); - rpath += this->Convert(*ri, NONE, shellFormat, false); + rpath += this->Convert(*ri, NONE, shellFormat); rpath += " "; } fout << rpath; @@ -2705,13 +2665,6 @@ std::string cmLocalGenerator::Convert(const std::string& source, OutputFormat output, bool optional) { - // Make sure the relative path conversion components are set. - if(!this->PathConversionsSetup) - { - this->SetupPathConversions(); - this->PathConversionsSetup = true; - } - // Convert the path to a relative path. std::string result = source; @@ -2721,25 +2674,23 @@ std::string cmLocalGenerator::Convert(const std::string& source, { case HOME: //result = cmSystemTools::CollapseFullPath(result.c_str()); - result = this->ConvertToRelativePath(this->HomeDirectoryComponents, - result); + result = this->ConvertToRelativePath( + this->GetState()->GetSourceDirectoryComponents(), result); break; case START: //result = cmSystemTools::CollapseFullPath(result.c_str()); - result = this->ConvertToRelativePath(this->StartDirectoryComponents, - result); + result = this->ConvertToRelativePath( + this->StateSnapshot.GetCurrentSourceDirectoryComponents(), result); break; case HOME_OUTPUT: //result = cmSystemTools::CollapseFullPath(result.c_str()); - result = - this->ConvertToRelativePath(this->HomeOutputDirectoryComponents, - result); + result = this->ConvertToRelativePath( + this->GetState()->GetBinaryDirectoryComponents(), result); break; case START_OUTPUT: //result = cmSystemTools::CollapseFullPath(result.c_str()); - result = - this->ConvertToRelativePath(this->StartOutputDirectoryComponents, - result); + result = this->ConvertToRelativePath( + this->StateSnapshot.GetCurrentBinaryDirectoryComponents(), result); break; case FULL: result = cmSystemTools::CollapseFullPath(result); @@ -2812,97 +2763,6 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote, } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::FindRelativePathTopSource() -{ - cmState::Snapshot snapshot = this->StateSnapshot; - std::vector<cmState::Snapshot> snapshots; - snapshots.push_back(snapshot); - while (true) - { - snapshot = snapshot.GetParent(); - if (snapshot.IsValid()) - { - snapshots.push_back(snapshot); - } - else - { - break; - } - } - - std::string result = snapshots.front().GetCurrentSourceDirectory(); - - for (std::vector<cmState::Snapshot>::const_iterator it = - snapshots.begin() + 1; it != snapshots.end(); ++it) - { - std::string currentSource = it->GetCurrentSourceDirectory(); - if(cmSystemTools::IsSubDirectory(result, currentSource)) - { - result = currentSource; - } - } - - return result; -} - -//---------------------------------------------------------------------------- -std::string cmLocalGenerator::FindRelativePathTopBinary() -{ - cmState::Snapshot snapshot = this->StateSnapshot; - std::vector<cmState::Snapshot> snapshots; - snapshots.push_back(snapshot); - while (true) - { - snapshot = snapshot.GetParent(); - if (snapshot.IsValid()) - { - snapshots.push_back(snapshot); - } - else - { - break; - } - } - - std::string result = snapshots.front().GetCurrentBinaryDirectory(); - - for (std::vector<cmState::Snapshot>::const_iterator it = - snapshots.begin() + 1; it != snapshots.end(); ++it) - { - std::string currentBinary = it->GetCurrentBinaryDirectory(); - if(cmSystemTools::IsSubDirectory(result, currentBinary)) - { - result = currentBinary; - } - } - - return result; -} - -//---------------------------------------------------------------------------- -void cmLocalGenerator::ConfigureRelativePaths() -{ - // Relative path conversion inside the source tree is not used to - // construct relative paths passed to build tools so it is safe to - // even when the source is a network path. - std::string source = this->FindRelativePathTopSource(); - this->RelativePathTopSource = source; - - // The current working directory on Windows cannot be a network - // path. Therefore relative paths cannot work when the binary tree - // is a network path. - std::string binary = this->FindRelativePathTopBinary(); - if(binary.size() < 2 || binary.substr(0, 2) != "//") - { - this->RelativePathTopBinary = binary; - } - else - { - this->RelativePathTopBinary = ""; - } -} - -//---------------------------------------------------------------------------- static bool cmLocalGeneratorNotAbove(const char* a, const char* b) { return (cmSystemTools::ComparePath(a, b) || @@ -2927,26 +2787,19 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local, return in_remote; } - // Make sure relative path conversion is configured. - if(!this->RelativePathsConfigured) - { - this->ConfigureRelativePaths(); - this->RelativePathsConfigured = true; - } - if(!force) { // Skip conversion if the path and local are not both in the source // or both in the binary tree. std::string local_path = cmSystemTools::JoinPath(local); if(!((cmLocalGeneratorNotAbove(local_path.c_str(), - this->RelativePathTopBinary.c_str()) && + this->StateSnapshot.GetRelativePathTopBinary()) && cmLocalGeneratorNotAbove(in_remote.c_str(), - this->RelativePathTopBinary.c_str())) || + this->StateSnapshot.GetRelativePathTopBinary())) || (cmLocalGeneratorNotAbove(local_path.c_str(), - this->RelativePathTopSource.c_str()) && + this->StateSnapshot.GetRelativePathTopSource()) && cmLocalGeneratorNotAbove(in_remote.c_str(), - this->RelativePathTopSource.c_str())))) + this->StateSnapshot.GetRelativePathTopSource())))) { return in_remote; } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index fa2f712..3fca225 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -395,7 +395,7 @@ public: protected: ///! put all the libraries for a target on into the given stream - virtual void OutputLinkLibraries(std::string& linkLibraries, + void OutputLinkLibraries(std::string& linkLibraries, std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget &, @@ -440,11 +440,6 @@ protected: std::string const& dir_max); void ComputeObjectMaxPath(); - void ConfigureRelativePaths(); - std::string FindRelativePathTopSource(); - std::string FindRelativePathTopBinary(); - void SetupPathConversions(); - virtual std::string ConvertToLinkReference(std::string const& lib, OutputFormat format = SHELL); @@ -452,16 +447,9 @@ protected: definition. Issues a warning. */ virtual bool CheckDefinition(std::string const& define) const; - /** Read the input CMakeLists.txt file. */ - void ReadInputFile(); - cmMakefile *Makefile; cmState::Snapshot StateSnapshot; cmGlobalGenerator *GlobalGenerator; - std::vector<std::string> HomeDirectoryComponents; - std::vector<std::string> StartDirectoryComponents; - std::vector<std::string> HomeOutputDirectoryComponents; - std::vector<std::string> StartOutputDirectoryComponents; cmLocalGenerator* Parent; std::vector<cmLocalGenerator*> Children; std::map<std::string, std::string> UniqueObjectNamesMap; @@ -470,7 +458,6 @@ protected: bool LinkScriptShell; bool UseRelativePaths; - bool IgnoreLibPrefix; bool Configured; bool EmitUniversalBinaryFlags; @@ -478,16 +465,6 @@ protected: // committed. std::string TargetImplib; - // The top-most directories for relative path conversion. Both the - // source and destination location of a relative path conversion - // must be underneath one of these directories (both under source or - // both under binary) in order for the relative path to be evaluated - // safely by the build tools. - std::string RelativePathTopSource; - std::string RelativePathTopBinary; - bool RelativePathsConfigured; - bool PathConversionsSetup; - cmIML_INT_uint64_t BackwardsCompatibility; bool BackwardsCompatibilityFinal; private: diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index f1f1202..bcae486 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -305,8 +305,8 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os) cmGlobalNinjaGenerator::WriteDivider(os); os << "# Write statements declared in CMakeLists.txt:" << std::endl - << "# " << this->Makefile->GetCurrentListFile() << std::endl - ; + << "# " + << this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE") << std::endl; if(this->IsRootMakefile()) os << "# Which is the root file." << std::endl; cmGlobalNinjaGenerator::WriteDivider(os); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index f11c79e..b68dc51 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -83,12 +83,7 @@ cmLocalUnixMakefileGenerator3:: cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmLocalGenerator* parent) : cmLocalGenerator(gg, parent) { - this->IncludeDirective = "include"; this->MakefileVariableSize = 0; - this->IgnoreLibPrefix = false; - this->PassMakeflags = false; - this->DefineWindowsNULL = false; - this->UnixCD = true; this->ColorMakefile = false; this->SkipPreprocessedSourceRules = false; this->SkipAssemblySourceRules = false; @@ -545,9 +540,11 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() // Setup relative path conversion tops. infoFileStream << "# Relative path conversion top directories.\n" - << "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \"" << this->RelativePathTopSource + << "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \"" + << this->StateSnapshot.GetRelativePathTopSource() << "\")\n" - << "set(CMAKE_RELATIVE_PATH_TOP_BINARY \"" << this->RelativePathTopBinary + << "set(CMAKE_RELATIVE_PATH_TOP_BINARY \"" + << this->StateSnapshot.GetRelativePathTopBinary() << "\")\n" << "\n"; @@ -720,7 +717,9 @@ cmLocalUnixMakefileGenerator3 makefileStream << "# Set environment variables for the build.\n" << "\n"; - if(this->DefineWindowsNULL) + cmGlobalUnixMakefileGenerator3* gg = + static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); + if(gg->DefineWindowsNULL) { makefileStream << "!IF \"$(OS)\" == \"Windows_NT\"\n" @@ -745,18 +744,16 @@ cmLocalUnixMakefileGenerator3 #endif } - std::string cmakecommand = - this->Makefile->GetRequiredDefinition("CMAKE_COMMAND"); makefileStream << "# The CMake executable.\n" << "CMAKE_COMMAND = " - << this->ConvertShellCommand(cmakecommand, FULL) + << this->ConvertShellCommand(cmSystemTools::GetCMakeCommand(), FULL) << "\n" << "\n"; makefileStream << "# The command to remove a file.\n" << "RM = " - << this->ConvertShellCommand(cmakecommand, FULL) + << this->ConvertShellCommand(cmSystemTools::GetCMakeCommand(), FULL) << " -E remove -f\n" << "\n"; makefileStream @@ -1613,16 +1610,15 @@ cmLocalUnixMakefileGenerator3 } // Setup relative path top directories. - this->RelativePathsConfigured = true; if(const char* relativePathTopSource = mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE")) { - this->RelativePathTopSource = relativePathTopSource; + this->StateSnapshot.SetRelativePathTopSource(relativePathTopSource); } if(const char* relativePathTopBinary = mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY")) { - this->RelativePathTopBinary = relativePathTopBinary; + this->StateSnapshot.SetRelativePathTopBinary(relativePathTopBinary); } } else @@ -2143,10 +2139,12 @@ cmLocalUnixMakefileGenerator3 cmd += this->Convert(makefile,NONE,SHELL); cmd += " "; + cmGlobalUnixMakefileGenerator3* gg = + static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); // Pass down verbosity level. - if(!this->GetMakeSilentFlag().empty()) + if(!gg->MakeSilentFlag.empty()) { - cmd += this->GetMakeSilentFlag(); + cmd += gg->MakeSilentFlag; cmd += " "; } @@ -2154,7 +2152,7 @@ cmLocalUnixMakefileGenerator3 // sub-invoked makes via an environment variable. However, some // makes do not support that, so you have to pass the flags // explicitly. - if(this->GetPassMakeflags()) + if(gg->PassMakeflags) { cmd += "-$(MAKEFLAGS) "; } @@ -2346,7 +2344,9 @@ void cmLocalUnixMakefileGenerator3 // support changing the drive letter with just "d:"). const char* cd_cmd = this->IsMinGWMake() ? "cd /d " : "cd "; - if(!this->UnixCD) + cmGlobalUnixMakefileGenerator3* gg = + static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); + if(!gg->UnixCD) { // On Windows we must perform each step separately and then change // back because the shell keeps the working directory between diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 7b436a5..0b056ff 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -67,52 +67,11 @@ public: void WriteMakeVariables(std::ostream& makefileStream); /** - * If true, then explicitly pass MAKEFLAGS on the make all target for makes - * that do not use environment variables. - * - */ - void SetPassMakeflags(bool s){this->PassMakeflags = s;} - bool GetPassMakeflags() { return this->PassMakeflags; } - - /** - * Set the flag used to keep the make program silent. - */ - void SetMakeSilentFlag(const std::string& s) { this->MakeSilentFlag = s; } - std::string &GetMakeSilentFlag() { return this->MakeSilentFlag; } - - /** - * If set to true, then NULL is set to nil for non Windows_NT. - * This uses make syntax used by nmake and borland. - * The default is false. - */ - void SetDefineWindowsNULL(bool v) {this->DefineWindowsNULL = v;} - - /** - * If set to true, cd dir && command is used to - * run commands in a different directory. - */ - void SetUnixCD(bool v) {this->UnixCD = v;} - - /** - * Set the string used to include one makefile into another default - * is include. - */ - void SetIncludeDirective(const std::string& s) - { this->IncludeDirective = s; } - const std::string& GetIncludeDirective() { return this->IncludeDirective; } - - /** * Set max makefile variable size, default is 0 which means unlimited. */ void SetMakefileVariableSize(int s) { this->MakefileVariableSize = s; } /** - * If ignore lib prefix is true, then do not strip lib from the name - * of a library. - */ - void SetIgnoreLibPrefix(bool s) { this->IgnoreLibPrefix = s; } - - /** * Set whether passing a make target on a command line requires an * extra level of escapes. */ @@ -303,12 +262,7 @@ private: //========================================================================== // Configuration settings. int MakefileVariableSize; - std::string IncludeDirective; - std::string MakeSilentFlag; std::string ConfigurationName; - bool DefineWindowsNULL; - bool UnixCD; - bool PassMakeflags; bool MakeCommandEscapeTargetTwice; bool BorlandMakeCurlyHack; //========================================================================== diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 06a3b6c..37b722a 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -62,9 +62,9 @@ class cmVS10XMLParser : public cmXMLParser //---------------------------------------------------------------------------- cmLocalVisualStudio10Generator -::cmLocalVisualStudio10Generator(VSVersion v, cmGlobalGenerator* gg, +::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmLocalGenerator* parent): - cmLocalVisualStudio7Generator(v, gg, parent) + cmLocalVisualStudio7Generator(gg, parent) { } diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index 987e08b..afd52b9 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -25,7 +25,7 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio10Generator(VSVersion v, cmGlobalGenerator* gg, + cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmLocalGenerator* parent); virtual ~cmLocalVisualStudio10Generator(); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 42da639..7afb53a 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -26,7 +26,7 @@ cmLocalVisualStudio6Generator ::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmLocalGenerator* parent): - cmLocalVisualStudioGenerator(VS6, gg, parent) + cmLocalVisualStudioGenerator(gg, parent) { } @@ -221,10 +221,8 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt) { std::string dspname = GetVS6TargetName(tgt.GetName()); dspname += ".dsp.cmake"; - const char* dsprule = - this->Makefile->GetRequiredDefinition("CMAKE_COMMAND"); cmCustomCommandLine commandLine; - commandLine.push_back(dsprule); + commandLine.push_back(cmSystemTools::GetCMakeCommand()); std::string makefileIn = this->Makefile->GetCurrentSourceDirectory(); makefileIn += "/"; makefileIn += "CMakeLists.txt"; @@ -817,7 +815,7 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target, // Add a pre-link event to create the directory. cmCustomCommandLine command; - command.push_back(this->Makefile->GetRequiredDefinition("CMAKE_COMMAND")); + command.push_back(cmSystemTools::GetCMakeCommand()); command.push_back("-E"); command.push_back("make_directory"); command.push_back(outDir); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 63c18a7..d2fb970 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -55,11 +55,10 @@ static void cmConvertToWindowsSlash(std::string& s) //---------------------------------------------------------------------------- cmLocalVisualStudio7Generator -::cmLocalVisualStudio7Generator(VSVersion v, cmGlobalGenerator* gg, +::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmLocalGenerator* parent): - cmLocalVisualStudioGenerator(v, gg, parent) + cmLocalVisualStudioGenerator(gg, parent) { - this->ExtraFlagTable = 0; this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); } @@ -241,18 +240,17 @@ void cmLocalVisualStudio7Generator::WriteStampFiles() void cmLocalVisualStudio7Generator ::CreateSingleVCProj(const std::string& lname, cmTarget &target) { - this->FortranProject = - static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator) - ->TargetIsFortranOnly(target); - this->WindowsCEProject = - static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator) - ->TargetsWindowsCE(); + cmGlobalVisualStudioGenerator* gg + = static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator); + this->FortranProject = gg->TargetIsFortranOnly(target); + this->WindowsCEProject = gg->TargetsWindowsCE(); // Intel Fortran for VS10 uses VS9 format ".vfproj" files. - VSVersion realVersion = this->Version; - if(this->FortranProject && this->Version >= VS10) + cmGlobalVisualStudioGenerator::VSVersion realVersion = gg->GetVersion(); + if(this->FortranProject + && gg->GetVersion() >= cmGlobalVisualStudioGenerator::VS10) { - this->Version = VS9; + gg->SetVersion(cmGlobalVisualStudioGenerator::VS9); } // add to the list of projects @@ -282,7 +280,7 @@ void cmLocalVisualStudio7Generator this->GlobalGenerator->FileReplacedDuringGenerate(fname); } - this->Version = realVersion; + gg->SetVersion(realVersion); } //---------------------------------------------------------------------------- @@ -292,10 +290,8 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() stampName += "/"; stampName += cmake::GetCMakeFilesDirectoryPostSlash(); stampName += "generate.stamp"; - const char* dsprule = - this->Makefile->GetRequiredDefinition("CMAKE_COMMAND"); cmCustomCommandLine commandLine; - commandLine.push_back(dsprule); + commandLine.push_back(cmSystemTools::GetCMakeCommand()); std::string makefileIn = this->Makefile->GetCurrentSourceDirectory(); makefileIn += "/"; makefileIn += "CMakeLists.txt"; @@ -343,17 +339,14 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() } } -void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout, - const std::string& libName, - cmTarget &target) +void cmLocalVisualStudio7Generator::WriteConfigurations( + std::ostream& fout, std::vector<std::string> const& configs, + const std::string& libName, cmTarget &target + ) { - std::vector<std::string> *configs = - static_cast<cmGlobalVisualStudio7Generator *> - (this->GlobalGenerator)->GetConfigurations(); - fout << "\t<Configurations>\n"; - for( std::vector<std::string>::iterator i = configs->begin(); - i != configs->end(); ++i) + for (std::vector<std::string>::const_iterator i = configs.begin(); + i != configs.end(); ++i) { this->WriteConfiguration(fout, i->c_str(), libName, target); } @@ -773,7 +766,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, } Options targetOptions(this, t, table, - this->ExtraFlagTable); + gg->ExtraFlagTable); targetOptions.FixExceptionHandlingDefault(); std::string asmLocation = configName + "/"; targetOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str()); @@ -995,7 +988,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, // end of <Tool Name=VCMIDLTool // Check if we need the FAT32 workaround. - if(targetBuilds && this->Version >= VS8) + if(targetBuilds && this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8) { // Check the filesystem type where the target will be written. if(cmLVS6G_IsFAT(target.GetDirectory(configName).c_str())) @@ -1130,7 +1123,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, fout << "\t\t\t<Tool\n" << "\t\t\t\tName=\"" << tool << "\"\n"; - if(this->GetVersion() < VS8 || this->FortranProject) + if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS8 + || this->FortranProject) { std::ostringstream libdeps; this->Internal->OutputObjects(libdeps, &target); @@ -1190,7 +1184,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, // libraries which may be set by the user to something bad. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " << this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); - if(this->GetVersion() < VS8 || this->FortranProject) + if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS8 + || this->FortranProject) { this->Internal->OutputObjects(fout, &target, " "); } @@ -1218,7 +1213,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } if(this->WindowsCEProject) { - if(this->GetVersion() < VS9) + if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS9) { fout << "\t\t\t\tSubSystem=\"9\"\n"; } @@ -1288,7 +1283,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, // libraries which may be set by the user to something bad. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " << this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); - if(this->GetVersion() < VS8 || this->FortranProject) + if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS8 + || this->FortranProject) { this->Internal->OutputObjects(fout, &target, " "); } @@ -1316,7 +1312,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } if ( this->WindowsCEProject ) { - if(this->GetVersion() < VS9) + if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS9) { fout << "\t\t\t\tSubSystem=\"9\"\n"; } @@ -1469,10 +1465,8 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, const std::string& libName, cmTarget &target) { - // get the configurations - std::vector<std::string> *configs = - static_cast<cmGlobalVisualStudio7Generator *> - (this->GlobalGenerator)->GetConfigurations(); + std::vector<std::string> configs; + this->Makefile->GetConfigurations(configs); // We may be modifying the source groups temporarily, so make a copy. std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); @@ -1505,7 +1499,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // open the project this->WriteProjectStart(fout, libName, target, sourceGroups); // write the configuration information - this->WriteConfigurations(fout, libName, target); + this->WriteConfigurations(fout, configs, libName, target); fout << "\t<Files>\n"; @@ -1517,7 +1511,8 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, this->WriteGroup(&sg, target, fout, libName, configs); } - if(this->GetVersion() >= VS8 && !this->FortranProject) + if(this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8 + && !this->FortranProject) { // VS >= 8 support per-config source locations so we // list object library content as external objects. @@ -1561,7 +1556,7 @@ public: cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg, cmTarget& target, cmSourceFile const& sf, - std::vector<std::string>* configs); + std::vector<std::string> const& configs); std::map<std::string, cmLVS7GFileConfig> FileConfigMap; }; @@ -1569,7 +1564,7 @@ cmLocalVisualStudio7GeneratorFCInfo ::cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg, cmTarget& target, cmSourceFile const& sf, - std::vector<std::string>* configs) + std::vector<std::string> const& configs) { cmGeneratorTarget* gt = lg->GetGlobalGenerator()->GetGeneratorTarget(&target); @@ -1580,8 +1575,8 @@ cmLocalVisualStudio7GeneratorFCInfo } // Compute per-source, per-config information. - for(std::vector<std::string>::iterator i = configs->begin(); - i != configs->end(); ++i) + for(std::vector<std::string>::const_iterator i = configs.begin(); + i != configs.end(); ++i) { std::string configUpper = cmSystemTools::UpperCase(*i); cmLVS7GFileConfig fc; @@ -1691,13 +1686,13 @@ std::string cmLocalVisualStudio7Generator ::ComputeLongestObjectDirectory(cmTarget& target) const { - std::vector<std::string> *configs = - static_cast<cmGlobalVisualStudio7Generator *> - (this->GlobalGenerator)->GetConfigurations(); + std::vector<std::string> configs; + target.GetMakefile()->GetConfigurations(configs); + // Compute the maximum length configuration name. std::string config_max; - for(std::vector<std::string>::iterator i = configs->begin(); - i != configs->end(); ++i) + for(std::vector<std::string>::iterator i = configs.begin(); + i != configs.end(); ++i) { if(i->size() > config_max.size()) { @@ -1721,7 +1716,7 @@ cmLocalVisualStudio7Generator bool cmLocalVisualStudio7Generator ::WriteGroup(const cmSourceGroup *sg, cmTarget& target, std::ostream &fout, const std::string& libName, - std::vector<std::string> *configs) + std::vector<std::string> const& configs) { cmGlobalVisualStudio7Generator* gg = static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); @@ -1771,7 +1766,8 @@ bool cmLocalVisualStudio7Generator fout << "\t\t\t\tRelativePath=\"" << d << "\">\n"; if(cmCustomCommand const* command = (*sf)->GetCustomCommand()) { - this->WriteCustomRule(fout, source.c_str(), *command, fcinfo); + this->WriteCustomRule(fout, configs, source.c_str(), + *command, fcinfo); } else if(!fcinfo.FileConfigMap.empty()) { @@ -1842,7 +1838,7 @@ bool cmLocalVisualStudio7Generator table = cmLocalVisualStudio7GeneratorFortranFlagTable; } Options fileOptions(this, tool, table, - this->ExtraFlagTable); + gg->ExtraFlagTable); fileOptions.Parse(fc.CompileFlags.c_str()); fileOptions.AddDefines(fc.CompileDefs.c_str()); fileOptions.AddDefines(fc.CompileDefsConfig.c_str()); @@ -1887,6 +1883,7 @@ bool cmLocalVisualStudio7Generator void cmLocalVisualStudio7Generator:: WriteCustomRule(std::ostream& fout, + std::vector<std::string> const& configs, const char* source, const cmCustomCommand& command, FCInfo& fcinfo) @@ -1895,10 +1892,6 @@ WriteCustomRule(std::ostream& fout, static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); // Write the rule for each configuration. - std::vector<std::string>::iterator i; - std::vector<std::string> *configs = - static_cast<cmGlobalVisualStudio7Generator *> - (this->GlobalGenerator)->GetConfigurations(); const char* compileTool = "VCCLCompilerTool"; if(this->FortranProject) { @@ -1909,7 +1902,8 @@ WriteCustomRule(std::ostream& fout, { customTool = "VFCustomBuildTool"; } - for(i = configs->begin(); i != configs->end(); ++i) + for (std::vector<std::string>::const_iterator i = configs.begin(); + i != configs.end(); ++i) { cmCustomCommandGenerator ccg(command, *i, this->Makefile); cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i]; @@ -2149,13 +2143,13 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, << gg->Encoding() << "\"?>\n" << "<VisualStudioProject\n" << "\tProjectType=\"Visual C++\"\n"; - if(this->Version == VS71) + if(gg->GetVersion() == cmGlobalVisualStudioGenerator::VS71) { fout << "\tVersion=\"7.10\"\n"; } else { - fout << "\tVersion=\"" << (this->Version/10) << ".00\"\n"; + fout << "\tVersion=\"" << (gg->GetVersion()/10) << ".00\"\n"; } const char* projLabel = target.GetProperty("PROJECT_LABEL"); if(!projLabel) @@ -2168,7 +2162,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, keyword = "Win32Proj"; } fout << "\tName=\"" << projLabel << "\"\n"; - if(this->Version >= VS8) + if(gg->GetVersion() >= cmGlobalVisualStudioGenerator::VS8) { fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n"; } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 1891369..59c2144 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -35,7 +35,7 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio7Generator(VSVersion v, cmGlobalGenerator* gg, + cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmLocalGenerator* parent); virtual ~cmLocalVisualStudio7Generator(); @@ -54,8 +54,6 @@ public: */ void SetBuildType(BuildType,const std::string& name); - void SetExtraFlagTable(cmVS7FlagTable const* table) - { this->ExtraFlagTable = table; } virtual std::string GetTargetDirectory(cmTarget const&) const; cmSourceFile* CreateVCProjBuildRule(); void WriteStampFiles(); @@ -79,6 +77,7 @@ private: void WriteVCProjFile(std::ostream& fout, const std::string& libName, cmTarget &tgt); void WriteConfigurations(std::ostream& fout, + std::vector<std::string> const& configs, const std::string& libName, cmTarget &tgt); void WriteConfiguration(std::ostream& fout, const std::string& configName, @@ -103,6 +102,7 @@ private: void WriteVCProjEndGroup(std::ostream& fout); void WriteCustomRule(std::ostream& fout, + std::vector<std::string> const& configs, const char* source, const cmCustomCommand& command, FCInfo& fcinfo); @@ -111,7 +111,7 @@ private: bool WriteGroup(const cmSourceGroup *sg, cmTarget& target, std::ostream &fout, const std::string& libName, - std::vector<std::string> *configs); + std::vector<std::string> const& configs); friend class cmLocalVisualStudio7GeneratorFCInfo; friend class cmLocalVisualStudio7GeneratorInternals; @@ -119,7 +119,6 @@ private: class EventWriter; friend class EventWriter; - cmVS7FlagTable const* ExtraFlagTable; std::string ModuleDefinitionFile; bool FortranProject; bool WindowsCEProject; diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 4a596d5..f472bba 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -19,11 +19,10 @@ //---------------------------------------------------------------------------- cmLocalVisualStudioGenerator -::cmLocalVisualStudioGenerator(VSVersion v, cmGlobalGenerator* gg, +::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent) : cmLocalGenerator(gg, parent) { - this->Version = v; } //---------------------------------------------------------------------------- @@ -32,6 +31,15 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator() } //---------------------------------------------------------------------------- +cmGlobalVisualStudioGenerator::VSVersion +cmLocalVisualStudioGenerator::GetVersion() const +{ + cmGlobalVisualStudioGenerator* gg = + static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator); + return gg->GetVersion(); +} + +//---------------------------------------------------------------------------- void cmLocalVisualStudioGenerator::ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, cmGeneratorTarget const* gt) @@ -91,7 +99,7 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target, // Add a pre-build event to create the directory. cmCustomCommandLine command; - command.push_back(this->Makefile->GetRequiredDefinition("CMAKE_COMMAND")); + command.push_back(cmSystemTools::GetCMakeCommand()); command.push_back("-E"); command.push_back("make_directory"); command.push_back(impDir); diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 1152e82..df7d20c 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -13,6 +13,7 @@ #define cmLocalVisualStudioGenerator_h #include "cmLocalGenerator.h" +#include "cmGlobalVisualStudioGenerator.h" #include <cmsys/auto_ptr.hxx> @@ -30,22 +31,7 @@ class cmCustomCommandGenerator; class cmLocalVisualStudioGenerator : public cmLocalGenerator { public: - /** Known versions of Visual Studio. */ - enum VSVersion - { - VS6 = 60, - VS7 = 70, - VS71 = 71, - VS8 = 80, - VS9 = 90, - VS10 = 100, - VS11 = 110, - VS12 = 120, - /* VS13 = 130 was skipped */ - VS14 = 140 - }; - - cmLocalVisualStudioGenerator(VSVersion v, cmGlobalGenerator* gg, + cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent); virtual ~cmLocalVisualStudioGenerator(); @@ -57,8 +43,7 @@ public: sequence of custom commands. */ const char* GetReportErrorLabel() const; - /** Version of Visual Studio. */ - VSVersion GetVersion() const { return this->Version; } + cmGlobalVisualStudioGenerator::VSVersion GetVersion() const; virtual std::string ComputeLongestObjectDirectory(cmTarget&) const = 0; @@ -76,8 +61,6 @@ protected: cmsys::auto_ptr<cmCustomCommand> MaybeCreateImplibDir(cmTarget& target, const std::string& config, bool isFortran); - - VSVersion Version; }; #endif diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7b8d3af..3e8ae85 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -38,7 +38,6 @@ #include <cmsys/FStream.hxx> #include <cmsys/auto_ptr.hxx> -#include <stack> #include <list> #include <ctype.h> // for isspace #include <assert.h> @@ -47,8 +46,6 @@ class cmMakefile::Internals { public: std::list<cmDefinitions> VarStack; - std::stack<std::set<std::string> > VarInitStack; - std::stack<std::set<std::string> > VarUsageStack; bool IsSourceFileTryCompile; void PushDefinitions() @@ -69,6 +66,12 @@ public: this->VarStack.rend()); } + bool IsInitialized(std::string const& name) + { + return cmDefinitions::HasKey(name, this->VarStack.rbegin(), + this->VarStack.rend()); + } + void SetDefinition(std::string const& name, std::string const& value) { this->VarStack.back().Set(name, value.c_str()); @@ -76,34 +79,18 @@ public: void RemoveDefinition(std::string const& name) { - if (this->VarStack.size() > 1) - { - // In lower scopes we store keys, defined or not. - this->VarStack.back().Set(name, 0); - } - else - { - this->VarStack.back().Erase(name); - } + this->VarStack.back().Set(name, 0); } - std::vector<std::string> LocalKeys() const + std::vector<std::string> UnusedKeys() const { - return this->VarStack.back().LocalKeys(); + return this->VarStack.back().UnusedKeys(); } std::vector<std::string> ClosureKeys() const { - std::vector<std::string> closureKeys; - std::set<std::string> bound; - for (std::list<cmDefinitions>::const_reverse_iterator it = - this->VarStack.rbegin(); it != this->VarStack.rend(); ++it) - { - std::vector<std::string> const& localKeys = it->ClosureKeys(bound); - closureKeys.insert(closureKeys.end(), - localKeys.begin(), localKeys.end()); - } - return closureKeys; + return cmDefinitions::ClosureKeys(this->VarStack.rbegin(), + this->VarStack.rend()); } void PopDefinitions() @@ -113,35 +100,32 @@ public: bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf) { - assert(this->VarStack.size() > 0); - std::list<cmDefinitions>::reverse_iterator it = this->VarStack.rbegin(); + assert(it != this->VarStack.rend()); ++it; if(it == this->VarStack.rend()) { - if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent()) + cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent(); + if(!plg) { - // Update the definition in the parent directory top scope. This - // directory's scope was initialized by the closure of the parent - // scope, so we do not need to localize the definition first. - cmMakefile* parent = plg->GetMakefile(); - if (varDef) - { - parent->AddDefinition(var, varDef); - } - else - { - parent->RemoveDefinition(var); - } - return true; + return false; + } + // Update the definition in the parent directory top scope. This + // directory's scope was initialized by the closure of the parent + // scope, so we do not need to localize the definition first. + cmMakefile* parent = plg->GetMakefile(); + if (varDef) + { + parent->AddDefinition(var, varDef); } else { - return false; + parent->RemoveDefinition(var); } + return true; } // First localize the definition in the current scope. - this->GetDefinition(var); + cmDefinitions::Raise(var, this->VarStack.rbegin(), this->VarStack.rend()); // Now update the definition in the parent scope. it->Set(var, varDef); @@ -156,13 +140,11 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) StateSnapshot(localGenerator->GetStateSnapshot()) { this->Internal->PushDefinitions(); - this->Internal->VarInitStack.push(std::set<std::string>()); - this->Internal->VarUsageStack.push(std::set<std::string>()); this->Internal->IsSourceFileTryCompile = false; // Initialize these first since AddDefaultDefinitions calls AddDefinition - this->WarnUnused = false; - this->CheckSystemVars = false; + this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused(); + this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars(); this->GeneratingBuildSystem = false; this->SuppressWatches = false; @@ -232,24 +214,16 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) #endif this->Properties.SetCMakeInstance(this->GetCMakeInstance()); - this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused(); - this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars(); { const char* dir = this->GetCMakeInstance()->GetHomeDirectory(); this->AddDefinition("CMAKE_SOURCE_DIR", dir); - if ( !this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR") ) - { - this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir); - } + this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir); } { const char* dir = this->GetCMakeInstance()->GetHomeOutputDirectory(); this->AddDefinition("CMAKE_BINARY_DIR", dir); - if ( !this->GetDefinition("CMAKE_CURRENT_BINARY_DIR") ) - { - this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir); - } + this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir); } } @@ -270,77 +244,18 @@ cmMakefile::~cmMakefile() } } -void cmMakefile::PrintStringVector(const char* s, - const std::vector<std::string>& v) const -{ - std::cout << s << ": ( \n" << cmWrap('"', v, '"', " ") << ")\n"; -} - -void cmMakefile -::PrintStringVector(const char* s, - const std::vector<std::pair<std::string, bool> >& v) const -{ - std::cout << s << ": ( \n"; - for(std::vector<std::pair<std::string, bool> >::const_iterator i - = v.begin(); i != v.end(); ++i) - { - std::cout << i->first << " " << i->second; - } - std::cout << " )\n"; -} - - -// call print on all the classes in the makefile -void cmMakefile::Print() const -{ - // print the class lists - std::cout << "classes:\n"; - - std::cout << " this->Targets: "; - for (cmTargets::iterator l = this->Targets.begin(); - l != this->Targets.end(); l++) - { - std::cout << l->first << std::endl; - } - - std::cout << " this->StartOutputDirectory; " << - this->GetCurrentBinaryDirectory() << std::endl; - std::cout << " this->HomeOutputDirectory; " << - this->GetHomeOutputDirectory() << std::endl; - std::cout << " this->cmStartDirectory; " << - this->GetCurrentSourceDirectory() << std::endl; - std::cout << " this->cmHomeDirectory; " << - this->GetHomeDirectory() << std::endl; - std::cout << " this->ProjectName; " - << this->ProjectName << std::endl; - this->PrintStringVector("this->LinkDirectories", this->LinkDirectories); -#if defined(CMAKE_BUILD_WITH_CMAKE) - for( std::vector<cmSourceGroup>::const_iterator i = - this->SourceGroups.begin(); i != this->SourceGroups.end(); ++i) - { - std::cout << "Source Group: " << i->GetName() << std::endl; - } -#endif -} - //---------------------------------------------------------------------------- void cmMakefile::IssueMessage(cmake::MessageType t, std::string const& text) const { // Collect context information. - cmLocalGenerator* localGen = this->GetLocalGenerator(); - if(this->CallStack.empty() && this->GetCMakeInstance()->GetIsInTryCompile()) - { - localGen = 0; - } - cmListFileBacktrace backtrace(localGen); if(!this->CallStack.empty()) { if((t == cmake::FATAL_ERROR) || (t == cmake::INTERNAL_ERROR)) { this->CallStack.back().Status->SetNestedError(true); } - backtrace = this->GetBacktrace(); + this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace()); } else { @@ -357,12 +272,15 @@ void cmMakefile::IssueMessage(cmake::MessageType t, // command. Add whatever context information we have. lfc.FilePath = this->ListFileStack.back(); } + if(!this->CallStack.empty() + || !this->GetCMakeInstance()->GetIsInTryCompile()) + { + lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath, + cmLocalGenerator::HOME); + } lfc.Line = 0; - backtrace.push_back(lfc); + this->GetCMakeInstance()->IssueMessage(t, text, lfc); } - - // Issue the message. - this->GetCMakeInstance()->IssueMessage(t, text, backtrace); } //---------------------------------------------------------------------------- @@ -372,12 +290,18 @@ cmListFileBacktrace cmMakefile::GetBacktrace() const for(CallStackType::const_reverse_iterator i = this->CallStack.rbegin(); i != this->CallStack.rend(); ++i) { - backtrace.push_back(*i->Context); + backtrace.Append(*i->Context); } return backtrace; } //---------------------------------------------------------------------------- +cmListFileContext cmMakefile::GetExecutionContext() const +{ + return *this->CallStack.back().Context; +} + +//---------------------------------------------------------------------------- void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const { std::ostringstream msg; @@ -603,7 +527,6 @@ void cmMakefile::IncludeScope::EnforceCMP0011() bool cmMakefile::ProcessBuildsystemFile(const char* listfile) { this->AddDefinition("CMAKE_PARENT_LIST_FILE", listfile); - this->cmCurrentListFile = listfile; std::string curSrc = this->GetCurrentSourceDirectory(); return this->ReadListFile(listfile, true, curSrc == this->GetHomeDirectory()); @@ -611,17 +534,16 @@ bool cmMakefile::ProcessBuildsystemFile(const char* listfile) bool cmMakefile::ReadDependentFile(const char* listfile, bool noPolicyScope) { - this->AddDefinition("CMAKE_PARENT_LIST_FILE", this->GetCurrentListFile()); - this->cmCurrentListFile = - cmSystemTools::CollapseFullPath(listfile, - this->GetCurrentSourceDirectory()); - return this->ReadListFile(this->cmCurrentListFile.c_str(), - noPolicyScope); + this->AddDefinition("CMAKE_PARENT_LIST_FILE", + this->GetDefinition("CMAKE_CURRENT_LIST_FILE")); + return this->ReadListFile(listfile, noPolicyScope, false); +} + +bool cmMakefile::ReadListFile(const char* listfile) +{ + return this->ReadListFile(listfile, true, false); } -//---------------------------------------------------------------------------- -// Parse the given CMakeLists.txt file executing all commands -// bool cmMakefile::ReadListFile(const char* listfile, bool noPolicyScope, bool requireProjectCommand) @@ -660,7 +582,6 @@ bool cmMakefile::ReadListFile(const char* listfile, if (res) { - // Check for unused variables this->CheckForUnusedVariables(); } @@ -1706,7 +1627,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, // create a new local generator and set its parent cmLocalGenerator *lg2 = this->GetGlobalGenerator() - ->CreateLocalGenerator(this->LocalGenerator); + ->MakeLocalGenerator(this->LocalGenerator); this->GetGlobalGenerator()->AddLocalGenerator(lg2); // set the subdirs start dirs @@ -1795,14 +1716,11 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value) return; } - this->Internal->SetDefinition(name, value); - if (!this->Internal->VarUsageStack.empty() && - this->VariableInitialized(name)) + if (this->VariableInitialized(name)) { - this->CheckForUnused("changing definition", name); - this->Internal->VarUsageStack.top().erase(name); + this->LogUnused("changing definition", name); } - this->Internal->VarInitStack.top().insert(name); + this->Internal->SetDefinition(name, value); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); @@ -1871,14 +1789,11 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, void cmMakefile::AddDefinition(const std::string& name, bool value) { - this->Internal->SetDefinition(name, value ? "ON" : "OFF"); - if (!this->Internal->VarUsageStack.empty() && - this->VariableInitialized(name)) + if (this->VariableInitialized(name)) { - this->CheckForUnused("changing definition", name); - this->Internal->VarUsageStack.top().erase(name); + this->LogUnused("changing definition", name); } - this->Internal->VarInitStack.top().insert(name); + this->Internal->SetDefinition(name, value ? "ON" : "OFF"); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) @@ -1895,61 +1810,46 @@ void cmMakefile::CheckForUnusedVariables() const { return; } - const std::vector<std::string>& locals = this->Internal->LocalKeys(); - std::vector<std::string>::const_iterator it = locals.begin(); - for (; it != locals.end(); ++it) + const std::vector<std::string>& unused = this->Internal->UnusedKeys(); + std::vector<std::string>::const_iterator it = unused.begin(); + for (; it != unused.end(); ++it) { - this->CheckForUnused("out of scope", *it); + this->LogUnused("out of scope", *it); } } void cmMakefile::MarkVariableAsUsed(const std::string& var) { - this->Internal->VarUsageStack.top().insert(var); + this->Internal->GetDefinition(var); } bool cmMakefile::VariableInitialized(const std::string& var) const { - if(this->Internal->VarInitStack.top().find(var) != - this->Internal->VarInitStack.top().end()) - { - return true; - } - return false; + return this->Internal->IsInitialized(var); } -bool cmMakefile::VariableUsed(const std::string& var) const -{ - if(this->Internal->VarUsageStack.top().find(var) != - this->Internal->VarUsageStack.top().end()) - { - return true; - } - return false; -} - -void cmMakefile::CheckForUnused(const char* reason, +void cmMakefile::LogUnused(const char* reason, const std::string& name) const { - if (this->WarnUnused && !this->VariableUsed(name)) + if (this->WarnUnused) { std::string path; - cmListFileBacktrace bt(this->GetLocalGenerator()); + cmListFileContext lfc; if (!this->CallStack.empty()) { - const cmListFileContext* file = this->CallStack.back().Context; - bt.push_back(*file); - path = file->FilePath.c_str(); + lfc = this->GetExecutionContext(); + path = lfc.FilePath; } else { path = this->GetCurrentSourceDirectory(); path += "/CMakeLists.txt"; - cmListFileContext lfc; lfc.FilePath = path; lfc.Line = 0; - bt.push_back(lfc); } + lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath, + cmLocalGenerator::HOME); + if (this->CheckSystemVars || cmSystemTools::IsSubDirectory(path, this->GetHomeDirectory()) || @@ -1962,21 +1862,18 @@ void cmMakefile::CheckForUnused(const char* reason, msg << "unused variable (" << reason << ") \'" << name << "\'"; this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, msg.str(), - bt); + lfc); } } } void cmMakefile::RemoveDefinition(const std::string& name) { - this->Internal->RemoveDefinition(name); - if (!this->Internal->VarUsageStack.empty() && - this->VariableInitialized(name)) + if (this->VariableInitialized(name)) { - this->CheckForUnused("unsetting", name); - this->Internal->VarUsageStack.top().erase(name); + this->LogUnused("unsetting", name); } - this->Internal->VarInitStack.top().insert(name); + this->Internal->RemoveDefinition(name); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) @@ -2443,7 +2340,6 @@ const char* cmMakefile::GetRequiredDefinition(const std::string& name) const bool cmMakefile::IsDefinitionSet(const std::string& name) const { const char* def = this->Internal->GetDefinition(name); - this->Internal->VarUsageStack.top().insert(name); if(!def) { def = this->GetState()->GetInitializedCacheValue(name); @@ -2464,10 +2360,6 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const const char* cmMakefile::GetDefinition(const std::string& name) const { - if (this->WarnUnused) - { - this->Internal->VarUsageStack.top().insert(name); - } const char* def = this->Internal->GetDefinition(name); if(!def) { @@ -2874,14 +2766,13 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew( this->GetHomeOutputDirectory())) { std::ostringstream msg; - cmListFileBacktrace bt(this->GetLocalGenerator()); cmListFileContext lfc; - lfc.FilePath = filename; + lfc.FilePath = this->LocalGenerator + ->Convert(filename, cmLocalGenerator::HOME); lfc.Line = line; - bt.push_back(lfc); msg << "uninitialized variable \'" << lookup << "\'"; this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, - msg.str(), bt); + msg.str(), lfc); } } } @@ -3276,6 +3167,7 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError) this->FunctionBlockerBarriers.back(); while(this->FunctionBlockers.size() > barrier) { + cmMakefile::LoopBlockPop loopBlockPop(this); cmsys::auto_ptr<cmFunctionBlocker> fb(this->FunctionBlockers.back()); this->FunctionBlockers.pop_back(); if(reportError) @@ -3410,7 +3302,7 @@ void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb) if(!this->CallStack.empty()) { // Record the context in which the blocker is created. - fb->SetStartingContext(*(this->CallStack.back().Context)); + fb->SetStartingContext(this->GetExecutionContext()); } this->FunctionBlockers.push_back(fb); @@ -3576,7 +3468,6 @@ int cmMakefile::TryCompile(const std::string& srcdir, // make sure the same generator is used // use this program as the cmake to be run, it should not // be run that way but the cmake object requires a vailid path - std::string cmakeCommand = this->GetDefinition("CMAKE_COMMAND"); cmake cm; cm.SetIsInTryCompile(true); cmGlobalGenerator *gg = cm.CreateGlobalGenerator @@ -4365,13 +4256,13 @@ void cmMakefile::AddCMakeDependFilesFromUser() } } -std::string cmMakefile::GetListFileStack() const +std::string cmMakefile::FormatListFileStack() const { std::ostringstream tmp; size_t depth = this->ListFileStack.size(); if (depth > 0) { - std::deque<std::string>::const_iterator it = this->ListFileStack.end(); + std::vector<std::string>::const_iterator it = this->ListFileStack.end(); do { if (depth != this->ListFileStack.size()) @@ -4394,10 +4285,6 @@ std::string cmMakefile::GetListFileStack() const void cmMakefile::PushScope() { this->Internal->PushDefinitions(); - const std::set<std::string>& init = this->Internal->VarInitStack.top(); - const std::set<std::string>& usage = this->Internal->VarUsageStack.top(); - this->Internal->VarInitStack.push(init); - this->Internal->VarUsageStack.push(usage); this->PushLoopBlockBarrier(); @@ -4414,31 +4301,9 @@ void cmMakefile::PopScope() this->PopLoopBlockBarrier(); - std::set<std::string> init = this->Internal->VarInitStack.top(); - std::set<std::string> usage = this->Internal->VarUsageStack.top(); - const std::vector<std::string>& locals = this->Internal->LocalKeys(); - // Remove initialization and usage information for variables in the local - // scope. - std::vector<std::string>::const_iterator it = locals.begin(); - for (; it != locals.end(); ++it) - { - init.erase(*it); - if (!this->VariableUsed(*it)) - { - this->CheckForUnused("out of scope", *it); - } - else - { - usage.erase(*it); - } - } + this->CheckForUnusedVariables(); this->Internal->PopDefinitions(); - this->Internal->VarInitStack.pop(); - this->Internal->VarUsageStack.pop(); - // Push initialization and usage up to the parent scope. - this->Internal->VarInitStack.top().insert(init.begin(), init.end()); - this->Internal->VarUsageStack.top().insert(usage.begin(), usage.end()); } void cmMakefile::RaiseScope(const std::string& var, const char *varDef) @@ -4935,20 +4800,9 @@ bool cmMakefile::SetPolicyVersion(const char *version) } //---------------------------------------------------------------------------- -bool cmMakefile::HasCMP0054AlreadyBeenReported( - cmListFileContext context) const +bool cmMakefile::HasCMP0054AlreadyBeenReported() const { - cmCMP0054Id id(context); - - bool alreadyReported = - this->CMP0054ReportedIds.find(id) != this->CMP0054ReportedIds.end(); - - if(!alreadyReported) - { - this->CMP0054ReportedIds.insert(id); - } - - return alreadyReported; + return !this->CMP0054ReportedIds.insert(this->GetExecutionContext()).second; } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index e0eef6f..efd73a1 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -31,11 +31,14 @@ #include <cmsys/auto_ptr.hxx> #include <cmsys/RegularExpression.hxx> #if defined(CMAKE_BUILD_WITH_CMAKE) -# include <cmsys/hash_map.hxx> +# ifdef CMake_HAVE_CXX11_UNORDERED_MAP +# include <unordered_map> +# else +# include <cmsys/hash_map.hxx> +# endif #endif #include <stack> -#include <deque> class cmFunctionBlocker; class cmCommand; @@ -62,14 +65,10 @@ class cmMakefile class Internals; cmsys::auto_ptr<Internals> Internal; public: - /* Check for unused variables in this scope */ - void CheckForUnusedVariables() const; /* Mark a variable as used */ void MarkVariableAsUsed(const std::string& var); /* return true if a variable has been initialized */ bool VariableInitialized(const std::string& ) const; - /* return true if a variable has been used */ - bool VariableUsed(const std::string& ) const; /** * Construct an empty makefile. @@ -81,12 +80,7 @@ public: */ ~cmMakefile(); - /** - * Read and parse a CMakeLists.txt file. - */ - bool ReadListFile(const char* listfile, - bool noPolicyScope = true, - bool requireProjectCommand = false); + bool ReadListFile(const char* listfile); bool ReadDependentFile(const char* listfile, bool noPolicyScope = true); @@ -159,11 +153,6 @@ public: */ void FinalPass(); - /** - * Print the object state to std::cout. - */ - void Print() const; - /** Add a custom command to the build. */ void AddCustomCommandToTarget(const std::string& target, const std::vector<std::string>& byproducts, @@ -387,33 +376,13 @@ public: */ cmPolicies *GetPolicies() const; - struct cmCMP0054Id - { - cmCMP0054Id(cmListFileContext const& context): - Context(context) - { - - } - - bool operator< (cmCMP0054Id const& id) const - { - if(this->Context.FilePath != id.Context.FilePath) - return this->Context.FilePath < id.Context.FilePath; - - return this->Context.Line < id.Context.Line; - } - - cmListFileContext Context; - }; - - mutable std::set<cmCMP0054Id> CMP0054ReportedIds; + mutable std::set<cmListFileContext> CMP0054ReportedIds; /** * Determine if the given context, name pair has already been reported * in context of CMP0054. */ - bool HasCMP0054AlreadyBeenReported( - cmListFileContext context) const; + bool HasCMP0054AlreadyBeenReported() const; bool IgnoreErrorsCMP0061() const; @@ -435,14 +404,6 @@ public: void SetCurrentBinaryDirectory(const std::string& dir); const char* GetCurrentBinaryDirectory() const; - /* Get the current CMakeLists.txt file that is being processed. This - * is just used in order to be able to 'branch' from one file to a second - * transparently */ - const char* GetCurrentListFile() const - { - return this->cmCurrentListFile.c_str(); - } - //@} /** @@ -605,12 +566,13 @@ public: { this->ListFiles.push_back(file);} void AddCMakeDependFilesFromUser(); - std::string GetListFileStack() const; + std::string FormatListFileStack() const; /** * Get the current context backtrace. */ cmListFileBacktrace GetBacktrace() const; + cmListFileContext GetExecutionContext() const; /** * Get the vector of files created by this makefile @@ -859,16 +821,18 @@ protected: void AddGlobalLinkInformation(const std::string& name, cmTarget& target); // Check for a an unused variable - void CheckForUnused(const char* reason, const std::string& name) const; - - std::string cmCurrentListFile; + void LogUnused(const char* reason, const std::string& name) const; std::string ProjectName; // project name // libraries, classes, and executables mutable cmTargets Targets; #if defined(CMAKE_BUILD_WITH_CMAKE) +#ifdef CMake_HAVE_CXX11_UNORDERED_MAP + typedef std::unordered_map<std::string, cmTarget*> TargetMap; +#else typedef cmsys::hash_map<std::string, cmTarget*> TargetMap; +#endif #else typedef std::map<std::string, cmTarget*> TargetMap; #endif @@ -924,6 +888,10 @@ private: cmState::Snapshot StateSnapshot; + bool ReadListFile(const char* listfile, + bool noPolicyScope, + bool requireProjectCommand); + bool ReadListFileInternal(const char* filenametoread, bool noPolicyScope, bool requireProjectCommand); @@ -935,10 +903,6 @@ private: friend class cmMakeDepend; // make depend needs direct access // to the Sources array - void PrintStringVector(const char* s, const - std::vector<std::pair<std::string, bool> >& v) const; - void PrintStringVector(const char* s, - const std::vector<std::string>& v) const; void AddDefaultDefinitions(); typedef std::vector<cmFunctionBlocker*> FunctionBlockersType; @@ -963,7 +927,7 @@ private: bool CheckSystemVars; // stack of list files being read - std::deque<std::string> ListFileStack; + std::vector<std::string> ListFileStack; // stack of commands being invoked. struct CallStackEntry @@ -971,7 +935,7 @@ private: cmListFileContext const* Context; cmExecutionStatus* Status; }; - typedef std::deque<CallStackEntry> CallStackType; + typedef std::vector<CallStackEntry> CallStackType; CallStackType CallStack; friend class cmMakefileCall; @@ -1041,7 +1005,11 @@ private: // A map for fast output to input look up. #if defined(CMAKE_BUILD_WITH_CMAKE) +#ifdef CMake_HAVE_CXX11_UNORDERED_MAP + typedef std::unordered_map<std::string, cmSourceFile*> OutputToSourceMap; +#else typedef cmsys::hash_map<std::string, cmSourceFile*> OutputToSourceMap; +#endif #else typedef std::map<std::string, cmSourceFile*> OutputToSourceMap; #endif @@ -1070,6 +1038,8 @@ private: bool HaveCxxStandardAvailable(cmTarget const* target, const std::string& feature) const; + void CheckForUnusedVariables() const; + mutable bool SuppressWatches; }; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index c001622..450f573 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -626,7 +626,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules install_name_dir = this->LocalGenerator->Convert(install_name_dir, cmLocalGenerator::NONE, - cmLocalGenerator::SHELL, false); + cmLocalGenerator::SHELL); vars.TargetInstallNameDir = install_name_dir.c_str(); } } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b28a701..7b88bc7 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -226,7 +226,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() dependFileNameFull += "/depend.make"; *this->BuildFileStream << "# Include any dependencies generated for this target.\n" - << this->LocalGenerator->IncludeDirective << " " << root + << this->GlobalGenerator->IncludeDirective << " " << root << this->Convert(dependFileNameFull, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKERULE) @@ -237,7 +237,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() // Include the progress variables for the target. *this->BuildFileStream << "# Include the progress variables for this target.\n" - << this->LocalGenerator->IncludeDirective << " " << root + << this->GlobalGenerator->IncludeDirective << " " << root << this->Convert(this->ProgressFileNameFull, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKERULE) @@ -270,7 +270,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() // Include the flags for the target. *this->BuildFileStream << "# Include the compile flags for this target's objects.\n" - << this->LocalGenerator->IncludeDirective << " " << root + << this->GlobalGenerator->IncludeDirective << " " << root << this->Convert(this->FlagFileNameFull, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKERULE) diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index 617214f..25d929c 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -51,7 +51,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() // Include the progress variables for the target. *this->BuildFileStream << "# Include the progress variables for this target.\n" - << this->LocalGenerator->IncludeDirective << " " << root + << this->GlobalGenerator->IncludeDirective << " " << root << this->Convert(this->ProgressFileNameFull, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKERULE) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 7f9c09f..bbf03ff 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -282,8 +282,7 @@ cmNinjaNormalTargetGenerator !this->GetTarget()->IsFrameworkOnApple()) { std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat( - this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"), - cmLocalGenerator::SHELL); + cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); if (targetType == cmTarget::EXECUTABLE) this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_EXECUTABLE", cmakeCommand + @@ -337,8 +336,7 @@ cmNinjaNormalTargetGenerator { std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat( - mf->GetRequiredDefinition("CMAKE_COMMAND"), - cmLocalGenerator::SHELL); + cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); linkCmds.push_back(cmakeCommand + " -E remove $TARGET_FILE"); } // TODO: Use ARCHIVE_APPEND for archives over a certain size. @@ -527,8 +525,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() { vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir, cmLocalGenerator::NONE, - cmLocalGenerator::SHELL, - false); + cmLocalGenerator::SHELL); } } } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 457de11..add5e61 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -20,7 +20,7 @@ #include "cmAlgorithms.h" #if defined(_WIN32) && !defined(__CYGWIN__) -# include "cmLocalVisualStudioGenerator.h" +# include "cmGlobalVisualStudioGenerator.h" #endif #include <sys/stat.h> @@ -320,7 +320,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) std::string targetDir = getAutogenTargetDir(target); cmCustomCommandLine currentLine; - currentLine.push_back(makefile->GetSafeDefinition("CMAKE_COMMAND")); + currentLine.push_back(cmSystemTools::GetCMakeCommand()); currentLine.push_back("-E"); currentLine.push_back("cmake_autogen"); currentLine.push_back(targetDir); @@ -372,13 +372,13 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) cmGlobalGenerator* gg = localGen->GetGlobalGenerator(); if(gg->GetName().find("Visual Studio") != std::string::npos) { - cmLocalVisualStudioGenerator* vslg = - static_cast<cmLocalVisualStudioGenerator*>(localGen); + 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 = vslg->GetVersion() >= cmLocalVisualStudioGenerator::VS7; + usePRE_BUILD = vsgg->GetVersion() >= cmGlobalVisualStudioGenerator::VS7; if(usePRE_BUILD) { for (std::vector<std::string>::iterator it = depends.begin(); @@ -1203,23 +1203,6 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) return std::string(); } -static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, - const std::string& targetDirectory) -{ - cmGlobalGenerator* gg = new cmGlobalGenerator(); - gg->SetCMakeInstance(cm); - - cm->SetHomeOutputDirectory(targetDirectory); - cm->SetHomeDirectory(targetDirectory); - - cmLocalGenerator* lg = gg->CreateLocalGenerator(); - lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); - lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); - gg->SetCurrentLocalGenerator(lg); - - return gg; -} - bool cmQtAutoGenerators::Run(const std::string& targetDirectory, const std::string& config) { @@ -1227,25 +1210,27 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cmake cm; cm.SetHomeOutputDirectory(targetDirectory); cm.SetHomeDirectory(targetDirectory); - cmGlobalGenerator* gg = CreateGlobalGenerator(&cm, targetDirectory); - cmMakefile* makefile = gg->GetCurrentLocalGenerator()->GetMakefile(); + cmGlobalGenerator gg; + gg.SetCMakeInstance(&cm); + + cmLocalGenerator* lg = gg.MakeLocalGenerator(); + lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); + lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); + gg.SetCurrentLocalGenerator(lg); - this->ReadAutogenInfoFile(makefile, targetDirectory, config); - this->ReadOldMocDefinitionsFile(makefile, targetDirectory); + this->ReadAutogenInfoFile(lg->GetMakefile(), targetDirectory, config); + this->ReadOldMocDefinitionsFile(lg->GetMakefile(), targetDirectory); this->Init(); if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") { - success = this->RunAutogen(makefile); + success = this->RunAutogen(lg->GetMakefile()); } this->WriteOldMocDefinitionsFile(targetDirectory); - delete gg->GetCurrentLocalGenerator(); - delete gg; - gg = NULL; - makefile = NULL; + delete lg; return success; } diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 82a2939..4965ae3 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -197,6 +197,10 @@ void cmState::Initialize() this->Locations.clear(); this->OutputLocations.clear(); this->ParentPositions.clear(); + this->CurrentSourceDirectoryComponents.clear(); + this->CurrentBinaryDirectoryComponents.clear(); + this->RelativePathTopSource.clear(); + this->RelativePathTopBinary.clear(); this->CreateSnapshot(Snapshot()); this->DefineProperty @@ -458,6 +462,10 @@ void cmState::SetSourceDirectory(std::string const& sourceDirectory) { this->SourceDirectory = sourceDirectory; cmSystemTools::ConvertToUnixSlashes(this->SourceDirectory); + + cmSystemTools::SplitPath( + cmSystemTools::CollapseFullPath(this->SourceDirectory), + this->SourceDirectoryComponents); } const char* cmState::GetSourceDirectory() const @@ -465,10 +473,19 @@ const char* cmState::GetSourceDirectory() const return this->SourceDirectory.c_str(); } +std::vector<std::string> const& cmState::GetSourceDirectoryComponents() const +{ + return this->SourceDirectoryComponents; +} + void cmState::SetBinaryDirectory(std::string const& binaryDirectory) { this->BinaryDirectory = binaryDirectory; cmSystemTools::ConvertToUnixSlashes(this->BinaryDirectory); + + cmSystemTools::SplitPath( + cmSystemTools::CollapseFullPath(this->BinaryDirectory), + this->BinaryDirectoryComponents); } const char* cmState::GetBinaryDirectory() const @@ -476,12 +493,103 @@ const char* cmState::GetBinaryDirectory() const return this->BinaryDirectory.c_str(); } +std::vector<std::string> const& cmState::GetBinaryDirectoryComponents() const +{ + return this->BinaryDirectoryComponents; +} + +void cmState::Snapshot::ComputeRelativePathTopSource() +{ + // Relative path conversion inside the source tree is not used to + // construct relative paths passed to build tools so it is safe to use + // even when the source is a network path. + + cmState::Snapshot snapshot = *this; + std::vector<cmState::Snapshot> snapshots; + snapshots.push_back(snapshot); + while (true) + { + snapshot = snapshot.GetParent(); + if (snapshot.IsValid()) + { + snapshots.push_back(snapshot); + } + else + { + break; + } + } + + std::string result = snapshots.front().GetCurrentSourceDirectory(); + + for (std::vector<cmState::Snapshot>::const_iterator it = + snapshots.begin() + 1; it != snapshots.end(); ++it) + { + std::string currentSource = it->GetCurrentSourceDirectory(); + if(cmSystemTools::IsSubDirectory(result, currentSource)) + { + result = currentSource; + } + } + this->State->RelativePathTopSource[this->Position] = result; +} + +void cmState::Snapshot::ComputeRelativePathTopBinary() +{ + cmState::Snapshot snapshot = *this; + std::vector<cmState::Snapshot> snapshots; + snapshots.push_back(snapshot); + while (true) + { + snapshot = snapshot.GetParent(); + if (snapshot.IsValid()) + { + snapshots.push_back(snapshot); + } + else + { + break; + } + } + + std::string result = + snapshots.front().GetCurrentBinaryDirectory(); + + for (std::vector<cmState::Snapshot>::const_iterator it = + snapshots.begin() + 1; it != snapshots.end(); ++it) + { + std::string currentBinary = it->GetCurrentBinaryDirectory(); + if(cmSystemTools::IsSubDirectory(result, currentBinary)) + { + result = currentBinary; + } + } + + // The current working directory on Windows cannot be a network + // path. Therefore relative paths cannot work when the binary tree + // is a network path. + if(result.size() < 2 || result.substr(0, 2) != "//") + { + this->State->RelativePathTopBinary[this->Position] = result; + } + else + { + this->State->RelativePathTopBinary[this->Position] = ""; + } +} + cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot) { PositionType pos = this->ParentPositions.size(); this->ParentPositions.push_back(originSnapshot.Position); this->Locations.resize(this->Locations.size() + 1); this->OutputLocations.resize(this->OutputLocations.size() + 1); + this->CurrentSourceDirectoryComponents.resize( + this->CurrentSourceDirectoryComponents.size() + 1); + this->CurrentBinaryDirectoryComponents.resize( + this->CurrentBinaryDirectoryComponents.size() + 1); + this->RelativePathTopSource.resize(this->RelativePathTopSource.size() + 1); + this->RelativePathTopBinary.resize(this->RelativePathTopBinary.size() + 1); return cmState::Snapshot(this, pos); } @@ -505,6 +613,11 @@ void cmState::Snapshot::SetCurrentSourceDirectory(std::string const& dir) this->State->Locations[this->Position]); this->State->Locations[this->Position] = cmSystemTools::CollapseFullPath(this->State->Locations[this->Position]); + + cmSystemTools::SplitPath( + this->State->Locations[this->Position], + this->State->CurrentSourceDirectoryComponents[this->Position]); + this->ComputeRelativePathTopSource(); } const char* cmState::Snapshot::GetCurrentBinaryDirectory() const @@ -521,6 +634,43 @@ void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir) this->State->OutputLocations[this->Position] = cmSystemTools::CollapseFullPath( this->State->OutputLocations[this->Position]); + + cmSystemTools::SplitPath( + this->State->OutputLocations[this->Position], + this->State->CurrentBinaryDirectoryComponents[this->Position]); + this->ComputeRelativePathTopBinary(); +} + +std::vector<std::string> const& +cmState::Snapshot::GetCurrentSourceDirectoryComponents() +{ + return this->State->CurrentSourceDirectoryComponents[this->Position]; +} + +std::vector<std::string> const& +cmState::Snapshot::GetCurrentBinaryDirectoryComponents() +{ + return this->State->CurrentBinaryDirectoryComponents[this->Position]; +} + +const char* cmState::Snapshot::GetRelativePathTopSource() const +{ + return this->State->RelativePathTopSource[this->Position].c_str(); +} + +const char* cmState::Snapshot::GetRelativePathTopBinary() const +{ + return this->State->RelativePathTopBinary[this->Position].c_str(); +} + +void cmState::Snapshot::SetRelativePathTopSource(const char* dir) +{ + this->State->RelativePathTopSource[this->Position] = dir; +} + +void cmState::Snapshot::SetRelativePathTopBinary(const char* dir) +{ + this->State->RelativePathTopBinary[this->Position] = dir; } bool cmState::Snapshot::IsValid() const diff --git a/Source/cmState.h b/Source/cmState.h index ed58c64..23d3f0d 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -36,10 +36,22 @@ public: const char* GetCurrentBinaryDirectory() const; void SetCurrentBinaryDirectory(std::string const& dir); + std::vector<std::string> const& GetCurrentSourceDirectoryComponents(); + std::vector<std::string> const& GetCurrentBinaryDirectoryComponents(); + + const char* GetRelativePathTopSource() const; + const char* GetRelativePathTopBinary() const; + void SetRelativePathTopSource(const char* dir); + void SetRelativePathTopBinary(const char* dir); + bool IsValid() const; Snapshot GetParent() const; private: + void ComputeRelativePathTopSource(); + void ComputeRelativePathTopBinary(); + + private: friend class cmState; cmState* State; cmState::PositionType Position; @@ -123,6 +135,9 @@ public: const char* GetBinaryDirectory() const; void SetBinaryDirectory(std::string const& binaryDirectory); + std::vector<std::string> const& GetSourceDirectoryComponents() const; + std::vector<std::string> const& GetBinaryDirectoryComponents() const; + private: std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions; std::vector<std::string> EnabledLanguages; @@ -132,6 +147,19 @@ private: std::vector<std::string> Locations; std::vector<std::string> OutputLocations; std::vector<PositionType> ParentPositions; + + std::vector<std::vector<std::string> > CurrentSourceDirectoryComponents; + std::vector<std::vector<std::string> > CurrentBinaryDirectoryComponents; + // The top-most directories for relative path conversion. Both the + // source and destination location of a relative path conversion + // must be underneath one of these directories (both under source or + // both under binary) in order for the relative path to be evaluated + // safely by the build tools. + std::vector<std::string> RelativePathTopSource; + std::vector<std::string> RelativePathTopBinary; + + std::vector<std::string> SourceDirectoryComponents; + std::vector<std::string> BinaryDirectoryComponents; std::string SourceDirectory; std::string BinaryDirectory; bool IsInTryCompile; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7d0d216..70005b4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1241,8 +1241,11 @@ bool cmTarget::PushTLLCommandTrace(TLLSignature signature) ret = false; } } - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->TLLCommands.push_back(std::make_pair(signature, lfbt)); + cmListFileContext lfc = this->Makefile->GetExecutionContext(); + if (this->TLLCommands.empty() || this->TLLCommands.back().second != lfc) + { + this->TLLCommands.push_back(std::make_pair(signature, lfc)); + } return ret; } @@ -1250,39 +1253,19 @@ bool cmTarget::PushTLLCommandTrace(TLLSignature signature) void cmTarget::GetTllSignatureTraces(std::ostringstream &s, TLLSignature sig) const { - std::vector<cmListFileBacktrace> sigs; - typedef std::vector<std::pair<TLLSignature, cmListFileBacktrace> > Container; + const char *sigString = (sig == cmTarget::KeywordTLLSignature ? "keyword" + : "plain"); + s << "The uses of the " << sigString << " signature are here:\n"; + typedef std::vector<std::pair<TLLSignature, cmListFileContext> > Container; + cmLocalGenerator* lg = this->GetMakefile()->GetLocalGenerator(); for(Container::const_iterator it = this->TLLCommands.begin(); it != this->TLLCommands.end(); ++it) { if (it->first == sig) { - sigs.push_back(it->second); - } - } - if (!sigs.empty()) - { - const char *sigString - = (sig == cmTarget::KeywordTLLSignature ? "keyword" - : "plain"); - s << "The uses of the " << sigString << " signature are here:\n"; - UNORDERED_SET<std::string> emitted; - for(std::vector<cmListFileBacktrace>::iterator it = sigs.begin(); - it != sigs.end(); ++it) - { - it->MakeRelative(); - cmListFileBacktrace::const_iterator i = it->begin(); - if(i != it->end()) - { - cmListFileContext const& lfc = *i; - std::ostringstream line; - line << " * " << (lfc.Line? "": " in ") << lfc << std::endl; - if (emitted.insert(line.str()).second) - { - s << line.str(); - } - ++i; - } + cmListFileContext lfc = it->second; + lfc.FilePath = lg->Convert(lfc.FilePath, cmLocalGenerator::HOME); + s << " * " << lfc << std::endl; } } } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a032414..1a8b75a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -19,7 +19,11 @@ #include <cmsys/auto_ptr.hxx> #if defined(CMAKE_BUILD_WITH_CMAKE) -#include <cmsys/hash_map.hxx> +# ifdef CMake_HAVE_CXX11_UNORDERED_MAP +# include <unordered_map> +# else +# include <cmsys/hash_map.hxx> +# endif #endif #define CM_FOR_EACH_TARGET_POLICY(F) \ @@ -641,7 +645,7 @@ private: // directories. std::set<std::string> SystemIncludeDirectories; - std::vector<std::pair<TLLSignature, cmListFileBacktrace> > TLLCommands; + std::vector<std::pair<TLLSignature, cmListFileContext> > TLLCommands; #if defined(_WIN32) && !defined(__CYGWIN__) /** @@ -849,7 +853,11 @@ private: }; #ifdef CMAKE_BUILD_WITH_CMAKE -typedef cmsys::hash_map<std::string,cmTarget> cmTargets; +#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +typedef std::unordered_map<std::string, cmTarget> cmTargets; +#else +typedef cmsys::hash_map<std::string, cmTarget> cmTargets; +#endif #else typedef std::map<std::string,cmTarget> cmTargets; #endif diff --git a/Source/cmTest.h b/Source/cmTest.h index c6e7e42..ca88afe 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -40,11 +40,6 @@ public: return this->Command; } - /** - * Print the structure to std::cout. - */ - void Print() const; - ///! Set/Get a property of this source file void SetProperty(const std::string& prop, const char *value); void AppendProperty(const std::string& prop, diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 3cd92cb..b9ffe5e 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -375,7 +375,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, comment += "Run arguments : "; comment += runArgs; comment += "\n"; - comment += " Called from: " + this->Makefile->GetListFileStack(); + comment += " Called from: " + this->Makefile->FormatListFileStack(); cmsys::SystemTools::ReplaceString(comment, "\n", "\n# "); file << comment << "\n\n"; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 131a134..5dfdb14 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -47,13 +47,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetClFlagTable() const { if(this->MSTools) { - cmLocalVisualStudioGenerator::VSVersion + cmGlobalVisualStudioGenerator::VSVersion v = this->LocalGenerator->GetVersion(); - if(v >= cmLocalVisualStudioGenerator::VS14) + if(v >= cmGlobalVisualStudioGenerator::VS14) { return cmVS14CLFlagTable; } - else if(v >= cmLocalVisualStudioGenerator::VS12) + else if(v >= cmGlobalVisualStudioGenerator::VS12) { return cmVS12CLFlagTable; } - else if(v == cmLocalVisualStudioGenerator::VS11) + else if(v == cmGlobalVisualStudioGenerator::VS11) { return cmVS11CLFlagTable; } else { return cmVS10CLFlagTable; } @@ -65,13 +65,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetRcFlagTable() const { if(this->MSTools) { - cmLocalVisualStudioGenerator::VSVersion + cmGlobalVisualStudioGenerator::VSVersion v = this->LocalGenerator->GetVersion(); - if(v >= cmLocalVisualStudioGenerator::VS14) + if(v >= cmGlobalVisualStudioGenerator::VS14) { return cmVS14RCFlagTable; } - else if(v >= cmLocalVisualStudioGenerator::VS12) + else if(v >= cmGlobalVisualStudioGenerator::VS12) { return cmVS12RCFlagTable; } - else if(v == cmLocalVisualStudioGenerator::VS11) + else if(v == cmGlobalVisualStudioGenerator::VS11) { return cmVS11RCFlagTable; } else { return cmVS10RCFlagTable; } @@ -83,13 +83,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLibFlagTable() const { if(this->MSTools) { - cmLocalVisualStudioGenerator::VSVersion + cmGlobalVisualStudioGenerator::VSVersion v = this->LocalGenerator->GetVersion(); - if(v >= cmLocalVisualStudioGenerator::VS14) + if(v >= cmGlobalVisualStudioGenerator::VS14) { return cmVS14LibFlagTable; } - else if(v >= cmLocalVisualStudioGenerator::VS12) + else if(v >= cmGlobalVisualStudioGenerator::VS12) { return cmVS12LibFlagTable; } - else if(v == cmLocalVisualStudioGenerator::VS11) + else if(v == cmGlobalVisualStudioGenerator::VS11) { return cmVS11LibFlagTable; } else { return cmVS10LibFlagTable; } @@ -101,13 +101,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLinkFlagTable() const { if(this->MSTools) { - cmLocalVisualStudioGenerator::VSVersion + cmGlobalVisualStudioGenerator::VSVersion v = this->LocalGenerator->GetVersion(); - if(v >= cmLocalVisualStudioGenerator::VS14) + if(v >= cmGlobalVisualStudioGenerator::VS14) { return cmVS14LinkFlagTable; } - else if(v >= cmLocalVisualStudioGenerator::VS12) + else if(v >= cmGlobalVisualStudioGenerator::VS12) { return cmVS12LinkFlagTable; } - else if(v == cmLocalVisualStudioGenerator::VS11) + else if(v == cmGlobalVisualStudioGenerator::VS11) { return cmVS11LinkFlagTable; } else { return cmVS10LinkFlagTable; } @@ -119,13 +119,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetMasmFlagTable() const { if(this->MSTools) { - cmLocalVisualStudioGenerator::VSVersion + cmGlobalVisualStudioGenerator::VSVersion v = this->LocalGenerator->GetVersion(); - if(v >= cmLocalVisualStudioGenerator::VS14) + if(v >= cmGlobalVisualStudioGenerator::VS14) { return cmVS14MASMFlagTable; } - else if(v >= cmLocalVisualStudioGenerator::VS12) + else if(v >= cmGlobalVisualStudioGenerator::VS12) { return cmVS12MASMFlagTable; } - else if(v == cmLocalVisualStudioGenerator::VS11) + else if(v == cmGlobalVisualStudioGenerator::VS11) { return cmVS11MASMFlagTable; } else { return cmVS10MASMFlagTable; } @@ -173,6 +173,7 @@ cmVisualStudio10TargetGenerator(cmTarget* target, this->Target = target; this->GeneratorTarget = gg->GetGeneratorTarget(target); this->Makefile = target->GetMakefile(); + this->Makefile->GetConfigurations(this->Configurations); this->LocalGenerator = (cmLocalVisualStudio7Generator*) this->Makefile->GetLocalGenerator(); @@ -525,10 +526,9 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h"; (*this->BuildFileStream) << hFileName << "</DependentUpon>\n"; - std::vector<std::string> const * configs = - this->GlobalGenerator->GetConfigurations(); - for(std::vector<std::string>::const_iterator i = configs->begin(); - i != configs->end(); ++i) + for(std::vector<std::string>::const_iterator + i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) { this->WritePlatformConfigTag("LogicalName", i->c_str(), 3); if(this->Target->GetProperty("VS_GLOBAL_ROOTNAMESPACE")) @@ -629,11 +629,9 @@ void cmVisualStudio10TargetGenerator::WriteWinRTReferences() void cmVisualStudio10TargetGenerator::WriteProjectConfigurations() { this->WriteString("<ItemGroup Label=\"ProjectConfigurations\">\n", 1); - std::vector<std::string> *configs = - static_cast<cmGlobalVisualStudio7Generator *> - (this->GlobalGenerator)->GetConfigurations(); - for(std::vector<std::string>::iterator i = configs->begin(); - i != configs->end(); ++i) + for(std::vector<std::string>::const_iterator + i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) { this->WriteString("<ProjectConfiguration Include=\"", 2); (*this->BuildFileStream ) << *i << "|" << this->Platform << "\">\n"; @@ -649,11 +647,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurations() void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() { - std::vector<std::string> *configs = - static_cast<cmGlobalVisualStudio7Generator *> - (this->GlobalGenerator)->GetConfigurations(); - for(std::vector<std::string>::iterator i = configs->begin(); - i != configs->end(); ++i) + for(std::vector<std::string>::const_iterator + i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) { this->WritePlatformConfigTag("PropertyGroup", i->c_str(), @@ -864,14 +860,12 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source, } } cmLocalVisualStudio7Generator* lg = this->LocalGenerator; - std::vector<std::string> *configs = - static_cast<cmGlobalVisualStudio7Generator *> - (this->GlobalGenerator)->GetConfigurations(); this->WriteSource("CustomBuild", source, ">\n"); - for(std::vector<std::string>::iterator i = configs->begin(); - i != configs->end(); ++i) + for(std::vector<std::string>::const_iterator + i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) { cmCustomCommandGenerator ccg(command, *i, this->Makefile); std::string comment = lg->ConstructComment(ccg); @@ -911,7 +905,8 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source, sep = ";"; } (*this->BuildFileStream ) << "</Outputs>\n"; - if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) + if(this->LocalGenerator->GetVersion() + > cmGlobalVisualStudioGenerator::VS10) { // VS >= 11 let us turn off linking of custom command outputs. this->WritePlatformConfigTag("LinkObjects", i->c_str(), 3); @@ -1339,8 +1334,6 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) if(!deployContent.empty()) { - std::vector<std::string> const* configs = - this->GlobalGenerator->GetConfigurations(); cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(deployContent); @@ -1352,13 +1345,14 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) << "\\%(FileName)%(Extension)"; this->WriteString("</Link>\n", 0); } - for(size_t i = 0; i != configs->size(); ++i) + for(size_t i = 0; i != this->Configurations.size(); ++i) { - if(0 == strcmp(cge->Evaluate(this->Makefile, (*configs)[i]), "1")) + if(0 == strcmp(cge->Evaluate(this->Makefile, + this->Configurations[i]), "1")) { this->WriteString("<DeploymentContent Condition=\"" "'$(Configuration)|$(Platform)'=='", 3); - (*this->BuildFileStream) << (*configs)[i] << "|" + (*this->BuildFileStream) << this->Configurations[i] << "|" << this->Platform << "'\">true"; this->WriteString("</DeploymentContent>\n", 0); } @@ -1366,7 +1360,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) { this->WriteString("<ExcludedFromBuild Condition=\"" "'$(Configuration)|$(Platform)'=='", 3); - (*this->BuildFileStream) << (*configs)[i] << "|" + (*this->BuildFileStream) << this->Configurations[i] << "|" << this->Platform << "'\">true"; this->WriteString("</ExcludedFromBuild>\n", 0); } @@ -1416,7 +1410,7 @@ void cmVisualStudio10TargetGenerator::WriteSource( // conversion uses full paths when possible to allow deeper trees. bool forceRelative = false; std::string sourceFile = this->ConvertPath(sf->GetFullPath(), false); - if(this->LocalGenerator->GetVersion() == cmLocalVisualStudioGenerator::VS10 + if(this->LocalGenerator->GetVersion() == cmGlobalVisualStudioGenerator::VS10 && cmSystemTools::FileIsFullPath(sourceFile.c_str())) { // Normal path conversion resulted in a full path. VS 10 (but not 11) @@ -1544,7 +1538,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() ++si; } } - if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) + if(this->LocalGenerator->GetVersion() > cmGlobalVisualStudioGenerator::VS10) { // For VS >= 11 we use LinkObjects to avoid linking custom command // outputs. Use Object for all external objects, generated or not. @@ -1654,11 +1648,9 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( (*this->BuildFileStream ) << "$(IntDir)/" << objectName << "</ObjectFileName>\n"; } - std::vector<std::string> *configs = - static_cast<cmGlobalVisualStudio7Generator *> - (this->GlobalGenerator)->GetConfigurations(); - for( std::vector<std::string>::iterator config = configs->begin(); - config != configs->end(); ++config) + for(std::vector<std::string>::const_iterator + config = this->Configurations.begin(); + config != this->Configurations.end(); ++config) { std::string configUpper = cmSystemTools::UpperCase(*config); std::string configDefines = defines; @@ -1736,11 +1728,9 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() this->WriteString("<PropertyGroup>\n", 2); this->WriteString("<_ProjectFileVersion>10.0.20506.1" "</_ProjectFileVersion>\n", 3); - std::vector<std::string> *configs = - static_cast<cmGlobalVisualStudio7Generator *> - (this->GlobalGenerator)->GetConfigurations(); - for(std::vector<std::string>::iterator config = configs->begin(); - config != configs->end(); ++config) + for(std::vector<std::string>::const_iterator + config = this->Configurations.begin(); + config != this->Configurations.end(); ++config) { if(ttype >= cmTarget::UTILITY) { @@ -1854,10 +1844,9 @@ OutputLinkIncremental(std::string const& configName) //---------------------------------------------------------------------------- bool cmVisualStudio10TargetGenerator::ComputeClOptions() { - std::vector<std::string> const* configs = - this->GlobalGenerator->GetConfigurations(); - for(std::vector<std::string>::const_iterator i = configs->begin(); - i != configs->end(); ++i) + for(std::vector<std::string>::const_iterator + i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) { if(!this->ComputeClOptions(*i)) { @@ -2025,10 +2014,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( //---------------------------------------------------------------------------- bool cmVisualStudio10TargetGenerator::ComputeRcOptions() { - std::vector<std::string> const* configs = - this->GlobalGenerator->GetConfigurations(); - for(std::vector<std::string>::const_iterator i = configs->begin(); - i != configs->end(); ++i) + for(std::vector<std::string>::const_iterator + i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) { if(!this->ComputeRcOptions(*i)) { @@ -2091,10 +2079,9 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions() { return true; } - std::vector<std::string> const* configs = - this->GlobalGenerator->GetConfigurations(); - for(std::vector<std::string>::const_iterator i = configs->begin(); - i != configs->end(); ++i) + for(std::vector<std::string>::const_iterator + i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) { if(!this->ComputeMasmOptions(*i)) { @@ -2238,10 +2225,9 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions() this->Target->GetType() == cmTarget::SHARED_LIBRARY || this->Target->GetType() == cmTarget::MODULE_LIBRARY) { - std::vector<std::string> const* configs = - this->GlobalGenerator->GetConfigurations(); - for(std::vector<std::string>::const_iterator i = configs->begin(); - i != configs->end(); ++i) + for(std::vector<std::string>::const_iterator + i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) { if(!this->ComputeLinkOptions(*i)) { @@ -2590,11 +2576,9 @@ WriteMidlOptions(std::string const& /*config*/, void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() { - std::vector<std::string> *configs = - static_cast<cmGlobalVisualStudio7Generator *> - (this->GlobalGenerator)->GetConfigurations(); - for(std::vector<std::string>::iterator i = configs->begin(); - i != configs->end(); ++i) + for(std::vector<std::string>::const_iterator + i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) { std::vector<std::string> includes; this->LocalGenerator->GetIncludeDirectories(includes, diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index a2776de..451f8b2 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -137,6 +137,7 @@ private: OptionsMap MasmOptions; OptionsMap LinkOptions; std::string PathToVcxproj; + std::vector<std::string> Configurations; cmTarget* Target; cmGeneratorTarget* GeneratorTarget; cmMakefile* Makefile; diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 00386f6..6512fc2 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -96,14 +96,14 @@ void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault() // remove the flag we need to override the IDE default of on. switch (this->Version) { - case cmLocalVisualStudioGenerator::VS7: - case cmLocalVisualStudioGenerator::VS71: + case cmGlobalVisualStudioGenerator::VS7: + case cmGlobalVisualStudioGenerator::VS71: this->FlagMap["ExceptionHandling"] = "FALSE"; break; - case cmLocalVisualStudioGenerator::VS10: - case cmLocalVisualStudioGenerator::VS11: - case cmLocalVisualStudioGenerator::VS12: - case cmLocalVisualStudioGenerator::VS14: + case cmGlobalVisualStudioGenerator::VS10: + case cmGlobalVisualStudioGenerator::VS11: + case cmGlobalVisualStudioGenerator::VS12: + case cmGlobalVisualStudioGenerator::VS14: // by default VS puts <ExceptionHandling></ExceptionHandling> empty // for a project, to make our projects look the same put a new line // and space over for the closing </ExceptionHandling> as the default @@ -132,7 +132,7 @@ void cmVisualStudioGeneratorOptions::SetVerboseMakefile(bool verbose) this->FlagMap.find("SuppressStartupBanner") == this->FlagMap.end()) { this->FlagMap["SuppressStartupBanner"] = - this->Version < cmLocalVisualStudioGenerator::VS10 ? "FALSE" : ""; + this->Version < cmGlobalVisualStudioGenerator::VS10 ? "FALSE" : ""; } } @@ -270,7 +270,7 @@ cmVisualStudioGeneratorOptions { return; } - if(this->Version >= cmLocalVisualStudioGenerator::VS10) + if(this->Version >= cmGlobalVisualStudioGenerator::VS10) { // if there are configuration specific flags, then // use the configuration specific tag for PreprocessorDefinitions @@ -298,7 +298,7 @@ cmVisualStudioGeneratorOptions { // Escape the definition for the compiler. std::string define; - if(this->Version < cmLocalVisualStudioGenerator::VS10) + if(this->Version < cmGlobalVisualStudioGenerator::VS10) { define = this->LocalGenerator->EscapeForShell(di->c_str(), true); @@ -308,7 +308,7 @@ cmVisualStudioGeneratorOptions define = *di; } // Escape this flag for the IDE. - if(this->Version >= cmLocalVisualStudioGenerator::VS10) + if(this->Version >= cmGlobalVisualStudioGenerator::VS10) { define = cmVisualStudio10GeneratorOptionsEscapeForXML(define); @@ -325,7 +325,7 @@ cmVisualStudioGeneratorOptions fout << sep << define; sep = ";"; } - if(this->Version >= cmLocalVisualStudioGenerator::VS10) + if(this->Version >= cmGlobalVisualStudioGenerator::VS10) { fout << ";%(PreprocessorDefinitions)</PreprocessorDefinitions>" << suffix; } @@ -340,7 +340,7 @@ void cmVisualStudioGeneratorOptions ::OutputFlagMap(std::ostream& fout, const char* indent) { - if(this->Version >= cmLocalVisualStudioGenerator::VS10) + if(this->Version >= cmGlobalVisualStudioGenerator::VS10) { for(std::map<std::string, FlagValue>::iterator m = this->FlagMap.begin(); m != this->FlagMap.end(); ++m) @@ -395,7 +395,7 @@ cmVisualStudioGeneratorOptions { if(!this->FlagString.empty()) { - if(this->Version >= cmLocalVisualStudioGenerator::VS10) + if(this->Version >= cmGlobalVisualStudioGenerator::VS10) { fout << prefix; if(this->Configuration.size()) diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index 5490a43..0179134 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -73,7 +73,7 @@ public: void SetConfiguration(const char* config); private: cmLocalVisualStudioGenerator* LocalGenerator; - cmLocalVisualStudioGenerator::VSVersion Version; + cmGlobalVisualStudioGenerator::VSVersion Version; std::string Configuration; Tool CurrentTool; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 5c5c428..b4565e7 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -88,8 +88,6 @@ # include "cmGlobalKdevelopGenerator.h" #endif -#include "cmExtraQbsGenerator.h" - #ifdef CMAKE_USE_ECLIPSE # include "cmExtraEclipseCDT4Generator.h" #endif @@ -376,7 +374,7 @@ void cmake::ReadListFile(const std::vector<std::string>& args, std::string homeOutputDir = this->GetHomeOutputDirectory(); this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); - cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(gg->MakeLocalGenerator()); lg->GetMakefile()->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetCurrentSourceDirectory @@ -418,7 +416,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args) this->SetGlobalGenerator(gg); // read in the list file to fill the cache - cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(gg->MakeLocalGenerator()); cmMakefile* mf = lg->GetMakefile(); mf->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); @@ -456,8 +454,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args) std::vector<std::string> includeDirs; cmSystemTools::ExpandListArgument(includes, includeDirs); - std::string includeFlags = lg->GetIncludeFlags(includeDirs, 0, - language, false); + std::string includeFlags = lg->GetIncludeFlags(includeDirs, 0, language); std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS"); printf("%s %s\n", includeFlags.c_str(), definitions.c_str()); @@ -903,8 +900,6 @@ void cmake::AddDefaultExtraGenerators() &cmExtraSublimeTextGenerator::New); this->AddExtraGenerator(cmExtraKateGenerator::GetActualName(), &cmExtraKateGenerator::New); - this->AddExtraGenerator(cmExtraQbsGenerator::GetActualName(), - &cmExtraQbsGenerator::New); #ifdef CMAKE_USE_ECLIPSE this->AddExtraGenerator(cmExtraEclipseCDT4Generator::GetActualName(), @@ -1925,9 +1920,11 @@ int cmake::CheckBuildSystem() // Read the rerun check file and use it to decide whether to do the // global generate. cmake cm; + cm.SetHomeDirectory(""); + cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg; gg.SetCMakeInstance(&cm); - cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator()); cmMakefile* mf = lg->GetMakefile(); if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || cmSystemTools::GetErrorOccuredFlag()) @@ -1957,7 +1954,7 @@ int cmake::CheckBuildSystem() ggd(this->CreateGlobalGenerator(genName)); if(ggd.get()) { - cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->MakeLocalGenerator()); lgd->ClearDependencies(mf, verbose); } } @@ -2435,24 +2432,15 @@ static bool cmakeCheckStampList(const char* stampList) return true; } -//---------------------------------------------------------------------------- -void cmake::IssueMessage(cmake::MessageType t, std::string const& text, - cmListFileBacktrace const& bt) +bool cmake::PrintMessagePreamble(cmake::MessageType t, std::ostream& msg) { - cmListFileBacktrace backtrace = bt; - backtrace.MakeRelative(); - - std::ostringstream msg; - bool isError = false; // Construct the message header. if(t == cmake::FATAL_ERROR) { - isError = true; msg << "CMake Error"; } else if(t == cmake::INTERNAL_ERROR) { - isError = true; msg << "CMake Internal Error (please report a bug)"; } else if(t == cmake::LOG) @@ -2462,7 +2450,6 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, else if(t == cmake::DEPRECATION_ERROR) { msg << "CMake Deprecation Error"; - isError = true; } else if (t == cmake::DEPRECATION_WARNING) { @@ -2478,40 +2465,24 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, "CMAKE_SUPPRESS_DEVELOPER_WARNINGS"); if(suppress && cmSystemTools::IsOn(suppress)) { - return; + return false; } msg << " (dev)"; } } + return true; +} - // Add the immediate context. - cmListFileBacktrace::const_iterator i = backtrace.begin(); - if(i != backtrace.end()) - { - cmListFileContext const& lfc = *i; - msg << (lfc.Line? " at ": " in ") << lfc; - ++i; - } - - // Add the message text. - { - msg << ":\n"; - cmDocumentationFormatter formatter; - formatter.SetIndent(" "); - formatter.PrintFormatted(msg, text.c_str()); - } +void printMessageText(std::ostream& msg, std::string const& text) +{ + msg << ":\n"; + cmDocumentationFormatter formatter; + formatter.SetIndent(" "); + formatter.PrintFormatted(msg, text.c_str()); +} - // Add the rest of the context. - if(i != backtrace.end()) - { - msg << "Call Stack (most recent call first):\n"; - while(i != backtrace.end()) - { - cmListFileContext const& lfc = *i; - msg << " " << lfc << "\n"; - ++i; - } - } +void displayMessage(cmake::MessageType t, std::ostringstream& msg) +{ // Add a note about warning suppression. if(t == cmake::AUTHOR_WARNING) @@ -2540,7 +2511,9 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, #endif // Output the message. - if(isError) + if(t == cmake::FATAL_ERROR + || t == cmake::INTERNAL_ERROR + || t == cmake::DEPRECATION_ERROR) { cmSystemTools::SetErrorOccured(); cmSystemTools::Message(msg.str().c_str(), "Error"); @@ -2552,6 +2525,48 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, } //---------------------------------------------------------------------------- +void cmake::IssueMessage(cmake::MessageType t, std::string const& text, + cmListFileBacktrace const& bt) +{ + cmListFileBacktrace backtrace = bt; + backtrace.MakeRelative(); + + std::ostringstream msg; + if (!this->PrintMessagePreamble(t, msg)) + { + return; + } + + // Add the immediate context. + backtrace.PrintTitle(msg); + + printMessageText(msg, text); + + // Add the rest of the context. + backtrace.PrintCallStack(msg); + + displayMessage(t, msg); +} + +//---------------------------------------------------------------------------- +void cmake::IssueMessage(cmake::MessageType t, std::string const& text, + cmListFileContext const& lfc) +{ + std::ostringstream msg; + if (!this->PrintMessagePreamble(t, msg)) + { + return; + } + + // Add the immediate context. + msg << (lfc.Line ? " at " : " in ") << lfc; + + printMessageText(msg, text); + + displayMessage(t, msg); +} + +//---------------------------------------------------------------------------- std::vector<std::string> cmake::GetDebugConfigs() { std::vector<std::string> configs; @@ -2580,6 +2595,9 @@ int cmake::Build(const std::string& dir, const std::vector<std::string>& nativeOptions, bool clean) { + + this->SetHomeDirectory(""); + this->SetHomeOutputDirectory(""); if(!cmSystemTools::FileIsDirectory(dir)) { std::cerr << "Error: " << dir << " is not a directory\n"; diff --git a/Source/cmake.h b/Source/cmake.h index 0d1977e..7f95fb6 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -303,6 +303,9 @@ class cmake /** Display a message to the user. */ void IssueMessage(cmake::MessageType t, std::string const& text, cmListFileBacktrace const& backtrace = cmListFileBacktrace(NULL)); + void IssueMessage(cmake::MessageType t, std::string const& text, + cmListFileContext const& lfc); + ///! run the --build option int Build(const std::string& dir, const std::string& target, @@ -399,11 +402,13 @@ private: // Print a list of valid generators to stderr. void PrintGeneratorList(); + + bool PrintMessagePreamble(cmake::MessageType t, std::ostream& msg); }; #define CMAKE_STANDARD_OPTIONS_TABLE \ {"-C <initial-cache>", "Pre-load a script to populate the cache."}, \ - {"-D <var>:<type>=<value>", "Create a cmake cache entry."}, \ + {"-D <var>[:<type>]=<value>", "Create a cmake cache entry."}, \ {"-U <globbing_expr>", "Remove matching entries from CMake cache."}, \ {"-G <generator-name>", "Specify a build system generator."},\ {"-T <toolset-name>", "Specify toolset name if supported by generator."}, \ diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index d82087f..e5f4700 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -130,7 +130,7 @@ static std::string cmakemainGetStack(void *clientdata) cmMakefile* mf=cmakemainGetMakefile(clientdata); if (mf) { - msg = mf->GetListFileStack(); + msg = mf->FormatListFileStack(); if (!msg.empty()) { msg = "\n Called from: " + msg; @@ -214,6 +214,8 @@ int do_cmake(int ac, char const* const* av) { // Construct and print requested documentation. cmake hcm; + hcm.SetHomeDirectory(""); + hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); // the command line args are processed here so that you can do @@ -317,10 +319,14 @@ int do_cmake(int ac, char const* const* av) if (sysinfo) { cmake cm; + cm.SetHomeDirectory(""); + cm.SetHomeOutputDirectory(""); int ret = cm.GetSystemInformation(args); return ret; } cmake cm; + cm.SetHomeDirectory(""); + cm.SetHomeOutputDirectory(""); cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void *)&cm); cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm); cm.SetWorkingMode(workingMode); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 50254ff..3ea2186 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -728,7 +728,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen)) { cm.SetGlobalGenerator(ggd); - cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->MakeLocalGenerator()); lgd->GetMakefile()->SetCurrentSourceDirectory(startDir); lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir); diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 0fc47b7..e784759 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -160,6 +160,8 @@ int main (int argc, char const* const* argv) if(doc.CheckOptions(argc, argv)) { cmake hcm; + hcm.SetHomeDirectory(""); + hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); // Construct and print requested documentation. diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index b61e3af..1f93675 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -589,21 +589,7 @@ if(BUILD_TESTING) --test-command Simple) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_KDevelop3Generator") endif () - # check for the Qbs generator - if ("${cmakeOutput}" MATCHES Qbs) - add_test(Simple_QbsGenerator ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/Simple" - "${CMake_BINARY_DIR}/Tests/Simple_QbsGenerator" - --build-two-config - --build-generator "Qbs - Unix Makefiles" - --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}" - --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" - --build-project Simple - --build-options ${build_options} - --test-command Simple) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_QbsGenerator") - endif () + endif() # test for correct sub-project generation diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index d2fa86a..de62ce7 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -492,3 +492,38 @@ message(STATUS "do_cvs_tests='${do_cvs_tests}'") message(STATUS "do_svn_tests='${do_svn_tests}'") message(STATUS "do_git_tests='${do_git_tests}' GIT_EXECUTABLE='${GIT_EXECUTABLE}'") message(STATUS "do_hg_tests='${do_hg_tests}' HG_EXECUTABLE='${HG_EXECUTABLE}'") + + +# Test if log works when the first arguments of *_COMMAND is "COMMAND". +set(proj ExternalProject-no-log) +set(download_cmd "") +set(patch_cmd "") +set(update_cmd "") +set(configure_cmd "") +set(build_cmd "") +set(install_cmd "") + +ExternalProject_Add(${proj} + DOWNLOAD_COMMAND "${download_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "download" + PATCH_COMMAND "${patch_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "patch" + UPDATE_COMMAND "${update_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "update" + CONFIGURE_COMMAND "${configure_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "configure" + BUILD_COMMAND "${build_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "build" + INSTALL_COMMAND "${install_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "install" + ) + +set(proj ExternalProject-log) +ExternalProject_Add(${proj} + DOWNLOAD_COMMAND "${download_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "download" + PATCH_COMMAND "${patch_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "patch" + UPDATE_COMMAND "${update_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "update" + CONFIGURE_COMMAND "${configure_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "configure" + BUILD_COMMAND "${build_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "build" + INSTALL_COMMAND "${install_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "install" + LOG_DOWNLOAD 1 + LOG_PATCH 1 + LOG_UPDATE 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 + ) diff --git a/Tests/RunCMake/Syntax/FunctionUnmatchedForeach-result.txt b/Tests/RunCMake/Syntax/FunctionUnmatchedForeach-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Syntax/FunctionUnmatchedForeach-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Syntax/FunctionUnmatchedForeach-stderr.txt b/Tests/RunCMake/Syntax/FunctionUnmatchedForeach-stderr.txt new file mode 100644 index 0000000..f4ff709 --- /dev/null +++ b/Tests/RunCMake/Syntax/FunctionUnmatchedForeach-stderr.txt @@ -0,0 +1,8 @@ +^CMake Error at FunctionUnmatchedForeach.cmake:[0-9]+ \(f\): + A logical block opening on the line + + .*/Tests/RunCMake/Syntax/FunctionUnmatchedForeach.cmake:[0-9]+ \(foreach\) + + is not closed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/Syntax/FunctionUnmatchedForeach.cmake b/Tests/RunCMake/Syntax/FunctionUnmatchedForeach.cmake new file mode 100644 index 0000000..ee9c184 --- /dev/null +++ b/Tests/RunCMake/Syntax/FunctionUnmatchedForeach.cmake @@ -0,0 +1,5 @@ +function(f) + foreach(i 1) + #endforeach() # missing +endfunction() +f() diff --git a/Tests/RunCMake/Syntax/MacroUnmatchedForeach-result.txt b/Tests/RunCMake/Syntax/MacroUnmatchedForeach-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Syntax/MacroUnmatchedForeach-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Syntax/MacroUnmatchedForeach-stderr.txt b/Tests/RunCMake/Syntax/MacroUnmatchedForeach-stderr.txt new file mode 100644 index 0000000..820cd2e --- /dev/null +++ b/Tests/RunCMake/Syntax/MacroUnmatchedForeach-stderr.txt @@ -0,0 +1,8 @@ +^CMake Error at MacroUnmatchedForeach.cmake:[0-9]+ \(m\): + A logical block opening on the line + + .*/Tests/RunCMake/Syntax/MacroUnmatchedForeach.cmake:[0-9]+ \(foreach\) + + is not closed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/Syntax/MacroUnmatchedForeach.cmake b/Tests/RunCMake/Syntax/MacroUnmatchedForeach.cmake new file mode 100644 index 0000000..be443dd --- /dev/null +++ b/Tests/RunCMake/Syntax/MacroUnmatchedForeach.cmake @@ -0,0 +1,5 @@ +macro(m) + foreach(i 1) + #endforeach() # missing +endmacro() +m() diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake index cecd338..c431280 100644 --- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake +++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake @@ -108,3 +108,7 @@ run_cmake(CMP0053-NameWithNewlineQuoted) run_cmake(CMP0053-NameWithCarriageReturnQuoted) run_cmake(CMP0053-NameWithEscapedSpacesQuoted) run_cmake(CMP0053-NameWithEscapedTabsQuoted) + +# Function and macro tests. +run_cmake(FunctionUnmatchedForeach) +run_cmake(MacroUnmatchedForeach) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1-stderr.txt index 791c4a9..75a729e 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1-stderr.txt @@ -3,4 +3,4 @@ CMake Error: \$<TARGET_PROPERTY:INCLUDE_DIRECTORIES> - Self reference on target "TargetPropertyGeneratorExpressions".$ + Self reference on target "TargetPropertyGeneratorExpressions". diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2-stderr.txt index 791c4a9..75a729e 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2-stderr.txt @@ -3,4 +3,4 @@ CMake Error: \$<TARGET_PROPERTY:INCLUDE_DIRECTORIES> - Self reference on target "TargetPropertyGeneratorExpressions".$ + Self reference on target "TargetPropertyGeneratorExpressions". diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3-stderr.txt index f60d726..f52a27d 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3-stderr.txt @@ -3,4 +3,4 @@ CMake Error: \$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,INCLUDE_DIRECTORIES> - Self reference on target "TargetPropertyGeneratorExpressions".$ + Self reference on target "TargetPropertyGeneratorExpressions". diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4-stderr.txt index f60d726..f52a27d 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4-stderr.txt @@ -3,4 +3,4 @@ CMake Error: \$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,INCLUDE_DIRECTORIES> - Self reference on target "TargetPropertyGeneratorExpressions".$ + Self reference on target "TargetPropertyGeneratorExpressions". diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5-stderr.txt index 2b22d0f..d8d12b5 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5-stderr.txt @@ -3,4 +3,4 @@ CMake Error: \$<TARGET_PROPERTY:COMPILE_DEFINITIONS> - Self reference on target "TargetPropertyGeneratorExpressions".$ + Self reference on target "TargetPropertyGeneratorExpressions". diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6-stderr.txt index fe7caa3..0b1dd26 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6-stderr.txt @@ -3,4 +3,4 @@ CMake Error: \$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,COMPILE_DEFINITIONS> - Self reference on target "TargetPropertyGeneratorExpressions".$ + Self reference on target "TargetPropertyGeneratorExpressions". diff --git a/Tests/RunCMake/if/RunCMakeTest.cmake b/Tests/RunCMake/if/RunCMakeTest.cmake index 6b6b74b..b5546a7 100644 --- a/Tests/RunCMake/if/RunCMakeTest.cmake +++ b/Tests/RunCMake/if/RunCMakeTest.cmake @@ -2,3 +2,4 @@ include(RunCMake) run_cmake(IsDirectory) run_cmake(IsDirectoryLong) +run_cmake(elseif-message) diff --git a/Tests/RunCMake/if/elseif-message-result.txt b/Tests/RunCMake/if/elseif-message-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/if/elseif-message-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/if/elseif-message-stderr.txt b/Tests/RunCMake/if/elseif-message-stderr.txt new file mode 100644 index 0000000..c73977c --- /dev/null +++ b/Tests/RunCMake/if/elseif-message-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at elseif-message.cmake:[0-9]+ \(elseif\): + given arguments: + + "Unknown" "arguments" + + Unknown arguments specified +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/if/elseif-message.cmake b/Tests/RunCMake/if/elseif-message.cmake new file mode 100644 index 0000000..5930966 --- /dev/null +++ b/Tests/RunCMake/if/elseif-message.cmake @@ -0,0 +1,4 @@ + +if (0) +elseif(Unknown arguments) +endif() |