| 1 |
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 2 |
# file Copyright.txt or https://cmake.org/licensing for details. |
| 3 |
|
| 4 |
#[=======================================================================[.rst: |
| 5 |
FindwxWidgets |
| 6 |
------------- |
| 7 |
|
| 8 |
Find a wxWidgets (a.k.a., wxWindows) installation. |
| 9 |
|
| 10 |
This module finds if wxWidgets is installed and selects a default |
| 11 |
configuration to use. wxWidgets is a modular library. To specify the |
| 12 |
modules that you will use, you need to name them as components to the |
| 13 |
package: |
| 14 |
|
| 15 |
find_package(wxWidgets COMPONENTS core base ... OPTIONAL_COMPONENTS net ...) |
| 16 |
|
| 17 |
There are two search branches: a windows style and a unix style. For |
| 18 |
windows, the following variables are searched for and set to defaults |
| 19 |
in case of multiple choices. Change them if the defaults are not |
| 20 |
desired (i.e., these are the only variables you should change to |
| 21 |
select a configuration): |
| 22 |
|
| 23 |
:: |
| 24 |
|
| 25 |
wxWidgets_ROOT_DIR - Base wxWidgets directory |
| 26 |
(e.g., C:/wxWidgets-2.6.3). |
| 27 |
wxWidgets_LIB_DIR - Path to wxWidgets libraries |
| 28 |
(e.g., C:/wxWidgets-2.6.3/lib/vc_lib). |
| 29 |
wxWidgets_CONFIGURATION - Configuration to use |
| 30 |
(e.g., msw, mswd, mswu, mswunivud, etc.) |
| 31 |
wxWidgets_EXCLUDE_COMMON_LIBRARIES |
| 32 |
- Set to TRUE to exclude linking of |
| 33 |
commonly required libs (e.g., png tiff |
| 34 |
jpeg zlib regex expat). |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
For unix style it uses the wx-config utility. You can select between |
| 39 |
debug/release, unicode/ansi, universal/non-universal, and |
| 40 |
static/shared in the QtDialog or ccmake interfaces by turning ON/OFF |
| 41 |
the following variables: |
| 42 |
|
| 43 |
:: |
| 44 |
|
| 45 |
wxWidgets_USE_DEBUG |
| 46 |
wxWidgets_USE_UNICODE |
| 47 |
wxWidgets_USE_UNIVERSAL |
| 48 |
wxWidgets_USE_STATIC |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
There is also a wxWidgets_CONFIG_OPTIONS variable for all other |
| 53 |
options that need to be passed to the wx-config utility. For example, |
| 54 |
to use the base toolkit found in the /usr/local path, set the variable |
| 55 |
(before calling the FIND_PACKAGE command) as such: |
| 56 |
|
| 57 |
:: |
| 58 |
|
| 59 |
set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr) |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
The following are set after the configuration is done for both windows |
| 64 |
and unix style: |
| 65 |
|
| 66 |
:: |
| 67 |
|
| 68 |
wxWidgets_FOUND - Set to TRUE if wxWidgets was found. |
| 69 |
wxWidgets_INCLUDE_DIRS - Include directories for WIN32 |
| 70 |
i.e., where to find "wx/wx.h" and |
| 71 |
"wx/setup.h"; possibly empty for unices. |
| 72 |
wxWidgets_LIBRARIES - Path to the wxWidgets libraries. |
| 73 |
wxWidgets_LIBRARY_DIRS - compile time link dirs, useful for |
| 74 |
rpath on UNIX. Typically an empty string |
| 75 |
in WIN32 environment. |
| 76 |
wxWidgets_DEFINITIONS - Contains defines required to compile/link |
| 77 |
against WX, e.g. WXUSINGDLL |
| 78 |
wxWidgets_DEFINITIONS_DEBUG- Contains defines required to compile/link |
| 79 |
against WX debug builds, e.g. __WXDEBUG__ |
| 80 |
wxWidgets_CXX_FLAGS - Include dirs and compiler flags for |
| 81 |
unices, empty on WIN32. Essentially |
| 82 |
"`wx-config --cxxflags`". |
| 83 |
wxWidgets_USE_FILE - Convenience include file. |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
Sample usage: |
| 88 |
|
| 89 |
:: |
| 90 |
|
| 91 |
# Note that for MinGW users the order of libs is important! |
| 92 |
find_package(wxWidgets COMPONENTS gl core base OPTIONAL_COMPONENTS net) |
| 93 |
if(wxWidgets_FOUND) |
| 94 |
include(${wxWidgets_USE_FILE}) |
| 95 |
# and for each of your dependent executable/library targets: |
| 96 |
target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES}) |
| 97 |
endif() |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
If wxWidgets is required (i.e., not an optional part): |
| 102 |
|
| 103 |
:: |
| 104 |
|
| 105 |
find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net) |
| 106 |
include(${wxWidgets_USE_FILE}) |
| 107 |
# and for each of your dependent executable/library targets: |
| 108 |
target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES}) |
| 109 |
#]=======================================================================] |
| 110 |
|
| 111 |
# |
| 112 |
# FIXME: check this and provide a correct sample usage... |
| 113 |
# Remember to connect back to the upper text. |
| 114 |
# Sample usage with monolithic wx build: |
| 115 |
# |
| 116 |
# find_package(wxWidgets COMPONENTS mono) |
| 117 |
# ... |
| 118 |
|
| 119 |
# NOTES |
| 120 |
# |
| 121 |
# This module has been tested on the WIN32 platform with wxWidgets |
| 122 |
# 2.6.2, 2.6.3, and 2.5.3. However, it has been designed to |
| 123 |
# easily extend support to all possible builds, e.g., static/shared, |
| 124 |
# debug/release, unicode, universal, multilib/monolithic, etc.. |
| 125 |
# |
| 126 |
# If you want to use the module and your build type is not supported |
| 127 |
# out-of-the-box, please contact me to exchange information on how |
| 128 |
# your system is setup and I'll try to add support for it. |
| 129 |
# |
| 130 |
# AUTHOR |
| 131 |
# |
| 132 |
# Miguel A. Figueroa-Villanueva (miguelf at ieee dot org). |
| 133 |
# Jan Woetzel (jw at mip.informatik.uni-kiel.de). |
| 134 |
# |
| 135 |
# Based on previous works of: |
| 136 |
# Jan Woetzel (FindwxWindows.cmake), |
| 137 |
# Jorgen Bodde and Jerry Fath (FindwxWin.cmake). |
| 138 |
|
| 139 |
# TODO/ideas |
| 140 |
# |
| 141 |
# (1) Option/Setting to use all available wx libs |
| 142 |
# In contrast to expert developer who lists the |
| 143 |
# minimal set of required libs in wxWidgets_USE_LIBS |
| 144 |
# there is the newbie user: |
| 145 |
# - who just wants to link against WX with more 'magic' |
| 146 |
# - doesn't know the internal structure of WX or how it was built, |
| 147 |
# in particular if it is monolithic or not |
| 148 |
# - want to link against all available WX libs |
| 149 |
# Basically, the intent here is to mimic what wx-config would do by |
| 150 |
# default (i.e., `wx-config --libs`). |
| 151 |
# |
| 152 |
# Possible solution: |
| 153 |
# Add a reserved keyword "std" that initializes to what wx-config |
| 154 |
# would default to. If the user has not set the wxWidgets_USE_LIBS, |
| 155 |
# default to "std" instead of "base core" as it is now. To implement |
| 156 |
# "std" will basically boil down to a FOR_EACH lib-FOUND, but maybe |
| 157 |
# checking whether a minimal set was found. |
| 158 |
|
| 159 |
|
| 160 |
# FIXME: This and all the DBG_MSG calls should be removed after the |
| 161 |
# module stabilizes. |
| 162 |
# |
| 163 |
# Helper macro to control the debugging output globally. There are |
| 164 |
# two versions for controlling how verbose your output should be. |
| 165 |
macro(DBG_MSG _MSG) |
| 166 |
# message(STATUS |
| 167 |
# "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}") |
| 168 |
endmacro() |
| 169 |
macro(DBG_MSG_V _MSG) |
| 170 |
# message(STATUS |
| 171 |
# "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}") |
| 172 |
endmacro() |
| 173 |
|
| 174 |
# Clear return values in case the module is loaded more than once. |
| 175 |
set(wxWidgets_FOUND FALSE) |
| 176 |
set(wxWidgets_INCLUDE_DIRS "") |
| 177 |
set(wxWidgets_LIBRARIES "") |
| 178 |
set(wxWidgets_LIBRARY_DIRS "") |
| 179 |
set(wxWidgets_CXX_FLAGS "") |
| 180 |
|
| 181 |
# DEPRECATED: This is a patch to support the DEPRECATED use of |
| 182 |
# wxWidgets_USE_LIBS. |
| 183 |
# |
| 184 |
# If wxWidgets_USE_LIBS is set: |
| 185 |
# - if using <components>, then override wxWidgets_USE_LIBS |
| 186 |
# - else set wxWidgets_FIND_COMPONENTS to wxWidgets_USE_LIBS |
| 187 |
if(wxWidgets_USE_LIBS AND NOT wxWidgets_FIND_COMPONENTS) |
| 188 |
set(wxWidgets_FIND_COMPONENTS ${wxWidgets_USE_LIBS}) |
| 189 |
endif() |
| 190 |
DBG_MSG("wxWidgets_FIND_COMPONENTS : ${wxWidgets_FIND_COMPONENTS}") |
| 191 |
|
| 192 |
# Add the convenience use file if available. |
| 193 |
# |
| 194 |
# Get dir of this file which may reside in: |
| 195 |
# - CMAKE_MAKE_ROOT/Modules on CMake installation |
| 196 |
# - CMAKE_MODULE_PATH if user prefers his own specialized version |
| 197 |
set(wxWidgets_USE_FILE "") |
| 198 |
get_filename_component( |
| 199 |
wxWidgets_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) |
| 200 |
# Prefer an existing customized version, but the user might override |
| 201 |
# the FindwxWidgets module and not the UsewxWidgets one. |
| 202 |
if(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake") |
| 203 |
set(wxWidgets_USE_FILE |
| 204 |
"${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake") |
| 205 |
else() |
| 206 |
set(wxWidgets_USE_FILE UsewxWidgets) |
| 207 |
endif() |
| 208 |
|
| 209 |
#===================================================================== |
| 210 |
# Determine whether unix or win32 paths should be used |
| 211 |
#===================================================================== |
| 212 |
if(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_CROSSCOMPILING) |
| 213 |
set(wxWidgets_FIND_STYLE "win32") |
| 214 |
else() |
| 215 |
set(wxWidgets_FIND_STYLE "unix") |
| 216 |
endif() |
| 217 |
|
| 218 |
#===================================================================== |
| 219 |
# WIN32_FIND_STYLE |
| 220 |
#===================================================================== |
| 221 |
if(wxWidgets_FIND_STYLE STREQUAL "win32") |
| 222 |
# Useful common wx libs needed by almost all components. |
| 223 |
set(wxWidgets_COMMON_LIBRARIES png tiff jpeg zlib regex expat) |
| 224 |
|
| 225 |
# DEPRECATED: Use find_package(wxWidgets COMPONENTS mono) instead. |
| 226 |
if(NOT wxWidgets_FIND_COMPONENTS) |
| 227 |
if(wxWidgets_USE_MONOLITHIC) |
| 228 |
set(wxWidgets_FIND_COMPONENTS mono) |
| 229 |
else() |
| 230 |
set(wxWidgets_FIND_COMPONENTS core base) # this is default |
| 231 |
endif() |
| 232 |
endif() |
| 233 |
|
| 234 |
# Add the common (usually required libs) unless |
| 235 |
# wxWidgets_EXCLUDE_COMMON_LIBRARIES has been set. |
| 236 |
if(NOT wxWidgets_EXCLUDE_COMMON_LIBRARIES) |
| 237 |
list(APPEND wxWidgets_FIND_COMPONENTS |
| 238 |
${wxWidgets_COMMON_LIBRARIES}) |
| 239 |
endif() |
| 240 |
|
| 241 |
#------------------------------------------------------------------- |
| 242 |
# WIN32: Helper MACROS |
| 243 |
#------------------------------------------------------------------- |
| 244 |
# |
| 245 |
# Get filename components for a configuration. For example, |
| 246 |
# if _CONFIGURATION = mswunivud, then _PF="msw", _UNV=univ, _UCD=u _DBG=d |
| 247 |
# if _CONFIGURATION = mswu, then _PF="msw", _UNV="", _UCD=u _DBG="" |
| 248 |
# |
| 249 |
macro(WX_GET_NAME_COMPONENTS _CONFIGURATION _PF _UNV _UCD _DBG) |
| 250 |
DBG_MSG_V(${_CONFIGURATION}) |
| 251 |
string(REGEX MATCH "univ" ${_UNV} "${_CONFIGURATION}") |
| 252 |
string(REGEX REPLACE "[msw|qt].*(u)[d]*$" "u" ${_UCD} "${_CONFIGURATION}") |
| 253 |
if(${_UCD} STREQUAL ${_CONFIGURATION}) |
| 254 |
set(${_UCD} "") |
| 255 |
endif() |
| 256 |
string(REGEX MATCH "d$" ${_DBG} "${_CONFIGURATION}") |
| 257 |
string(REGEX MATCH "^[msw|qt]*" ${_PF} "${_CONFIGURATION}") |
| 258 |
endmacro() |
| 259 |
|
| 260 |
# |
| 261 |
# Find libraries associated to a configuration. |
| 262 |
# |
| 263 |
macro(WX_FIND_LIBS _PF _UNV _UCD _DBG) |
| 264 |
DBG_MSG_V("m_unv = ${_UNV}") |
| 265 |
DBG_MSG_V("m_ucd = ${_UCD}") |
| 266 |
DBG_MSG_V("m_dbg = ${_DBG}") |
| 267 |
|
| 268 |
# FIXME: What if both regex libs are available. regex should be |
| 269 |
# found outside the loop and only wx${LIB}${_UCD}${_DBG}. |
| 270 |
# Find wxWidgets common libraries. |
| 271 |
foreach(LIB ${wxWidgets_COMMON_LIBRARIES} scintilla) |
| 272 |
find_library(WX_${LIB}${_DBG} |
| 273 |
NAMES |
| 274 |
wx${LIB}${_UCD}${_DBG} # for regex |
| 275 |
wx${LIB}${_DBG} |
| 276 |
PATHS ${WX_LIB_DIR} |
| 277 |
NO_DEFAULT_PATH |
| 278 |
) |
| 279 |
mark_as_advanced(WX_${LIB}${_DBG}) |
| 280 |
endforeach() |
| 281 |
|
| 282 |
# Find wxWidgets multilib base libraries. |
| 283 |
find_library(WX_base${_DBG} |
| 284 |
NAMES |
| 285 |
wxbase31${_UCD}${_DBG} |
| 286 |
wxbase30${_UCD}${_DBG} |
| 287 |
wxbase29${_UCD}${_DBG} |
| 288 |
wxbase28${_UCD}${_DBG} |
| 289 |
wxbase27${_UCD}${_DBG} |
| 290 |
wxbase26${_UCD}${_DBG} |
| 291 |
wxbase25${_UCD}${_DBG} |
| 292 |
PATHS ${WX_LIB_DIR} |
| 293 |
NO_DEFAULT_PATH |
| 294 |
) |
| 295 |
mark_as_advanced(WX_base${_DBG}) |
| 296 |
foreach(LIB net odbc xml) |
| 297 |
find_library(WX_${LIB}${_DBG} |
| 298 |
NAMES |
| 299 |
wxbase31${_UCD}${_DBG}_${LIB} |
| 300 |
wxbase30${_UCD}${_DBG}_${LIB} |
| 301 |
wxbase29${_UCD}${_DBG}_${LIB} |
| 302 |
wxbase28${_UCD}${_DBG}_${LIB} |
| 303 |
wxbase27${_UCD}${_DBG}_${LIB} |
| 304 |
wxbase26${_UCD}${_DBG}_${LIB} |
| 305 |
wxbase25${_UCD}${_DBG}_${LIB} |
| 306 |
PATHS ${WX_LIB_DIR} |
| 307 |
NO_DEFAULT_PATH |
| 308 |
) |
| 309 |
mark_as_advanced(WX_${LIB}${_DBG}) |
| 310 |
endforeach() |
| 311 |
|
| 312 |
# Find wxWidgets monolithic library. |
| 313 |
find_library(WX_mono${_DBG} |
| 314 |
NAMES |
| 315 |
wx${_PF}${_UNV}31${_UCD}${_DBG} |
| 316 |
wx${_PF}${_UNV}30${_UCD}${_DBG} |
| 317 |
wx${_PF}${_UNV}29${_UCD}${_DBG} |
| 318 |
wx${_PF}${_UNV}28${_UCD}${_DBG} |
| 319 |
wx${_PF}${_UNV}27${_UCD}${_DBG} |
| 320 |
wx${_PF}${_UNV}26${_UCD}${_DBG} |
| 321 |
wx${_PF}${_UNV}25${_UCD}${_DBG} |
| 322 |
PATHS ${WX_LIB_DIR} |
| 323 |
NO_DEFAULT_PATH |
| 324 |
) |
| 325 |
mark_as_advanced(WX_mono${_DBG}) |
| 326 |
|
| 327 |
# Find wxWidgets multilib libraries. |
| 328 |
foreach(LIB core adv aui html media xrc dbgrid gl qa richtext |
| 329 |
stc ribbon propgrid webview) |
| 330 |
find_library(WX_${LIB}${_DBG} |
| 331 |
NAMES |
| 332 |
wx${_PF}${_UNV}31${_UCD}${_DBG}_${LIB} |
| 333 |
wx${_PF}${_UNV}30${_UCD}${_DBG}_${LIB} |
| 334 |
wx${_PF}${_UNV}29${_UCD}${_DBG}_${LIB} |
| 335 |
wx${_PF}${_UNV}28${_UCD}${_DBG}_${LIB} |
| 336 |
wx${_PF}${_UNV}27${_UCD}${_DBG}_${LIB} |
| 337 |
wx${_PF}${_UNV}26${_UCD}${_DBG}_${LIB} |
| 338 |
wx${_PF}${_UNV}25${_UCD}${_DBG}_${LIB} |
| 339 |
PATHS ${WX_LIB_DIR} |
| 340 |
NO_DEFAULT_PATH |
| 341 |
) |
| 342 |
mark_as_advanced(WX_${LIB}${_DBG}) |
| 343 |
endforeach() |
| 344 |
endmacro() |
| 345 |
|
| 346 |
# |
| 347 |
# Clear all library paths, so that FIND_LIBRARY refinds them. |
| 348 |
# |
| 349 |
# Clear a lib, reset its found flag, and mark as advanced. |
| 350 |
macro(WX_CLEAR_LIB _LIB) |
| 351 |
set(${_LIB} "${_LIB}-NOTFOUND" CACHE FILEPATH "Cleared." FORCE) |
| 352 |
set(${_LIB}_FOUND FALSE) |
| 353 |
mark_as_advanced(${_LIB}) |
| 354 |
endmacro() |
| 355 |
# Clear all debug or release library paths (arguments are "d" or ""). |
| 356 |
macro(WX_CLEAR_ALL_LIBS _DBG) |
| 357 |
# Clear wxWidgets common libraries. |
| 358 |
foreach(LIB ${wxWidgets_COMMON_LIBRARIES} scintilla) |
| 359 |
WX_CLEAR_LIB(WX_${LIB}${_DBG}) |
| 360 |
endforeach() |
| 361 |
|
| 362 |
# Clear wxWidgets multilib base libraries. |
| 363 |
WX_CLEAR_LIB(WX_base${_DBG}) |
| 364 |
foreach(LIB net odbc xml) |
| 365 |
WX_CLEAR_LIB(WX_${LIB}${_DBG}) |
| 366 |
endforeach() |
| 367 |
|
| 368 |
# Clear wxWidgets monolithic library. |
| 369 |
WX_CLEAR_LIB(WX_mono${_DBG}) |
| 370 |
|
| 371 |
# Clear wxWidgets multilib libraries. |
| 372 |
foreach(LIB core adv aui html media xrc dbgrid gl qa richtext |
| 373 |
webview stc ribbon propgrid) |
| 374 |
WX_CLEAR_LIB(WX_${LIB}${_DBG}) |
| 375 |
endforeach() |
| 376 |
endmacro() |
| 377 |
# Clear all wxWidgets debug libraries. |
| 378 |
macro(WX_CLEAR_ALL_DBG_LIBS) |
| 379 |
WX_CLEAR_ALL_LIBS("d") |
| 380 |
endmacro() |
| 381 |
# Clear all wxWidgets release libraries. |
| 382 |
macro(WX_CLEAR_ALL_REL_LIBS) |
| 383 |
WX_CLEAR_ALL_LIBS("") |
| 384 |
endmacro() |
| 385 |
|
| 386 |
# |
| 387 |
# Set the wxWidgets_LIBRARIES variable. |
| 388 |
# Also, Sets output variable wxWidgets_FOUND to FALSE if it fails. |
| 389 |
# |
| 390 |
macro(WX_SET_LIBRARIES _LIBS _DBG) |
| 391 |
DBG_MSG_V("Looking for ${${_LIBS}}") |
| 392 |
if(WX_USE_REL_AND_DBG) |
| 393 |
foreach(LIB ${${_LIBS}}) |
| 394 |
DBG_MSG_V("Searching for ${LIB} and ${LIB}d") |
| 395 |
DBG_MSG_V("WX_${LIB} : ${WX_${LIB}}") |
| 396 |
DBG_MSG_V("WX_${LIB}d : ${WX_${LIB}d}") |
| 397 |
if(WX_${LIB} AND WX_${LIB}d) |
| 398 |
DBG_MSG_V("Found ${LIB} and ${LIB}d") |
| 399 |
list(APPEND wxWidgets_LIBRARIES |
| 400 |
debug ${WX_${LIB}d} optimized ${WX_${LIB}} |
| 401 |
) |
| 402 |
set(wxWidgets_${LIB}_FOUND TRUE) |
| 403 |
elseif(NOT wxWidgets_FIND_REQUIRED_${LIB}) |
| 404 |
DBG_MSG_V("- ignored optional missing WX_${LIB}=${WX_${LIB}} or WX_${LIB}d=${WX_${LIB}d}") |
| 405 |
else() |
| 406 |
DBG_MSG_V("- not found due to missing WX_${LIB}=${WX_${LIB}} or WX_${LIB}d=${WX_${LIB}d}") |
| 407 |
set(wxWidgets_FOUND FALSE) |
| 408 |
endif() |
| 409 |
endforeach() |
| 410 |
else() |
| 411 |
foreach(LIB ${${_LIBS}}) |
| 412 |
DBG_MSG_V("Searching for ${LIB}${_DBG}") |
| 413 |
DBG_MSG_V("WX_${LIB}${_DBG} : ${WX_${LIB}${_DBG}}") |
| 414 |
if(WX_${LIB}${_DBG}) |
| 415 |
DBG_MSG_V("Found ${LIB}${_DBG}") |
| 416 |
list(APPEND wxWidgets_LIBRARIES ${WX_${LIB}${_DBG}}) |
| 417 |
set(wxWidgets_${LIB}_FOUND TRUE) |
| 418 |
elseif(NOT wxWidgets_FIND_REQUIRED_${LIB}) |
| 419 |
DBG_MSG_V("- ignored optional missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}") |
| 420 |
else() |
| 421 |
DBG_MSG_V("- not found due to missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}") |
| 422 |
set(wxWidgets_FOUND FALSE) |
| 423 |
endif() |
| 424 |
endforeach() |
| 425 |
endif() |
| 426 |
|
| 427 |
DBG_MSG_V("OpenGL") |
| 428 |
list(FIND ${_LIBS} gl WX_USE_GL) |
| 429 |
if(NOT WX_USE_GL EQUAL -1) |
| 430 |
DBG_MSG_V("- is required.") |
| 431 |
list(APPEND wxWidgets_LIBRARIES opengl32 glu32) |
| 432 |
endif() |
| 433 |
|
| 434 |
list(APPEND wxWidgets_LIBRARIES winmm comctl32 uuid oleacc uxtheme rpcrt4 shlwapi version wsock32) |
| 435 |
endmacro() |
| 436 |
|
| 437 |
#------------------------------------------------------------------- |
| 438 |
# WIN32: Start actual work. |
| 439 |
#------------------------------------------------------------------- |
| 440 |
|
| 441 |
# Look for an installation tree. |
| 442 |
find_path(wxWidgets_ROOT_DIR |
| 443 |
NAMES include/wx/wx.h |
| 444 |
PATHS |
| 445 |
ENV wxWidgets_ROOT_DIR |
| 446 |
ENV WXWIN |
| 447 |
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWidgets_is1;Inno Setup: App Path]" # WX 2.6.x |
| 448 |
C:/ |
| 449 |
D:/ |
| 450 |
ENV ProgramFiles |
| 451 |
PATH_SUFFIXES |
| 452 |
wxWidgets-3.1.3 |
| 453 |
wxWidgets-3.1.2 |
| 454 |
wxWidgets-3.1.1 |
| 455 |
wxWidgets-3.1.0 |
| 456 |
wxWidgets-3.0.2 |
| 457 |
wxWidgets-3.0.1 |
| 458 |
wxWidgets-3.0.0 |
| 459 |
wxWidgets-2.9.5 |
| 460 |
wxWidgets-2.9.4 |
| 461 |
wxWidgets-2.9.3 |
| 462 |
wxWidgets-2.9.2 |
| 463 |
wxWidgets-2.9.1 |
| 464 |
wxWidgets-2.9.0 |
| 465 |
wxWidgets-2.8.9 |
| 466 |
wxWidgets-2.8.8 |
| 467 |
wxWidgets-2.8.7 |
| 468 |
wxWidgets-2.8.6 |
| 469 |
wxWidgets-2.8.5 |
| 470 |
wxWidgets-2.8.4 |
| 471 |
wxWidgets-2.8.3 |
| 472 |
wxWidgets-2.8.2 |
| 473 |
wxWidgets-2.8.1 |
| 474 |
wxWidgets-2.8.0 |
| 475 |
wxWidgets-2.7.4 |
| 476 |
wxWidgets-2.7.3 |
| 477 |
wxWidgets-2.7.2 |
| 478 |
wxWidgets-2.7.1 |
| 479 |
wxWidgets-2.7.0 |
| 480 |
wxWidgets-2.7.0-1 |
| 481 |
wxWidgets-2.6.4 |
| 482 |
wxWidgets-2.6.3 |
| 483 |
wxWidgets-2.6.2 |
| 484 |
wxWidgets-2.6.1 |
| 485 |
wxWidgets-2.5.4 |
| 486 |
wxWidgets-2.5.3 |
| 487 |
wxWidgets-2.5.2 |
| 488 |
wxWidgets-2.5.1 |
| 489 |
wxWidgets |
| 490 |
DOC "wxWidgets base/installation directory" |
| 491 |
) |
| 492 |
|
| 493 |
# If wxWidgets_ROOT_DIR changed, clear lib dir. |
| 494 |
if(NOT WX_ROOT_DIR STREQUAL wxWidgets_ROOT_DIR) |
| 495 |
set(WX_ROOT_DIR ${wxWidgets_ROOT_DIR} |
| 496 |
CACHE INTERNAL "wxWidgets_ROOT_DIR") |
| 497 |
set(wxWidgets_LIB_DIR "wxWidgets_LIB_DIR-NOTFOUND" |
| 498 |
CACHE PATH "Cleared." FORCE) |
| 499 |
endif() |
| 500 |
|
| 501 |
if(WX_ROOT_DIR) |
| 502 |
# Select one default tree inside the already determined wx tree. |
| 503 |
# Prefer static/shared order usually consistent with build |
| 504 |
# settings. |
| 505 |
set(_WX_TOOL "") |
| 506 |
set(_WX_TOOLVER "") |
| 507 |
set(_WX_ARCH "") |
| 508 |
if(MINGW) |
| 509 |
set(_WX_TOOL gcc) |
| 510 |
elseif(MSVC) |
| 511 |
set(_WX_TOOL vc) |
| 512 |
set(_WX_TOOLVER ${MSVC_TOOLSET_VERSION}) |
| 513 |
# support for a lib/vc14x_x64_dll/ path from wxW 3.1.3 distribution |
| 514 |
string(REGEX REPLACE ".$" "x" _WX_TOOLVERx ${_WX_TOOLVER}) |
| 515 |
if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 516 |
set(_WX_ARCH _x64) |
| 517 |
endif() |
| 518 |
endif() |
| 519 |
if(BUILD_SHARED_LIBS) |
| 520 |
find_path(wxWidgets_LIB_DIR |
| 521 |
NAMES |
| 522 |
qtu/wx/setup.h |
| 523 |
qtud/wx/setup.h |
| 524 |
msw/wx/setup.h |
| 525 |
mswd/wx/setup.h |
| 526 |
mswu/wx/setup.h |
| 527 |
mswud/wx/setup.h |
| 528 |
mswuniv/wx/setup.h |
| 529 |
mswunivd/wx/setup.h |
| 530 |
mswunivu/wx/setup.h |
| 531 |
mswunivud/wx/setup.h |
| 532 |
PATHS |
| 533 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}_xp${_WX_ARCH}_dll # prefer shared |
| 534 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_dll # prefer shared |
| 535 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}_xp${_WX_ARCH}_dll # prefer shared |
| 536 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}${_WX_ARCH}_dll # prefer shared |
| 537 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_dll # prefer shared |
| 538 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}_xp${_WX_ARCH}_lib |
| 539 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_lib |
| 540 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}_xp${_WX_ARCH}_lib |
| 541 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}${_WX_ARCH}_lib |
| 542 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_lib |
| 543 |
DOC "Path to wxWidgets libraries" |
| 544 |
NO_DEFAULT_PATH |
| 545 |
) |
| 546 |
else() |
| 547 |
find_path(wxWidgets_LIB_DIR |
| 548 |
NAMES |
| 549 |
qtu/wx/setup.h |
| 550 |
qtud/wx/setup.h |
| 551 |
msw/wx/setup.h |
| 552 |
mswd/wx/setup.h |
| 553 |
mswu/wx/setup.h |
| 554 |
mswud/wx/setup.h |
| 555 |
mswuniv/wx/setup.h |
| 556 |
mswunivd/wx/setup.h |
| 557 |
mswunivu/wx/setup.h |
| 558 |
mswunivud/wx/setup.h |
| 559 |
PATHS |
| 560 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}_xp${_WX_ARCH}_lib # prefer static |
| 561 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_lib # prefer static |
| 562 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}_xp${_WX_ARCH}_lib # prefer static |
| 563 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}${_WX_ARCH}_lib # prefer static |
| 564 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_lib # prefer static |
| 565 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}_xp${_WX_ARCH}_dll |
| 566 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_dll |
| 567 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}_xp${_WX_ARCH}_dll |
| 568 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}${_WX_ARCH}_dll |
| 569 |
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_dll |
| 570 |
DOC "Path to wxWidgets libraries" |
| 571 |
NO_DEFAULT_PATH |
| 572 |
) |
| 573 |
endif() |
| 574 |
unset(_WX_TOOL) |
| 575 |
unset(_WX_TOOLVER) |
| 576 |
unset(_WX_ARCH) |
| 577 |
|
| 578 |
# If wxWidgets_LIB_DIR changed, clear all libraries. |
| 579 |
if(NOT WX_LIB_DIR STREQUAL wxWidgets_LIB_DIR) |
| 580 |
set(WX_LIB_DIR ${wxWidgets_LIB_DIR} CACHE INTERNAL "wxWidgets_LIB_DIR") |
| 581 |
WX_CLEAR_ALL_DBG_LIBS() |
| 582 |
WX_CLEAR_ALL_REL_LIBS() |
| 583 |
endif() |
| 584 |
|
| 585 |
if(WX_LIB_DIR) |
| 586 |
# If building shared libs, define WXUSINGDLL to use dllimport. |
| 587 |
if(WX_LIB_DIR MATCHES "[dD][lL][lL]") |
| 588 |
set(wxWidgets_DEFINITIONS_GENERAL WXUSINGDLL) |
| 589 |
DBG_MSG_V("detected SHARED/DLL tree WX_LIB_DIR=${WX_LIB_DIR}") |
| 590 |
endif() |
| 591 |
|
| 592 |
# Search for available configuration types. |
| 593 |
foreach(CFG mswunivud mswunivd mswud mswd mswunivu mswuniv mswu msw qt qtd qtu qtud) |
| 594 |
set(WX_${CFG}_FOUND FALSE) |
| 595 |
if(EXISTS ${WX_LIB_DIR}/${CFG}) |
| 596 |
list(APPEND WX_CONFIGURATION_LIST ${CFG}) |
| 597 |
set(WX_${CFG}_FOUND TRUE) |
| 598 |
set(WX_CONFIGURATION ${CFG}) |
| 599 |
endif() |
| 600 |
endforeach() |
| 601 |
DBG_MSG_V("WX_CONFIGURATION_LIST=${WX_CONFIGURATION_LIST}") |
| 602 |
|
| 603 |
if(WX_CONFIGURATION) |
| 604 |
set(wxWidgets_FOUND TRUE) |
| 605 |
|
| 606 |
# If the selected configuration wasn't found force the default |
| 607 |
# one. Otherwise, use it but still force a refresh for |
| 608 |
# updating the doc string with the current list of available |
| 609 |
# configurations. |
| 610 |
if(NOT WX_${wxWidgets_CONFIGURATION}_FOUND) |
| 611 |
set(wxWidgets_CONFIGURATION ${WX_CONFIGURATION} CACHE STRING |
| 612 |
"Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE) |
| 613 |
else() |
| 614 |
set(wxWidgets_CONFIGURATION ${wxWidgets_CONFIGURATION} CACHE STRING |
| 615 |
"Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE) |
| 616 |
endif() |
| 617 |
|
| 618 |
# If release config selected, and both release/debug exist. |
| 619 |
if(WX_${wxWidgets_CONFIGURATION}d_FOUND) |
| 620 |
option(wxWidgets_USE_REL_AND_DBG |
| 621 |
"Use release and debug configurations?" TRUE) |
| 622 |
set(WX_USE_REL_AND_DBG ${wxWidgets_USE_REL_AND_DBG}) |
| 623 |
else() |
| 624 |
# If the option exists (already in cache), force it false. |
| 625 |
if(wxWidgets_USE_REL_AND_DBG) |
| 626 |
set(wxWidgets_USE_REL_AND_DBG FALSE CACHE BOOL |
| 627 |
"No ${wxWidgets_CONFIGURATION}d found." FORCE) |
| 628 |
endif() |
| 629 |
set(WX_USE_REL_AND_DBG FALSE) |
| 630 |
endif() |
| 631 |
|
| 632 |
# Get configuration parameters from the name. |
| 633 |
WX_GET_NAME_COMPONENTS(${wxWidgets_CONFIGURATION} PF UNV UCD DBG) |
| 634 |
|
| 635 |
# Set wxWidgets lib setup include directory. |
| 636 |
if(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h) |
| 637 |
set(wxWidgets_INCLUDE_DIRS |
| 638 |
${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}) |
| 639 |
else() |
| 640 |
DBG_MSG("wxWidgets_FOUND FALSE because ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h does not exists.") |
| 641 |
set(wxWidgets_FOUND FALSE) |
| 642 |
endif() |
| 643 |
|
| 644 |
# Set wxWidgets main include directory. |
| 645 |
if(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h) |
| 646 |
list(APPEND wxWidgets_INCLUDE_DIRS ${WX_ROOT_DIR}/include) |
| 647 |
else() |
| 648 |
DBG_MSG("wxWidgets_FOUND FALSE because WX_ROOT_DIR=${WX_ROOT_DIR} has no ${WX_ROOT_DIR}/include/wx/wx.h") |
| 649 |
set(wxWidgets_FOUND FALSE) |
| 650 |
endif() |
| 651 |
|
| 652 |
# Find wxWidgets libraries. |
| 653 |
WX_FIND_LIBS("${PF}" "${UNV}" "${UCD}" "${DBG}") |
| 654 |
if(WX_USE_REL_AND_DBG) |
| 655 |
WX_FIND_LIBS("${PF}" "${UNV}" "${UCD}" "d") |
| 656 |
endif() |
| 657 |
|
| 658 |
# Settings for requested libs (i.e., include dir, libraries, etc.). |
| 659 |
WX_SET_LIBRARIES(wxWidgets_FIND_COMPONENTS "${DBG}") |
| 660 |
|
| 661 |
# Add necessary definitions for unicode builds |
| 662 |
if("${UCD}" STREQUAL "u") |
| 663 |
list(APPEND wxWidgets_DEFINITIONS_GENERAL UNICODE _UNICODE) |
| 664 |
endif() |
| 665 |
|
| 666 |
# Add necessary definitions for debug builds |
| 667 |
set(wxWidgets_DEFINITIONS_DEBUG _DEBUG __WXDEBUG__) |
| 668 |
|
| 669 |
endif() |
| 670 |
endif() |
| 671 |
endif() |
| 672 |
|
| 673 |
#===================================================================== |
| 674 |
# UNIX_FIND_STYLE |
| 675 |
#===================================================================== |
| 676 |
else() |
| 677 |
if(wxWidgets_FIND_STYLE STREQUAL "unix") |
| 678 |
#----------------------------------------------------------------- |
| 679 |
# UNIX: Helper MACROS |
| 680 |
#----------------------------------------------------------------- |
| 681 |
# |
| 682 |
# Set the default values based on "wx-config --selected-config". |
| 683 |
# |
| 684 |
macro(WX_CONFIG_SELECT_GET_DEFAULT) |
| 685 |
execute_process( |
| 686 |
COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" |
| 687 |
${wxWidgets_CONFIG_OPTIONS} --selected-config |
| 688 |
OUTPUT_VARIABLE _wx_selected_config |
| 689 |
RESULT_VARIABLE _wx_result |
| 690 |
ERROR_QUIET |
| 691 |
) |
| 692 |
if(_wx_result EQUAL 0) |
| 693 |
foreach(_opt_name debug static unicode universal) |
| 694 |
string(TOUPPER ${_opt_name} _upper_opt_name) |
| 695 |
if(_wx_selected_config MATCHES "${_opt_name}") |
| 696 |
set(wxWidgets_DEFAULT_${_upper_opt_name} ON) |
| 697 |
else() |
| 698 |
set(wxWidgets_DEFAULT_${_upper_opt_name} OFF) |
| 699 |
endif() |
| 700 |
endforeach() |
| 701 |
else() |
| 702 |
foreach(_upper_opt_name DEBUG STATIC UNICODE UNIVERSAL) |
| 703 |
set(wxWidgets_DEFAULT_${_upper_opt_name} OFF) |
| 704 |
endforeach() |
| 705 |
endif() |
| 706 |
endmacro() |
| 707 |
|
| 708 |
# |
| 709 |
# Find flavours |
| 710 |
# |
| 711 |
macro(WX_CONFIG_SELECT_QUERY_FLAVOUR) |
| 712 |
execute_process( |
| 713 |
COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" |
| 714 |
${wxWidgets_CONFIG_OPTIONS} --flavour=debug |
| 715 |
RESULT_VARIABLE _wx_result_debug |
| 716 |
OUTPUT_QUIET |
| 717 |
ERROR_QUIET |
| 718 |
) |
| 719 |
|
| 720 |
if(_wx_result_debug EQUAL 0) |
| 721 |
set(wxWidgets_HAS_DEBUG ON CACHE BOOL "") |
| 722 |
endif() |
| 723 |
|
| 724 |
execute_process( |
| 725 |
COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" |
| 726 |
${wxWidgets_CONFIG_OPTIONS} --flavour=release |
| 727 |
RESULT_VARIABLE _wx_result_release |
| 728 |
OUTPUT_QUIET |
| 729 |
ERROR_QUIET |
| 730 |
) |
| 731 |
|
| 732 |
if(_wx_result_release EQUAL 0) |
| 733 |
set(wxWidgets_HAS_RELEASE ON CACHE BOOL "") |
| 734 |
endif() |
| 735 |
endmacro() |
| 736 |
|
| 737 |
# |
| 738 |
# Query a boolean configuration option to determine if the system |
| 739 |
# has both builds available. If so, provide the selection option |
| 740 |
# to the user. |
| 741 |
# |
| 742 |
macro(WX_CONFIG_SELECT_QUERY_BOOL _OPT_NAME _OPT_HELP) |
| 743 |
execute_process( |
| 744 |
COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" |
| 745 |
${wxWidgets_CONFIG_OPTIONS} --${_OPT_NAME}=yes |
| 746 |
RESULT_VARIABLE _wx_result_yes |
| 747 |
OUTPUT_QUIET |
| 748 |
ERROR_QUIET |
| 749 |
) |
| 750 |
execute_process( |
| 751 |
COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" |
| 752 |
${wxWidgets_CONFIG_OPTIONS} --${_OPT_NAME}=no |
| 753 |
RESULT_VARIABLE _wx_result_no |
| 754 |
OUTPUT_QUIET |
| 755 |
ERROR_QUIET |
| 756 |
) |
| 757 |
string(TOUPPER ${_OPT_NAME} _UPPER_OPT_NAME) |
| 758 |
if(_wx_result_yes EQUAL 0 AND _wx_result_no EQUAL 0) |
| 759 |
option(wxWidgets_USE_${_UPPER_OPT_NAME} |
| 760 |
${_OPT_HELP} ${wxWidgets_DEFAULT_${_UPPER_OPT_NAME}}) |
| 761 |
else() |
| 762 |
# If option exists (already in cache), force to available one. |
| 763 |
if(DEFINED wxWidgets_USE_${_UPPER_OPT_NAME}) |
| 764 |
if(_wx_result_yes EQUAL 0) |
| 765 |
set(wxWidgets_USE_${_UPPER_OPT_NAME} ON CACHE BOOL ${_OPT_HELP} FORCE) |
| 766 |
else() |
| 767 |
set(wxWidgets_USE_${_UPPER_OPT_NAME} OFF CACHE BOOL ${_OPT_HELP} FORCE) |
| 768 |
endif() |
| 769 |
endif() |
| 770 |
endif() |
| 771 |
endmacro() |
| 772 |
|
| 773 |
# |
| 774 |
# Set wxWidgets_SELECT_OPTIONS to wx-config options for selecting |
| 775 |
# among multiple builds. |
| 776 |
# |
| 777 |
macro(WX_CONFIG_SELECT_SET_OPTIONS) |
| 778 |
set(wxWidgets_SELECT_OPTIONS ${wxWidgets_CONFIG_OPTIONS}) |
| 779 |
foreach(_opt_name static unicode universal) |
| 780 |
string(TOUPPER ${_opt_name} _upper_opt_name) |
| 781 |
if(DEFINED wxWidgets_USE_${_upper_opt_name}) |
| 782 |
if(wxWidgets_USE_${_upper_opt_name}) |
| 783 |
list(APPEND wxWidgets_SELECT_OPTIONS --${_opt_name}=yes) |
| 784 |
else() |
| 785 |
list(APPEND wxWidgets_SELECT_OPTIONS --${_opt_name}=no) |
| 786 |
endif() |
| 787 |
endif() |
| 788 |
endforeach() |
| 789 |
endmacro() |
| 790 |
|
| 791 |
macro(WX_CONFIG_GET_CONFIG _FLAVOUR _KIND) |
| 792 |
# run the wx-config program to get cxxflags |
| 793 |
execute_process( |
| 794 |
COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" |
| 795 |
${wxWidgets_SELECT_OPTIONS} ${_FLAVOUR} --cxxflags |
| 796 |
OUTPUT_VARIABLE _wx_result_cxxflags |
| 797 |
RESULT_VARIABLE RET |
| 798 |
ERROR_QUIET |
| 799 |
) |
| 800 |
if(RET EQUAL 0) |
| 801 |
string(STRIP "${_wx_result_cxxflags}" _wx_result_cxxflags) |
| 802 |
separate_arguments(wxWidgets_CXX_FLAGS_LIST NATIVE_COMMAND "${_wx_result_cxxflags}") |
| 803 |
|
| 804 |
DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}") |
| 805 |
|
| 806 |
string(TOUPPER ${_KIND} _SFX) |
| 807 |
|
| 808 |
# parse definitions and include dirs from cxxflags |
| 809 |
# drop the -D and -I prefixes |
| 810 |
foreach(arg IN LISTS wxWidgets_CXX_FLAGS_LIST) |
| 811 |
if("${arg}" MATCHES "^-I(.*)$") |
| 812 |
# include directory |
| 813 |
list(APPEND wxWidgets_INCLUDE_DIRS "${CMAKE_MATCH_1}") |
| 814 |
elseif("${arg}" MATCHES "^-D(.*)$") |
| 815 |
# compile definition |
| 816 |
list(APPEND wxWidgets_DEFINITIONS_${_SFX} "${CMAKE_MATCH_1}") |
| 817 |
else() |
| 818 |
list(APPEND wxWidgets_CXX_FLAGS_${_SFX} "${arg}") |
| 819 |
endif() |
| 820 |
endforeach() |
| 821 |
|
| 822 |
DBG_MSG_V("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS_${_SFX}}") |
| 823 |
DBG_MSG_V("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS_${_SFX}}") |
| 824 |
DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS_${_SFX}}") |
| 825 |
|
| 826 |
set(wxWidgets_FOUND TRUE) |
| 827 |
else() |
| 828 |
set(wxWidgets_FOUND FALSE) |
| 829 |
DBG_MSG_V( |
| 830 |
"${wxWidgets_CONFIG_EXECUTABLE} --cxxflags FAILED with RET=${RET}") |
| 831 |
endif() |
| 832 |
|
| 833 |
# run the wx-config program to get the libs |
| 834 |
# - NOTE: wx-config doesn't verify that the libs requested exist |
| 835 |
# it just produces the names. Maybe a TRY_COMPILE would |
| 836 |
# be useful here... |
| 837 |
unset(_cmp_req) |
| 838 |
unset(_cmp_opt) |
| 839 |
foreach(_cmp IN LISTS wxWidgets_FIND_COMPONENTS) |
| 840 |
if(wxWidgets_FIND_REQUIRED_${_cmp}) |
| 841 |
list(APPEND _cmp_req "${_cmp}") |
| 842 |
else() |
| 843 |
list(APPEND _cmp_opt "${_cmp}") |
| 844 |
endif() |
| 845 |
endforeach() |
| 846 |
DBG_MSG_V("wxWidgets required components : ${_cmp_req}") |
| 847 |
DBG_MSG_V("wxWidgets optional components : ${_cmp_opt}") |
| 848 |
if(DEFINED _cmp_opt) |
| 849 |
string(REPLACE ";" "," _cmp_opt "--optional-libs ${_cmp_opt}") |
| 850 |
endif() |
| 851 |
string(REPLACE ";" "," _cmp_req "${_cmp_req}") |
| 852 |
execute_process( |
| 853 |
COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" |
| 854 |
${wxWidgets_SELECT_OPTIONS} ${_FLAVOUR} --libs ${_cmp_req} ${_cmp_opt} |
| 855 |
OUTPUT_VARIABLE _wx_result_libraries |
| 856 |
RESULT_VARIABLE RET |
| 857 |
ERROR_QUIET |
| 858 |
) |
| 859 |
if(RET EQUAL 0) |
| 860 |
string(STRIP "${_wx_result_libraries}" _wx_result_libraries) |
| 861 |
separate_arguments(_wx_result_libraries) |
| 862 |
string(REPLACE "-framework;" "-framework " |
| 863 |
_wx_result_libraries "${_wx_result_libraries}") |
| 864 |
string(REPLACE "-weak_framework;" "-weak_framework " |
| 865 |
_wx_result_libraries "${_wx_result_libraries}") |
| 866 |
string(REPLACE "-arch;" "-arch " |
| 867 |
_wx_result_libraries "${_wx_result_libraries}") |
| 868 |
string(REPLACE "-isysroot;" "-isysroot " |
| 869 |
_wx_result_libraries "${_wx_result_libraries}") |
| 870 |
|
| 871 |
# extract linkdirs (-L) for rpath (i.e., LINK_DIRECTORIES) |
| 872 |
string(REGEX MATCHALL "-L[^;]+" |
| 873 |
_wx_result_library_dirs "${_wx_result_libraries}") |
| 874 |
string(REGEX REPLACE "-L([^;]+)" "\\1" |
| 875 |
wxWidgets_LIBRARY_DIRS "${_wx_result_library_dirs}") |
| 876 |
|
| 877 |
foreach(_arg IN LISTS _wx_result_libraries) |
| 878 |
if(_arg) |
| 879 |
list(APPEND wxWidgets_LIBRARIES ${_KIND} ${_arg}) |
| 880 |
endif() |
| 881 |
endforeach() |
| 882 |
|
| 883 |
message("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}") |
| 884 |
message("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}") |
| 885 |
DBG_MSG_V("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}") |
| 886 |
DBG_MSG_V("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}") |
| 887 |
|
| 888 |
else() |
| 889 |
set(wxWidgets_FOUND FALSE) |
| 890 |
DBG_MSG("${wxWidgets_CONFIG_EXECUTABLE} --libs ${_cmp_req} ${_cmp_opt} FAILED with RET=${RET}") |
| 891 |
endif() |
| 892 |
unset(_cmp_req) |
| 893 |
unset(_cmp_opt) |
| 894 |
endmacro() |
| 895 |
|
| 896 |
#----------------------------------------------------------------- |
| 897 |
# UNIX: Start actual work. |
| 898 |
#----------------------------------------------------------------- |
| 899 |
# Support cross-compiling, only search in the target platform. |
| 900 |
find_program(wxWidgets_CONFIG_EXECUTABLE |
| 901 |
NAMES $ENV{WX_CONFIG} wx-config wx-config-3.1 wx-config-3.0 wx-config-2.9 wx-config-2.8 |
| 902 |
DOC "Location of wxWidgets library configuration provider binary (wx-config)." |
| 903 |
ONLY_CMAKE_FIND_ROOT_PATH |
| 904 |
) |
| 905 |
|
| 906 |
if(wxWidgets_CONFIG_EXECUTABLE) |
| 907 |
set(wxWidgets_FOUND TRUE) |
| 908 |
|
| 909 |
# get defaults based on "wx-config --selected-config" |
| 910 |
WX_CONFIG_SELECT_GET_DEFAULT() |
| 911 |
|
| 912 |
# for each option: if both builds are available, provide option |
| 913 |
WX_CONFIG_SELECT_QUERY_BOOL(unicode "Use unicode build?") |
| 914 |
WX_CONFIG_SELECT_QUERY_BOOL(universal "Use universal build?") |
| 915 |
WX_CONFIG_SELECT_QUERY_BOOL(static "Link libraries statically?") |
| 916 |
|
| 917 |
# process selection to set wxWidgets_SELECT_OPTIONS |
| 918 |
WX_CONFIG_SELECT_SET_OPTIONS() |
| 919 |
DBG_MSG("wxWidgets_SELECT_OPTIONS=${wxWidgets_SELECT_OPTIONS}") |
| 920 |
|
| 921 |
# find available flavours |
| 922 |
WX_CONFIG_SELECT_QUERY_FLAVOUR() |
| 923 |
if(wxWidgets_HAS_DEBUG) |
| 924 |
WX_CONFIG_GET_CONFIG("--flavour=debug" debug) |
| 925 |
endif() |
| 926 |
|
| 927 |
if(wxWidgets_HAS_RELEASE) |
| 928 |
WX_CONFIG_GET_CONFIG("--flavour=release" optimized) |
| 929 |
endif() |
| 930 |
|
| 931 |
if(NOT wxWidgets_HAS_DEBUG AND NOT wxWidgets_HAS_RELEASE) |
| 932 |
WX_CONFIG_GET_CONFIG("" general) |
| 933 |
endif() |
| 934 |
endif() |
| 935 |
|
| 936 |
# When using wx-config in MSYS, the include paths are UNIX style paths which may or may |
| 937 |
# not work correctly depending on you MSYS/MinGW configuration. CMake expects native |
| 938 |
# paths internally. |
| 939 |
if(wxWidgets_FOUND AND MSYS) |
| 940 |
find_program(_cygpath_exe cygpath ONLY_CMAKE_FIND_ROOT_PATH) |
| 941 |
DBG_MSG_V("_cygpath_exe: ${_cygpath_exe}") |
| 942 |
if(_cygpath_exe) |
| 943 |
set(_tmp_path "") |
| 944 |
foreach(_path ${wxWidgets_INCLUDE_DIRS}) |
| 945 |
execute_process( |
| 946 |
COMMAND cygpath -w ${_path} |
| 947 |
OUTPUT_VARIABLE _native_path |
| 948 |
RESULT_VARIABLE _retv |
| 949 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
| 950 |
ERROR_QUIET |
| 951 |
) |
| 952 |
if(_retv EQUAL 0) |
| 953 |
file(TO_CMAKE_PATH ${_native_path} _native_path) |
| 954 |
DBG_MSG_V("Path ${_path} converted to ${_native_path}") |
| 955 |
string(APPEND _tmp_path " ${_native_path}") |
| 956 |
endif() |
| 957 |
endforeach() |
| 958 |
DBG_MSG("Setting wxWidgets_INCLUDE_DIRS = ${_tmp_path}") |
| 959 |
set(wxWidgets_INCLUDE_DIRS ${_tmp_path}) |
| 960 |
separate_arguments(wxWidgets_INCLUDE_DIRS) |
| 961 |
list(REMOVE_ITEM wxWidgets_INCLUDE_DIRS "") |
| 962 |
|
| 963 |
set(_tmp_path "") |
| 964 |
foreach(_path ${wxWidgets_LIBRARY_DIRS}) |
| 965 |
execute_process( |
| 966 |
COMMAND cygpath -w ${_path} |
| 967 |
OUTPUT_VARIABLE _native_path |
| 968 |
RESULT_VARIABLE _retv |
| 969 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
| 970 |
ERROR_QUIET |
| 971 |
) |
| 972 |
if(_retv EQUAL 0) |
| 973 |
file(TO_CMAKE_PATH ${_native_path} _native_path) |
| 974 |
DBG_MSG_V("Path ${_path} converted to ${_native_path}") |
| 975 |
string(APPEND _tmp_path " ${_native_path}") |
| 976 |
endif() |
| 977 |
endforeach() |
| 978 |
DBG_MSG("Setting wxWidgets_LIBRARY_DIRS = ${_tmp_path}") |
| 979 |
set(wxWidgets_LIBRARY_DIRS ${_tmp_path}) |
| 980 |
separate_arguments(wxWidgets_LIBRARY_DIRS) |
| 981 |
list(REMOVE_ITEM wxWidgets_LIBRARY_DIRS "") |
| 982 |
endif() |
| 983 |
unset(_cygpath_exe CACHE) |
| 984 |
endif() |
| 985 |
|
| 986 |
#===================================================================== |
| 987 |
# Neither UNIX_FIND_STYLE, nor WIN32_FIND_STYLE |
| 988 |
#===================================================================== |
| 989 |
else() |
| 990 |
if(NOT wxWidgets_FIND_QUIETLY) |
| 991 |
message(STATUS |
| 992 |
"${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): \n" |
| 993 |
" Platform unknown/unsupported. It's neither WIN32 nor UNIX " |
| 994 |
"find style." |
| 995 |
) |
| 996 |
endif() |
| 997 |
endif() |
| 998 |
endif() |
| 999 |
|
| 1000 |
# Check that all libraries are present, as wx-config does not check it |
| 1001 |
set(_wx_libraries "") |
| 1002 |
set(_wx_lib_missing "") |
| 1003 |
foreach(_wx_lib_ ${wxWidgets_LIBRARIES}) |
| 1004 |
if("${_wx_lib_}" MATCHES "^-l(.*)") |
| 1005 |
set(_wx_lib_name "${CMAKE_MATCH_1}") |
| 1006 |
unset(_wx_lib_found CACHE) |
| 1007 |
find_library(_wx_lib_found NAMES ${_wx_lib_name} HINTS ${wxWidgets_LIBRARY_DIRS}) |
| 1008 |
if(_wx_lib_found STREQUAL _wx_lib_found-NOTFOUND) |
| 1009 |
list(APPEND _wx_lib_missing ${_wx_lib_name}) |
| 1010 |
else() |
| 1011 |
list(APPEND _wx_libraries ${_wx_lib_found}) |
| 1012 |
endif() |
| 1013 |
unset(_wx_lib_found CACHE) |
| 1014 |
else() |
| 1015 |
list(APPEND _wx_libraries ${_wx_lib_}) |
| 1016 |
endif() |
| 1017 |
endforeach() |
| 1018 |
set(wxWidgets_LIBRARIES ${_wx_libraries}) |
| 1019 |
unset(_wx_libraries) |
| 1020 |
|
| 1021 |
if (_wx_lib_missing) |
| 1022 |
string(REPLACE ";" " " _wx_lib_missing "${_wx_lib_missing}") |
| 1023 |
DBG_MSG_V("wxWidgets not found due to following missing libraries: ${_wx_lib_missing}") |
| 1024 |
set(wxWidgets_FOUND FALSE) |
| 1025 |
unset(wxWidgets_LIBRARIES) |
| 1026 |
endif() |
| 1027 |
unset(_wx_lib_missing) |
| 1028 |
|
| 1029 |
# Check if a specific version was requested by find_package(). |
| 1030 |
if(wxWidgets_FOUND) |
| 1031 |
unset(_wx_filename) |
| 1032 |
find_file(_wx_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH) |
| 1033 |
dbg_msg("_wx_filename: ${_wx_filename}") |
| 1034 |
|
| 1035 |
if(NOT _wx_filename) |
| 1036 |
message(FATAL_ERROR "wxWidgets wx/version.h file not found in ${wxWidgets_INCLUDE_DIRS}.") |
| 1037 |
endif() |
| 1038 |
|
| 1039 |
file(READ "${_wx_filename}" _wx_version_h) |
| 1040 |
unset(_wx_filename CACHE) |
| 1041 |
|
| 1042 |
string(REGEX REPLACE "^(.*\n)?#define +wxMAJOR_VERSION +([0-9]+).*" |
| 1043 |
"\\2" wxWidgets_VERSION_MAJOR "${_wx_version_h}" ) |
| 1044 |
string(REGEX REPLACE "^(.*\n)?#define +wxMINOR_VERSION +([0-9]+).*" |
| 1045 |
"\\2" wxWidgets_VERSION_MINOR "${_wx_version_h}" ) |
| 1046 |
string(REGEX REPLACE "^(.*\n)?#define +wxRELEASE_NUMBER +([0-9]+).*" |
| 1047 |
"\\2" wxWidgets_VERSION_PATCH "${_wx_version_h}" ) |
| 1048 |
set(wxWidgets_VERSION_STRING |
| 1049 |
"${wxWidgets_VERSION_MAJOR}.${wxWidgets_VERSION_MINOR}.${wxWidgets_VERSION_PATCH}" ) |
| 1050 |
dbg_msg("wxWidgets_VERSION_STRING: ${wxWidgets_VERSION_STRING}") |
| 1051 |
endif() |
| 1052 |
|
| 1053 |
# Debug output: |
| 1054 |
DBG_MSG("wxWidgets_FOUND : ${wxWidgets_FOUND}") |
| 1055 |
DBG_MSG("wxWidgets_INCLUDE_DIRS : ${wxWidgets_INCLUDE_DIRS}") |
| 1056 |
DBG_MSG("wxWidgets_LIBRARY_DIRS : ${wxWidgets_LIBRARY_DIRS}") |
| 1057 |
DBG_MSG("wxWidgets_LIBRARIES : ${wxWidgets_LIBRARIES}") |
| 1058 |
DBG_MSG("wxWidgets_CXX_FLAGS : ${wxWidgets_CXX_FLAGS}") |
| 1059 |
DBG_MSG("wxWidgets_USE_FILE : ${wxWidgets_USE_FILE}") |
| 1060 |
|
| 1061 |
#===================================================================== |
| 1062 |
#===================================================================== |
| 1063 |
|
| 1064 |
include(FindPackageHandleStandardArgs) |
| 1065 |
|
| 1066 |
# FIXME: set wxWidgets_<comp>_FOUND for wx-config branch |
| 1067 |
# and use HANDLE_COMPONENTS on Unix too |
| 1068 |
if(wxWidgets_FIND_STYLE STREQUAL "win32") |
| 1069 |
set(wxWidgets_HANDLE_COMPONENTS "HANDLE_COMPONENTS") |
| 1070 |
endif() |
| 1071 |
|
| 1072 |
find_package_handle_standard_args(wxWidgets |
| 1073 |
REQUIRED_VARS wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS |
| 1074 |
VERSION_VAR wxWidgets_VERSION_STRING |
| 1075 |
${wxWidgets_HANDLE_COMPONENTS} |
| 1076 |
) |
| 1077 |
unset(wxWidgets_HANDLE_COMPONENTS) |
| 1078 |
|
| 1079 |
#===================================================================== |
| 1080 |
# Macros for use in wxWidgets apps. |
| 1081 |
# - This module will not fail to find wxWidgets based on the code |
| 1082 |
# below. Hence, it's required to check for validity of: |
| 1083 |
# |
| 1084 |
# wxWidgets_wxrc_EXECUTABLE |
| 1085 |
#===================================================================== |
| 1086 |
|
| 1087 |
# Resource file compiler. |
| 1088 |
find_program(wxWidgets_wxrc_EXECUTABLE |
| 1089 |
NAMES $ENV{WXRC_CMD} wxrc |
| 1090 |
PATHS ${wxWidgets_ROOT_DIR}/utils/wxrc/vc_msw |
| 1091 |
DOC "Location of wxWidgets resource file compiler binary (wxrc)" |
| 1092 |
) |
| 1093 |
|
| 1094 |
# |
| 1095 |
# WX_SPLIT_ARGUMENTS_ON(<keyword> <left> <right> <arg1> <arg2> ...) |
| 1096 |
# |
| 1097 |
# Sets <left> and <right> to contain arguments to the left and right, |
| 1098 |
# respectively, of <keyword>. |
| 1099 |
# |
| 1100 |
# Example usage: |
| 1101 |
# function(WXWIDGETS_ADD_RESOURCES outfiles) |
| 1102 |
# WX_SPLIT_ARGUMENTS_ON(OPTIONS wxrc_files wxrc_options ${ARGN}) |
| 1103 |
# ... |
| 1104 |
# endfunction() |
| 1105 |
# |
| 1106 |
# WXWIDGETS_ADD_RESOURCES(sources ${xrc_files} OPTIONS -e -o file.C) |
| 1107 |
# |
| 1108 |
# NOTE: This is a generic piece of code that should be renamed to |
| 1109 |
# SPLIT_ARGUMENTS_ON and put in a file serving the same purpose as |
| 1110 |
# FindPackageStandardArgs.cmake. At the time of this writing |
| 1111 |
# FindQt4.cmake has a QT4_EXTRACT_OPTIONS, which I basically copied |
| 1112 |
# here a bit more generalized. So, there are already two find modules |
| 1113 |
# using this approach. |
| 1114 |
# |
| 1115 |
function(WX_SPLIT_ARGUMENTS_ON _keyword _leftvar _rightvar) |
| 1116 |
# FIXME: Document that the input variables will be cleared. |
| 1117 |
#list(APPEND ${_leftvar} "") |
| 1118 |
#list(APPEND ${_rightvar} "") |
| 1119 |
set(${_leftvar} "") |
| 1120 |
set(${_rightvar} "") |
| 1121 |
|
| 1122 |
set(_doing_right FALSE) |
| 1123 |
foreach(element ${ARGN}) |
| 1124 |
if("${element}" STREQUAL "${_keyword}") |
| 1125 |
set(_doing_right TRUE) |
| 1126 |
else() |
| 1127 |
if(_doing_right) |
| 1128 |
list(APPEND ${_rightvar} "${element}") |
| 1129 |
else() |
| 1130 |
list(APPEND ${_leftvar} "${element}") |
| 1131 |
endif() |
| 1132 |
endif() |
| 1133 |
endforeach() |
| 1134 |
|
| 1135 |
set(${_leftvar} ${${_leftvar}} PARENT_SCOPE) |
| 1136 |
set(${_rightvar} ${${_rightvar}} PARENT_SCOPE) |
| 1137 |
endfunction() |
| 1138 |
|
| 1139 |
# |
| 1140 |
# WX_GET_DEPENDENCIES_FROM_XML( |
| 1141 |
# <depends> |
| 1142 |
# <match_pattern> |
| 1143 |
# <clean_pattern> |
| 1144 |
# <xml_contents> |
| 1145 |
# <depends_path> |
| 1146 |
# ) |
| 1147 |
# |
| 1148 |
# FIXME: Add documentation here... |
| 1149 |
# |
| 1150 |
function(WX_GET_DEPENDENCIES_FROM_XML |
| 1151 |
_depends |
| 1152 |
_match_patt |
| 1153 |
_clean_patt |
| 1154 |
_xml_contents |
| 1155 |
_depends_path |
| 1156 |
) |
| 1157 |
|
| 1158 |
string(REGEX MATCHALL |
| 1159 |
${_match_patt} |
| 1160 |
dep_file_list |
| 1161 |
"${${_xml_contents}}" |
| 1162 |
) |
| 1163 |
foreach(dep_file ${dep_file_list}) |
| 1164 |
string(REGEX REPLACE ${_clean_patt} "" dep_file "${dep_file}") |
| 1165 |
|
| 1166 |
# make the file have an absolute path |
| 1167 |
if(NOT IS_ABSOLUTE "${dep_file}") |
| 1168 |
set(dep_file "${${_depends_path}}/${dep_file}") |
| 1169 |
endif() |
| 1170 |
|
| 1171 |
# append file to dependency list |
| 1172 |
list(APPEND ${_depends} "${dep_file}") |
| 1173 |
endforeach() |
| 1174 |
|
| 1175 |
set(${_depends} ${${_depends}} PARENT_SCOPE) |
| 1176 |
endfunction() |
| 1177 |
|
| 1178 |
# |
| 1179 |
# WXWIDGETS_ADD_RESOURCES(<sources> <xrc_files> |
| 1180 |
# OPTIONS <options> [NO_CPP_CODE]) |
| 1181 |
# |
| 1182 |
# Adds a custom command for resource file compilation of the |
| 1183 |
# <xrc_files> and appends the output files to <sources>. |
| 1184 |
# |
| 1185 |
# Example usages: |
| 1186 |
# WXWIDGETS_ADD_RESOURCES(sources xrc/main_frame.xrc) |
| 1187 |
# WXWIDGETS_ADD_RESOURCES(sources ${xrc_files} OPTIONS -e -o altname.cxx) |
| 1188 |
# |
| 1189 |
function(WXWIDGETS_ADD_RESOURCES _outfiles) |
| 1190 |
WX_SPLIT_ARGUMENTS_ON(OPTIONS rc_file_list rc_options ${ARGN}) |
| 1191 |
|
| 1192 |
# Parse files for dependencies. |
| 1193 |
set(rc_file_list_abs "") |
| 1194 |
set(rc_depends "") |
| 1195 |
foreach(rc_file ${rc_file_list}) |
| 1196 |
get_filename_component(depends_path ${rc_file} PATH) |
| 1197 |
|
| 1198 |
get_filename_component(rc_file_abs ${rc_file} ABSOLUTE) |
| 1199 |
list(APPEND rc_file_list_abs "${rc_file_abs}") |
| 1200 |
|
| 1201 |
# All files have absolute paths or paths relative to the location |
| 1202 |
# of the rc file. |
| 1203 |
file(READ "${rc_file_abs}" rc_file_contents) |
| 1204 |
|
| 1205 |
# get bitmap/bitmap2 files |
| 1206 |
WX_GET_DEPENDENCIES_FROM_XML( |
| 1207 |
rc_depends |
| 1208 |
"<bitmap[^<]+" |
| 1209 |
"^<bitmap[^>]*>" |
| 1210 |
rc_file_contents |
| 1211 |
depends_path |
| 1212 |
) |
| 1213 |
|
| 1214 |
# get url files |
| 1215 |
WX_GET_DEPENDENCIES_FROM_XML( |
| 1216 |
rc_depends |
| 1217 |
"<url[^<]+" |
| 1218 |
"^<url[^>]*>" |
| 1219 |
rc_file_contents |
| 1220 |
depends_path |
| 1221 |
) |
| 1222 |
|
| 1223 |
# get wxIcon files |
| 1224 |
WX_GET_DEPENDENCIES_FROM_XML( |
| 1225 |
rc_depends |
| 1226 |
"<object[^>]*class=\"wxIcon\"[^<]+" |
| 1227 |
"^<object[^>]*>" |
| 1228 |
rc_file_contents |
| 1229 |
depends_path |
| 1230 |
) |
| 1231 |
endforeach() |
| 1232 |
|
| 1233 |
# |
| 1234 |
# Parse options. |
| 1235 |
# |
| 1236 |
# If NO_CPP_CODE option specified, then produce .xrs file rather |
| 1237 |
# than a .cpp file (i.e., don't add the default --cpp-code option). |
| 1238 |
list(FIND rc_options NO_CPP_CODE index) |
| 1239 |
if(index EQUAL -1) |
| 1240 |
list(APPEND rc_options --cpp-code) |
| 1241 |
# wxrc's default output filename for cpp code. |
| 1242 |
set(outfile resource.cpp) |
| 1243 |
else() |
| 1244 |
list(REMOVE_AT rc_options ${index}) |
| 1245 |
# wxrc's default output filename for xrs file. |
| 1246 |
set(outfile resource.xrs) |
| 1247 |
endif() |
| 1248 |
|
| 1249 |
# Get output name for use in ADD_CUSTOM_COMMAND. |
| 1250 |
# - short option scanning |
| 1251 |
list(FIND rc_options -o index) |
| 1252 |
if(NOT index EQUAL -1) |
| 1253 |
math(EXPR filename_index "${index} + 1") |
| 1254 |
list(GET rc_options ${filename_index} outfile) |
| 1255 |
#list(REMOVE_AT rc_options ${index} ${filename_index}) |
| 1256 |
endif() |
| 1257 |
# - long option scanning |
| 1258 |
string(REGEX MATCH "--output=[^;]*" outfile_opt "${rc_options}") |
| 1259 |
if(outfile_opt) |
| 1260 |
string(REPLACE "--output=" "" outfile "${outfile_opt}") |
| 1261 |
endif() |
| 1262 |
#string(REGEX REPLACE "--output=[^;]*;?" "" rc_options "${rc_options}") |
| 1263 |
#string(REGEX REPLACE ";$" "" rc_options "${rc_options}") |
| 1264 |
|
| 1265 |
if(NOT IS_ABSOLUTE "${outfile}") |
| 1266 |
set(outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}") |
| 1267 |
endif() |
| 1268 |
add_custom_command( |
| 1269 |
OUTPUT "${outfile}" |
| 1270 |
COMMAND ${wxWidgets_wxrc_EXECUTABLE} ${rc_options} ${rc_file_list_abs} |
| 1271 |
DEPENDS ${rc_file_list_abs} ${rc_depends} |
| 1272 |
) |
| 1273 |
|
| 1274 |
# Add generated header to output file list. |
| 1275 |
list(FIND rc_options -e short_index) |
| 1276 |
list(FIND rc_options --extra-cpp-code long_index) |
| 1277 |
if(NOT short_index EQUAL -1 OR NOT long_index EQUAL -1) |
| 1278 |
get_filename_component(outfile_ext ${outfile} EXT) |
| 1279 |
string(REPLACE "${outfile_ext}" ".h" outfile_header "${outfile}") |
| 1280 |
list(APPEND ${_outfiles} "${outfile_header}") |
| 1281 |
set_source_files_properties( |
| 1282 |
"${outfile_header}" PROPERTIES GENERATED TRUE |
| 1283 |
) |
| 1284 |
endif() |
| 1285 |
|
| 1286 |
# Add generated file to output file list. |
| 1287 |
list(APPEND ${_outfiles} "${outfile}") |
| 1288 |
|
| 1289 |
set(${_outfiles} ${${_outfiles}} PARENT_SCOPE) |
| 1290 |
endfunction() |