|
| 1 | +# Distributed under the OSI-approved MIT License. See accompanying |
| 2 | +# file LICENSE for details. |
| 3 | + |
| 4 | +#[=======================================================================[.rst: |
| 5 | +FindWIX |
| 6 | +--------- |
| 7 | +
|
| 8 | +Find components of ``WIX`` package. |
| 9 | +
|
| 10 | +The module defines the following variables: |
| 11 | +
|
| 12 | +``WIX_FOUND`` |
| 13 | + "True" if the programs ``candle`` and ``light`` wer found |
| 14 | +
|
| 15 | +``WIX_ROOT`` |
| 16 | + path to the directory containing the ``candle`` program |
| 17 | +
|
| 18 | +``WIX_VERSION_STRING`` |
| 19 | + version of ``candle`` |
| 20 | +
|
| 21 | +``WIX_CANDLE`` |
| 22 | + path to the ``candle`` program |
| 23 | +
|
| 24 | +``WIX_LIGHT`` |
| 25 | + path to the ``light`` program |
| 26 | +
|
| 27 | +``WIX_DARK`` |
| 28 | + path to the ``dark`` program |
| 29 | +
|
| 30 | +``WIX_HEAT`` |
| 31 | + path to the ``heat`` program |
| 32 | +
|
| 33 | +``WIX_INSIGNIA`` |
| 34 | + path to the ``insignia`` program |
| 35 | +
|
| 36 | +``WIX_LIT`` |
| 37 | + path to the ``lit`` program |
| 38 | +
|
| 39 | +``WIX_LUX`` |
| 40 | + path to the ``lux`` program |
| 41 | +
|
| 42 | +``WIX_MELT`` |
| 43 | + path to the ``melt`` program |
| 44 | +
|
| 45 | +``WIX_NIT`` |
| 46 | + path to the ``nit`` program |
| 47 | +
|
| 48 | +``WIX_PYRO`` |
| 49 | + path to the ``pyro`` program |
| 50 | +
|
| 51 | +``WIX_SHINE`` |
| 52 | + path to the ``shine`` program |
| 53 | +
|
| 54 | +``WIX_SMOKE`` |
| 55 | + path to the ``smoke`` program |
| 56 | +
|
| 57 | +``WIX_THMVIEWER`` |
| 58 | + path to the ``ThmViewer`` program |
| 59 | +
|
| 60 | +``WIX_TORCH`` |
| 61 | + path to the ``torch`` program |
| 62 | +
|
| 63 | +``WIX_WIXCOP`` |
| 64 | + path to the ``WixCop`` program |
| 65 | +
|
| 66 | +The minimum required version of ``WIX`` can be specified using the |
| 67 | +standard CMake syntax, e.g. :command:`find_package(WIX 2.1.3)`. |
| 68 | +
|
| 69 | +Example usage: |
| 70 | +
|
| 71 | +.. code-block:: cmake |
| 72 | +
|
| 73 | + find_package(WIX) |
| 74 | +#]=======================================================================] |
| 75 | + |
| 76 | +# Original coding |
| 77 | +# 2009/02 Petr Pytelka (pyta at lightcomp.cz) |
| 78 | +# Retrieved from https://gitlab.kitware.com/cmake/community/-/wikis/contrib/modules/FindWix |
| 79 | +# |
| 80 | +# WIX homepage has moved to https://wixtoolset.org/ |
| 81 | +# -- Bob Apthorpe (bob.apthorpe at gmail.com) 20200620 |
| 82 | +# Cleaned syntax and logic |
| 83 | +# -- Bob Apthorpe (bob.apthorpe at gmail.com) 20201012 |
| 84 | +# Substantially revised and modernized; removeed legacy macros |
| 85 | +# -- Bob Apthorpe (bob.apthorpe at gmail.com) 20201020 |
| 86 | +# |
| 87 | +# - Try to find Windows Installer XML |
| 88 | +# See http://wix.sourceforge.net |
| 89 | +# |
| 90 | +# The follwoing variables are optionally searched for defaults |
| 91 | +# WIX_ROOT_DIR: Base directory of WIX2 tree to use. |
| 92 | +# |
| 93 | +# The following are set after configuration is done: |
| 94 | +# WIX_FOUND |
| 95 | +# WIX_ROOT |
| 96 | +# WIX_VERSION_STRING |
| 97 | +# WIX_CANDLE |
| 98 | +# WIX_LIGHT |
| 99 | +# WIX_DARK |
| 100 | +# WIX_HEAT |
| 101 | +# WIX_INSIGNIA |
| 102 | +# WIX_LIT |
| 103 | +# WIX_LUX |
| 104 | +# WIX_MELT |
| 105 | +# WIX_NIT |
| 106 | +# WIX_PYRO |
| 107 | +# WIX_SHINE |
| 108 | +# WIX_SMOKE |
| 109 | +# WIX_THMVIEWER |
| 110 | +# WIX_TORCH |
| 111 | +# WIX_WIXCOP |
| 112 | + |
| 113 | +# Typical root dirs of installations, exactly one of them is used |
| 114 | +set(WIX_POSSIBLE_BIN_DIRS |
| 115 | + "${WIX_BINARY_DIR}" |
| 116 | + "${WIX_ROOT_DIR}/bin" |
| 117 | + "$ENV{WIX}/bin" |
| 118 | + "$ENV{WIX_ROOT_DIR}/bin" |
| 119 | + "$ENV{ProgramFiles}/Windows Installer XML/bin" |
| 120 | + "$ENV{ProgramFiles}/WiX Toolset v3.11/bin" |
| 121 | +) |
| 122 | + |
| 123 | +# WiX functionality requires at least candle.exe and light.exe |
| 124 | + |
| 125 | +find_program(WIX_CANDLE |
| 126 | + NAMES candle |
| 127 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 128 | +) |
| 129 | + |
| 130 | +if(EXISTS "${WIX_CANDLE}") |
| 131 | + execute_process(COMMAND "${WIX_CANDLE}" -help |
| 132 | + OUTPUT_VARIABLE WIX_CANDLE_OUTPUT_VARIABLE |
| 133 | + OUTPUT_STRIP_TRAILING_WHITESPACE |
| 134 | + ERROR_QUIET) |
| 135 | + # First line of help output looks like |
| 136 | + # "Windows Installer XML Toolset Compiler version 3.11.2.4516" |
| 137 | + # Remaining lines can be dropped; regex fragment ' *\n.*' trims output |
| 138 | + string(REGEX REPLACE "^Windows.*version ([0-9\\.]+) *\n.*" "\\1" |
| 139 | + WIX_VERSION_STRING "${WIX_CANDLE_OUTPUT_VARIABLE}") |
| 140 | + unset(WIX_CANDLE_OUTPUT_VARIABLE) |
| 141 | +endif() |
| 142 | + |
| 143 | +# Lesser tools |
| 144 | +find_program(WIX_LIGHT |
| 145 | + NAMES light |
| 146 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 147 | +) |
| 148 | + |
| 149 | +find_program(WIX_DARK |
| 150 | + NAMES dark |
| 151 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 152 | +) |
| 153 | + |
| 154 | +find_program(WIX_HEAT |
| 155 | + NAMES heat |
| 156 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 157 | +) |
| 158 | + |
| 159 | +find_program(WIX_INSIGNIA |
| 160 | + NAMES insignia |
| 161 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 162 | +) |
| 163 | + |
| 164 | +find_program(WIX_LIT |
| 165 | + NAMES lit |
| 166 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 167 | +) |
| 168 | + |
| 169 | +find_program(WIX_LUX |
| 170 | + NAMES lux |
| 171 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 172 | +) |
| 173 | + |
| 174 | +find_program(WIX_MELT |
| 175 | + NAMES melt |
| 176 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 177 | +) |
| 178 | + |
| 179 | +find_program(WIX_NIT |
| 180 | + NAMES nit |
| 181 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 182 | +) |
| 183 | + |
| 184 | +find_program(WIX_PYRO |
| 185 | + NAMES pyro |
| 186 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 187 | +) |
| 188 | + |
| 189 | +find_program(WIX_SHINE |
| 190 | + NAMES shine |
| 191 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 192 | +) |
| 193 | + |
| 194 | +find_program(WIX_SMOKE |
| 195 | + NAMES smoke |
| 196 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 197 | +) |
| 198 | + |
| 199 | +find_program(WIX_THMVIEWER |
| 200 | + NAMES ThmViewer |
| 201 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 202 | +) |
| 203 | + |
| 204 | +find_program(WIX_TORCH |
| 205 | + NAMES torch |
| 206 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 207 | +) |
| 208 | + |
| 209 | +find_program(WIX_WIXCOP |
| 210 | + NAMES WixCop |
| 211 | + PATHS ${WIX_POSSIBLE_BIN_DIRS} |
| 212 | +) |
| 213 | + |
| 214 | +include(FindPackageHandleStandardArgs) |
| 215 | +# find_package_handle_standard_args(WIX DEFAULT_MSG |
| 216 | +# WIX_CANDLE WIX_LIGHT) |
| 217 | +find_package_handle_standard_args(WIX |
| 218 | + REQUIRED_VARS WIX_CANDLE WIX_LIGHT |
| 219 | + VERSION_VAR WIX_VERSION_STRING) |
| 220 | + |
| 221 | +# Set WiX root directory based on location of candle.exe |
| 222 | +if(WIX_FOUND) |
| 223 | + # message(STATUS "WiX version: ${WIX_VERSION_STRING}") |
| 224 | + get_filename_component(WIX_BINARY_DIR_ "${WIX_CANDLE}" DIRECTORY) |
| 225 | + get_filename_component(WIX_ROOT "${WIX_BINARY_DIR_}/.." ABSOLUTE) |
| 226 | +endif() |
| 227 | + |
| 228 | +mark_as_advanced( |
| 229 | + WIX_ROOT |
| 230 | + WIX_CANDLE |
| 231 | + WIX_LIGHT |
| 232 | + WIX_DARK |
| 233 | + WIX_HEAT |
| 234 | + WIX_INSIGNIA |
| 235 | + WIX_LIT |
| 236 | + WIX_LUX |
| 237 | + WIX_MELT |
| 238 | + WIX_NIT |
| 239 | + WIX_PYRO |
| 240 | + WIX_SHINE |
| 241 | + WIX_SMOKE |
| 242 | + WIX_THMVIEWER |
| 243 | + WIX_TORCH |
| 244 | + WIX_WIXCOP |
| 245 | +) |
0 commit comments