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 介面中,藉由開啟/關閉以下變數,選擇除錯/發行、Unicode/ANSI、通用/非通用和靜態/共用。

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_CONFIGWXRC_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

一個介面程式庫,提供找到的組件的使用需求。