diff options
-rw-r--r-- | Help/manual/cmake-qt.7.rst | 19 | ||||
-rw-r--r-- | Help/prop_tgt/AUTORCC.rst | 5 | ||||
-rw-r--r-- | Modules/UseSWIG.cmake | 6 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmCustomCommandGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 28 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 102 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.h | 1 | ||||
-rw-r--r-- | Source/kwsys/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 141 | ||||
-rw-r--r-- | Source/kwsys/testSystemTools.cxx | 36 | ||||
-rw-r--r-- | Tests/CudaOnly/GPUDebugFlag/main.cu | 5 |
12 files changed, 165 insertions, 194 deletions
diff --git a/Help/manual/cmake-qt.7.rst b/Help/manual/cmake-qt.7.rst index e5c593f..724d8ec 100644 --- a/Help/manual/cmake-qt.7.rst +++ b/Help/manual/cmake-qt.7.rst @@ -217,19 +217,16 @@ enabling :prop_sf:`SKIP_AUTORCC` or the broader :prop_sf:`SKIP_AUTOGEN`. Visual Studio Generators ======================== -When using the :manual:`Visual Studio generators <cmake-generators(7)>` -CMake tries to use a ``PRE_BUILD`` -:command:`custom command <add_custom_command>` instead -of a :command:`custom target <add_custom_target>` for autogen. -``PRE_BUILD`` can't be used when the autogen target depends on files. +When using the :manual:`Visual Studio generators <cmake-generators(7)>`, +CMake uses a ``PRE_BUILD`` :command:`custom command <add_custom_command>` for +:prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC`. +If the :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC` processing depends on files, +a :command:`custom target <add_custom_target>` is used instead. This happens when -- :prop_tgt:`AUTOMOC` or :prop_tgt:`AUTOUIC` is enabled and the origin target - depends on :prop_sf:`GENERATED` files which aren't excluded from autogen by - :prop_sf:`SKIP_AUTOMOC`, :prop_sf:`SKIP_AUTOUIC`, :prop_sf:`SKIP_AUTOGEN` - or :policy:`CMP0071` -- :prop_tgt:`AUTORCC` is enabled and a ``.qrc`` file is listed in - the origin target sources +- The origin target depends on :prop_sf:`GENERATED` files which aren't excluded + from :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC` by :prop_sf:`SKIP_AUTOMOC`, + :prop_sf:`SKIP_AUTOUIC`, :prop_sf:`SKIP_AUTOGEN` or :policy:`CMP0071` - :prop_tgt:`AUTOGEN_TARGET_DEPENDS` lists a source file qtmain.lib on Windows diff --git a/Help/prop_tgt/AUTORCC.rst b/Help/prop_tgt/AUTORCC.rst index c0f6a26..3cc5990 100644 --- a/Help/prop_tgt/AUTORCC.rst +++ b/Help/prop_tgt/AUTORCC.rst @@ -13,6 +13,11 @@ as target sources at build time and invoke ``rcc`` accordingly. This property is initialized by the value of the :variable:`CMAKE_AUTORCC` variable if it is set when a target is created. +By default :prop_tgt:`AUTORCC` is processed inside a +:command:`custom command <add_custom_command>`. +If the ``.qrc`` file is :prop_sf:`GENERATED` though, a +:command:`custom target <add_custom_target>` is used instead. + Additional command line options for rcc can be set via the :prop_sf:`AUTORCC_OPTIONS` source file property on the ``.qrc`` file. diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index b38e2b7..959893f 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -219,7 +219,7 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) if(CMAKE_GENERATOR MATCHES "Make") get_filename_component(swig_generated_timestamp "${swig_generated_file_fullname}" NAME_WE) - set(swig_gen_target gen_${swig_generated_timestamp}) + set(swig_gen_target gen_${name}_${swig_generated_timestamp}) set(swig_generated_timestamp "${swig_outdir}/${swig_generated_timestamp}.stamp") set(swig_custom_output ${swig_generated_timestamp}) @@ -311,9 +311,11 @@ macro(SWIG_ADD_LIBRARY name) endforeach() set(swig_generated_sources) + set(swig_generated_targets) foreach(it ${swig_dot_i_sources}) SWIG_ADD_SOURCE_TO_MODULE(${name} swig_generated_source ${it}) set(swig_generated_sources ${swig_generated_sources} "${swig_generated_source}") + list(APPEND swig_generated_targets "${swig_gen_target}") endforeach() get_directory_property(swig_extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES) set_directory_properties(PROPERTIES @@ -324,7 +326,7 @@ macro(SWIG_ADD_LIBRARY name) ${swig_other_sources}) if(CMAKE_GENERATOR MATCHES "Make") # see IMPLICIT_DEPENDS above - add_dependencies(${SWIG_MODULE_${name}_REAL_NAME} ${swig_gen_target}) + add_dependencies(${SWIG_MODULE_${name}_REAL_NAME} ${swig_generated_targets}) endif() if("${_SAM_TYPE}" STREQUAL "MODULE") set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES NO_SONAME ON) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 7d735ea..a6e8503 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 10) -set(CMake_VERSION_PATCH 20180201) +set(CMake_VERSION_PATCH 20180205) #set(CMake_VERSION_RC 1) diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 0f5119e..136cf39 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -8,7 +8,6 @@ #include "cmGeneratorTarget.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" -#include "cmOutputConverter.h" #include "cmStateTypes.h" #include "cmSystemTools.h" @@ -167,8 +166,7 @@ void cmCustomCommandGenerator::AppendArguments(unsigned int c, if (this->OldStyle) { cmd += escapeForShellOldStyle(arg); } else { - cmOutputConverter converter(this->LG->GetStateSnapshot()); - cmd += converter.EscapeForShell(arg, this->MakeVars); + cmd += this->LG->EscapeForShell(arg, this->MakeVars); } } } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index eb595ba..ddbc772 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -685,16 +685,11 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() } } - cmNinjaDeps byproducts; - if (!this->TargetNameImport.empty()) { const std::string impLibPath = localGen.ConvertToOutputFormat( targetOutputImplib, cmOutputConverter::SHELL); vars["TARGET_IMPLIB"] = impLibPath; EnsureParentDirectoryExists(impLibPath); - if (genTarget.HasImportLibrary()) { - byproducts.push_back(targetOutputImplib); - } } const std::string objPath = GetGeneratorTarget()->GetSupportDirectory(); @@ -712,29 +707,6 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() std::replace(link_path.begin(), link_path.end(), '\\', '/'); } - const std::vector<cmCustomCommand>* cmdLists[3] = { - &genTarget.GetPreBuildCommands(), &genTarget.GetPreLinkCommands(), - &genTarget.GetPostBuildCommands() - }; - - std::vector<std::string> preLinkCmdLines, postBuildCmdLines; - vars["PRE_LINK"] = localGen.BuildCommandLine(preLinkCmdLines); - vars["POST_BUILD"] = localGen.BuildCommandLine(postBuildCmdLines); - - std::vector<std::string>* cmdLineLists[3] = { &preLinkCmdLines, - &preLinkCmdLines, - &postBuildCmdLines }; - - for (unsigned i = 0; i != 3; ++i) { - for (cmCustomCommand const& cc : *cmdLists[i]) { - cmCustomCommandGenerator ccg(cc, cfgName, this->GetLocalGenerator()); - localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]); - std::vector<std::string> const& ccByproducts = ccg.GetByproducts(); - std::transform(ccByproducts.begin(), ccByproducts.end(), - std::back_inserter(byproducts), MapToNinjaPath()); - } - } - cmGlobalNinjaGenerator& globalGen = *this->GetGlobalGenerator(); // Device linking currently doesn't support response files so diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 9115eb7..ec31bd6 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -18,6 +18,8 @@ #include <iterator> #include <memory> // IWYU pragma: keep +static void ConvertToWindowsSlash(std::string& s); + static std::string cmVS10EscapeXML(std::string arg) { cmSystemTools::ReplaceString(arg, "&", "&"); @@ -482,7 +484,7 @@ void cmVisualStudio10TargetGenerator::Generate() std::string propsLocal; propsLocal += this->DefaultArtifactDir; propsLocal += "\\nasm.props"; - this->ConvertToWindowsSlash(propsLocal); + ConvertToWindowsSlash(propsLocal); this->Makefile->ConfigureFile(propsTemplate.c_str(), propsLocal.c_str(), false, true, true); std::string import = std::string("<Import Project=\"") + @@ -505,7 +507,7 @@ void cmVisualStudio10TargetGenerator::Generate() props = p; } if (!props.empty()) { - this->ConvertToWindowsSlash(props); + ConvertToWindowsSlash(props); this->WriteString("", 2); (*this->BuildFileStream) << "<Import Project=\"" << cmVS10EscapeXML(props) << "\"" @@ -604,7 +606,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() ->GetCurrentSourceDirectory()) + "/" + path; } - this->ConvertToWindowsSlash(path); + ConvertToWindowsSlash(path); hintReferences.push_back(HintReference(name, path)); } } @@ -617,7 +619,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() if (cmsys::SystemTools::FileExists(ri, true)) { std::string name = cmsys::SystemTools::GetFilenameWithoutExtension(ri); std::string path = ri; - this->ConvertToWindowsSlash(path); + ConvertToWindowsSlash(path); hintReferences.push_back(HintReference(name, path)); } else { this->WriteDotNetReference(ri, ""); @@ -691,11 +693,11 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() if (!resxObjs.empty()) { this->WriteString("<ItemGroup>\n", 1); std::string srcDir = this->Makefile->GetCurrentSourceDirectory(); - this->ConvertToWindowsSlash(srcDir); + ConvertToWindowsSlash(srcDir); for (cmSourceFile const* oi : resxObjs) { std::string obj = oi->GetFullPath(); this->WriteString("<EmbeddedResource Include=\"", 2); - this->ConvertToWindowsSlash(obj); + ConvertToWindowsSlash(obj); bool useRelativePath = false; if (this->ProjectType == csproj && this->InSourceBuild) { // If we do an in-source build and the resource file is in a @@ -704,7 +706,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() // visual studio does not show the file in the IDE. Sorry. if (obj.find(srcDir) == 0) { obj = this->ConvertPath(obj, true); - this->ConvertToWindowsSlash(obj); + ConvertToWindowsSlash(obj); useRelativePath = true; } } @@ -728,7 +730,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() } } else { std::string binDir = this->Makefile->GetCurrentBinaryDirectory(); - this->ConvertToWindowsSlash(binDir); + ConvertToWindowsSlash(binDir); // If the resource was NOT added using a relative path (which should // be the default), we have to provide a link here if (!useRelativePath) { @@ -767,7 +769,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() designerResource = cmsys::SystemTools::GetFilenameName(designerResource); } - this->ConvertToWindowsSlash(designerResource); + ConvertToWindowsSlash(designerResource); this->WriteString("<LastGenOutput>", 3); (*this->BuildFileStream) << designerResource << "</LastGenOutput>\n"; @@ -827,7 +829,7 @@ void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup() link = cmsys::SystemTools::GetFilenameName(obj); } if (!link.empty()) { - this->ConvertToWindowsSlash(link); + ConvertToWindowsSlash(link); this->WriteString("<Link>", 3); (*this->BuildFileStream) << link << "</Link>\n"; } @@ -1055,7 +1057,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( } std::string outDir = this->GeneratorTarget->GetDirectory(config) + "/"; - this->ConvertToWindowsSlash(outDir); + ConvertToWindowsSlash(outDir); this->WriteString("<OutputPath>", 2); (*this->BuildFileStream) << cmVS10EscapeXML(outDir) << "</OutputPath>\n"; @@ -1235,7 +1237,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( d != ccg.GetDepends().end(); ++d) { std::string dep; if (this->LocalGenerator->GetRealDependency(*d, *i, dep)) { - this->ConvertToWindowsSlash(dep); + ConvertToWindowsSlash(dep); inputs << ";" << cmVS10EscapeXML(dep); } } @@ -1245,7 +1247,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( for (std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin(); o != ccg.GetOutputs().end(); ++o) { std::string out = *o; - this->ConvertToWindowsSlash(out); + ConvertToWindowsSlash(out); outputs << sep << cmVS10EscapeXML(out); sep = ";"; } @@ -1323,7 +1325,7 @@ std::string cmVisualStudio10TargetGenerator::ConvertPath( : path.c_str(); } -void cmVisualStudio10TargetGenerator::ConvertToWindowsSlash(std::string& s) +static void ConvertToWindowsSlash(std::string& s) { // first convert all of the slashes std::string::size_type pos = 0; @@ -1424,7 +1426,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() for (cmSourceFile const* oi : resxObjs) { std::string obj = oi->GetFullPath(); this->WriteString("<EmbeddedResource Include=\"", 2); - this->ConvertToWindowsSlash(obj); + ConvertToWindowsSlash(obj); (*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\">\n"; this->WriteString("<Filter>Resource Files</Filter>\n", 3); this->WriteString("</EmbeddedResource>\n", 2); @@ -1526,7 +1528,7 @@ void cmVisualStudio10TargetGenerator::WriteGroupSources( std::string const& filter = sourceGroup->GetFullName(); this->WriteString("<", 2); std::string path = this->ConvertPath(source, s.RelativePath); - this->ConvertToWindowsSlash(path); + ConvertToWindowsSlash(path); (*this->BuildFileStream) << name << " Include=\"" << cmVS10EscapeXML(path); if (!filter.empty()) { (*this->BuildFileStream) << "\">\n"; @@ -1599,7 +1601,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) sourceLink = cmsys::SystemTools::GetFilenameName(fullFileName); } if (!sourceLink.empty()) { - this->ConvertToWindowsSlash(sourceLink); + ConvertToWindowsSlash(sourceLink); } } } @@ -1871,7 +1873,7 @@ void cmVisualStudio10TargetGenerator::WriteSource(std::string const& tool, this->GlobalGenerator->PathTooLong(this->GeneratorTarget, sf, sourceRel); } } - this->ConvertToWindowsSlash(sourceFile); + ConvertToWindowsSlash(sourceFile); this->WriteString("<", 2); (*this->BuildFileStream) << tool << " Include=\"" << cmVS10EscapeXML(sourceFile) << "\"" @@ -2262,8 +2264,8 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() outDir = this->GeneratorTarget->GetDirectory(config) + "/"; targetNameFull = this->GeneratorTarget->GetFullName(config); } - this->ConvertToWindowsSlash(intermediateDir); - this->ConvertToWindowsSlash(outDir); + ConvertToWindowsSlash(intermediateDir); + ConvertToWindowsSlash(outDir); this->WritePlatformConfigTag("OutDir", config, 2); *this->BuildFileStream << cmVS10EscapeXML(outDir) << "</OutDir>\n"; @@ -2350,7 +2352,7 @@ std::vector<std::string> cmVisualStudio10TargetGenerator::GetIncludes( this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, lang, config); for (std::string& i : includes) { - this->ConvertToWindowsSlash(i); + ConvertToWindowsSlash(i); } return includes; } @@ -2580,7 +2582,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( // Specify the compiler program database file if configured. std::string pdb = this->GeneratorTarget->GetCompilePDBPath(configName); if (!pdb.empty()) { - this->ConvertToWindowsSlash(pdb); + ConvertToWindowsSlash(pdb); this->WriteString("<ProgramDataBaseFileName>", 3); *this->BuildFileStream << cmVS10EscapeXML(pdb) << "</ProgramDataBaseFileName>\n"; @@ -3032,7 +3034,7 @@ void cmVisualStudio10TargetGenerator::WriteManifestOptions( this->WriteString("<AdditionalManifestFiles>", 3); for (cmSourceFile const* mi : manifest_srcs) { std::string m = this->ConvertPath(mi->GetFullPath(), false); - this->ConvertToWindowsSlash(m); + ConvertToWindowsSlash(m); (*this->BuildFileStream) << m << ";"; } (*this->BuildFileStream) << "</AdditionalManifestFiles>\n"; @@ -3063,7 +3065,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( std::string antBuildPath = rootDir; this->WriteString("<AntBuild>\n", 2); this->WriteString("<AntBuildPath>", 3); - this->ConvertToWindowsSlash(antBuildPath); + ConvertToWindowsSlash(antBuildPath); (*this->BuildFileStream) << cmVS10EscapeXML(antBuildPath) << "</AntBuildPath>\n"; } @@ -3150,7 +3152,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( { std::string manifest_xml = rootDir + "/AndroidManifest.xml"; - this->ConvertToWindowsSlash(manifest_xml); + ConvertToWindowsSlash(manifest_xml); this->WriteString("<AndroidManifestLocation>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(manifest_xml) << "</AndroidManifestLocation>\n"; @@ -3429,7 +3431,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions( if (l.IsPath && cmVS10IsTargetsFile(l.Value)) { std::string path = this->LocalGenerator->ConvertToRelativePath(currentBinDir, l.Value); - this->ConvertToWindowsSlash(path); + ConvertToWindowsSlash(path); this->AddTargetsFileAndConfigPair(path, config); } } @@ -3475,7 +3477,7 @@ void cmVisualStudio10TargetGenerator::AddLibraries( if (l.IsPath) { std::string path = this->LocalGenerator->ConvertToRelativePath(currentBinDir, l.Value); - this->ConvertToWindowsSlash(path); + ConvertToWindowsSlash(path); if (cmVS10IsTargetsFile(l.Value)) { vsTargetVec.push_back(path); } else { @@ -3694,7 +3696,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() path += dt->GetName(); path += computeProjectFileExtension(dt, *this->Configurations.begin()); } - this->ConvertToWindowsSlash(path); + ConvertToWindowsSlash(path); (*this->BuildFileStream) << cmVS10EscapeXML(path) << "\">\n"; this->WriteString("<Project>", 3); (*this->BuildFileStream) << "{" << this->GlobalGenerator->GetGUID(name) @@ -3825,7 +3827,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() this->GeneratorTarget->GetCertificates(certificates, ""); for (cmSourceFile const* si : certificates) { pfxFile = this->ConvertPath(si->GetFullPath(), false); - this->ConvertToWindowsSlash(pfxFile); + ConvertToWindowsSlash(pfxFile); break; } @@ -3835,7 +3837,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() // Move the manifest to a project directory to avoid clashes std::string artifactDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); - this->ConvertToWindowsSlash(artifactDir); + ConvertToWindowsSlash(artifactDir); this->WriteString("<PropertyGroup>\n", 1); this->WriteString("<AppxPackageArtifactsDir>", 2); (*this->BuildFileStream) << cmVS10EscapeXML(artifactDir) @@ -3843,7 +3845,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() this->WriteString("<ProjectPriFullPath>", 2); std::string resourcePriFile = this->DefaultArtifactDir + "/resources.pri"; - this->ConvertToWindowsSlash(resourcePriFile); + ConvertToWindowsSlash(resourcePriFile); (*this->BuildFileStream) << resourcePriFile << "</ProjectPriFullPath>\n"; // If we are missing files and we don't have a certificate and @@ -3854,7 +3856,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() pfxFile = this->DefaultArtifactDir + "/Windows_TemporaryKey.pfx"; cmSystemTools::CopyAFile(templateFolder + "/Windows_TemporaryKey.pfx", pfxFile, false); - this->ConvertToWindowsSlash(pfxFile); + ConvertToWindowsSlash(pfxFile); this->AddedFiles.push_back(pfxFile); } @@ -4098,7 +4100,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80() std::string("/WMAppManifest.xml"); std::string artifactDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); - this->ConvertToWindowsSlash(artifactDir); + ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); std::string targetNameXML = cmVS10EscapeXML(this->GeneratorTarget->GetName()); @@ -4145,7 +4147,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80() /* clang-format on */ std::string sourceFile = this->ConvertPath(manifestFile, false); - this->ConvertToWindowsSlash(sourceFile); + ConvertToWindowsSlash(sourceFile); this->WriteString("<Xml Include=\"", 2); (*this->BuildFileStream) << cmVS10EscapeXML(sourceFile) << "\">\n"; this->WriteString("<SubType>Designer</SubType>\n", 3); @@ -4155,14 +4157,14 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80() std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png"; cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png", smallLogo, false); - this->ConvertToWindowsSlash(smallLogo); + ConvertToWindowsSlash(smallLogo); this->WriteString("<Image Include=\"", 2); (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo) << "\" />\n"; this->AddedFiles.push_back(smallLogo); std::string logo = this->DefaultArtifactDir + "/Logo.png"; cmSystemTools::CopyAFile(templateFolder + "/Logo.png", logo, false); - this->ConvertToWindowsSlash(logo); + ConvertToWindowsSlash(logo); this->WriteString("<Image Include=\"", 2); (*this->BuildFileStream) << cmVS10EscapeXML(logo) << "\" />\n"; this->AddedFiles.push_back(logo); @@ -4171,7 +4173,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80() this->DefaultArtifactDir + "/ApplicationIcon.png"; cmSystemTools::CopyAFile(templateFolder + "/ApplicationIcon.png", applicationIcon, false); - this->ConvertToWindowsSlash(applicationIcon); + ConvertToWindowsSlash(applicationIcon); this->WriteString("<Image Include=\"", 2); (*this->BuildFileStream) << cmVS10EscapeXML(applicationIcon) << "\" />\n"; this->AddedFiles.push_back(applicationIcon); @@ -4183,7 +4185,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81() this->DefaultArtifactDir + "/package.appxManifest"; std::string artifactDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); - this->ConvertToWindowsSlash(artifactDir); + ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); std::string targetNameXML = cmVS10EscapeXML(this->GeneratorTarget->GetName()); @@ -4246,7 +4248,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80() this->DefaultArtifactDir + "/package.appxManifest"; std::string artifactDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); - this->ConvertToWindowsSlash(artifactDir); + ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); std::string targetNameXML = cmVS10EscapeXML(this->GeneratorTarget->GetName()); @@ -4301,7 +4303,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81() this->DefaultArtifactDir + "/package.appxManifest"; std::string artifactDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); - this->ConvertToWindowsSlash(artifactDir); + ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); std::string targetNameXML = cmVS10EscapeXML(this->GeneratorTarget->GetName()); @@ -4361,7 +4363,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0() this->DefaultArtifactDir + "/package.appxManifest"; std::string artifactDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); - this->ConvertToWindowsSlash(artifactDir); + ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); std::string targetNameXML = cmVS10EscapeXML(this->GeneratorTarget->GetName()); @@ -4423,7 +4425,7 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles( cmSystemTools::GetCMakeRoot() + "/Templates/Windows"; std::string sourceFile = this->ConvertPath(manifestFile, false); - this->ConvertToWindowsSlash(sourceFile); + ConvertToWindowsSlash(sourceFile); this->WriteString("<AppxManifest Include=\"", 2); (*this->BuildFileStream) << cmVS10EscapeXML(sourceFile) << "\">\n"; this->WriteString("<SubType>Designer</SubType>\n", 3); @@ -4433,7 +4435,7 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles( std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png"; cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png", smallLogo, false); - this->ConvertToWindowsSlash(smallLogo); + ConvertToWindowsSlash(smallLogo); this->WriteString("<Image Include=\"", 2); (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo) << "\" />\n"; this->AddedFiles.push_back(smallLogo); @@ -4441,14 +4443,14 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles( std::string smallLogo44 = this->DefaultArtifactDir + "/SmallLogo44x44.png"; cmSystemTools::CopyAFile(templateFolder + "/SmallLogo44x44.png", smallLogo44, false); - this->ConvertToWindowsSlash(smallLogo44); + ConvertToWindowsSlash(smallLogo44); this->WriteString("<Image Include=\"", 2); (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo44) << "\" />\n"; this->AddedFiles.push_back(smallLogo44); std::string logo = this->DefaultArtifactDir + "/Logo.png"; cmSystemTools::CopyAFile(templateFolder + "/Logo.png", logo, false); - this->ConvertToWindowsSlash(logo); + ConvertToWindowsSlash(logo); this->WriteString("<Image Include=\"", 2); (*this->BuildFileStream) << cmVS10EscapeXML(logo) << "\" />\n"; this->AddedFiles.push_back(logo); @@ -4456,7 +4458,7 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles( std::string storeLogo = this->DefaultArtifactDir + "/StoreLogo.png"; cmSystemTools::CopyAFile(templateFolder + "/StoreLogo.png", storeLogo, false); - this->ConvertToWindowsSlash(storeLogo); + ConvertToWindowsSlash(storeLogo); this->WriteString("<Image Include=\"", 2); (*this->BuildFileStream) << cmVS10EscapeXML(storeLogo) << "\" />\n"; this->AddedFiles.push_back(storeLogo); @@ -4464,14 +4466,14 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles( std::string splashScreen = this->DefaultArtifactDir + "/SplashScreen.png"; cmSystemTools::CopyAFile(templateFolder + "/SplashScreen.png", splashScreen, false); - this->ConvertToWindowsSlash(splashScreen); + ConvertToWindowsSlash(splashScreen); this->WriteString("<Image Include=\"", 2); (*this->BuildFileStream) << cmVS10EscapeXML(splashScreen) << "\" />\n"; this->AddedFiles.push_back(splashScreen); // This file has already been added to the build so don't copy it std::string keyFile = this->DefaultArtifactDir + "/Windows_TemporaryKey.pfx"; - this->ConvertToWindowsSlash(keyFile); + ConvertToWindowsSlash(keyFile); this->WriteString("<None Include=\"", 2); (*this->BuildFileStream) << cmVS10EscapeXML(keyFile) << "\" />\n"; } @@ -4542,7 +4544,7 @@ void cmVisualStudio10TargetGenerator::GetCSharpSourceLink( if (const char* l = sf->GetProperty("VS_CSHARP_Link")) { link = l; } - this->ConvertToWindowsSlash(link); + ConvertToWindowsSlash(link); } } } @@ -4553,7 +4555,7 @@ std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath( // Always search in the standard modules location. std::string path = cmSystemTools::GetCMakeRoot() + "/"; path += relativeFilePath; - this->ConvertToWindowsSlash(path); + ConvertToWindowsSlash(path); return path; } diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 2bc5da9..33d4fb7 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -54,7 +54,6 @@ private: }; std::string ConvertPath(std::string const& path, bool forceRelative); - static void ConvertToWindowsSlash(std::string& s); void WriteString(const char* line, int indentLevel); void WriteProjectConfigurations(); void WriteProjectConfigurationValues(); diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 2570e5b..c0154c8 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -496,6 +496,16 @@ IF(KWSYS_USE_SystemTools) KWSYS_CXX_STAT_HAS_ST_MTIM=${KWSYS_CXX_STAT_HAS_ST_MTIM} KWSYS_CXX_STAT_HAS_ST_MTIMESPEC=${KWSYS_CXX_STAT_HAS_ST_MTIMESPEC} ) + IF(NOT WIN32) + IF(KWSYS_STANDALONE) + OPTION(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES "If true, Windows paths will be supported on Unix as well" ON) + ENDIF() + IF(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES) + SET_PROPERTY(SOURCE SystemTools.cxx testSystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS + KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES + ) + ENDIF() + ENDIF() # Disable getpwnam for static linux builds since it depends on shared glibc GET_PROPERTY(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 999beb3..38910c8 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1884,21 +1884,23 @@ static void ConvertVMSToUnix(std::string& path) // convert windows slashes to unix slashes void SystemTools::ConvertToUnixSlashes(std::string& path) { + if (path.empty()) { + return; + } + const char* pathCString = path.c_str(); bool hasDoubleSlash = false; #ifdef __VMS ConvertVMSToUnix(path); #else const char* pos0 = pathCString; - const char* pos1 = pathCString + 1; for (std::string::size_type pos = 0; *pos0; ++pos) { - // make sure we don't convert an escaped space to a unix slash - if (*pos0 == '\\' && *pos1 != ' ') { + if (*pos0 == '\\') { path[pos] = '/'; } // Also, reuse the loop to check for slash followed by another slash - if (*pos1 == '/' && *(pos1 + 1) == '/' && !hasDoubleSlash) { + if (!hasDoubleSlash && *(pos0 + 1) == '/' && *(pos0 + 2) == '/') { #ifdef _WIN32 // However, on windows if the first characters are both slashes, // then keep them that way, so that network paths can be handled. @@ -1911,43 +1913,41 @@ void SystemTools::ConvertToUnixSlashes(std::string& path) } pos0++; - pos1++; } if (hasDoubleSlash) { SystemTools::ReplaceString(path, "//", "/"); } #endif + // remove any trailing slash - if (!path.empty()) { - // if there is a tilda ~ then replace it with HOME - pathCString = path.c_str(); - if (pathCString[0] == '~' && - (pathCString[1] == '/' || pathCString[1] == '\0')) { - std::string homeEnv; - if (SystemTools::GetEnv("HOME", homeEnv)) { - path.replace(0, 1, homeEnv); - } + // if there is a tilda ~ then replace it with HOME + pathCString = path.c_str(); + if (pathCString[0] == '~' && + (pathCString[1] == '/' || pathCString[1] == '\0')) { + std::string homeEnv; + if (SystemTools::GetEnv("HOME", homeEnv)) { + path.replace(0, 1, homeEnv); } + } #ifdef HAVE_GETPWNAM - else if (pathCString[0] == '~') { - std::string::size_type idx = path.find_first_of("/\0"); - std::string user = path.substr(1, idx - 1); - passwd* pw = getpwnam(user.c_str()); - if (pw) { - path.replace(0, idx, pw->pw_dir); - } + else if (pathCString[0] == '~') { + std::string::size_type idx = path.find_first_of("/\0"); + std::string user = path.substr(1, idx - 1); + passwd* pw = getpwnam(user.c_str()); + if (pw) { + path.replace(0, idx, pw->pw_dir); } + } #endif - // remove trailing slash if the path is more than - // a single / - pathCString = path.c_str(); - size_t size = path.size(); - if (size > 1 && *path.rbegin() == '/') { - // if it is c:/ then do not remove the trailing slash - if (!((size == 3 && pathCString[1] == ':'))) { - path.resize(size - 1); - } + // remove trailing slash if the path is more than + // a single / + pathCString = path.c_str(); + size_t size = path.size(); + if (size > 1 && *path.rbegin() == '/') { + // if it is c:/ then do not remove the trailing slash + if (!((size == 3 && pathCString[1] == ':'))) { + path.resize(size - 1); } } } @@ -3171,8 +3171,8 @@ void SystemTools::CheckTranslationPath(std::string& path) static void SystemToolsAppendComponents( std::vector<std::string>& out_components, - std::vector<std::string>::const_iterator first, - std::vector<std::string>::const_iterator last) + std::vector<std::string>::iterator first, + std::vector<std::string>::iterator last) { static const std::string up = ".."; static const std::string cur = "."; @@ -3182,7 +3182,11 @@ static void SystemToolsAppendComponents( out_components.resize(out_components.size() - 1); } } else if (!i->empty() && *i != cur) { +#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) + out_components.push_back(std::move(*i)); +#else out_components.push_back(*i); +#endif } } } @@ -3190,63 +3194,18 @@ static void SystemToolsAppendComponents( std::string SystemTools::CollapseFullPath(const std::string& in_path, const char* in_base) { - // Collect the output path components. - std::vector<std::string> out_components; - - // Split the input path components. - std::vector<std::string> path_components; - SystemTools::SplitPath(in_path, path_components); - - // If the input path is relative, start with a base path. - if (path_components[0].empty()) { - std::vector<std::string> base_components; - if (in_base) { - // Use the given base path. - SystemTools::SplitPath(in_base, base_components); + // Use the current working directory as a base path. + char buf[2048]; + const char* res_in_base = in_base; + if (!res_in_base) { + if (const char* cwd = Getcwd(buf, 2048)) { + res_in_base = cwd; } else { - // Use the current working directory as a base path. - char buf[2048]; - if (const char* cwd = Getcwd(buf, 2048)) { - SystemTools::SplitPath(cwd, base_components); - } else { - base_components.push_back(""); - } + res_in_base = ""; } - - // Append base path components to the output path. - out_components.push_back(base_components[0]); - SystemToolsAppendComponents(out_components, base_components.begin() + 1, - base_components.end()); } - // Append input path components to the output path. - SystemToolsAppendComponents(out_components, path_components.begin(), - path_components.end()); - - // Transform the path back to a string. - std::string newPath = SystemTools::JoinPath(out_components); - - // Update the translation table with this potentially new path. I am not - // sure why this line is here, it seems really questionable, but yet I - // would put good money that if I remove it something will break, basically - // from what I can see it created a mapping from the collapsed path, to be - // replaced by the input path, which almost completely does the opposite of - // this function, the only thing preventing this from happening a lot is - // that if the in_path has a .. in it, then it is not added to the - // translation table. So for most calls this either does nothing due to the - // .. or it adds a translation between identical paths as nothing was - // collapsed, so I am going to try to comment it out, and see what hits the - // fan, hopefully quickly. - // Commented out line below: - // SystemTools::AddTranslationPath(newPath, in_path); - - SystemTools::CheckTranslationPath(newPath); -#ifdef _WIN32 - newPath = SystemTools::GetActualCaseForPath(newPath); - SystemTools::ConvertToUnixSlashes(newPath); -#endif - // Return the reconstructed path. - return newPath; + return SystemTools::CollapseFullPath(in_path, std::string(res_in_base)); } std::string SystemTools::CollapseFullPath(const std::string& in_path, @@ -3258,9 +3217,10 @@ std::string SystemTools::CollapseFullPath(const std::string& in_path, // Split the input path components. std::vector<std::string> path_components; SystemTools::SplitPath(in_path, path_components); + out_components.reserve(path_components.size()); // If the input path is relative, start with a base path. - if (path_components[0].length() == 0) { + if (path_components[0].empty()) { std::vector<std::string> base_components; // Use the given base path. SystemTools::SplitPath(in_base, base_components); @@ -3619,7 +3579,7 @@ std::string SystemTools::JoinPath( // All remaining components are always separated with a slash. while (first != last) { - result.append("/"); + result.push_back('/'); result.append((*first++)); } @@ -3715,7 +3675,12 @@ std::string SystemTools::GetFilenamePath(const std::string& filename) */ std::string SystemTools::GetFilenameName(const std::string& filename) { - std::string::size_type slash_pos = filename.find_last_of("/\\"); +#if defined(_WIN32) || defined(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES) + const char* separators = "/\\"; +#else + char separators = '/'; +#endif + std::string::size_type slash_pos = filename.find_last_of(separators); if (slash_pos != std::string::npos) { return filename.substr(slash_pos + 1); } else { diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index f1321e5..e436a2b 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -39,19 +39,19 @@ typedef unsigned short mode_t; static const char* toUnixPaths[][2] = { { "/usr/local/bin/passwd", "/usr/local/bin/passwd" }, { "/usr/lo cal/bin/pa sswd", "/usr/lo cal/bin/pa sswd" }, - { "/usr/lo\\ cal/bin/pa\\ sswd", "/usr/lo\\ cal/bin/pa\\ sswd" }, + { "/usr/lo\\ cal/bin/pa\\ sswd", "/usr/lo/ cal/bin/pa/ sswd" }, { "c:/usr/local/bin/passwd", "c:/usr/local/bin/passwd" }, { "c:/usr/lo cal/bin/pa sswd", "c:/usr/lo cal/bin/pa sswd" }, - { "c:/usr/lo\\ cal/bin/pa\\ sswd", "c:/usr/lo\\ cal/bin/pa\\ sswd" }, + { "c:/usr/lo\\ cal/bin/pa\\ sswd", "c:/usr/lo/ cal/bin/pa/ sswd" }, { "\\usr\\local\\bin\\passwd", "/usr/local/bin/passwd" }, { "\\usr\\lo cal\\bin\\pa sswd", "/usr/lo cal/bin/pa sswd" }, - { "\\usr\\lo\\ cal\\bin\\pa\\ sswd", "/usr/lo\\ cal/bin/pa\\ sswd" }, + { "\\usr\\lo\\ cal\\bin\\pa\\ sswd", "/usr/lo/ cal/bin/pa/ sswd" }, { "c:\\usr\\local\\bin\\passwd", "c:/usr/local/bin/passwd" }, { "c:\\usr\\lo cal\\bin\\pa sswd", "c:/usr/lo cal/bin/pa sswd" }, - { "c:\\usr\\lo\\ cal\\bin\\pa\\ sswd", "c:/usr/lo\\ cal/bin/pa\\ sswd" }, + { "c:\\usr\\lo\\ cal\\bin\\pa\\ sswd", "c:/usr/lo/ cal/bin/pa/ sswd" }, { "\\\\usr\\local\\bin\\passwd", "//usr/local/bin/passwd" }, { "\\\\usr\\lo cal\\bin\\pa sswd", "//usr/lo cal/bin/pa sswd" }, - { "\\\\usr\\lo\\ cal\\bin\\pa\\ sswd", "//usr/lo\\ cal/bin/pa\\ sswd" }, + { "\\\\usr\\lo\\ cal\\bin\\pa\\ sswd", "//usr/lo/ cal/bin/pa/ sswd" }, { KWSYS_NULLPTR, KWSYS_NULLPTR } }; @@ -700,6 +700,16 @@ static bool CheckCollapsePath() bool res = true; res &= CheckCollapsePath("/usr/share/*", "/usr/share/*"); res &= CheckCollapsePath("C:/Windows/*", "C:/Windows/*"); + res &= CheckCollapsePath("/usr/share/../lib", "/usr/lib"); + res &= CheckCollapsePath("/usr/share/./lib", "/usr/share/lib"); + res &= CheckCollapsePath("/usr/share/../../lib", "/lib"); + res &= CheckCollapsePath("/usr/share/.././../lib", "/lib"); + res &= CheckCollapsePath("/../lib", "/lib"); + res &= CheckCollapsePath("/../lib/", "/lib"); + res &= CheckCollapsePath("/", "/"); + res &= CheckCollapsePath("C:/", "C:/"); + res &= CheckCollapsePath("C:/../", "C:/"); + res &= CheckCollapsePath("C:/../../", "C:/"); return res; } @@ -764,20 +774,26 @@ static bool CheckGetFilenameName() const char* windowsFilepath = "C:\\somewhere\\something"; const char* unixFilepath = "/somewhere/something"; - std::string expectedFilename = "something"; +#if defined(_WIN32) || defined(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES) + std::string expectedWindowsFilename = "something"; +#else + std::string expectedWindowsFilename = "C:\\somewhere\\something"; +#endif + std::string expectedUnixFilename = "something"; bool res = true; std::string filename = kwsys::SystemTools::GetFilenameName(windowsFilepath); - if (filename != expectedFilename) { + if (filename != expectedWindowsFilename) { std::cerr << "GetFilenameName(" << windowsFilepath << ") yielded " - << filename << " instead of " << expectedFilename << std::endl; + << filename << " instead of " << expectedWindowsFilename + << std::endl; res = false; } filename = kwsys::SystemTools::GetFilenameName(unixFilepath); - if (filename != expectedFilename) { + if (filename != expectedUnixFilename) { std::cerr << "GetFilenameName(" << unixFilepath << ") yielded " << filename - << " instead of " << expectedFilename << std::endl; + << " instead of " << expectedUnixFilename << std::endl; res = false; } return res; diff --git a/Tests/CudaOnly/GPUDebugFlag/main.cu b/Tests/CudaOnly/GPUDebugFlag/main.cu index 8b97a3f..1f3fc12 100644 --- a/Tests/CudaOnly/GPUDebugFlag/main.cu +++ b/Tests/CudaOnly/GPUDebugFlag/main.cu @@ -49,6 +49,11 @@ int main(int argc, char** argv) { bool* has_debug; cudaError_t err = cudaMallocManaged(&has_debug, sizeof(bool)); + if (err != cudaSuccess) { + std::cerr << "cudaMallocManaged failed:\n" + << " " << cudaGetErrorString(err) << std::endl; + return 1; + } debug_kernel<<<1, 1>>>(has_debug); err = cudaDeviceSynchronize(); |