CMake:CPackWin32NewbiesChecklist: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
(Add explicit preformat markup)
(Remove leading space rectangles from preformatted blocks)
Line 16: Line 16:
<B> WRONG CMAKE CODE </B>
<B> WRONG CMAKE CODE </B>
<pre>
<pre>
    INSTALL(FILES MyLibrary.dll  
INSTALL(FILES MyLibrary.dll  
        DESTINATION ${CMAKE_INSTALL_PREFIX}/bin  
  DESTINATION ${CMAKE_INSTALL_PREFIX}/bin  
        CONFIGURATIONS Debug  
  CONFIGURATIONS Debug  
        COMPONENT Runtime)
  COMPONENT Runtime)
</pre>
</pre>


Line 26: Line 26:
<B> CORRECT CMAKE CODE </B>
<B> CORRECT CMAKE CODE </B>
<pre>
<pre>
    INSTALL(FILES MyLibrary.dll  
INSTALL(FILES MyLibrary.dll  
        DESTINATION bin  
  DESTINATION bin  
        CONFIGURATIONS Debug  
  CONFIGURATIONS Debug  
        COMPONENT Runtime)
  COMPONENT Runtime)
</pre>
</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.
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.

Revision as of 18:33, 24 April 2018

I just wanted to jot down some notes that I took during my "learning curve" of CPack on Windows XP.


First, what would seem like obvious things to do but worth mentioning.

Pre-requisite Software

  1. Download and install the NSIS installer from NSIS Downloads page
  2. Download and install a Zip package. I used 7zip from 7Zip Downloads page
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 How To Manage Environment Variables in Windows XP

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 bug in my own cmake code which I thought might be good to show here so that others do not make the same mistake.

WRONG CMAKE CODE

INSTALL(FILES MyLibrary.dll 
   DESTINATION ${CMAKE_INSTALL_PREFIX}/bin 
   CONFIGURATIONS Debug 
   COMPONENT Runtime)

Note the ${CMAKE_INSTALL_PREFIX} 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.

CORRECT CMAKE CODE

INSTALL(FILES MyLibrary.dll 
   DESTINATION bin 
   CONFIGURATIONS Debug 
   COMPONENT Runtime)

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 At this post on the CMake mailing list.



CMake: [Welcome | Site Map]