Skip to content

Commit

Permalink
[wxwidgets] Update to 3.2 (microsoft#25943)
Browse files Browse the repository at this point in the history
* Update wxwidgets to 3.2.0

* Update portfile

* Update wrapper for win32

* [cmake-user] Test wxwidgets on mingw

* Fixup cmake config

* Updated nanosvg patch

* Handle search path for gtk3 link libs

* Update versions

* Remove obsolete option

* Cleanup pkg-config setup

* Update versions

Co-authored-by: Tal Regev <[email protected]>
  • Loading branch information
dg0yt and talregev authored Jul 27, 2022
1 parent 12a0050 commit e59f740
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 33 deletions.
5 changes: 5 additions & 0 deletions ports/wxwidgets/example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ target_compile_definitions(main PRIVATE ${wxWidgets_DEFINITIONS} "$<$<CONFIG:DEB
target_include_directories(main PRIVATE ${wxWidgets_INCLUDE_DIRS})
target_link_libraries(main PRIVATE ${wxWidgets_LIBRARIES})

add_executable(main2 WIN32 popup.cpp)

find_package(wxWidgets CONFIG REQUIRED)
target_link_libraries(main2 PRIVATE wx::core wx::base)

option(USE_WXRC "Use the wxrc resource compiler" ON)
if(USE_WXRC)
execute_process(
Expand Down
12 changes: 12 additions & 0 deletions ports/wxwidgets/gtk3-link-libraries.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/build/cmake/modules/FindGTK3.cmake b/build/cmake/modules/FindGTK3.cmake
index d2939a1..daf33fe 100644
--- a/build/cmake/modules/FindGTK3.cmake
+++ b/build/cmake/modules/FindGTK3.cmake
@@ -47,6 +47,7 @@ include(CheckSymbolExists)
set(CMAKE_REQUIRED_INCLUDES ${GTK3_INCLUDE_DIRS})
check_symbol_exists(GDK_WINDOWING_WAYLAND "gdk/gdk.h" wxHAVE_GDK_WAYLAND)
check_symbol_exists(GDK_WINDOWING_X11 "gdk/gdk.h" wxHAVE_GDK_X11)
+set(GTK3_LIBRARIES "${GTK3_LINK_LIBRARIES}" CACHE INTERNAL "")
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3 DEFAULT_MSG GTK3_INCLUDE_DIRS GTK3_LIBRARIES VERSION_OK)

2 changes: 1 addition & 1 deletion ports/wxwidgets/install-layout.patch
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ index d6b3465..870897b 100644
@@ -38,7 +38,7 @@ if(wxUSE_XRC)
endif()

install(CODE "execute_process( \
wx_install(CODE "execute_process( \
- COMMAND ${CMAKE_COMMAND} -E create_symlink \
+ COMMAND ${CMAKE_COMMAND} -E copy \
${CMAKE_INSTALL_PREFIX}/bin/${wxrc_output_name}${EXE_SUFFIX} \
Expand Down
13 changes: 13 additions & 0 deletions ports/wxwidgets/nanosvg-ext-depend.patch
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,16 @@ index 49c536a..5630526 100644

wx_option(wxUSE_LIBLZMA "use LZMA compression" OFF)
set(wxTHIRD_PARTY_LIBRARIES ${wxTHIRD_PARTY_LIBRARIES} wxUSE_LIBLZMA "use liblzma for LZMA compression")
diff --git a/build/cmake/wxWidgetsConfig.cmake.in b/build/cmake/wxWidgetsConfig.cmake.in
index 6ef5a6e..248a701 100644
--- a/build/cmake/wxWidgetsConfig.cmake.in
+++ b/build/cmake/wxWidgetsConfig.cmake.in
@@ -1,5 +1,8 @@
@PACKAGE_INIT@

+include(CMakeFindDependencyMacro)
+find_dependency(unofficial-nanosvg CONFIG)
+
# determine target from compiler, platform and library type
if(WIN32 AND NOT CYGWIN AND NOT MSYS)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
27 changes: 13 additions & 14 deletions ports/wxwidgets/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO wxWidgets/wxWidgets
REF v3.1.7
SHA512 d6c9613b82a7e697b60217ba8fe9be4406ce7fad1f8d2d16cbf94c9aa9b5a38f1f3e175cb7a80dac8a57196dd6aa2fc3db83b4099a4257bb1a79707002db4af2
REF v3.2.0
SHA512 0bb40ccab51f5e83a38feeaf462c9d1852f821d19592328327f829890d89a3abb2a991c43cdbac55da8f5ee40aab8bd5fea6abcd052198302770292f92f9f9ad
HEAD_REF master
PATCHES
install-layout.patch
relocatable-wx-config.patch
nanosvg-ext-depend.patch
fix-libs-export.patch
fix-pcre2.patch
gtk3-link-libraries.patch
)

if(VCPKG_TARGET_IS_LINUX)
Expand All @@ -36,18 +37,12 @@ vcpkg_check_features(
sound wxUSE_SOUND
)

vcpkg_find_acquire_program(PKGCONFIG)

set(OPTIONS_RELEASE "")
if(NOT "debug-support" IN_LIST FEATURES)
list(APPEND OPTIONS_RELEASE "-DwxBUILD_DEBUG_LEVEL=0")
endif()

set(OPTIONS "")
if(VCPKG_TARGET_IS_OSX)
list(APPEND OPTIONS -DCOTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES=9999)
endif()

if(VCPKG_TARGET_IS_WINDOWS AND (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm"))
list(APPEND OPTIONS
-DwxUSE_OPENGL=OFF
Expand All @@ -61,17 +56,20 @@ else()
list(APPEND OPTIONS -DwxUSE_WEBREQUEST_CURL=ON)
endif()

# wxWidgets on Linux currently needs to find the system's `gtk+-3.0.pc`.
# vcpkg's port pkgconf would prevent this lookup.
if(VCPKG_TARGET_IS_LINUX AND NOT VCPKG_CROSSCOMPILING AND NOT DEFINED ENV{PKG_CONFIG})
if(DEFINED ENV{PKG_CONFIG})
set(PKGCONFIG "$ENV{PKG_CONFIG}")
elseif(VCPKG_TARGET_IS_LINUX AND NOT VCPKG_CROSSCOMPILING)
# wxWidgets on Linux currently needs to find the system's `gtk+-3.0.pc`.
# vcpkg's port pkgconf would prevent this lookup.
find_program(system_pkg_config NAMES pkg-config)
if(system_pkg_config)
set(ENV{PKG_CONFIG} "${system_pkg_config}")
set(PKGCONFIG "${system_pkg_config}")
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
list(APPEND OPTIONS -DPKG_CONFIG_ARGN=--static)
endif()
endif()
vcpkg_find_acquire_program(PKGCONFIG)

# This may be set to ON by users in a custom triplet.
# The use of 'wxUSE_STL' and 'WXWIDGETS_USE_STD_CONTAINERS' (ON or OFF) are not API compatible
Expand Down Expand Up @@ -108,6 +106,7 @@ vcpkg_cmake_configure(
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/wxWidgets)

# The CMake export is not ready for use: It lacks a config file.
file(REMOVE_RECURSE
Expand All @@ -117,7 +116,7 @@ file(REMOVE_RECURSE

set(tools wxrc)
if(NOT VCPKG_TARGET_IS_WINDOWS OR NOT VCPKG_HOST_IS_WINDOWS)
list(APPEND tools wxrc-3.1)
list(APPEND tools wxrc-3.2)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
file(RENAME "${CURRENT_PACKAGES_DIR}/bin/wx-config" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/wx-config")
if(NOT VCPKG_BUILD_TYPE)
Expand Down Expand Up @@ -191,7 +190,7 @@ if(NOT "debug-support" IN_LIST FEATURES)
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_HOST_IS_WINDOWS)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/wx/debug.h" "#define wxDEBUG_LEVEL 1" "#define wxDEBUG_LEVEL 0")
else()
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/wx-3.1/wx/debug.h" "#define wxDEBUG_LEVEL 1" "#define wxDEBUG_LEVEL 0")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/wx-3.2/wx/debug.h" "#define wxDEBUG_LEVEL 1" "#define wxDEBUG_LEVEL 0")
endif()
endif()

Expand Down
8 changes: 3 additions & 5 deletions ports/wxwidgets/usage
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
The package wxwidgets provides CMake integration:
The package wxwidgets provides CMake targets:

find_package(wxWidgets REQUIRED)
target_compile_definitions(main PRIVATE ${wxWidgets_DEFINITIONS} "$<$<CONFIG:DEBUG>:${wxWidgets_DEFINITIONS_DEBUG}>")
target_include_directories(main PRIVATE ${wxWidgets_INCLUDE_DIRS})
target_link_libraries(main PRIVATE ${wxWidgets_LIBRARIES})
find_package(wxWidgets CONFIG REQUIRED)
target_link_libraries(main PRIVATE wx::core wx::base)
28 changes: 18 additions & 10 deletions ports/wxwidgets/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,26 @@ set(WX_ROOT_DIR "${_vcpkg_wx_root}" CACHE INTERNAL "")
unset(_vcpkg_wx_root)

if(WIN32 AND CMAKE_HOST_WIN32)
# FindwxWidgets.cmake win32 mode, multi-config
# Find all libs with "32" infix which is unknown to FindwxWidgets.cmake
function(z_vcpkg_wxwidgets_find_base_library BASENAME)
find_library(WX_${BASENAME}d wx${BASENAME}32ud NAMES wx${BASENAME}d PATHS "${wxWidgets_ROOT_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(WX_${BASENAME} wx${BASENAME}32u NAMES wx${BASENAME} PATHS "${wxWidgets_ROOT_DIR}/lib" NO_DEFAULT_PATH REQUIRED)
endfunction()
function(z_vcpkg_wxwidgets_find_suffix_library BASENAME)
foreach(lib IN LISTS ARGN)
find_library(WX_${lib}d NAMES wx${BASENAME}32ud_${lib} PATHS "${wxWidgets_ROOT_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(WX_${lib} NAMES wx${BASENAME}32u_${lib} PATHS "${wxWidgets_ROOT_DIR}/lib" NO_DEFAULT_PATH)
endforeach()
endfunction()
z_vcpkg_wxwidgets_find_base_library(base)
z_vcpkg_wxwidgets_find_suffix_library(base net odbc xml)
z_vcpkg_wxwidgets_find_suffix_library(msw core adv aui html media xrc dbgrid gl qa richtext stc ribbon propgrid webview)
if(WX_stc AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
z_vcpkg_wxwidgets_find_base_library(scintilla)
endif()
# Force FindwxWidgets.cmake win32 mode for all windows targets built on windows
set(_vcpkg_wxwidgets_backup_crosscompiling "${CMAKE_CROSSCOMPILING}")
set(CMAKE_CROSSCOMPILING 0)
# Get cache variables for debug libs
set(wxWidgets_LIB_DIR "${wxWidgets_ROOT_DIR}/debug/lib" CACHE INTERNAL "")
set(WX_LIB_DIR "${wxWidgets_LIB_DIR}" CACHE INTERNAL "")
_find_package(${ARGS})
# Reset for regular lookup
unset(wxWidgets_CONFIGURATION CACHE)
unset(wxWidgets_USE_REL_AND_DBG CACHE)
set(WX_CONFIGURATION_LIST "")
set(wxWidgets_LIB_DIR "${wxWidgets_ROOT_DIR}/lib" CACHE INTERNAL "")
else()
# FindwxWidgets.cmake unix mode, single-config
Expand Down Expand Up @@ -51,7 +59,7 @@ if(DEFINED _vcpkg_wxwidgets_backup_crosscompiling)
unset(_vcpkg_wxwidgets_backup_crosscompiling)
endif()

if(WIN32 AND CMAKE_HOST_WIN32 AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
if(WIN32 AND CMAKE_HOST_WIN32 AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static" AND NOT "wx::core" IN_LIST wxWidgets_LIBRARIES)
find_package(EXPAT QUIET)
find_package(JPEG QUIET)
find_package(PNG QUIET)
Expand Down
6 changes: 5 additions & 1 deletion ports/wxwidgets/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wxwidgets",
"version": "3.1.7",
"version": "3.2.0",
"description": [
"Widget toolkit and tools library for creating graphical user interfaces (GUIs) for cross-platform applications. ",
"Set WXWIDGETS_USE_STL in a custom triplet to build with the wxUSE_STL build option.",
Expand All @@ -25,6 +25,10 @@
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
"zlib"
],
"default-features": [
Expand Down
2 changes: 1 addition & 1 deletion scripts/test_ports/cmake-user/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"$package": "wxWidgets",
"name": "wxwidgets",
"default-features": false,
"platform": "!linux & !mingw & !uwp"
"platform": "!linux & !uwp"
},
{
"$package": "ZLIB",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -7673,7 +7673,7 @@
"port-version": 0
},
"wxwidgets": {
"baseline": "3.1.7",
"baseline": "3.2.0",
"port-version": 0
},
"x-plane": {
Expand Down
5 changes: 5 additions & 0 deletions versions/w-/wxwidgets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "204fda7008c12569ddf44a935b32bbe5df87cef4",
"version": "3.2.0",
"port-version": 0
},
{
"git-tree": "2610601e9e585455bc709f29636f79b5ad9382a2",
"version": "3.1.7",
Expand Down

0 comments on commit e59f740

Please sign in to comment.