[cmake-developers] WiX generator and generic file IDs

Ådne Hovda ahovda at openit.com
Wed Oct 9 05:03:25 EDT 2013


Hi

I've taken the CPack WiX generator for a spin and it covers most of our 
requirements, but I have a few suggestions for improvement:

1. Make it possible to specify a list of extra .wxs files to be included 
when building the installer.

2. Automatically generated IDs for <File />, <Directory /> and 
<Component /> tags, DIR_ID_1, FILE_ID_1, COMP_ID_1, are 
non-deterministic and that makes it impossible to reference those 
objects by ID from other parts of the WiX code, to execute an installed 
binary, add service config and firewall exceptions, for example.

So, instead compose the ID by concatenating the relative path from 
INSTALL_ROOT and the file name, using some valid delimiter, a 
combination which should always be unique within one installer.

A file and its component should simply share ID.

3. Move the main <Directory Id="TARGETDIR" Name="SourceDir" /> tag 
including the program files folder entry to the main.wxs file, leaving 
only INSTALL_ROOT and below in directories.wxs. That makes it easier to 
override the install location with a custom template. Selecting the 
correct ProgramFilesFolder/ProgramFiles64Folder should be handled by a 
new include variable and a new <?if ?> block.

Here are some excerpts to (hopefully) clarify my ideas:


cpack_variables.wxi:

<?define CPACK_WIX_ARCH="x86" ?>


WIX.template.in:

<?if $(var.CPACK_WIX_ARCH) = x86 ?>
   <?define Win64 = "no" ?>
   <?define SystemFolder = "SystemFolder" ?>
   <?define CAQuietExec = "CAQuietExec" ?>
   <?define ProgramFilesFolder = "ProgramFilesFolder" ?>
   <?define ExecSecureObjects = "ExecSecureObjects" ?>
<?else?>
   <?define Win64 = "yes" ?>
   <?define SystemFolder = "System64Folder" ?>
   <?define CAQuietExec = "CAQuietExec64" ?>
   <?define ProgramFilesFolder = "ProgramFiles64Folder" ?>
   <?define ExecSecureObjects = "ExecSecureObjects_64" ?>
<?endif?>


<Directory Id="TARGETDIR" Name="SourceDir">
   <Directory Id="$(var.ProgramFilesFolder)">
     <DirectoryRef Id="INSTALL_ROOT" />
   </Directory>
</Directory>



directories.wxs:

<Directory Id="INSTALL_ROOT" Name="MyProduct">
   <Directory Id="bin" Name="bin"/>
   <Directory Id="include" Name="include"/>
   <Directory Id="lib" Name="lib"/>
   <Directory Id="share" Name="share">
     <Directory Id="share.man" Name="man">
       <Directory Id="share.man.man3" Name="man3"/>
     </Directory>
   </Directory>
</Directory>




files.wxs:

<DirectoryRef Id="bin">
   <Component Id="bin.prog1.exe" Guid="*" Win64="$(var.Win64)">
     <File Id="bin.prog1.exe" Source="bin/prog1.exe" KeyPath="yes"/>
   </Component>
</DirectoryRef>
<DirectoryRef Id="include">
   <Component Id="include.lib1.h" Guid="*" Win64="$(var.Win64)">
     <File Id="include.lib1.h" Source="include/lib1.h" KeyPath="yes"/>
   </Component>
</DirectoryRef>
<DirectoryRef Id="lib">
   <Component Id="lib.lib1.lib" Guid="*" Win64="$(var.Win64)">
     <File Id="lib.lib1.lib" Source="lib/lib1.lib" KeyPath="yes"/>
   </Component>
</DirectoryRef>
<DirectoryRef Id="share.man.man3">
   <Component Id="share.man.man3.prog.3" Guid="*" Win64="$(var.Win64)">
     <File Id="share.man.man3.prog.3" Source="share/man/man3/prog.3" 
KeyPath="yes"/>
   </Component>
</DirectoryRef>


-- 
Best regards,
Ådne Hovda




More information about the cmake-developers mailing list