Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wxwidgets] Use vcpkg gtk3 for linux et al., fix mingw cross builds #27087

Merged
merged 11 commits into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 15 additions & 35 deletions ports/wxwidgets/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,16 @@ vcpkg_from_github(
fix-libs-export.patch
fix-pcre2.patch
gtk3-link-libraries.patch
sdl2.patch
)

if(VCPKG_TARGET_IS_LINUX)
message(WARNING [[
Port wxwidgets currently requires the following packages from the system package manager:
pkg-config
GTK 3
libsecret
libgcrypt
LilyWangLL marked this conversation as resolved.
Show resolved Hide resolved
libsystemd
These development packages can be installed on Ubuntu systems via
sudo apt-get install pkg-config libgtk-3-dev libsecret-1-dev libgcrypt20-dev libsystemd-dev
]])
foreach(conflicting_port IN ITEMS freetype glib)
if(EXISTS "${CURRENT_INSTALLED_DIR}/share/${conflicting_port}/copyright")
message(FATAL_ERROR "Port ${conflicting_port} must not be installed when building ${PORT}:${TARGET_TRIPLET}.")
endif()
endforeach()
endif()

vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
sound wxUSE_SOUND
fonts wxUSE_PRIVATE_FONTS
media wxUSE_MEDIACTRL
sound wxUSE_SOUND
webview wxUSE_WEBVIEW
webview wxUSE_WEBVIEW_EDGE
)

