Difference between revisions of "CMake:CPackWin32NewbiesChecklist"

From KitwarePublic
Jump to navigationJump to search
(Remove leading space rectangles from preformatted blocks)
(Replace content with link to new CMake community wiki)
 
Line 1: Line 1:
I just wanted to jot down some notes that I took during my "learning curve" of CPack on Windows XP.<br>
+
{{CMake/Template/Moved}}
  
<br>First, what would seem like obvious things to do but worth mentioning.
+
This page has moved [https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/Win32NewbiesChecklist here].
 
 
= Pre-requisite Software    =
 
# Download and install the NSIS installer from [http://nsis.sourceforge.net/Download NSIS Downloads page]
 
# Download and install a Zip package. I used 7zip from [http://www.7-zip.org/download.html 7Zip Downloads page]
 
::<b>After you install 7zip (or what ever package you want for zip compression) be sure to add that program to the "PATH" variable for windows.
 
::Instructions for that can be found at Microsoft's web site [http://support.microsoft.com/kb/310519 How To Manage Environment Variables in Windows XP]</b>
 
 
 
Now you should be ready to start writing some CPack Code.
 
 
 
= Bumps in the Road    =
 
Early on I had some trouble getting some support libraries to show up in the installer. This was because of a <b>bug</b> in my own cmake code which I thought might be good to show here so that others do not make the same mistake.
 
 
 
<B> WRONG CMAKE CODE </B>
 
<pre>
 
INSTALL(FILES MyLibrary.dll
 
  DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
 
  CONFIGURATIONS Debug
 
  COMPONENT Runtime)
 
</pre>
 
 
 
Note the <tt>${CMAKE_INSTALL_PREFIX}</tt> in the Destination property. Having this was a bug and caused all sorts of problems. Basically CPack runs the "install" command first and then does the packaging. By using an Absolute path in the "Destination" property CMake was dutifully copying the files into the installation directory and NOT the staging area for CPack. OOPS. Here is the corrected code.
 
 
 
<B> CORRECT CMAKE CODE </B>
 
<pre>
 
INSTALL(FILES MyLibrary.dll
 
  DESTINATION bin
 
  CONFIGURATIONS Debug
 
  COMPONENT Runtime)
 
</pre>
 
Also note that I am using a "CONFIGURATION" property because I actually name outputs based on the build configuration. Both the "CONFIGURATION" and the "COMPONENT" are optional. Using the COMPONENT Property will allow you to eventually do component based installs. See [[CMake:Component Install With CPack]] for more information.
 
 
 
There are ways to use Absolute file paths but there seems to be lots of issues with this approach and the approach is not supported on NSIS anyway. For more information on the subject take a look [http://www.cmake.org/pipermail/cmake/2008-May/021638.html At this post]  on the CMake mailing list.
 
 
 
{{CMake/Template/Footer}}
 

Latest revision as of 10:40, 30 April 2018


The CMake community Wiki has moved to the Kitware GitLab Instance.

This page has moved here.