1 From ed51e0bb752ecaae29c4ac7a6a89ebfbe5fb4016 Mon Sep 17 00:00:00 2001
2 From: Maarten Bent <MaartenBent@users.noreply.github.com>
3 Date: Wed, 15 Jun 2022 18:23:41 +0200
4 Subject: [PATCH 1/3] FindwxWidgets: Move extracting version number to a macro
7 Modules/FindwxWidgets.cmake | 44 ++++++++++++++++++++-----------------
8 1 file changed, 24 insertions(+), 20 deletions(-)
10 diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake
11 index f7996bacb0..accae50e80 100644
12 --- a/Modules/FindwxWidgets.cmake
13 +++ b/Modules/FindwxWidgets.cmake
14 @@ -215,6 +215,29 @@ else()
15 set(wxWidgets_USE_FILE UsewxWidgets)
18 +macro(wx_extract_version)
20 + find_file(_wx_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH)
21 + dbg_msg("_wx_filename: ${_wx_filename}")
23 + if(NOT _wx_filename)
24 + message(FATAL_ERROR "wxWidgets wx/version.h file not found in ${wxWidgets_INCLUDE_DIRS}.")
27 + file(READ "${_wx_filename}" _wx_version_h)
28 + unset(_wx_filename CACHE)
30 + string(REGEX REPLACE "^(.*\n)?#define +wxMAJOR_VERSION +([0-9]+).*"
31 + "\\2" wxWidgets_VERSION_MAJOR "${_wx_version_h}" )
32 + string(REGEX REPLACE "^(.*\n)?#define +wxMINOR_VERSION +([0-9]+).*"
33 + "\\2" wxWidgets_VERSION_MINOR "${_wx_version_h}" )
34 + string(REGEX REPLACE "^(.*\n)?#define +wxRELEASE_NUMBER +([0-9]+).*"
35 + "\\2" wxWidgets_VERSION_PATCH "${_wx_version_h}" )
36 + set(wxWidgets_VERSION_STRING
37 + "${wxWidgets_VERSION_MAJOR}.${wxWidgets_VERSION_MINOR}.${wxWidgets_VERSION_PATCH}" )
38 + dbg_msg("wxWidgets_VERSION_STRING: ${wxWidgets_VERSION_STRING}")
41 #=====================================================================
42 # Determine whether unix or win32 paths should be used
43 #=====================================================================
44 @@ -981,26 +1004,7 @@ unset(_wx_lib_missing)
46 # Check if a specific version was requested by find_package().
49 - find_file(_wx_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH)
50 - dbg_msg("_wx_filename: ${_wx_filename}")
52 - if(NOT _wx_filename)
53 - message(FATAL_ERROR "wxWidgets wx/version.h file not found in ${wxWidgets_INCLUDE_DIRS}.")
56 - file(READ "${_wx_filename}" _wx_version_h)
57 - unset(_wx_filename CACHE)
59 - string(REGEX REPLACE "^(.*\n)?#define +wxMAJOR_VERSION +([0-9]+).*"
60 - "\\2" wxWidgets_VERSION_MAJOR "${_wx_version_h}" )
61 - string(REGEX REPLACE "^(.*\n)?#define +wxMINOR_VERSION +([0-9]+).*"
62 - "\\2" wxWidgets_VERSION_MINOR "${_wx_version_h}" )
63 - string(REGEX REPLACE "^(.*\n)?#define +wxRELEASE_NUMBER +([0-9]+).*"
64 - "\\2" wxWidgets_VERSION_PATCH "${_wx_version_h}" )
65 - set(wxWidgets_VERSION_STRING
66 - "${wxWidgets_VERSION_MAJOR}.${wxWidgets_VERSION_MINOR}.${wxWidgets_VERSION_PATCH}" )
67 - dbg_msg("wxWidgets_VERSION_STRING: ${wxWidgets_VERSION_STRING}")
68 + wx_extract_version()
76 From 853449429dec94d64bd0c0cfd41d0104416210df Mon Sep 17 00:00:00 2001
77 From: Maarten Bent <MaartenBent@users.noreply.github.com>
78 Date: Wed, 15 Jun 2022 18:26:08 +0200
79 Subject: [PATCH 2/3] FindwxWidgets: Use version number from header for library
83 Modules/FindwxWidgets.cmake | 47 ++++++++++---------------------------
84 1 file changed, 12 insertions(+), 35 deletions(-)
86 diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake
87 index accae50e80..3567a62df0 100644
88 --- a/Modules/FindwxWidgets.cmake
89 +++ b/Modules/FindwxWidgets.cmake
90 @@ -292,10 +292,11 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
92 # Find libraries associated to a configuration.
94 - macro(WX_FIND_LIBS _PF _UNV _UCD _DBG)
95 + macro(WX_FIND_LIBS _PF _UNV _UCD _DBG _VER)
96 DBG_MSG_V("m_unv = ${_UNV}")
97 DBG_MSG_V("m_ucd = ${_UCD}")
98 DBG_MSG_V("m_dbg = ${_DBG}")
99 + DBG_MSG_V("m_ver = ${_VER}")
101 # FIXME: What if both regex libs are available. regex should be
102 # found outside the loop and only wx${LIB}${_UCD}${_DBG}.
103 @@ -313,28 +314,14 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
105 # Find wxWidgets multilib base libraries.
106 find_library(WX_base${_DBG}
108 - wxbase31${_UCD}${_DBG}
109 - wxbase30${_UCD}${_DBG}
110 - wxbase29${_UCD}${_DBG}
111 - wxbase28${_UCD}${_DBG}
112 - wxbase27${_UCD}${_DBG}
113 - wxbase26${_UCD}${_DBG}
114 - wxbase25${_UCD}${_DBG}
115 + NAMES wxbase${_VER}${_UCD}${_DBG}
119 mark_as_advanced(WX_base${_DBG})
120 foreach(LIB net odbc xml)
121 find_library(WX_${LIB}${_DBG}
123 - wxbase31${_UCD}${_DBG}_${LIB}
124 - wxbase30${_UCD}${_DBG}_${LIB}
125 - wxbase29${_UCD}${_DBG}_${LIB}
126 - wxbase28${_UCD}${_DBG}_${LIB}
127 - wxbase27${_UCD}${_DBG}_${LIB}
128 - wxbase26${_UCD}${_DBG}_${LIB}
129 - wxbase25${_UCD}${_DBG}_${LIB}
130 + NAMES wxbase${_VER}${_UCD}${_DBG}_${LIB}
134 @@ -343,14 +330,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
136 # Find wxWidgets monolithic library.
137 find_library(WX_mono${_DBG}
139 - wx${_PF}${_UNV}31${_UCD}${_DBG}
140 - wx${_PF}${_UNV}30${_UCD}${_DBG}
141 - wx${_PF}${_UNV}29${_UCD}${_DBG}
142 - wx${_PF}${_UNV}28${_UCD}${_DBG}
143 - wx${_PF}${_UNV}27${_UCD}${_DBG}
144 - wx${_PF}${_UNV}26${_UCD}${_DBG}
145 - wx${_PF}${_UNV}25${_UCD}${_DBG}
146 + NAMES wx${_PF}${_UNV}${_VER}${_UCD}${_DBG}
150 @@ -360,14 +340,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
151 foreach(LIB core adv aui html media xrc dbgrid gl qa richtext
152 stc ribbon propgrid webview)
153 find_library(WX_${LIB}${_DBG}
155 - wx${_PF}${_UNV}31${_UCD}${_DBG}_${LIB}
156 - wx${_PF}${_UNV}30${_UCD}${_DBG}_${LIB}
157 - wx${_PF}${_UNV}29${_UCD}${_DBG}_${LIB}
158 - wx${_PF}${_UNV}28${_UCD}${_DBG}_${LIB}
159 - wx${_PF}${_UNV}27${_UCD}${_DBG}_${LIB}
160 - wx${_PF}${_UNV}26${_UCD}${_DBG}_${LIB}
161 - wx${_PF}${_UNV}25${_UCD}${_DBG}_${LIB}
162 + NAMES wx${_PF}${_UNV}${_VER}${_UCD}${_DBG}_${LIB}
166 @@ -678,10 +651,14 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
167 set(wxWidgets_FOUND FALSE)
170 + # Get version number.
171 + wx_extract_version()
172 + set(VER "${wxWidgets_VERSION_MAJOR}${wxWidgets_VERSION_MINOR}")
174 # Find wxWidgets libraries.
175 - WX_FIND_LIBS("${PF}" "${UNV}" "${UCD}" "${DBG}")
176 + WX_FIND_LIBS("${PF}" "${UNV}" "${UCD}" "${DBG}" "${VER}")
177 if(WX_USE_REL_AND_DBG)
178 - WX_FIND_LIBS("${PF}" "${UNV}" "${UCD}" "d")
179 + WX_FIND_LIBS("${PF}" "${UNV}" "${UCD}" "d" "${VER}")
182 # Settings for requested libs (i.e., include dir, libraries, etc.).
187 From 2a19231d618482755e9aae981a65680bb1ec1050 Mon Sep 17 00:00:00 2001
188 From: Maarten Bent <MaartenBent@users.noreply.github.com>
189 Date: Wed, 15 Jun 2022 18:28:00 +0200
190 Subject: [PATCH 3/3] FindwxWidgets: Support more wxWidgets versions, including
193 Update the example to use a more recent wxWidgets version.
195 Use a list with known version numbers when searching for installation directories and wx-config names.
197 Modules/FindwxWidgets.cmake | 58 ++++++++++++-------------------------
198 1 file changed, 18 insertions(+), 40 deletions(-)
200 diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake
201 index 3567a62df0..9e7937e2ea 100644
202 --- a/Modules/FindwxWidgets.cmake
203 +++ b/Modules/FindwxWidgets.cmake
204 @@ -29,9 +29,9 @@ select a configuration):
207 wxWidgets_ROOT_DIR - Base wxWidgets directory
208 - (e.g., C:/wxWidgets-2.6.3).
209 + (e.g., C:/wxWidgets-3.2.0).
210 wxWidgets_LIB_DIR - Path to wxWidgets libraries
211 - (e.g., C:/wxWidgets-2.6.3/lib/vc_lib).
212 + (e.g., C:/wxWidgets-3.2.0/lib/vc_x64_lib).
213 wxWidgets_CONFIGURATION - Configuration to use
214 (e.g., msw, mswd, mswu, mswunivud, etc.)
215 wxWidgets_EXCLUDE_COMMON_LIBRARIES
216 @@ -215,6 +215,9 @@ else()
217 set(wxWidgets_USE_FILE UsewxWidgets)
220 +# Known wxWidgets versions.
221 +set(wx_versions 3.3 3.2 3.1 3.0 2.9 2.8 2.7 2.6 2.5)
223 macro(wx_extract_version)
225 find_file(_wx_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH)
226 @@ -443,6 +446,13 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
227 # WIN32: Start actual work.
228 #-------------------------------------------------------------------
230 + set(wx_paths "wxWidgets")
231 + foreach(version ${wx_versions})
232 + foreach(patch RANGE 15 0 -1)
233 + list(APPEND wx_paths "wxWidgets-${version}.${patch}")
237 # Look for an installation tree.
238 find_path(wxWidgets_ROOT_DIR
239 NAMES include/wx/wx.h
240 @@ -454,41 +464,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
280 DOC "wxWidgets base/installation directory"
283 @@ -773,12 +749,14 @@ else()
284 # Look for wx-config -- this can be set in the environment,
285 # or try versioned and toolchain-versioned variants of the -config
286 # executable as well.
287 + set(wx_config_names "wx-config")
288 + foreach(version ${wx_versions})
289 + list(APPEND wx_config_names "wx-config-${version}" "wxgtk3u-${version}-config" "wxgtk2u-${version}-config")
291 find_program(wxWidgets_CONFIG_EXECUTABLE
295 - wx-config-3.1 wx-config-3.0 wx-config-2.9 wx-config-2.8
296 - wxgtk3u-3.1-config wxgtk3u-3.0-config wxgtk2u-2.8-config
298 DOC "Location of wxWidgets library configuration provider binary (wx-config)."
299 ONLY_CMAKE_FIND_ROOT_PATH