diff options
60 files changed, 596 insertions, 129 deletions
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 571770e..1b2fa61 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -89,6 +89,7 @@ # CPACK_PACKAGE_FILE_NAME - The name of the package file to generate, # not including the extension. For example, cmake-2.6.1-Linux-i686. # The default value is +# # ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}. ##end # diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 5d93ab1..39d3a76 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -13,11 +13,10 @@ # When the 'QUIET' argument is set, no status messages will be printed. # # It sets the following variables: -# PKG_CONFIG_FOUND ... true if pkg-config works on the system +# PKG_CONFIG_FOUND ... if pkg-config executable was found # PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program # PKG_CONFIG_VERSION_STRING ... the version of the pkg-config program found # (since CMake 2.8.8) -# PKG_CONFIG_FOUND ... if pkg-config executable was found # # For the following variables two sets of values exist; first one is the # common one and has the given PREFIX. The second set contains flags @@ -104,6 +103,11 @@ find_package_handle_standard_args(PkgConfig REQUIRED_VARS PKG_CONFIG_EXECUTABLE VERSION_VAR PKG_CONFIG_VERSION_STRING) +# This is needed because the module name is "PkgConfig" but the name of +# this variable has always been PKG_CONFIG_FOUND so this isn't automatically +# handled by FPHSA. +set(PKG_CONFIG_FOUND "${PKGCONFIG_FOUND}") + # Unsets the given variables macro(_pkgconfig_unset var) set(${var} "" CACHE INTERNAL "") diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index fcd0838..591b3e6 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -82,7 +82,12 @@ FOREACH(_CURRENT_VERSION ${_Python_VERSIONS}) ENDIF(WIN32) FIND_LIBRARY(PYTHON_LIBRARY - NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION} + NAMES + python${_CURRENT_VERSION_NO_DOTS} + python${_CURRENT_VERSION}mu + python${_CURRENT_VERSION}m + python${_CURRENT_VERSION}u + python${_CURRENT_VERSION} PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs @@ -120,12 +125,14 @@ FOREACH(_CURRENT_VERSION ${_Python_VERSIONS}) [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include PATH_SUFFIXES + python${_CURRENT_VERSION}mu + python${_CURRENT_VERSION}m + python${_CURRENT_VERSION}u python${_CURRENT_VERSION} ) - # For backward compatibility, set PYTHON_INCLUDE_PATH, but make it internal. - SET(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}" CACHE INTERNAL - "Path to where Python.h is found (deprecated)") + # For backward compatibility, set PYTHON_INCLUDE_PATH. + SET(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}") IF(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}/patchlevel.h") FILE(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" python_version_str diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 84d0afd..30cc920 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -130,7 +130,7 @@ # Example: # create_javadoc(my_example_doc # PACKAGES com.exmaple.foo com.example.bar -# SOURCEPATH ${CMAKE_CURRENT_SOURCE_PATH} +# SOURCEPATH "${CMAKE_CURRENT_SOURCE_DIR}" # CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} # WINDOWTITLE "My example" # DOCTITLE "<h1>My example</h1>" diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index f9d1c03..c01c490 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -355,18 +355,18 @@ IF (WIN32) ENDIF(NOT UNIX) ENDIF (WIN32) -# turn on Ninja by default +# Turn on Ninja by default, but disable it +# on platforms where it does not pass all tests. +# Enforce Ninja support by setting CMAKE_USE_NINJA set(_CMAKE_DEFAULT_NINJA_VALUE TRUE) -# turn it off for platforms where it does not pass all the -# tests if(WIN32 OR APPLE) SET(_CMAKE_DEFAULT_NINJA_VALUE FALSE) endif() SET(CMAKE_ENABLE_NINJA ${_CMAKE_DEFAULT_NINJA_VALUE} CACHE BOOL - "Enable the ninja generator for CMake. currently not fully working for Windows or OSX") + "Enable the ninja generator for CMake. On Windows and OSX broken") MARK_AS_ADVANCED(CMAKE_ENABLE_NINJA) IF(CMAKE_ENABLE_NINJA) - MESSAGE(STATUS "Enable ninja generator.") + MESSAGE(STATUS "Ninja generator enabled.") SET(SRCS ${SRCS} cmGlobalNinjaGenerator.cxx cmGlobalNinjaGenerator.h @@ -382,7 +382,7 @@ IF(CMAKE_ENABLE_NINJA) ) ADD_DEFINITIONS(-DCMAKE_USE_NINJA) ELSE() - MESSAGE(STATUS "Disable ninja generator.") + MESSAGE(STATUS "Ninja generator disabled, enforce with -DCMAKE_ENABLE_NINJA=ON") ENDIF() # create a library used by the command line and the GUI diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d42b6dd..33b8f04 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) SET(CMake_VERSION_PATCH 8) -SET(CMake_VERSION_TWEAK 20120421) +SET(CMake_VERSION_TWEAK 20120425) #SET(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 178a18d..fa456de 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -480,11 +480,16 @@ int cmCPackDebGenerator::createDeb() // Do not end the md5sum file with yet another (invalid) } - cmd = "\""; - cmd += cmakeExecutable; - cmd += "\" -E tar cfz control.tar.gz ./control ./md5sums"; - const char* controlExtra = - this->GetOption("CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA"); + cmd = ""; + if (NULL != this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE")) + { + cmd = this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE"); + } + cmd += " \""; + cmd += cmakeExecutable; + cmd += "\" -E tar cfz control.tar.gz ./control ./md5sums"; + const char* controlExtra = + this->GetOption("CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA"); if( controlExtra ) { std::vector<std::string> controlExtraList; diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 309abb1..ae06b0f 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -752,6 +752,33 @@ int cmCTestCoverageHandler::HandlePHPCoverage( return static_cast<int>(cont->TotalCoverage.size()); } +struct cmCTestCoverageHandlerLocale +{ + cmCTestCoverageHandlerLocale() + { + if(const char* l = cmSystemTools::GetEnv("LC_ALL")) + { + lc_all = l; + } + if(lc_all != "C") + { + cmSystemTools::PutEnv("LC_ALL=C"); + } + } + ~cmCTestCoverageHandlerLocale() + { + if(!lc_all.empty()) + { + cmSystemTools::PutEnv(("LC_ALL=" + lc_all).c_str()); + } + else + { + cmSystemTools::UnsetEnv("LC_ALL"); + } + } + std::string lc_all; +}; + //---------------------------------------------------------------------- int cmCTestCoverageHandler::HandleGCovCoverage( cmCTestCoverageHandlerContainer* cont) @@ -815,7 +842,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage( int file_count = 0; // make sure output from gcov is in English! - cmSystemTools::PutEnv("LC_ALL=POSIX"); + cmCTestCoverageHandlerLocale locale_C; + static_cast<void>(locale_C); // files is a list of *.da and *.gcda files with coverage data in them. // These are binary files that you give as input to gcov so that it will diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index ccb17f0..5df8627 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -60,6 +60,9 @@ cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator() // disable until somebody actually tests it: // this->SupportedGlobalGenerators.push_back("MSYS Makefiles"); #endif +#ifdef CMAKE_USE_NINJA + this->SupportedGlobalGenerators.push_back("Ninja"); +#endif this->SupportedGlobalGenerators.push_back("Unix Makefiles"); } @@ -383,6 +386,7 @@ void cmExtraCodeBlocksGenerator case cmTarget::STATIC_LIBRARY: case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: + case cmTarget::OBJECT_LIBRARY: { this->AppendTarget(fout, ti->first.c_str(), &ti->second, make.c_str(), makefile, compiler.c_str()); @@ -420,6 +424,7 @@ void cmExtraCodeBlocksGenerator case cmTarget::STATIC_LIBRARY: case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: + case cmTarget::OBJECT_LIBRARY: case cmTarget::UTILITY: // can have sources since 2.6.3 { const std::vector<cmSourceFile*>&sources=ti->second.GetSourceFiles(); @@ -532,6 +537,31 @@ void cmExtraCodeBlocksGenerator } +// Write a dummy file for OBJECT libraries, so C::B can reference some file +std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile( + cmMakefile* mf, cmTarget* target) const +{ + // this file doesn't seem to be used by C::B in custom makefile mode, + // but we generate a unique file for each OBJECT library so in case + // C::B uses it in some way, the targets don't interfere with each other. + std::string filename = mf->GetCurrentOutputDirectory(); + filename += "/"; + filename += mf->GetLocalGenerator()->GetTargetDirectory(*target); + filename += "/"; + filename += target->GetName(); + filename += ".objlib"; + cmGeneratedFileStream fout(filename.c_str()); + if(fout) + { + fout << "# This is a dummy file for the OBJECT library " + << target->GetName() + << " for the CMake CodeBlocks project generator.\n" + << "# Don't edit, this file will be overwritten.\n"; + } + return filename; +} + + // Generate the xml code for one target. void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, const char* targetName, @@ -570,7 +600,18 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, } const char* buildType = makefile->GetDefinition("CMAKE_BUILD_TYPE"); - fout<<" <Option output=\"" << target->GetLocation(buildType) + std::string location; + if ( target->GetType()==cmTarget::OBJECT_LIBRARY) + { + location = this->CreateDummyTargetFile(const_cast<cmMakefile*>(makefile), + target); + } + else + { + location = target->GetLocation(buildType); + } + + fout<<" <Option output=\"" << location << "\" prefix_auto=\"0\" extension_auto=\"0\" />\n" " <Option working_dir=\"" << workingDir << "\" />\n" " <Option object_output=\"./\" />\n" @@ -728,7 +769,8 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmTarget* target) return 1; } } - else if ( target->GetType()==cmTarget::STATIC_LIBRARY) + else if (( target->GetType()==cmTarget::STATIC_LIBRARY) + || (target->GetType()==cmTarget::OBJECT_LIBRARY)) { return 2; } diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h index 57751fc..e0a64ca 100644 --- a/Source/cmExtraCodeBlocksGenerator.h +++ b/Source/cmExtraCodeBlocksGenerator.h @@ -44,6 +44,8 @@ private: void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs, const std::string& filename); + std::string CreateDummyTargetFile(cmMakefile* mf, cmTarget* target) const; + std::string GetCBCompilerId(const cmMakefile* mf); int GetCBTargetType(cmTarget* target); std::string BuildMakeCommand(const std::string& make, const char* makefile, diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 3f14fa1..d69431e 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -300,7 +300,7 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args) offset = atoi(offsetArg.GetCString()); } - file.seekg(offset); + file.seekg(offset, std::ios::beg); // explicit ios::beg for IBM VisualAge 6 std::string output; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index ef16ce8..4f9ba7e 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -89,7 +89,7 @@ void cmFindPackageCommand::GenerateDocumentation() "FIND_XXX", "find_package"); this->CommandDocumentation = " find_package(<package> [version] [EXACT] [QUIET] [MODULE]\n" - " [[REQUIRED|COMPONENTS] [components...]]\n" + " [REQUIRED] [[COMPONENTS] [components...]]\n" " [OPTIONAL_COMPONENTS components...]\n" " [NO_POLICY_SCOPE])\n" "Finds and loads settings from an external project. " @@ -102,7 +102,7 @@ void cmFindPackageCommand::GenerateDocumentation() "package cannot be found." "\n" "A package-specific list of required components may be listed after the " - "COMPONENTS option or directly after the REQUIRED option. " + "COMPONENTS option (or after the REQUIRED option if present). " "Additional optional components may be listed after OPTIONAL_COMPONENTS. " "Available components and their influence on whether a package is " "considered to be found are defined by the target package." @@ -136,7 +136,7 @@ void cmFindPackageCommand::GenerateDocumentation() "proceeds to Config mode.\n" "The complete Config mode command signature is:\n" " find_package(<package> [version] [EXACT] [QUIET]\n" - " [[REQUIRED|COMPONENTS] [components...]]\n" + " [REQUIRED] [[COMPONENTS] [components...]]\n" " [CONFIG|NO_MODULE]\n" " [NO_POLICY_SCOPE]\n" " [NAMES name1 [name2 ...]]\n" @@ -353,6 +353,29 @@ void cmFindPackageCommand::GenerateDocumentation() "variable CMAKE_DISABLE_FIND_PACKAGE_<package> to TRUE. See the " "documentation for the CMAKE_DISABLE_FIND_PACKAGE_<package> variable for " "more information.\n" + "When loading a find module or package configuration file find_package " + "defines variables to provide information about the call arguments " + "(and restores their original state before returning):\n" + " <package>_FIND_REQUIRED = true if REQUIRED option was given\n" + " <package>_FIND_QUIETLY = true if QUIET option was given\n" + " <package>_FIND_VERSION = full requested version string\n" + " <package>_FIND_VERSION_MAJOR = major version if requested, else 0\n" + " <package>_FIND_VERSION_MINOR = minor version if requested, else 0\n" + " <package>_FIND_VERSION_PATCH = patch version if requested, else 0\n" + " <package>_FIND_VERSION_TWEAK = tweak version if requested, else 0\n" + " <package>_FIND_VERSION_COUNT = number of version components, 0 to 4\n" + " <package>_FIND_VERSION_EXACT = true if EXACT option was given\n" + " <package>_FIND_COMPONENTS = list of requested components\n" + " <package>_FIND_REQUIRED_<c> = true if component <c> is required\n" + " false if component <c> is optional\n" + "In Module mode the loaded find module is responsible to honor the " + "request detailed by these variables; see the find module for details. " + "In Config mode find_package handles REQUIRED, QUIET, and version " + "options automatically but leaves it to the package configuration file " + "to handle components in a way that makes sense for the package. " + "The package configuration file may set <package>_FOUND to false " + "to tell find_package that component requirements are not satisfied." + "\n" "See the cmake_policy() command documentation for discussion of the " "NO_POLICY_SCOPE option." ; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 545f9e8..b06cdb4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2092,6 +2092,21 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( } //---------------------------------------------------------------------------- +std::string +cmGlobalGenerator::GenerateRuleFile(std::string const& output) const +{ + std::string ruleFile = output; + ruleFile += ".rule"; + const char* dir = this->GetCMakeCFGIntDir(); + if(dir && dir[0] == '$') + { + cmSystemTools::ReplaceString(ruleFile, dir, + cmake::GetCMakeFilesDirectory()); + } + return ruleFile; +} + +//---------------------------------------------------------------------------- void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*, const char*, std::string&) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 80b948b..5254b89 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -277,6 +277,9 @@ public: i.e. "Can I build Debug and Release in the same tree?" */ virtual bool IsMultiConfig() { return false; } + /** Generate an <output>.rule file path for a given command output. */ + virtual std::string GenerateRuleFile(std::string const& output) const; + protected: typedef std::vector<cmLocalGenerator*> GeneratorVector; // for a project collect all its targets by following depend diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 22ead10..28d738a 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -212,3 +212,21 @@ bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf) return false; } } + +//---------------------------------------------------------------------------- +std::string +cmGlobalVisualStudio10Generator +::GenerateRuleFile(std::string const& output) const +{ + // The VS 10 generator needs to create the .rule files on disk. + // Hide them away under the CMakeFiles directory. + std::string ruleDir = this->GetCMakeInstance()->GetHomeOutputDirectory(); + ruleDir += cmake::GetCMakeFilesDirectory(); + ruleDir += "/"; + ruleDir += cmSystemTools::ComputeStringMD5( + cmSystemTools::GetFilenamePath(output).c_str()); + std::string ruleFile = ruleDir + "/"; + ruleFile += cmSystemTools::GetFilenameName(output); + ruleFile += ".rule"; + return ruleFile; +} diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 750b89c..e2cc14e 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -75,6 +75,10 @@ public: virtual const char* GetCMakeCFGIntDir() const { return "$(Configuration)";} bool Find64BitTools(cmMakefile* mf); + + /** Generate an <output>.rule file path for a given command output. */ + virtual std::string GenerateRuleFile(std::string const& output) const; + protected: virtual const char* GetIDEVersion() { return "10.0"; } diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index a5feaca..d6b653c 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -241,9 +241,12 @@ void cmGlobalVisualStudio71Generator ::WriteExternalProject(std::ostream& fout, const char* name, const char* location, + const char* typeGuid, const std::set<cmStdString>& depends) { - fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" + fout << "Project(\"{" + << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942") + << "}\") = \"" << name << "\", \"" << this->ConvertToSolutionPath(location) << "\", \"{" << this->GetGUID(name) @@ -279,18 +282,21 @@ void cmGlobalVisualStudio71Generator // executables to the libraries it uses are also done here void cmGlobalVisualStudio71Generator ::WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild) + bool partOfDefaultBuild, + const char* platformMapping) { std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { fout << "\t\t{" << guid << "}." << *i - << ".ActiveCfg = " << *i << "|Win32\n"; + << ".ActiveCfg = " << *i << "|" + << (platformMapping ? platformMapping : "Win32") << std::endl; if(partOfDefaultBuild) { fout << "\t\t{" << guid << "}." << *i - << ".Build.0 = " << *i << "|Win32\n"; + << ".Build.0 = " << *i << "|" + << (platformMapping ? platformMapping : "Win32") << std::endl; } } } diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index 81c2087..503b708 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -64,10 +64,12 @@ protected: const char* name, const char* path, cmTarget &t); virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild); + bool partOfDefaultBuild, + const char* platformMapping = NULL); virtual void WriteExternalProject(std::ostream& fout, const char* name, const char* path, + const char* typeGuid, const std::set<cmStdString>& depends); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index a68e6d8..6332d0b 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -250,8 +250,9 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( const char* expath = target->GetProperty("EXTERNAL_MSPROJECT"); if(expath) { - this->WriteProjectConfigurations(fout, target->GetName(), - true); + this->WriteProjectConfigurations( + fout, target->GetName(), + true, target->GetProperty("VS_PLATFORM_MAPPING")); } else { @@ -286,8 +287,12 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( { std::string project = target->GetName(); std::string location = expath; - this->WriteExternalProject(fout, project.c_str(), - location.c_str(), target->GetUtilities()); + + this->WriteExternalProject(fout, + project.c_str(), + location.c_str(), + target->GetProperty("VS_PROJECT_TYPE"), + target->GetUtilities()); written = true; } else @@ -580,18 +585,21 @@ cmGlobalVisualStudio7Generator // executables to the libraries it uses are also done here void cmGlobalVisualStudio7Generator ::WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild) + bool partOfDefaultBuild, + const char* platformMapping) { std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { fout << "\t\t{" << guid << "}." << *i - << ".ActiveCfg = " << *i << "|Win32\n"; + << ".ActiveCfg = " << *i << "|" + << (platformMapping ? platformMapping : "Win32") << "\n"; if(partOfDefaultBuild) { fout << "\t\t{" << guid << "}." << *i - << ".Build.0 = " << *i << "|Win32\n"; + << ".Build.0 = " << *i << "|" + << (platformMapping ? platformMapping : "Win32") << "\n"; } } } @@ -604,10 +612,14 @@ void cmGlobalVisualStudio7Generator void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout, const char* name, const char* location, + const char* typeGuid, const std::set<cmStdString>&) { std::string d = cmSystemTools::ConvertToOutputPath(location); - fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" + fout << "Project(" + << "\"{" + << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942") + << "}\") = \"" << name << "\", \"" << this->ConvertToSolutionPath(location) << "\", \"{" << this->GetGUID(name) diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index c92998e..9b9107d 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -107,7 +107,8 @@ protected: const char* name, const char* path, cmTarget &t); virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild); + bool partOfDefaultBuild, + const char* platformMapping = NULL); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); virtual std::string WriteUtilityDepend(cmTarget* target); @@ -130,6 +131,7 @@ protected: virtual void WriteExternalProject(std::ostream& fout, const char* name, const char* path, + const char* typeGuid, const std::set<cmStdString>& dependencies); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index a723109..e7c4232 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -214,13 +214,11 @@ void cmGlobalVisualStudio8Generator::AddCheckTarget() // (this could be avoided with per-target source files) const char* no_main_dependency = 0; const char* no_working_directory = 0; - mf->AddCustomCommandToOutput( - stamps, listFiles, - no_main_dependency, commandLines, "Checking Build System", - no_working_directory, true); - std::string ruleName = stamps[0]; - ruleName += ".rule"; - if(cmSourceFile* file = mf->GetSource(ruleName.c_str())) + if(cmSourceFile* file = + mf->AddCustomCommandToOutput( + stamps, listFiles, + no_main_dependency, commandLines, "Checking Build System", + no_working_directory, true)) { tgt->AddSourceFile(file); } @@ -270,20 +268,23 @@ cmGlobalVisualStudio8Generator void cmGlobalVisualStudio8Generator ::WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild) + bool partOfDefaultBuild, + const char* platformMapping) { std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { fout << "\t\t{" << guid << "}." << *i - << "|" << this->GetPlatformName() << ".ActiveCfg = " - << *i << "|" << this->GetPlatformName() << "\n"; + << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|" + << (platformMapping ? platformMapping : this->GetPlatformName()) + << "\n"; if(partOfDefaultBuild) { fout << "\t\t{" << guid << "}." << *i - << "|" << this->GetPlatformName() << ".Build.0 = " - << *i << "|" << this->GetPlatformName() << "\n"; + << "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|" + << (platformMapping ? platformMapping : this->GetPlatformName()) + << "\n"; } } } diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index e0913ed..7dae429 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -77,7 +77,8 @@ protected: virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild); + bool partOfDefaultBuild, + const char* platformMapping = NULL); virtual bool ComputeTargetDepends(); virtual void WriteProjectDepends(std::ostream& fout, const char* name, const char* path, cmTarget &t); diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx index a4369a3..d219c16 100644 --- a/Source/cmIncludeExternalMSProjectCommand.cxx +++ b/Source/cmIncludeExternalMSProjectCommand.cxx @@ -25,18 +25,75 @@ bool cmIncludeExternalMSProjectCommand #ifdef _WIN32 if(this->Makefile->GetDefinition("WIN32")) { + enum Doing { DoingNone, DoingType, DoingGuid, DoingPlatform }; + + Doing doing = DoingNone; + + std::string customType; + std::string customGuid; + std::string platformMapping; + + std::vector<std::string> depends; + for (unsigned int i=2; i<args.size(); ++i) + { + if (args[i] == "TYPE") + { + doing = DoingType; + } + else if (args[i] == "GUID") + { + doing = DoingGuid; + } + else if (args[i] == "PLATFORM") + { + doing = DoingPlatform; + } + else + { + switch (doing) + { + case DoingNone: depends.push_back(args[i]); break; + case DoingType: customType = args[i]; break; + case DoingGuid: customGuid = args[i]; break; + case DoingPlatform: platformMapping = args[i]; break; + } + doing = DoingNone; + } + } + + // Hack together a utility target storing enough information + // to reproduce the target inclusion. + std::string utility_name = args[0]; + std::string path = args[1]; cmSystemTools::ConvertToUnixSlashes(path); + if (!customGuid.empty()) + { + std::string guidVariable = utility_name + "_GUID_CMAKE"; + this->Makefile->GetCMakeInstance()->AddCacheEntry( + guidVariable.c_str(), customGuid.c_str(), + "Stored GUID", cmCacheManager::INTERNAL); + } + // Create a target instance for this utility. cmTarget* target=this->Makefile->AddNewTarget(cmTarget::UTILITY, - args[0].c_str()); + utility_name.c_str()); + + target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str()); target->SetProperty("EXTERNAL_MSPROJECT", path.c_str()); - target->SetProperty("EXCLUDE_FROM_ALL","FALSE"); - target->SetProperty("GENERATOR_FILE_NAME", args[0].c_str()); - for (unsigned int i=2; i<args.size(); ++i) + target->SetProperty("EXCLUDE_FROM_ALL", "FALSE"); + + if (!customType.empty()) + target->SetProperty("VS_PROJECT_TYPE",customType.c_str()); + if (!platformMapping.empty()) + target->SetProperty("VS_PLATFORM_MAPPING",platformMapping.c_str()); + + for (std::vector<std::string>::const_iterator it = depends.begin(); + it != depends.end(); + ++it) { - target->AddUtility(args[i].c_str()); + target->AddUtility(it->c_str()); } } #endif diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h index 911a772..2b2ed0d 100644 --- a/Source/cmIncludeExternalMSProjectCommand.h +++ b/Source/cmIncludeExternalMSProjectCommand.h @@ -59,11 +59,21 @@ public: { return " include_external_msproject(projectname location\n" + " [TYPE projectTypeGUID]\n" + " [GUID projectGUID]\n" + " [PLATFORM platformName]\n" " dep1 dep2 ...)\n" "Includes an external Microsoft project in the generated workspace " "file. Currently does nothing on UNIX. This will create a " "target named [projectname]. This can be used in the add_dependencies " - "command to make things depend on the external project."; + "command to make things depend on the external project." + "\n" + "TYPE, GUID and PLATFORM are optional parameters that allow one " + "to specify the type of project, id (GUID) of the project and " + "the name of the target platform. " + "This is useful for projects requiring values other than the default " + "(e.g. WIX projects). " + "These options are not supported by the Visual Studio 6 generator."; } cmTypeMacro(cmIncludeExternalMSProjectCommand, cmCommand); diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index cbbcbb0..908f3b0 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -204,6 +204,12 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args) this->Makefile->AddDefinition(variableName.c_str(), "NOTFOUND"); return true; } + // FIXME: Add policy to make non-existing lists an error like empty lists. + if(varArgsExpanded.empty()) + { + this->SetError("GET given empty list"); + return false; + } std::string value; size_t cc; @@ -318,7 +324,8 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args) // expand the variable int item = atoi(args[2].c_str()); std::vector<std::string> varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) && item != 0) + if((!this->GetList(varArgsExpanded, listName.c_str()) + || varArgsExpanded.empty()) && item != 0) { cmOStringStream str; str << "index: " << item << " out of range (0, 0)"; @@ -544,6 +551,12 @@ bool cmListCommand::HandleRemoveAtCommand( this->SetError("sub-command REMOVE_AT requires list to be present."); return false; } + // FIXME: Add policy to make non-existing lists an error like empty lists. + if(varArgsExpanded.empty()) + { + this->SetError("REMOVE_AT given empty list"); + return false; + } size_t cc; std::vector<size_t> removed; diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index bf0e997..ace7adf 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -99,6 +99,14 @@ void cmLocalVisualStudio10Generator { cmVS10XMLParser parser; parser.ParseFile(path); + + // if we can not find a GUID then create one + if(parser.GUID.empty()) + { + this->GlobalGenerator->CreateGUID(name); + return; + } + std::string guidStoreName = name; guidStoreName += "_GUID_CMAKE"; // save the GUID in the cache diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 99a4c95..5ab223b 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -320,7 +320,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, sourceGroup.AssignSource(*i); // while we are at it, if it is a .rule file then for visual studio 6 we // must generate it - if ((*i)->GetExtension() == "rule") + if ((*i)->GetPropertyAsBool("__CMAKE_RULE")) { if(!cmSystemTools::FileExists(source.c_str())) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e7e5eda..17bb5ed 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -883,7 +883,7 @@ cmMakefile::AddCustomCommandToTarget(const char* target, } //---------------------------------------------------------------------------- -void +cmSourceFile* cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, const std::vector<std::string>& depends, const char* main_dependency, @@ -897,7 +897,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, if(outputs.empty()) { cmSystemTools::Error("Attempt to add a custom rule with no output!"); - return; + return 0; } // Validate custom commands. TODO: More strict? @@ -910,7 +910,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, cmOStringStream e; e << "COMMAND may not contain literal quotes:\n " << cl[0] << "\n"; this->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; + return 0; } } @@ -928,7 +928,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, { // The existing custom command is identical. Silently ignore // the duplicate. - return; + return file; } else { @@ -948,17 +948,11 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, // Generate a rule file if the main dependency is not available. if(!file) { + cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); + // Construct a rule file associated with the first output produced. - std::string outName = outputs[0]; - outName += ".rule"; - const char* dir = - this->LocalGenerator->GetGlobalGenerator()-> - GetCMakeCFGIntDir(); - if(dir && dir[0] == '$') - { - cmSystemTools::ReplaceString(outName, dir, - cmake::GetCMakeFilesDirectory()); - } + std::string outName = gg->GenerateRuleFile(outputs[0]); + // Check if the rule file already exists. file = this->GetSource(outName.c_str()); if(file && file->GetCustomCommand() && !replace) @@ -970,11 +964,12 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, outName.c_str(), "\" which already has a custom rule."); } - return; + return file; } // Create a cmSourceFile for the rule file. file = this->GetOrCreateSource(outName.c_str(), true); + file->SetProperty("__CMAKE_RULE", "1"); } // Always create the output sources and mark them generated. @@ -1004,10 +999,11 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, cc->SetEscapeAllowMakeVars(true); file->SetCustomCommand(cc); } + return file; } //---------------------------------------------------------------------------- -void +cmSourceFile* cmMakefile::AddCustomCommandToOutput(const char* output, const std::vector<std::string>& depends, const char* main_dependency, @@ -1019,9 +1015,9 @@ cmMakefile::AddCustomCommandToOutput(const char* output, { std::vector<std::string> outputs; outputs.push_back(output); - this->AddCustomCommandToOutput(outputs, depends, main_dependency, - commandLines, comment, workingDir, - replace, escapeOldStyle); + return this->AddCustomCommandToOutput(outputs, depends, main_dependency, + commandLines, comment, workingDir, + replace, escapeOldStyle); } //---------------------------------------------------------------------------- @@ -1054,13 +1050,14 @@ cmMakefile::AddCustomCommandOldStyle(const char* target, { // Get the name of this output. const char* output = oi->c_str(); + cmSourceFile* sf; // Choose whether to use a main dependency. if(sourceFiles.find(source)) { // The source looks like a real file. Use it as the main dependency. - this->AddCustomCommandToOutput(output, depends, source, - commandLines, comment, 0); + sf = this->AddCustomCommandToOutput(output, depends, source, + commandLines, comment, 0); } else { @@ -1068,20 +1065,18 @@ cmMakefile::AddCustomCommandOldStyle(const char* target, const char* no_main_dependency = 0; std::vector<std::string> depends2 = depends; depends2.push_back(source); - this->AddCustomCommandToOutput(output, depends2, no_main_dependency, - commandLines, comment, 0); + sf = this->AddCustomCommandToOutput(output, depends2, no_main_dependency, + commandLines, comment, 0); } // If the rule was added to the source (and not a .rule file), // then add the source to the target to make sure the rule is // included. - std::string sname = output; - sname += ".rule"; - if(!this->GetSource(sname.c_str())) + if(sf && !sf->GetPropertyAsBool("__CMAKE_RULE")) { if (this->Targets.find(target) != this->Targets.end()) { - this->Targets[target].AddSource(source); + this->Targets[target].AddSourceFile(sf); } else { @@ -1976,7 +1971,6 @@ cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) // look through all the source files that have custom commands // and see if the custom command has the passed source file as an output - // keep in mind the possible .rule extension that may be tacked on for(std::vector<cmSourceFile*>::const_iterator i = this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 960ba39..8b3bef7 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -175,20 +175,22 @@ public: cmTarget::CustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle = true); - void AddCustomCommandToOutput(const std::vector<std::string>& outputs, - const std::vector<std::string>& depends, - const char* main_dependency, - const cmCustomCommandLines& commandLines, - const char* comment, const char* workingDir, - bool replace = false, - bool escapeOldStyle = true); - void AddCustomCommandToOutput(const char* output, - const std::vector<std::string>& depends, - const char* main_dependency, - const cmCustomCommandLines& commandLines, - const char* comment, const char* workingDir, - bool replace = false, - bool escapeOldStyle = true); + cmSourceFile* AddCustomCommandToOutput( + const std::vector<std::string>& outputs, + const std::vector<std::string>& depends, + const char* main_dependency, + const cmCustomCommandLines& commandLines, + const char* comment, const char* workingDir, + bool replace = false, + bool escapeOldStyle = true); + cmSourceFile* AddCustomCommandToOutput( + const char* output, + const std::vector<std::string>& depends, + const char* main_dependency, + const cmCustomCommandLines& commandLines, + const char* comment, const char* workingDir, + bool replace = false, + bool escapeOldStyle = true); void AddCustomCommandOldStyle(const char* target, const std::vector<std::string>& outputs, const std::vector<std::string>& depends, diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2bad32c..cf2b427 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -47,8 +47,7 @@ cmNinjaNormalTargetGenerator(cmTarget* target) { // on Windows the output dir is already needed at compile time // ensure the directory exists (OutDir test) - std::string outpath = target->GetDirectory(this->GetConfigName()); - cmSystemTools::MakeDirectory(outpath.c_str()); + EnsureDirectoryExists(target->GetDirectory(this->GetConfigName())); } } @@ -56,6 +55,21 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() { } +void +cmNinjaNormalTargetGenerator +::EnsureDirectoryExists(const std::string& dir) +{ + cmSystemTools::MakeDirectory(dir.c_str()); +} + +void +cmNinjaNormalTargetGenerator +::EnsureParentDirectoryExists(const std::string& path) +{ + EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str())); +} + + void cmNinjaNormalTargetGenerator::Generate() { if (!this->TargetLinkLanguage) { @@ -380,13 +394,18 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } } + std::string path; if (!this->TargetNameImport.empty()) { - vars["TARGET_IMPLIB"] = this->GetLocalGenerator()->ConvertToOutputFormat( - targetOutputImplib.c_str(), cmLocalGenerator::SHELL); + path = this->GetLocalGenerator()->ConvertToOutputFormat( + targetOutputImplib.c_str(), cmLocalGenerator::SHELL); + vars["TARGET_IMPLIB"] = path; + EnsureParentDirectoryExists(path); } - vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat( - this->GetTargetPDB().c_str(), cmLocalGenerator::SHELL); + path = this->GetLocalGenerator()->ConvertToOutputFormat( + this->GetTargetPDB().c_str(), cmLocalGenerator::SHELL); + vars["TARGET_PDB"] = path; + EnsureParentDirectoryExists(path); std::vector<cmCustomCommand> *cmdLists[3] = { &this->GetTarget()->GetPreBuildCommands(), @@ -413,7 +432,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for // the link commands. if (!preLinkCmdLines.empty()) { - std::string path = this->GetLocalGenerator()->ConvertToOutputFormat( + path = this->GetLocalGenerator()->ConvertToOutputFormat( this->GetMakefile()->GetHomeOutputDirectory(), cmLocalGenerator::SHELL); preLinkCmdLines.push_back("cd " + path); diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index 1702caf..7acbe8f 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -35,6 +35,9 @@ private: void WriteObjectLibStatement(); std::vector<std::string> ComputeLinkCmd(); + void EnsureDirectoryExists(const std::string& dir); + void EnsureParentDirectoryExists(const std::string& path); + private: // Target name info. std::string TargetNameOut; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 1376a48..25975e0 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -104,6 +104,9 @@ public: private: HANDLE handle_; }; +#elif defined(__APPLE__) +#include <crt_externs.h> +#define environ (*_NSGetEnviron()) #endif bool cmSystemTools::s_RunCommandHideConsole = false; diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index be866c3..63114d2 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -64,7 +64,8 @@ public: "Specify libraries or flags to use when linking a given target. " "The named <target> must have been created in the current directory " "by a command such as add_executable or add_library. " - "The remaining arguments specify library names or flags." + "The remaining arguments specify library names or flags. " + "Repeated calls for the same <target> append items in the order called." "\n" "If a library name matches that of another target in the project " "a dependency will automatically be added in the build system to make " diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 6caaad1..9c25b0c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -459,8 +459,9 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, command) { std::string sourcePath = source->GetFullPath(); - // the rule file seems to need to exist for vs10 - if (source->GetExtension() == "rule") + // VS 10 will always rebuild a custom command attached to a .rule + // file that doesn't exist so create the file explicitly. + if (source->GetPropertyAsBool("__CMAKE_RULE")) { if(!cmSystemTools::FileExists(sourcePath.c_str())) { diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt index 6604208..fc65e58 100644 --- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -71,7 +71,7 @@ endmacro(check_version_string) # reported. foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HSPELL - JASPER LIBXML2 LIBXSLT PERL PostgreSQL TIFF ZLIB) + JASPER LIBXML2 LIBXSLT PERL PKG_CONFIG PostgreSQL TIFF ZLIB) check_version_string(${VTEST} ${VTEST}_VERSION_STRING) endforeach(VTEST) @@ -82,4 +82,3 @@ endforeach(VTEST) check_version_string(PYTHONINTERP PYTHON_VERSION_STRING) check_version_string(SUBVERSION Subversion_VERSION_SVN) -check_version_string(PKGCONFIG PKG_CONFIG_VERSION_STRING) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 0b79efa..1c6db39 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -24,11 +24,16 @@ # 4.) Create a <SubTest>.cmake file for each sub-test named above # containing the actual test code. Optionally create files # containing expected test results: -# <SubTest>-result.txt = Process result expected if not "0" -# <SubTest>-stdout.txt = Regex matching expected stdout content -# <SubTest>-stderr.txt = Regex matching expected stderr content +# <SubTest>-result.txt = Process result expected if not "0" +# <SubTest>-stdout.txt = Regex matching expected stdout content +# <SubTest>-stderr.txt = Regex matching expected stderr content +# <SubTest>-check.cmake = Custom result check # Note that trailing newlines will be stripped from actual test # output before matching against the stdout and stderr expressions. +# The code in <SubTest>-check.cmake may use variables +# RunCMake_TEST_SOURCE_DIR = Top of test source tree +# RunCMake_TEST_BINARY_DIR = Top of test binary tree +# and an failure must store a message in RunCMake_TEST_FAILED. macro(add_RunCMake_test test) add_test(RunCMake.${test} ${CMAKE_CMAKE_COMMAND} @@ -44,3 +49,8 @@ add_RunCMake_test(ObjectLibrary) add_RunCMake_test(build_command) add_RunCMake_test(find_package) +add_RunCMake_test(list) + +if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") + add_RunCMake_test(include_external_msproject) +endif() diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 2639463..c3c161a 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -25,14 +25,14 @@ function(run_cmake test) unset(expect_std${o}) endif() endforeach() - set(source_dir "${top_src}") - set(binary_dir "${top_bin}/${test}-build") - file(REMOVE_RECURSE "${binary_dir}") - file(MAKE_DIRECTORY "${binary_dir}") + set(RunCMake_TEST_SOURCE_DIR "${top_src}") + set(RunCMake_TEST_BINARY_DIR "${top_bin}/${test}-build") + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") execute_process( - COMMAND ${CMAKE_COMMAND} "${source_dir}" + COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}" -G "${RunCMake_GENERATOR}" -DRunCMake_TEST=${test} - WORKING_DIRECTORY "${binary_dir}" + WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" OUTPUT_VARIABLE actual_stdout ERROR_VARIABLE actual_stderr RESULT_VARIABLE actual_result @@ -53,6 +53,11 @@ function(run_cmake test) endif() endif() endforeach() + unset(RunCMake_TEST_FAILED) + include(${top_src}/${test}-check.cmake OPTIONAL) + if(RunCMake_TEST_FAILED) + set(msg "${RunCMake_TEST_FAILED}\n${msg}") + endif() if(msg) string(REGEX REPLACE "\n" "\n actual-out> " actual_out " actual-out> ${actual_stdout}") string(REGEX REPLACE "\n" "\n actual-err> " actual_err " actual-err> ${actual_stderr}") diff --git a/Tests/RunCMake/include_external_msproject/CMakeLists.txt b/Tests/RunCMake/include_external_msproject/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/include_external_msproject/CustomGuid-check.cmake b/Tests/RunCMake/include_external_msproject/CustomGuid-check.cmake new file mode 100644 index 0000000..68dec4c --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomGuid-check.cmake @@ -0,0 +1 @@ +check_project(CustomGuid external "aaa-bbb-ccc-000" "" "") diff --git a/Tests/RunCMake/include_external_msproject/CustomGuid.cmake b/Tests/RunCMake/include_external_msproject/CustomGuid.cmake new file mode 100644 index 0000000..1dbe7da --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomGuid.cmake @@ -0,0 +1,2 @@ +include_external_msproject(external external.project + GUID aaa-bbb-ccc-000) diff --git a/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform-check.cmake b/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform-check.cmake new file mode 100644 index 0000000..614712e --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform-check.cmake @@ -0,0 +1 @@ +check_project(CustomGuidTypePlatform external "aaa-bbb-ccc-111" "aaa-bbb-ccc-ddd-eee" "Custom Platform") diff --git a/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform.cmake b/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform.cmake new file mode 100644 index 0000000..ee4db65 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform.cmake @@ -0,0 +1,5 @@ +# Test all optional parameters are set. +include_external_msproject(external external.project + GUID aaa-bbb-ccc-111 + TYPE aaa-bbb-ccc-ddd-eee + PLATFORM "Custom Platform") diff --git a/Tests/RunCMake/include_external_msproject/CustomTypePlatform-check.cmake b/Tests/RunCMake/include_external_msproject/CustomTypePlatform-check.cmake new file mode 100644 index 0000000..054eeb0 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomTypePlatform-check.cmake @@ -0,0 +1 @@ +check_project(CustomTypePlatform external "" "aaa-bbb-ccc-ddd-eee" "Custom Platform") diff --git a/Tests/RunCMake/include_external_msproject/CustomTypePlatform.cmake b/Tests/RunCMake/include_external_msproject/CustomTypePlatform.cmake new file mode 100644 index 0000000..8c76adb --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomTypePlatform.cmake @@ -0,0 +1,3 @@ +include_external_msproject(external external.project + TYPE aaa-bbb-ccc-ddd-eee + PLATFORM "Custom Platform") diff --git a/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake b/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake new file mode 100644 index 0000000..90710f9 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) +include(${CMAKE_CURRENT_LIST_DIR}/check_utils.cmake) + +run_cmake(CustomGuid) +run_cmake(CustomTypePlatform) +run_cmake(CustomGuidTypePlatform) diff --git a/Tests/RunCMake/include_external_msproject/check_utils.cmake b/Tests/RunCMake/include_external_msproject/check_utils.cmake new file mode 100644 index 0000000..7d6b8f8 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/check_utils.cmake @@ -0,0 +1,109 @@ +# Check that file contains line that matches regular expression. +# Sets IS_FOUND variable to TRUE if found and to FALSE otherwise. +macro(check_line_exists TARGET_FILE REG_EXP_REF) + set(IS_FOUND "FALSE") + + file(STRINGS ${TARGET_FILE} FOUND_LINE LIMIT_COUNT 1 REGEX "${${REG_EXP_REF}}") + list(LENGTH FOUND_LINE _VAR_LEN) + + if(_VAR_LEN GREATER 0) + set(IS_FOUND "TRUE") + endif(_VAR_LEN GREATER 0) +endmacro(check_line_exists TARGET_FILE REG_EXP_REF) + +# Search and parse project section line by project name. +# If search was successful stores found type and guid into FOUND_TYPE and FOUND_GUID variables respectively. +# Sets IS_FOUND variable to TRUE if found and to FALSE otherwise. +macro(parse_project_section TARGET_FILE PROJECT_NAME) + set(REG_EXP "^Project\\(\\\"{(.+)}\\\"\\) = \\\"${PROJECT_NAME}\\\", \\\".+\\..+\\\", \\\"{(.+)}\\\"$") + + check_line_exists(${TARGET_FILE} REG_EXP) + if(NOT IS_FOUND) + return() + endif(NOT IS_FOUND) + + string(REGEX REPLACE "${REG_EXP}" "\\1;\\2" _GUIDS "${FOUND_LINE}") + + list(GET _GUIDS 0 FOUND_TYPE) + list(GET _GUIDS 1 FOUND_GUID) +endmacro(parse_project_section TARGET_FILE PROJECT_NAME) + +# Search project section line by project name and type. +# Returns TRUE if found and FALSE otherwise +function(check_project_type TARGET_FILE PROJECT_NAME PROJECT_TYPE RESULT) + set(${RESULT} "FALSE" PARENT_SCOPE) + + parse_project_section(${TARGET_FILE} ${PROJECT_NAME}) + if(IS_FOUND AND FOUND_TYPE STREQUAL PROJECT_TYPE) + set(${RESULT} "TRUE" PARENT_SCOPE) + endif(IS_FOUND AND FOUND_TYPE STREQUAL PROJECT_TYPE) +endfunction(check_project_type TARGET_FILE PROJECT_NAME PROJECT_TYPE RESULT) + + +# Search project section line by project name and id. +# Returns TRUE if found and FALSE otherwise +function(check_project_guid TARGET_FILE PROJECT_NAME PROJECT_GUID RESULT) + set(${RESULT} "FALSE" PARENT_SCOPE) + + parse_project_section(${TARGET_FILE} ${PROJECT_NAME}) + if(IS_FOUND AND FOUND_GUID STREQUAL PROJECT_GUID) + set(${RESULT} "TRUE" PARENT_SCOPE) + endif(IS_FOUND AND FOUND_GUID STREQUAL PROJECT_GUID) +endfunction(check_project_guid TARGET_FILE PROJECT_NAME PROJECT_GUID RESULT) + + +# Search project's build configuration line by project name and target platform name. +# Returns TRUE if found and FALSE otherwise +function(check_custom_platform TARGET_FILE PROJECT_NAME PLATFORM_NAME RESULT) + set(${RESULT} "FALSE" PARENT_SCOPE) + + # extract project guid + parse_project_section(${TARGET_FILE} ${PROJECT_NAME}) + if(NOT IS_FOUND) + return() + endif(NOT IS_FOUND) + + # probably whould be better to use configuration name + # extracted from CMAKE_CONFIGURATION_TYPES than just hardcoded "Debug" instead + set(REG_EXP "^(\t)*\\{${FOUND_GUID}\\}\\.Debug[^ ]*\\.ActiveCfg = Debug\\|${PLATFORM_NAME}$") + check_line_exists(${TARGET_FILE} REG_EXP) + + set(${RESULT} ${IS_FOUND} PARENT_SCOPE) +endfunction(check_custom_platform TARGET_FILE PLATFORM_NAME RESULT) + +# RunCMake test check helper +function(check_project test name guid type platform) + set(sln "${RunCMake_TEST_BINARY_DIR}/${test}.sln") + set(sep "") + set(failed "") + if(NOT type) + set(type 8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942) + endif() + if(NOT platform) + if("${RunCMake_GENERATOR}" MATCHES "Win64") + set(platform "x64") + else() + set(platform "Win32") + endif() + endif() + if(guid) + check_project_guid("${sln}" "${name}" "${guid}" passed_guid) + if(NOT passed_guid) + set(failed "${failed}${sep}${name} solution has no project with expected GUID=${guid}") + set(sep "\n") + endif() + else() + set(passed_guid 1) + endif() + check_project_type("${sln}" "${name}" "${type}" passed_type) + if(NOT passed_type) + set(failed "${failed}${sep}${name} solution has no project with expected TYPE=${type}") + set(sep "\n") + endif() + check_custom_platform("${sln}" "${name}" "${platform}" passed_platform) + if(NOT passed_platform) + set(failed "${failed}${sep}${name} solution has no project with expected PLATFORM=${platform}") + set(sep "\n") + endif() + set(RunCMake_TEST_FAILED "${failed}" PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/include_external_msproject/main.cpp b/Tests/RunCMake/include_external_msproject/main.cpp new file mode 100644 index 0000000..9198103 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/main.cpp @@ -0,0 +1,3 @@ +void main() +{ +} diff --git a/Tests/RunCMake/list/CMakeLists.txt b/Tests/RunCMake/list/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/list/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/list/EmptyGet0-result.txt b/Tests/RunCMake/list/EmptyGet0-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/EmptyGet0-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/EmptyGet0-stderr.txt b/Tests/RunCMake/list/EmptyGet0-stderr.txt new file mode 100644 index 0000000..0c61b01 --- /dev/null +++ b/Tests/RunCMake/list/EmptyGet0-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at EmptyGet0.cmake:2 \(list\): + list GET given empty list +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/EmptyGet0.cmake b/Tests/RunCMake/list/EmptyGet0.cmake new file mode 100644 index 0000000..4947108 --- /dev/null +++ b/Tests/RunCMake/list/EmptyGet0.cmake @@ -0,0 +1,2 @@ +set(mylist "") +list(GET mylist 0 result) diff --git a/Tests/RunCMake/list/EmptyInsert-1-result.txt b/Tests/RunCMake/list/EmptyInsert-1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/EmptyInsert-1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/EmptyInsert-1-stderr.txt b/Tests/RunCMake/list/EmptyInsert-1-stderr.txt new file mode 100644 index 0000000..0900ff9 --- /dev/null +++ b/Tests/RunCMake/list/EmptyInsert-1-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at EmptyInsert-1.cmake:2 \(list\): + list index: -1 out of range \(0, 0\) +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/EmptyInsert-1.cmake b/Tests/RunCMake/list/EmptyInsert-1.cmake new file mode 100644 index 0000000..140da5d --- /dev/null +++ b/Tests/RunCMake/list/EmptyInsert-1.cmake @@ -0,0 +1,2 @@ +set(mylist "") +list(INSERT mylist -1 x) diff --git a/Tests/RunCMake/list/EmptyRemoveAt0-result.txt b/Tests/RunCMake/list/EmptyRemoveAt0-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/EmptyRemoveAt0-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt b/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt new file mode 100644 index 0000000..b24a0ed --- /dev/null +++ b/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at EmptyRemoveAt0.cmake:2 \(list\): + list REMOVE_AT given empty list +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/EmptyRemoveAt0.cmake b/Tests/RunCMake/list/EmptyRemoveAt0.cmake new file mode 100644 index 0000000..d6a3e85 --- /dev/null +++ b/Tests/RunCMake/list/EmptyRemoveAt0.cmake @@ -0,0 +1,2 @@ +set(mylist "") +list(REMOVE_AT mylist 0) diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake new file mode 100644 index 0000000..555051d --- /dev/null +++ b/Tests/RunCMake/list/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(EmptyGet0) +run_cmake(EmptyRemoveAt0) +run_cmake(EmptyInsert-1) diff --git a/Utilities/cmlibarchive/libarchive/archive_endian.h b/Utilities/cmlibarchive/libarchive/archive_endian.h index 1dd8536..c3c78b3 100644 --- a/Utilities/cmlibarchive/libarchive/archive_endian.h +++ b/Utilities/cmlibarchive/libarchive/archive_endian.h @@ -44,9 +44,12 @@ * - Watcom C++ in C code. (For any version?) * - SGI MIPSpro * - Microsoft Visual C++ 6.0 (supposedly newer versions too) + * - IBM VisualAge 6 (XL v6) */ #if defined(__WATCOMC__) || defined(__sgi) || defined(__hpux) || defined(__BORLANDC__) #define inline +#elif defined(__IBMC__) && __IBMC__ < 700 +#define inline #elif defined(_MSC_VER) || defined(__osf__) #define inline __inline #endif diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c index 87136a6..0b9aaf9 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c @@ -197,7 +197,7 @@ struct isofile { enum { NO = 0, BOOT_CATALOG, - BOOT_IMAGE, + BOOT_IMAGE } boot; /* @@ -850,7 +850,7 @@ enum dir_rec_type { DIR_REC_VD, /* Stored in Volume Descriptor. */ DIR_REC_SELF, /* Stored as Current Directory. */ DIR_REC_PARENT, /* Stored as Parent Directory. */ - DIR_REC_NORMAL, /* Stored as Child. */ + DIR_REC_NORMAL /* Stored as Child. */ }; /* @@ -860,7 +860,7 @@ enum vdc { VDC_STD, VDC_LOWERCASE, VDC_UCS2, - VDC_UCS2_DIRECT, + VDC_UCS2_DIRECT }; /* @@ -897,7 +897,7 @@ struct idr { enum char_type { A_CHAR, - D_CHAR, + D_CHAR }; @@ -3989,7 +3989,7 @@ enum keytype { KEY_FLG, KEY_STR, KEY_INT, - KEY_HEX, + KEY_HEX }; static void set_option_info(struct archive_string *info, int *opt, const char *key, |