Browse Source

Work around clang-cl breakage on make_unique/std::forward

Clang on Windows with the MSVC ABI produces link errors of the
form `unresolved std::_Iosb<int>::{app,_Openmode} in ...`.
Use a temporary variable to forward as lvalue rather than rvalue
to work around the problem.
Zsolt Parragi 7 years ago
parent
commit
006768903c

+ 2 - 1
Source/cmExportFileGenerator.cxx

@@ -70,8 +70,9 @@ bool cmExportFileGenerator::GenerateImportFile()
   std::unique_ptr<cmsys::ofstream> foutPtr;
   std::unique_ptr<cmsys::ofstream> foutPtr;
   if (this->AppendMode) {
   if (this->AppendMode) {
     // Open for append.
     // Open for append.
+    auto openmodeApp = std::ios::app;
     foutPtr = cm::make_unique<cmsys::ofstream>(this->MainImportFile.c_str(),
     foutPtr = cm::make_unique<cmsys::ofstream>(this->MainImportFile.c_str(),
-                                               std::ios::app);
+                                               openmodeApp);
   } else {
   } else {
     // Generate atomically and with copy-if-different.
     // Generate atomically and with copy-if-different.
     std::unique_ptr<cmGeneratedFileStream> ap(
     std::unique_ptr<cmGeneratedFileStream> ap(

+ 2 - 1
Source/cmExportLibraryDependenciesCommand.cxx

@@ -50,8 +50,9 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
   // Use copy-if-different if not appending.
   // Use copy-if-different if not appending.
   std::unique_ptr<cmsys::ofstream> foutPtr;
   std::unique_ptr<cmsys::ofstream> foutPtr;
   if (this->Append) {
   if (this->Append) {
+    const auto openmodeApp = std::ios::app;
     foutPtr =
     foutPtr =
-      cm::make_unique<cmsys::ofstream>(this->Filename.c_str(), std::ios::app);
+      cm::make_unique<cmsys::ofstream>(this->Filename.c_str(), openmodeApp);
   } else {
   } else {
     std::unique_ptr<cmGeneratedFileStream> ap(
     std::unique_ptr<cmGeneratedFileStream> ap(
       new cmGeneratedFileStream(this->Filename, true));
       new cmGeneratedFileStream(this->Filename, true));