Expand All @@ -58,19 +43,6 @@ else()
list(APPEND OPTIONS -DwxUSE_WEBREQUEST_CURL=ON)
endif()

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(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.
Expand All @@ -95,16 +67,24 @@ vcpkg_cmake_configure(
-DwxUSE_LIBPNG=sys
-DwxUSE_LIBTIFF=sys
-DwxUSE_NANOSVG=sys
-DwxUSE_SECRETSTORE=FALSE
-DwxUSE_LIBGNOMEVFS=OFF
-DwxUSE_LIBNOTIFY=OFF
-DwxUSE_SECRETSTORE=OFF
-DwxUSE_STL=${WXWIDGETS_USE_STL}
-DwxUSE_STD_CONTAINERS=${WXWIDGETS_USE_STD_CONTAINERS}
-DwxUSE_UIACTIONSIMULATOR=OFF
-DCMAKE_DISABLE_FIND_PACKAGE_GSPELL=ON
-DCMAKE_DISABLE_FIND_PACKAGE_MSPACK=ON
${OPTIONS}
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
# The minimum cmake version requirement for Cotire is 2.8.12.
# however, we need to declare that the minimum cmake version requirement is at least 3.1 to use CMAKE_PREFIX_PATH as the path to find .pc.
-DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=ON
OPTIONS_RELEASE
${OPTIONS_RELEASE}
MAYBE_UNUSED_VARIABLES
CMAKE_DISABLE_FIND_PACKAGE_GSPELL
CMAKE_DISABLE_FIND_PACKAGE_MSPACK
)

vcpkg_cmake_install()
Expand All @@ -117,7 +97,7 @@ file(REMOVE_RECURSE
)

set(tools wxrc)
if(NOT VCPKG_TARGET_IS_WINDOWS OR NOT VCPKG_HOST_IS_WINDOWS)
if(NOT VCPKG_TARGET_IS_WINDOWS)
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")
Expand Down Expand Up @@ -189,7 +169,7 @@ if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/mswud/wx/setup.h")
endif()

if(NOT "debug-support" IN_LIST FEATURES)
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_HOST_IS_WINDOWS)
if(VCPKG_TARGET_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.2/wx/debug.h" "#define wxDEBUG_LEVEL 1" "#define wxDEBUG_LEVEL 0")
Expand Down
29 changes: 29 additions & 0 deletions ports/wxwidgets/sdl2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake
index 7bd00d3..d903584 100644
--- a/build/cmake/init.cmake
+++ b/build/cmake/init.cmake
@@ -493,7 +493,9 @@ if(wxUSE_GUI)
endif()

if(wxUSE_SOUND AND wxUSE_LIBSDL AND UNIX AND NOT APPLE)
- find_package(SDL2)
+ find_package(SDL2 CONFIG REQUIRED)
+ set(SDL2_INCLUDE_DIR "" CACHE INTERNAL "")
LilyWangLL marked this conversation as resolved.
Show resolved Hide resolved
+ set(SDL2_LIBRARY SDL2::SDL2 CACHE INTERNAL "")
if(NOT SDL2_FOUND)
find_package(SDL)
endif()
diff --git a/build/cmake/wxWidgetsConfig.cmake.in b/build/cmake/wxWidgetsConfig.cmake.in
index 248a701..f617dc4 100644
--- a/build/cmake/wxWidgetsConfig.cmake.in
+++ b/build/cmake/wxWidgetsConfig.cmake.in
@@ -2,6 +2,9 @@

include(CMakeFindDependencyMacro)
find_dependency(unofficial-nanosvg CONFIG)
+if("@wxUSE_LIBSDL@")
+ find_dependency(SDL2 CONFIG)
+endif()

# determine target from compiler, platform and library type
if(WIN32 AND NOT CYGWIN AND NOT MSYS)
9 changes: 2 additions & 7 deletions ports/wxwidgets/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(wxWidgets_ROOT_DIR "${_vcpkg_wx_root}" CACHE INTERNAL "")
set(WX_ROOT_DIR "${_vcpkg_wx_root}" CACHE INTERNAL "")
unset(_vcpkg_wx_root)

if(WIN32 AND CMAKE_HOST_WIN32)
if(WIN32)
# 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)
Expand All @@ -31,11 +31,6 @@ if(WIN32 AND CMAKE_HOST_WIN32)
set(wxWidgets_LIB_DIR "${wxWidgets_ROOT_DIR}/lib" CACHE INTERNAL "")
else()
# FindwxWidgets.cmake unix mode, single-config
if(MINGW)
# Force FindwxWidgets.cmake unix mode for mingw cross builds
set(_vcpkg_wxwidgets_backup_crosscompiling "${CMAKE_CROSSCOMPILING}")
set(CMAKE_CROSSCOMPILING 1)
endif()
set(_vcpkg_wxconfig "")
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR "Debug" IN_LIST MAP_IMPORTED_CONFIG_${CMAKE_BUILD_TYPE})
# Debug
Expand All @@ -59,7 +54,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" AND NOT "wx::core" IN_LIST wxWidgets_LIBRARIES)
if(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
26 changes: 25 additions & 1 deletion ports/wxwidgets/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "wxwidgets",
"version": "3.2.1",
"port-version": 1,
"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 @@ -10,12 +11,25 @@
"license": "LGPL-2.0-or-later WITH WxWindows-exception-3.1",
"supports": "!uwp",
"dependencies": [
{
"name": "cairo",
"default-features": false,
"platform": "!windows & !osx & !ios"
},
{
"name": "curl",
"default-features": false,
"platform": "!windows & !osx"
},
"expat",
{
"name": "gtk3",
"platform": "!windows & !osx & !ios"
},
{
"name": "libiconv",
"platform": "!windows"
},
"libjpeg-turbo",
"libpng",
"nanosvg",
Expand Down Expand Up @@ -55,13 +69,23 @@
}
]
},
"media": {
"description": "Build wxMediaCtrl support",
"dependencies": [
{
"name": "gstreamer",
"default-features": false,
"platform": "!windows & !osx & !ios"
}
]
},
"sound": {
"description": "Build wxSound support",
"dependencies": [
{
"name": "sdl2",
"default-features": false,
"platform": "!windows & !osx"
"platform": "!windows & !osx & !ios"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,6 @@ wpilib:arm64-windows=fail
wpilib:x64-osx=fail
wincrypt:arm64-windows=skip # https://github.com/microsoft/vcpkg-tool/pull/599
wxchartdir:x64-osx=fail
wxwidgets:x64-linux=fail
x265:arm64-windows=fail
x265:arm-uwp=fail
x265:x64-uwp=fail
Expand Down Expand Up @@ -1303,6 +1302,7 @@ vcpkg-ci-paraview:x64-windows-static=pass
vcpkg-ci-paraview:x64-windows=pass
vcpkg-ci-paraview:x86-windows=pass
vcpkg-ci-wxwidgets:arm64-windows=pass
vcpkg-ci-wxwidgets:x64-linux=pass
vcpkg-ci-wxwidgets:x64-osx=pass
vcpkg-ci-wxwidgets:x64-windows-static-md=pass
vcpkg-ci-wxwidgets:x64-windows-static=pass
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 & !uwp"
"platform": "!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 @@ -7882,7 +7882,7 @@
},
"wxwidgets": {
"baseline": "3.2.1",
"port-version": 0
"port-version": 1
},
"x-plane": {
"baseline": "3.0.3",
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": "3a640144a98d7909a92ba363114f95bcaff554e5",
"version": "3.2.1",
"port-version": 1
},
{
"git-tree": "a113e248e95bf2305a91b4d7c2a93579cc911b15",
"version": "3.2.1",
Expand Down