Hi Clint,

>>Actually it's even worse because in current master HEAD I can see that 
>>INST_DIR is empty in generated project:
>>  !define INST_DIR ""
>>(not sure if that's caused by your change)
>Interesting... Do you know why this happens?  How is this problem related to 
>extended paths (with the \\?\ prefix)?  Do you have an example to demonstrate 
>this problem? That was my mistake, please ignore.
>>I've figured out that NSIS was not going to fix this (see  
>>http://sourceforge.net/p/nsis/feature-requests/241/ )
>
>Maybe they'll accept a patch to fix it there?  Was there any effort to fix it 
>there?
In the URL I've put they claim you should just use "\\?\" in your NSIS project.
I guess it's also possible to fix NSIS, but we cannot rely that user have 
latest NSIS.

>
>>
>>I've made a small patch to NSIS generator and template to put infamous \\?\ 
>>there.
>>
>>I can send directly to you as I guess you know more about these parts of code.
>
>You can send your patch to this mailing list for review.
Patch attached. It's a bit hacky, more fixing symptoms I guess. The purpose is 
only to demonstrate the idea.
Let me know if it can be done in better way.

Regards,
Dmitry


From a14fc375593f2d150dba8f93d34f04b954c9365e Mon Sep 17 00:00:00 2001
From: Dmitry Kochkin <dmitry.kochkin@here.com>
Date: Mon, 21 Sep 2015 11:23:19 +0200
Subject: [PATCH] Fixing NSIS packer for very long filenames on Windows

---
 Modules/NSIS.template.in              |  4 ++--
 Source/CPack/cmCPackNSISGenerator.cxx | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in
index 76310af..0fe19fe 100644
--- a/Modules/NSIS.template.in
+++ b/Modules/NSIS.template.in
@@ -5,7 +5,7 @@
 
   !define VERSION "@CPACK_PACKAGE_VERSION@"
   !define PATCH  "@CPACK_PACKAGE_VERSION_PATCH@"
-  !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
+  !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY_SAFE@"
 
 ;--------------------------------
 ;Variables
@@ -639,7 +639,7 @@ FunctionEnd
 Section "-Core installation"
   ;Use the entire tree produced by the INSTALL target.  Keep the
   ;list of directories here in sync with the RMDir commands below.
-  SetOutPath "$INSTDIR"
+  SetOutPath "\\?\$INSTDIR"
   @CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@
   @CPACK_NSIS_FULL_INSTALL@
 
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index 6cdda28..6676d3a 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -46,6 +46,12 @@ cmCPackNSISGenerator::~cmCPackNSISGenerator()
 //----------------------------------------------------------------------
 int cmCPackNSISGenerator::PackageFiles()
 {
+  std::string win_safe_tmp( this->GetOption( "CPACK_TEMPORARY_DIRECTORY" ) );
+#ifdef _WIN32
+  cmSystemTools::ReplaceString(win_safe_tmp, "/", "\\");
+  win_safe_tmp = "\\\\?\\" + win_safe_tmp;
+#endif
+  this->SetOptionIfNotSet( "CPACK_TEMPORARY_DIRECTORY_SAFE", win_safe_tmp.c_str( ) );
   // TODO: Fix nsis to force out file name
 
   std::string nsisInFileName = this->FindTemplate("NSIS.template.in");
@@ -83,7 +89,7 @@ int cmCPackNSISGenerator::PackageFiles()
       fileN = fileN.substr(fileN.find('/')+1, std::string::npos);
       }
     cmSystemTools::ReplaceString(fileN, "/", "\\");
-    str << "  Delete \"$INSTDIR\\" << fileN << "\"" << std::endl;
+    str << "  Delete \"\\\\?\\$INSTDIR\\" << fileN << "\"" << std::endl;
     }
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: "
     << str.str() << std::endl);
@@ -117,7 +123,7 @@ int cmCPackNSISGenerator::PackageFiles()
         }
       }
     cmSystemTools::ReplaceString(fileN, "/", "\\");
-    dstr << "  RMDir \"$INSTDIR\\" << fileN << "\"" << std::endl;
+    dstr << "  RMDir \"\\\\?\\$INSTDIR\\" << fileN << "\"" << std::endl;
     if (!componentName.empty())
       {
       this->Components[componentName].Directories.push_back(fileN);
-- 
2.5.1.windows.1

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to