summaryrefslogtreecommitdiff
path: root/Modules/FindwxWidgets.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/FindwxWidgets.cmake')
-rw-r--r--Modules/FindwxWidgets.cmake322
1 files changed, 222 insertions, 100 deletions
diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake
index 37a894c4d..af4daf061 100644
--- a/Modules/FindwxWidgets.cmake
+++ b/Modules/FindwxWidgets.cmake
@@ -1,93 +1,111 @@
-# - Find a wxWidgets (a.k.a., wxWindows) installation.
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#.rst:
+# FindwxWidgets
+# -------------
+#
+# Find a wxWidgets (a.k.a., wxWindows) installation.
+#
# This module finds if wxWidgets is installed and selects a default
-# configuration to use. wxWidgets is a modular library. To specify the
-# modules that you will use, you need to name them as components to
-# the package:
+# configuration to use. wxWidgets is a modular library. To specify the
+# modules that you will use, you need to name them as components to the
+# package:
#
# find_package(wxWidgets COMPONENTS core base ...)
#
-# There are two search branches: a windows style and a unix style. For
-# windows, the following variables are searched for and set to
-# defaults in case of multiple choices. Change them if the defaults
-# are not desired (i.e., these are the only variables you should
-# change to select a configuration):
+# There are two search branches: a windows style and a unix style. For
+# windows, the following variables are searched for and set to defaults
+# in case of multiple choices. Change them if the defaults are not
+# desired (i.e., these are the only variables you should change to
+# select a configuration):
+#
+# ::
+#
+# wxWidgets_ROOT_DIR - Base wxWidgets directory
+# (e.g., C:/wxWidgets-2.6.3).
+# wxWidgets_LIB_DIR - Path to wxWidgets libraries
+# (e.g., C:/wxWidgets-2.6.3/lib/vc_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).
+#
#
-# wxWidgets_ROOT_DIR - Base wxWidgets directory
-# (e.g., C:/wxWidgets-2.6.3).
-# wxWidgets_LIB_DIR - Path to wxWidgets libraries
-# (e.g., C:/wxWidgets-2.6.3/lib/vc_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).
#
-# For unix style it uses the wx-config utility. You can select between
+# For unix style it uses the wx-config utility. You can select between
# debug/release, unicode/ansi, universal/non-universal, and
# static/shared in the QtDialog or ccmake interfaces by turning ON/OFF
# the following variables:
#
-# wxWidgets_USE_DEBUG
-# wxWidgets_USE_UNICODE
-# wxWidgets_USE_UNIVERSAL
-# wxWidgets_USE_STATIC
+# ::
+#
+# wxWidgets_USE_DEBUG
+# wxWidgets_USE_UNICODE
+# wxWidgets_USE_UNIVERSAL
+# wxWidgets_USE_STATIC
+#
+#
#
# There is also a wxWidgets_CONFIG_OPTIONS variable for all other
-# options that need to be passed to the wx-config utility. For
-# example, to use the base toolkit found in the /usr/local path, set
-# the variable (before calling the FIND_PACKAGE command) as such:
+# options that need to be passed to the wx-config utility. For example,
+# to use the base toolkit found in the /usr/local path, set the variable
+# (before calling the FIND_PACKAGE command) as such:
+#
+# ::
+#
+# set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr)
+#
#
-# set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr)
#
-# The following are set after the configuration is done for both
-# windows and unix style:
+# The following are set after the configuration is done for both windows
+# and unix style:
+#
+# ::
+#
+# 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.
+#
#
-# 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.
#
# Sample usage:
-# # Note that for MinGW users the order of libs is important!
-# find_package(wxWidgets COMPONENTS net gl core base)
-# if(wxWidgets_FOUND)
-# include(${wxWidgets_USE_FILE})
-# # and for each of your dependent executable/library targets:
-# target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
-# endif()
+#
+# ::
+#
+# # Note that for MinGW users the order of libs is important!
+# find_package(wxWidgets COMPONENTS net gl core base)
+# if(wxWidgets_FOUND)
+# include(${wxWidgets_USE_FILE})
+# # and for each of your dependent executable/library targets:
+# target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
+# endif()
+#
+#
#
# If wxWidgets is required (i.e., not an optional part):
-# find_package(wxWidgets REQUIRED net gl core base)
-# include(${wxWidgets_USE_FILE})
-# # and for each of your dependent executable/library targets:
-# target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
-
-#=============================================================================
-# Copyright 2004-2009 Kitware, Inc.
-# Copyright 2007-2009 Miguel A. Figueroa-Villanueva <miguelf at ieee dot org>
#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
+# ::
#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
+# find_package(wxWidgets REQUIRED net gl core base)
+# include(${wxWidgets_USE_FILE})
+# # and for each of your dependent executable/library targets:
+# target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
#
# FIXME: check this and provide a correct sample usage...
@@ -159,18 +177,6 @@ set(wxWidgets_LIBRARIES "")
set(wxWidgets_LIBRARY_DIRS "")
set(wxWidgets_CXX_FLAGS "")
-# Using SYSTEM with INCLUDE_DIRECTORIES in conjunction with wxWidgets on
-# the Mac produces compiler errors. Set wxWidgets_INCLUDE_DIRS_NO_SYSTEM
-# to prevent UsewxWidgets.cmake from using SYSTEM.
-#
-# See cmake mailing list discussions for more info:
-# http://www.cmake.org/pipermail/cmake/2008-April/021115.html
-# http://www.cmake.org/pipermail/cmake/2008-April/021146.html
-#
-if(APPLE OR CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD")
- set(wxWidgets_INCLUDE_DIRS_NO_SYSTEM 1)
-endif()
-
# DEPRECATED: This is a patch to support the DEPRECATED use of
# wxWidgets_USE_LIBS.
#
@@ -200,13 +206,12 @@ else()
endif()
#=====================================================================
+# Determine whether unix or win32 paths should be used
#=====================================================================
-if(WIN32 AND NOT CYGWIN AND NOT MSYS)
+if(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_CROSSCOMPILING)
set(wxWidgets_FIND_STYLE "win32")
else()
- if(UNIX OR MSYS)
- set(wxWidgets_FIND_STYLE "unix")
- endif()
+ set(wxWidgets_FIND_STYLE "unix")
endif()
#=====================================================================
@@ -274,6 +279,8 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
# Find wxWidgets multilib base libraries.
find_library(WX_base${_DBG}
NAMES
+ wxbase31${_UCD}${_DBG}
+ wxbase30${_UCD}${_DBG}
wxbase29${_UCD}${_DBG}
wxbase28${_UCD}${_DBG}
wxbase27${_UCD}${_DBG}
@@ -286,6 +293,8 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
foreach(LIB net odbc xml)
find_library(WX_${LIB}${_DBG}
NAMES
+ wxbase31${_UCD}${_DBG}_${LIB}
+ wxbase30${_UCD}${_DBG}_${LIB}
wxbase29${_UCD}${_DBG}_${LIB}
wxbase28${_UCD}${_DBG}_${LIB}
wxbase27${_UCD}${_DBG}_${LIB}
@@ -300,6 +309,8 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
# Find wxWidgets monolithic library.
find_library(WX_mono${_DBG}
NAMES
+ wxmsw${_UNV}31${_UCD}${_DBG}
+ wxmsw${_UNV}30${_UCD}${_DBG}
wxmsw${_UNV}29${_UCD}${_DBG}
wxmsw${_UNV}28${_UCD}${_DBG}
wxmsw${_UNV}27${_UCD}${_DBG}
@@ -315,6 +326,8 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
stc ribbon propgrid webview)
find_library(WX_${LIB}${_DBG}
NAMES
+ wxmsw${_UNV}31${_UCD}${_DBG}_${LIB}
+ wxmsw${_UNV}30${_UCD}${_DBG}_${LIB}
wxmsw${_UNV}29${_UCD}${_DBG}_${LIB}
wxmsw${_UNV}28${_UCD}${_DBG}_${LIB}
wxmsw${_UNV}27${_UCD}${_DBG}_${LIB}
@@ -354,7 +367,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
# Clear wxWidgets multilib libraries.
foreach(LIB core adv aui html media xrc dbgrid gl qa richtext
- stc ribbon propgrid)
+ webview stc ribbon propgrid)
WX_CLEAR_LIB(WX_${LIB}${_DBG})
endforeach()
endmacro()
@@ -410,7 +423,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
list(APPEND wxWidgets_LIBRARIES opengl32 glu32)
endif()
- list(APPEND wxWidgets_LIBRARIES winmm comctl32 rpcrt4 wsock32)
+ list(APPEND wxWidgets_LIBRARIES winmm comctl32 oleacc rpcrt4 shlwapi version wsock32)
endmacro()
#-------------------------------------------------------------------
@@ -428,6 +441,11 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
D:/
ENV ProgramFiles
PATH_SUFFIXES
+ wxWidgets-3.1.0
+ wxWidgets-3.0.2
+ wxWidgets-3.0.1
+ wxWidgets-3.0.0
+ wxWidgets-2.9.5
wxWidgets-2.9.4
wxWidgets-2.9.3
wxWidgets-2.9.2
@@ -473,10 +491,29 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
# Select one default tree inside the already determined wx tree.
# Prefer static/shared order usually consistent with build
# settings.
+ set(_WX_TOOL "")
+ set(_WX_TOOLVER "")
+ set(_WX_ARCH "")
if(MINGW)
- set(WX_LIB_DIR_PREFIX gcc)
- else()
- set(WX_LIB_DIR_PREFIX vc)
+ set(_WX_TOOL gcc)
+ elseif(MSVC)
+ set(_WX_TOOL vc)
+ if(MSVC_VERSION EQUAL 1910)
+ set(_WX_TOOLVER 141)
+ elseif(MSVC_VERSION EQUAL 1900)
+ set(_WX_TOOLVER 140)
+ elseif(MSVC_VERSION EQUAL 1800)
+ set(_WX_TOOLVER 120)
+ elseif(MSVC_VERSION EQUAL 1700)
+ set(_WX_TOOLVER 110)
+ elseif(MSVC_VERSION EQUAL 1600)
+ set(_WX_TOOLVER 100)
+ elseif(MSVC_VERSION EQUAL 1500)
+ set(_WX_TOOLVER 90)
+ endif()
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(_WX_ARCH _x64)
+ endif()
endif()
if(BUILD_SHARED_LIBS)
find_path(wxWidgets_LIB_DIR
@@ -490,8 +527,10 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
mswunivu/wx/setup.h
mswunivud/wx/setup.h
PATHS
- ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll # prefer shared
- ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_dll # prefer shared
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_dll # prefer shared
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_lib
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_lib
DOC "Path to wxWidgets libraries"
NO_DEFAULT_PATH
)
@@ -507,12 +546,17 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
mswunivu/wx/setup.h
mswunivud/wx/setup.h
PATHS
- ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib # prefer static
- ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_lib # prefer static
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_lib # prefer static
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_dll
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_dll
DOC "Path to wxWidgets libraries"
NO_DEFAULT_PATH
)
endif()
+ unset(_WX_TOOL)
+ unset(_WX_TOOLVER)
+ unset(_WX_ARCH)
# If wxWidgets_LIB_DIR changed, clear all libraries.
if(NOT WX_LIB_DIR STREQUAL wxWidgets_LIB_DIR)
@@ -523,7 +567,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
if(WX_LIB_DIR)
# If building shared libs, define WXUSINGDLL to use dllimport.
- if(WX_LIB_DIR MATCHES ".*[dD][lL][lL].*")
+ if(WX_LIB_DIR MATCHES "[dD][lL][lL]")
set(wxWidgets_DEFINITIONS WXUSINGDLL)
DBG_MSG_V("detected SHARED/DLL tree WX_LIB_DIR=${WX_LIB_DIR}")
endif()
@@ -631,7 +675,7 @@ else()
if(_wx_result EQUAL 0)
foreach(_opt_name debug static unicode universal)
string(TOUPPER ${_opt_name} _upper_opt_name)
- if(_wx_selected_config MATCHES ".*${_opt_name}.*")
+ if(_wx_selected_config MATCHES "${_opt_name}")
set(wxWidgets_DEFAULT_${_upper_opt_name} ON)
else()
set(wxWidgets_DEFAULT_${_upper_opt_name} OFF)
@@ -702,7 +746,8 @@ else()
# UNIX: Start actual work.
#-----------------------------------------------------------------
# Support cross-compiling, only search in the target platform.
- find_program(wxWidgets_CONFIG_EXECUTABLE wx-config
+ find_program(wxWidgets_CONFIG_EXECUTABLE
+ NAMES wx-config wx-config-3.1 wx-config-3.0 wx-config-2.9 wx-config-2.8
DOC "Location of wxWidgets library configuration provider binary (wx-config)."
ONLY_CMAKE_FIND_ROOT_PATH
)
@@ -804,6 +849,36 @@ else()
endif()
endif()
+ # When using wx-config in MSYS, the include paths are UNIX style paths which may or may
+ # not work correctly depending on you MSYS/MinGW configuration. CMake expects native
+ # paths internally.
+ if(wxWidgets_FOUND AND MSYS)
+ find_program(_cygpath_exe cygpath ONLY_CMAKE_FIND_ROOT_PATH)
+ DBG_MSG_V("_cygpath_exe: ${_cygpath_exe}")
+ if(_cygpath_exe)
+ set(_tmp_path "")
+ foreach(_path ${wxWidgets_INCLUDE_DIRS})
+ execute_process(
+ COMMAND cygpath -w ${_path}
+ OUTPUT_VARIABLE _native_path
+ RESULT_VARIABLE _retv
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+ )
+ if(_retv EQUAL 0)
+ file(TO_CMAKE_PATH ${_native_path} _native_path)
+ DBG_MSG_V("Path ${_path} converted to ${_native_path}")
+ string(APPEND _tmp_path " ${_native_path}")
+ endif()
+ endforeach()
+ DBG_MSG("Setting wxWidgets_INCLUDE_DIRS = ${_tmp_path}")
+ set(wxWidgets_INCLUDE_DIRS ${_tmp_path})
+ separate_arguments(wxWidgets_INCLUDE_DIRS)
+ list(REMOVE_ITEM wxWidgets_INCLUDE_DIRS "")
+ endif()
+ unset(_cygpath_exe CACHE)
+ endif()
+
#=====================================================================
# Neither UNIX_FIND_STYLE, nor WIN32_FIND_STYLE
#=====================================================================
@@ -818,6 +893,50 @@ else()
endif()
endif()
+# Check that all libraries are present, as wx-config does not check it
+set(_wx_lib_missing "")
+foreach(_wx_lib_ ${wxWidgets_LIBRARIES})
+ if("${_wx_lib_}" MATCHES "^-l(.*)")
+ set(_wx_lib_name "${CMAKE_MATCH_1}")
+ unset(_wx_lib_found CACHE)
+ find_library(_wx_lib_found NAMES ${_wx_lib_name} HINTS ${wxWidgets_LIBRARY_DIRS})
+ if(_wx_lib_found STREQUAL _wx_lib_found-NOTFOUND)
+ list(APPEND _wx_lib_missing ${_wx_lib_name})
+ endif()
+ unset(_wx_lib_found CACHE)
+ endif()
+endforeach()
+
+if (_wx_lib_missing)
+ string(REPLACE ";" " " _wx_lib_missing "${_wx_lib_missing}")
+ DBG_MSG_V("wxWidgets not found due to following missing libraries: ${_wx_lib_missing}")
+ set(wxWidgets_FOUND FALSE)
+ unset(wxWidgets_LIBRARIES)
+endif()
+unset(_wx_lib_missing)
+
+# Check if a specfic version was requested by find_package().
+if(wxWidgets_FOUND)
+ find_file(_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH)
+ dbg_msg("_filename: ${_filename}")
+
+ if(NOT _filename)
+ message(FATAL_ERROR "wxWidgets wx/version.h file not found in ${wxWidgets_INCLUDE_DIRS}.")
+ endif()
+
+ file(READ ${_filename} _wx_version_h)
+
+ string(REGEX REPLACE "^(.*\n)?#define +wxMAJOR_VERSION +([0-9]+).*"
+ "\\2" wxWidgets_VERSION_MAJOR "${_wx_version_h}" )
+ string(REGEX REPLACE "^(.*\n)?#define +wxMINOR_VERSION +([0-9]+).*"
+ "\\2" wxWidgets_VERSION_MINOR "${_wx_version_h}" )
+ string(REGEX REPLACE "^(.*\n)?#define +wxRELEASE_NUMBER +([0-9]+).*"
+ "\\2" wxWidgets_VERSION_PATCH "${_wx_version_h}" )
+ set(wxWidgets_VERSION_STRING
+ "${wxWidgets_VERSION_MAJOR}.${wxWidgets_VERSION_MINOR}.${wxWidgets_VERSION_PATCH}" )
+ dbg_msg("wxWidgets_VERSION_STRING: ${wxWidgets_VERSION_STRING}")
+endif()
+
# Debug output:
DBG_MSG("wxWidgets_FOUND : ${wxWidgets_FOUND}")
DBG_MSG("wxWidgets_INCLUDE_DIRS : ${wxWidgets_INCLUDE_DIRS}")
@@ -828,10 +947,13 @@ DBG_MSG("wxWidgets_USE_FILE : ${wxWidgets_USE_FILE}")
#=====================================================================
#=====================================================================
+
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(wxWidgets DEFAULT_MSG wxWidgets_FOUND)
-# Maintain consistency with all other variables.
-set(wxWidgets_FOUND ${WXWIDGETS_FOUND})
+
+find_package_handle_standard_args(wxWidgets
+ REQUIRED_VARS wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS
+ VERSION_VAR wxWidgets_VERSION_STRING
+ )
#=====================================================================
# Macros for use in wxWidgets apps.