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
一個介面函式庫,提供已找到組件的使用需求。