Giter Club home page Giter Club logo

findwix's Introduction

FindWiX Build status

CMake module for building Windows Installer packages with WiX toolset

Introduction

A native solution for building Windows Installer packages in CMake is CPack. However it has several drawbacks:

  • limited to one installer project (cannot created several installers, for example client.msi and server.msi)
  • cannot directly work with wsx files (hard to convert existings installer source code to CMake)

FindWiX comes to rescue in such cases.

Requirements

Usage

find_package()

Add FindWiX to the module search path and call find_package:

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(WIX REQUIRED)

FindWiX will search for the installed WiX toolset, expose functions for creating installer packages and define the following variables:

  • WIX_FOUND - if false WiX toolset is absent
  • WIX_ROOT - path where WiX toolset is installed
  • WIX_COMPILE_FLAGS - flags to be used when compiling wxs source files
  • WIX_LINK_FLAGS - flags to be used when linking wixobj files

wix_add_project()

This function creates a new target for WiX project. It compiles one or several wsx files to wixobj files and then links them together into the resulting msi file.

wix_add_project(<name>
    source1 [source2 ...]
    [OUTPUT_NAME <msi_file_name>]
    [EXTENSIONS extension1 [extension2...]]
    [DEPENDS target1 [target2...]])

Where:

  • <name> - name of the project target
  • source1 [source2 ...] - one or several wsx files
  • OUTPUT_NAME - allows to set a name for the resulting msi file, if omitted the name is set to <name>
  • EXTENSIONS - add one or more WiX extensions (for example WixUIExtension)
  • DEPENDS - add project dependencies for the correct build order

Example:

wix_add_project(my_project 
    main.wxs one_more.wxs 
    OUTPUT_NAME "NameSample" 
    EXTENSIONS WixUIExtension WixUtilExtension
    DEPENDS CppExecutable)

WiX compile and link flags

You could do some fine tuning, for example treat warnings as errors:

set(WIX_COMPILE_FLAGS ${WIX_COMPILE_FLAGS} -wx)
set(WIX_LINK_FLAGS ${WIX_LINK_FLAGS} -wx)

CMake variables in WiX

FindWiX generates vars.wxi to make CMake variables available in WiX. Here is a fragment of vars.wxi:

<?xml version='1.0' encoding='UTF-8'?>
<Include>
    <?define ARGC='4' ?>
    <?define ARGN='Main.wxs;DEPENDS;CppExecutable' ?>
    <?define ARGV='WithExecutable;Main.wxs;DEPENDS;CppExecutable' ?>
    <?define ARGV0='WithExecutable' ?>
    <?define ARGV1='Main.wxs' ?>
    <?define ARGV2='DEPENDS' ?>
    <?define ARGV3='CppExecutable' ?>
    <?define CMAKE_AR='' ?>
    <?define CMAKE_AUTOMOC_COMPILER_PREDEFINES='ON' ?>
    <?define CMAKE_AUTOMOC_MACRO_NAMES='Q_OBJECT;Q_GADGET;Q_NAMESPACE' ?>
    ...
</Include>

To get access to those variables include vars.wxi into your wxs file:

<?include vars.wxi?> <!--cmake variables and their values-->

CMake project dependencies in WiX

Also FindWiX generates depends.wxi with file paths to CMake project dependencies. Here is a fragment of depends.wxi:

<?xml version='1.0' encoding='UTF-8'?>
<Include>
    <?define TARGET_FILE:CppExecutable='C:/my_proj/WithExecutable/Debug/CppExecutable.exe' ?>
    <?define TARGET_PDB_FILE:CppExecutable='C:/my_proj/WithExecutable/Debug/CppExecutable.pdb' ?>
    ...
</Include>

To get access to those variables include depends.wxi into your wxs file:

<?include depends.wxi?> <!--paths to cmake dependencies-->

Samples

Take a look at the samples folder to see how to use FindWiX.

License

Apriorit released FindWiX under the OSI-approved 3-clause BSD license. You can freely use it in your commercial or opensource software.

Version History

Version 1.0.0 (20 Sep 2018)

  • Initial public release

findwix's People

Contributors

sergiusthebest avatar sqzhr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.