FindwxWidgets

查找 wxWidgets (又名 wxWindows) 安装。

此模块查找是否安装了 wxWidgets 并选择要使用的默认配置。wxWidgets 是一个模块化库。要指定您将使用的模块,您需要将它们命名为包的组件

find_package(wxWidgets COMPONENTS core base ... OPTIONAL_COMPONENTS net ...)

3.4 版本新增: 支持 find_package() 版本参数;webview 组件。

3.14 版本新增: OPTIONAL_COMPONENTS 支持。

有两个搜索分支:Windows 样式和 Unix 样式。对于 Windows,将搜索以下变量,并在有多个选择的情况下将其设置为默认值。如果不需要默认值,请更改它们(即,这些是您应该更改以选择配置的唯一变量)

wxWidgets_ROOT_DIR      - Base wxWidgets directory
                          (e.g., C:/wxWidgets-3.2.0).
wxWidgets_LIB_DIR       - Path to wxWidgets libraries
                          (e.g., C:/wxWidgets-3.2.0/lib/vc_x64_lib).
wxWidgets_CONFIGURATION - Configuration to use
                          (e.g., msw, mswd, mswu, mswunivud, etc.)
wxWidgets_EXCLUDE_COMMON_LIBRARIES
                        - Set to TRUE to exclude linking of
                          commonly required libs (e.g., png tiff
                          jpeg zlib regex expat scintilla lexilla).

对于 Unix 样式,它使用 wx-config 实用程序。您可以通过在 QtDialog 或 ccmake 界面中打开/关闭以下变量,在 debug/release、unicode/ansi、universal/non-universal 和 static/shared 之间进行选择

wxWidgets_USE_DEBUG
wxWidgets_USE_UNICODE
wxWidgets_USE_UNIVERSAL
wxWidgets_USE_STATIC

还有一个 wxWidgets_CONFIG_OPTIONS 变量,用于所有其他需要传递给 wx-config 实用程序的选项。例如,要使用在 /usr/local 路径中找到的基础工具包,请按如下方式设置变量(在调用 FIND_PACKAGE 命令之前)

set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr)

配置完成后,将为 Windows 和 Unix 样式设置以下内容

wxWidgets_FOUND            - Set to TRUE if wxWidgets was found.
wxWidgets_INCLUDE_DIRS     - Include directories for WIN32
                             i.e., where to find "wx/wx.h" and
                             "wx/setup.h"; possibly empty for unices.
wxWidgets_LIBRARIES        - Path to the wxWidgets libraries.
wxWidgets_LIBRARY_DIRS     - compile time link dirs, useful for
                             rpath on UNIX. Typically an empty string
                             in WIN32 environment.
wxWidgets_DEFINITIONS      - Contains defines required to compile/link
                             against WX, e.g. WXUSINGDLL
wxWidgets_DEFINITIONS_DEBUG- Contains defines required to compile/link
                             against WX debug builds, e.g. __WXDEBUG__
wxWidgets_CXX_FLAGS        - Include dirs and compiler flags for
                             unices, empty on WIN32. Essentially
                             "`wx-config --cxxflags`".
wxWidgets_USE_FILE         - Convenience include file.

3.11 版本新增: 以下环境变量可以用作提示:WX_CONFIG, WXRC_CMD

用法示例

# Note that for MinGW users the order of libs is important!
find_package(wxWidgets COMPONENTS gl core base OPTIONAL_COMPONENTS net)
if(wxWidgets_FOUND)
  include(${wxWidgets_USE_FILE})
  # and for each of your dependent executable/library targets:
  target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
endif()

如果 wxWidgets 是必需的(即,不是可选部分)

find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net)
include(${wxWidgets_USE_FILE})
# and for each of your dependent executable/library targets:
target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})

导入目标

3.27 版本新增。

此模块定义以下 IMPORTED 目标

wxWidgets::wxWidgets

一个接口库,提供找到的组件的使用要求。