diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackPKGGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitHandler.cxx | 21 | ||||
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 23 | ||||
-rw-r--r-- | Source/cmExtraEclipseCDT4Generator.cxx | 2 | ||||
-rw-r--r-- | Source/cmMakefileExecutableTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmQtAutoGenInitializer.cxx | 91 | ||||
-rw-r--r-- | Source/cmQtAutoGeneratorMocUic.cxx | 10 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 29 | ||||
-rw-r--r-- | Source/cmSystemTools.h | 4 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 1 | ||||
-rw-r--r-- | Source/cmTarget.h | 8 | ||||
-rw-r--r-- | Source/cmTryRunCommand.cxx | 3 | ||||
-rw-r--r-- | Source/cmVSSetupHelper.cxx | 33 | ||||
-rw-r--r-- | Source/cmVSSetupHelper.h | 1 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmcmd.cxx | 4 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 32 |
20 files changed, 169 insertions, 111 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 93aad21..85cbbca 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 13) -set(CMake_VERSION_PATCH 20181128) +set(CMake_VERSION_PATCH 20181207) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index ea0ee58..29968af 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -80,7 +80,7 @@ DebGenerator::DebGenerator( , WorkDir(workDir) , TopLevelDir(topLevelDir) , TemporaryDir(temporaryDir) - , DebianArchiveType(debianArchiveType ? debianArchiveType : "paxr") + , DebianArchiveType(debianArchiveType ? debianArchiveType : "gnutar") , ControlValues(controlValues) , GenShLibs(genShLibs) , ShLibsFilename(shLibsFilename) diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index bdda386..9401bca 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -225,7 +225,8 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component, xout.Content(this->GetPackageName(component)); } else { xout.Content("file:./"); - xout.Content(relativePackageLocation); + xout.Content(cmSystemTools::EncodeURL(relativePackageLocation, + /*escapeSlashes=*/false)); } xout.EndElement(); // pkg-ref } diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 75e2cd5..67c669c 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -246,26 +246,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( *this->LogFile << "\tUpload file: " << local_file << " to " << remote_file << std::endl; - std::string ofile; - for (char c : remote_file) { - char hexCh[4] = { 0, 0, 0, 0 }; - hexCh[0] = c; - switch (c) { - case '+': - case '?': - case '/': - case '\\': - case '&': - case ' ': - case '=': - case '%': - sprintf(hexCh, "%%%02X", static_cast<int>(c)); - ofile.append(hexCh); - break; - default: - ofile.append(hexCh); - } - } + std::string ofile = cmSystemTools::EncodeURL(remote_file); std::string upload_as = url + ((url.find('?') == std::string::npos) ? '?' : '&') + "FileName=" + ofile; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index f6ec606..541ae76 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -121,6 +121,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, std::string cxxExtensions; std::string cudaExtensions; std::vector<std::string> targets; + std::vector<std::string> linkOptions; std::string libsToLink = " "; bool useOldLinkLibs = true; char targetNameBuf[64]; @@ -144,6 +145,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, DoingNone, DoingCMakeFlags, DoingCompileDefinitions, + DoingLinkOptions, DoingLinkLibraries, DoingOutputVariable, DoingCopyFile, @@ -165,6 +167,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, doing = DoingCMakeFlags; } else if (argv[i] == "COMPILE_DEFINITIONS") { doing = DoingCompileDefinitions; + } else if (argv[i] == "LINK_OPTIONS") { + doing = DoingLinkOptions; } else if (argv[i] == "LINK_LIBRARIES") { doing = DoingLinkLibraries; useOldLinkLibs = false; @@ -208,6 +212,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, cmakeFlags.push_back(argv[i]); } else if (doing == DoingCompileDefinitions) { compileDefs.push_back(argv[i]); + } else if (doing == DoingLinkOptions) { + linkOptions.push_back(argv[i]); } else if (doing == DoingLinkLibraries) { libsToLink += "\"" + cmSystemTools::TrimWhitespace(argv[i]) + "\" "; if (cmTarget* tgt = this->Makefile->FindTargetToUse(argv[i])) { @@ -814,6 +820,23 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, } } + if (!linkOptions.empty()) { + std::vector<std::string> options; + options.reserve(linkOptions.size()); + for (const auto& option : linkOptions) { + options.emplace_back(cmOutputConverter::EscapeForCMake(option)); + } + + if (targetType == cmStateEnums::STATIC_LIBRARY) { + fprintf(fout, + "set_property(TARGET %s PROPERTY STATIC_LIBRARY_OPTIONS %s)\n", + targetName.c_str(), cmJoin(options, " ").c_str()); + } else { + fprintf(fout, "target_link_options(%s PRIVATE %s)\n", + targetName.c_str(), cmJoin(options, " ").c_str()); + } + } + if (useOldLinkLibs) { fprintf(fout, "target_link_libraries(%s ${LINK_LIBRARIES})\n", targetName.c_str()); diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 8e25e9c..adb14ec 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -714,7 +714,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const xml.Attribute("path", p); xml.EndElement(); - // exlude source directory from output search path + // exclude source directory from output search path // - only if not named the same as an output directory if (!cmSystemTools::FileIsDirectory( std::string(this->HomeOutputDirectory + "/" + p))) { diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 08bb2ce..846b12c 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -84,6 +84,10 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule( bool relink) { #ifdef CMAKE_BUILD_WITH_CMAKE + if (!this->GlobalGenerator->GetLanguageEnabled("CUDA")) { + return; + } + const std::string cuda_lang("CUDA"); cmGeneratorTarget::LinkClosure const* closure = this->GeneratorTarget->GetLinkClosure(this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1386706..c953d20 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -557,6 +557,10 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() { + if (!this->GetGlobalGenerator()->GetLanguageEnabled("CUDA")) { + return; + } + cmGeneratorTarget& genTarget = *this->GetGeneratorTarget(); // determine if we need to do any device linking for this target diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 49236ed..d4819a3 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -521,6 +521,12 @@ bool cmQtAutoGenInitializer::InitMoc() [this, localGen](std::string const& cfg) -> std::set<std::string> { std::set<std::string> defines; localGen->GetTargetDefines(this->Target, cfg, "CXX", defines); +#ifdef _WIN32 + if (this->Moc.PredefsCmd.empty()) { + // Add WIN32 definition if we don't have a moc_predefs.h + defines.insert("WIN32"); + } +#endif return defines; }; @@ -1342,56 +1348,65 @@ void cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename, this->Target->AddSource(filename); } -cmQtAutoGenInitializer::IntegerVersion cmQtAutoGenInitializer::GetQtVersion( +static unsigned int CharPtrToInt(const char* const input) +{ + unsigned long tmp = 0; + if (input != nullptr && cmSystemTools::StringToULong(input, &tmp)) { + return static_cast<unsigned int>(tmp); + } + return 0; +} + +static unsigned int StringToInt(const std::string& input) +{ + return input.empty() ? 0 : CharPtrToInt(input.c_str()); +} + +static std::vector<cmQtAutoGenInitializer::IntegerVersion> GetKnownQtVersions( cmGeneratorTarget const* target) { - cmQtAutoGenInitializer::IntegerVersion res; cmMakefile* makefile = target->Target->GetMakefile(); - // -- Major version - std::string qtMajor = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); - if (qtMajor.empty()) { - qtMajor = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); - } - { - const char* targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", ""); - if (targetQtVersion != nullptr) { - qtMajor = targetQtVersion; + std::vector<cmQtAutoGenInitializer::IntegerVersion> result; + for (const std::string& prefix : + std::vector<std::string>({ "Qt5Core", "QT" })) { + auto tmp = cmQtAutoGenInitializer::IntegerVersion( + StringToInt(makefile->GetSafeDefinition(prefix + "_VERSION_MAJOR")), + StringToInt(makefile->GetSafeDefinition(prefix + "_VERSION_MINOR"))); + if (tmp.Major != 0) { + result.push_back(tmp); } } - // -- Minor version - std::string qtMinor; - if (!qtMajor.empty()) { - if (qtMajor == "5") { - qtMinor = makefile->GetSafeDefinition("Qt5Core_VERSION_MINOR"); - } - if (qtMinor.empty()) { - qtMinor = makefile->GetSafeDefinition("QT_VERSION_MINOR"); - } - { - const char* targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MINOR_VERSION", - ""); - if (targetQtVersion != nullptr) { - qtMinor = targetQtVersion; - } - } + return result; +} + +cmQtAutoGenInitializer::IntegerVersion cmQtAutoGenInitializer::GetQtVersion( + cmGeneratorTarget const* target) +{ + auto knownQtVersions = GetKnownQtVersions(target); + if (knownQtVersions.empty()) { + return cmQtAutoGenInitializer::IntegerVersion(); // No Qt + } + + // Pick a version from the known versions: + auto targetVersion = CharPtrToInt( + target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")); + + if (targetVersion == 0) { + // No specific version was requested by the target: + // Use highest known Qt version. + return knownQtVersions.at(0); } - // -- Convert to integer - if (!qtMajor.empty() && !qtMinor.empty()) { - unsigned long majorUL(0); - unsigned long minorUL(0); - if (cmSystemTools::StringToULong(qtMajor.c_str(), &majorUL) && - cmSystemTools::StringToULong(qtMinor.c_str(), &minorUL)) { - res.Major = static_cast<unsigned int>(majorUL); - res.Minor = static_cast<unsigned int>(minorUL); + for (auto it : knownQtVersions) { + if (it.Major == targetVersion) { + return it; } } - return res; + // Requested version was not found + return cmQtAutoGenInitializer::IntegerVersion(); } bool cmQtAutoGenInitializer::GetMocExecutable() diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx index 2e6f90f..446ef9a 100644 --- a/Source/cmQtAutoGeneratorMocUic.cxx +++ b/Source/cmQtAutoGeneratorMocUic.cxx @@ -1279,16 +1279,6 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile) Moc_.SkipList.insert(lst.begin(), lst.end()); } Moc_.Definitions = InfoGetConfigList("AM_MOC_DEFINITIONS"); -#ifdef _WIN32 - { - std::string win32("WIN32"); - auto itB = Moc().Definitions.cbegin(); - auto itE = Moc().Definitions.cend(); - if (std::find(itB, itE, win32) == itE) { - Moc_.Definitions.emplace_back(std::move(win32)); - } - } -#endif Moc_.IncludePaths = InfoGetConfigList("AM_MOC_INCLUDES"); Moc_.Options = InfoGetList("AM_MOC_OPTIONS"); Moc_.RelaxedMode = InfoGetBool("AM_MOC_RELAXED_MODE"); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 28aa57c..6fbe482 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -3009,6 +3009,35 @@ bool cmSystemTools::StringToULong(const char* str, unsigned long* value) return (*endp == '\0') && (endp != str) && (errno == 0); } +std::string cmSystemTools::EncodeURL(std::string const& in, bool escapeSlashes) +{ + std::string out; + for (char c : in) { + char hexCh[4] = { 0, 0, 0, 0 }; + hexCh[0] = c; + switch (c) { + case '+': + case '?': + case '\\': + case '&': + case ' ': + case '=': + case '%': + sprintf(hexCh, "%%%02X", static_cast<int>(c)); + break; + case '/': + if (escapeSlashes) { + strcpy(hexCh, "%2F"); + } + break; + default: + break; + } + out.append(hexCh); + } + return out; +} + bool cmSystemTools::CreateSymlink(const std::string& origName, const std::string& newName) { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 98300eb..832c1ca 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -495,6 +495,10 @@ public: static bool StringToLong(const char* str, long* value); static bool StringToULong(const char* str, unsigned long* value); + /** Encode a string as a URL. */ + static std::string EncodeURL(std::string const& in, + bool escapeSlashes = true); + #ifdef _WIN32 struct WindowsFileRetry { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 92d5505..688f73b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -6,7 +6,6 @@ #include <algorithm> #include <assert.h> #include <iterator> -#include <map> #include <set> #include <sstream> #include <string.h> diff --git a/Source/cmTarget.h b/Source/cmTarget.h index aa2859d..655cefd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -6,7 +6,6 @@ #include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> -#include <map> #include <set> #include <string> #include <unordered_map> @@ -344,11 +343,4 @@ private: typedef std::unordered_map<std::string, cmTarget> cmTargets; -class cmTargetSet : public std::set<std::string> -{ -}; -class cmTargetManifest : public std::map<std::string, cmTargetSet> -{ -}; - #endif diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 9396138..fafbd24 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -45,7 +45,8 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, if (argv[i] == "ARGS") { ++i; while (i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" && - argv[i] != "CMAKE_FLAGS" && argv[i] != "LINK_LIBRARIES") { + argv[i] != "CMAKE_FLAGS" && argv[i] != "LINK_OPTIONS" && + argv[i] != "LINK_LIBRARIES") { runArgs += " "; runArgs += argv[i]; ++i; diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index 22fe007..7a54e12 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/Source/cmVSSetupHelper.cxx @@ -267,6 +267,19 @@ bool cmVSSetupAPIHelper::GetVCToolsetVersion(std::string& vsToolsetVersion) return isInstalled && !vsToolsetVersion.empty(); } +bool cmVSSetupAPIHelper::IsEWDKEnabled() +{ + std::string envEnterpriseWDK, envDisableRegistryUse; + cmSystemTools::GetEnv("EnterpriseWDK", envEnterpriseWDK); + cmSystemTools::GetEnv("DisableRegistryUse", envDisableRegistryUse); + if (!cmSystemTools::Strucmp(envEnterpriseWDK.c_str(), "True") && + !cmSystemTools::Strucmp(envDisableRegistryUse.c_str(), "True")) { + return true; + } + + return false; +} + bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance() { bool isVSInstanceExists = false; @@ -274,6 +287,26 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance() return true; } + if (this->IsEWDKEnabled()) { + std::string envWindowsSdkDir81, envVSVersion, envVsInstallDir; + + cmSystemTools::GetEnv("WindowsSdkDir_81", envWindowsSdkDir81); + cmSystemTools::GetEnv("VisualStudioVersion", envVSVersion); + cmSystemTools::GetEnv("VSINSTALLDIR", envVsInstallDir); + if (envVSVersion.empty() || envVsInstallDir.empty()) + return false; + + chosenInstanceInfo.VSInstallLocation = + std::wstring(envVsInstallDir.begin(), envVsInstallDir.end()); + chosenInstanceInfo.Version = + std::wstring(envVSVersion.begin(), envVSVersion.end()); + chosenInstanceInfo.VCToolsetVersion = envVSVersion; + chosenInstanceInfo.ullVersion = std::stoi(envVSVersion); + chosenInstanceInfo.IsWin10SDKInstalled = true; + chosenInstanceInfo.IsWin81SDKInstalled = !envWindowsSdkDir81.empty(); + return true; + } + if (initializationFailure || setupConfig == NULL || setupConfig2 == NULL || setupHelper == NULL) return false; diff --git a/Source/cmVSSetupHelper.h b/Source/cmVSSetupHelper.h index 4144c15..b9cca45 100644 --- a/Source/cmVSSetupHelper.h +++ b/Source/cmVSSetupHelper.h @@ -150,6 +150,7 @@ private: HRESULT comInitialized; // current best instance of VS selected VSInstanceInfo chosenInstanceInfo; + bool IsEWDKEnabled(); std::string SpecifiedVSInstallLocation; }; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index e9a1a67..7d7defc 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3319,7 +3319,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::vector<std::string> vsTargetVec; this->AddLibraries(cli, libVec, vsTargetVec, config); if (std::find(linkClosure->Languages.begin(), linkClosure->Languages.end(), - "CUDA") != linkClosure->Languages.end()) { + "CUDA") != linkClosure->Languages.end() && + this->CudaOptions[config] != nullptr) { switch (this->CudaOptions[config]->GetCudaRuntime()) { case cmVisualStudioGeneratorOptions::CudaRuntimeStatic: libVec.push_back("cudadevrt.lib"); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 45881aa..930ced9 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -691,6 +691,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) if (args[1] == "touch" && args.size() > 2) { for (std::string::size_type cc = 2; cc < args.size(); cc++) { if (!cmSystemTools::Touch(args[cc], true)) { + std::cerr << "cmake -E touch: failed to update \""; + std::cerr << args[cc] << "\".\n"; return 1; } } @@ -701,6 +703,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) if (args[1] == "touch_nocreate" && args.size() > 2) { for (std::string::size_type cc = 2; cc < args.size(); cc++) { if (!cmSystemTools::Touch(args[cc], false)) { + std::cerr << "cmake -E touch_nocreate: failed to update \""; + std::cerr << args[cc] << "\".\n"; return 1; } } diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 0a4ad7a..331f16e 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1355,39 +1355,15 @@ bool SystemTools::Touch(const std::string& filename, bool create) } CloseHandle(h); #elif KWSYS_CXX_HAS_UTIMENSAT - struct timespec times[2] = { { 0, UTIME_OMIT }, { 0, UTIME_NOW } }; - if (utimensat(AT_FDCWD, filename.c_str(), times, 0) < 0) { + // utimensat is only available on newer Unixes and macOS 10.13+ + if (utimensat(AT_FDCWD, filename.c_str(), NULL, 0) < 0) { return false; } #else - struct stat st; - if (stat(filename.c_str(), &st) < 0) { - return false; - } - struct timeval mtime; - gettimeofday(&mtime, 0); -# if KWSYS_CXX_HAS_UTIMES - struct timeval atime; -# if KWSYS_CXX_STAT_HAS_ST_MTIM - atime.tv_sec = st.st_atim.tv_sec; - atime.tv_usec = st.st_atim.tv_nsec / 1000; -# elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC - atime.tv_sec = st.st_atimespec.tv_sec; - atime.tv_usec = st.st_atimespec.tv_nsec / 1000; -# else - atime.tv_sec = st.st_atime; - atime.tv_usec = 0; -# endif - struct timeval times[2] = { atime, mtime }; - if (utimes(filename.c_str(), times) < 0) { + // fall back to utimes + if (utimes(filename.c_str(), NULL) < 0) { return false; } -# else - struct utimbuf times = { st.st_atime, mtime.tv_sec }; - if (utime(filename.c_str(), ×) < 0) { - return false; - } -# endif #endif return true; } |