pcbjam/wasm/cmake/FindwxWidgets.cmake

111 lines
4 KiB
CMake
Raw Normal View History

# FindwxWidgets.cmake - WASM build version
# Uses wx-config to find wxWidgets for WASM cross-compilation
if(EMSCRIPTEN AND wxWidgets_CONFIG_EXECUTABLE)
message(STATUS "Finding wxWidgets using wx-config for WASM...")
# Get version
execute_process(
COMMAND "${wxWidgets_CONFIG_EXECUTABLE}" --version
OUTPUT_VARIABLE wxWidgets_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE RET
)
if(NOT RET EQUAL 0)
message(FATAL_ERROR "wx-config --version failed")
endif()
# Parse version
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)" _match "${wxWidgets_VERSION_STRING}")
set(wxWidgets_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(wxWidgets_VERSION_MINOR "${CMAKE_MATCH_2}")
set(wxWidgets_VERSION_PATCH "${CMAKE_MATCH_3}")
# Get include directories
execute_process(
COMMAND "${wxWidgets_CONFIG_EXECUTABLE}" --cxxflags
OUTPUT_VARIABLE wxWidgets_CXX_FLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Extract include directories from cxxflags
string(REGEX MATCHALL "-I[^ ]+" _includes "${wxWidgets_CXX_FLAGS}")
set(wxWidgets_INCLUDE_DIRS "")
foreach(_inc ${_includes})
string(REGEX REPLACE "^-I" "" _dir "${_inc}")
list(APPEND wxWidgets_INCLUDE_DIRS "${_dir}")
endforeach()
# Get libraries
execute_process(
COMMAND "${wxWidgets_CONFIG_EXECUTABLE}" --libs all
OUTPUT_VARIABLE _wx_libs_output
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Parse libraries
set(wxWidgets_LIBRARIES "")
set(wxWidgets_LIBRARY_DIRS "")
# Split into list
string(REPLACE " " ";" _wx_libs_list "${_wx_libs_output}")
foreach(_item ${_wx_libs_list})
if(_item MATCHES "^-L(.+)")
list(APPEND wxWidgets_LIBRARY_DIRS "${CMAKE_MATCH_1}")
elseif(_item MATCHES "^-l(.+)")
list(APPEND wxWidgets_LIBRARIES "${CMAKE_MATCH_1}")
elseif(_item MATCHES "\\.a$")
# Full path to static library
list(APPEND wxWidgets_LIBRARIES "${_item}")
elseif(_item MATCHES "^-s(.+)")
# Emscripten linker flags like -sUSE_LIBPNG=1
list(APPEND wxWidgets_LIBRARIES "${_item}")
elseif(_item MATCHES "^-pthread")
# Pthread flag
list(APPEND wxWidgets_LIBRARIES "-pthread")
endif()
endforeach()
# Get the wxWidgets root directory
get_filename_component(wxWidgets_ROOT_DIR "${wxWidgets_CONFIG_EXECUTABLE}" DIRECTORY)
# Set the wx configuration for port detection
# For WASM, we use our own port implementation
refactor: collapse dual-mode plumbing — the DOM port is the only WASM build The canvas (wxUniversal) mode is gone (wxwidgets submodule); remove every piece of side-by-side plumbing so there is exactly one build and one test flow: - scripts/build-wxuniversal-wasm.sh -> scripts/build-wx-wasm.sh; no --dom/--enable-universal; builds into build-wasm/wxwidgets - build-wasm-test.sh: no DOM_BUILD / apps-dom rsync mirror / PORT=dom; apps build straight into tests/apps (Makefile.wasm PORT conditionals collapsed; wx.js + wx-dom.js always pre-js) - docker/build.sh, build-kicad-target.sh, env.sh: WX_PORT / -dom / -universal suffixes removed; kicad builds to kicad-<app>, outputs to output/; wx.js/wx-dom.js copied from the real source path (/workspace/wxwidgets/build/wasm — the old build-wasm path never existed and silently failed) - setup-kicad-wasm.sh: single target dir; the perl wx-dom.js injection is gone — the 7 checked-in kicad pages now reference wx-dom.js directly - playwright configs serve apps/; fixtures drop the test-results/dom and logs/wxwidgets/dom namespacing; boot.spec asserts wxDomPort unconditionally; pcbnew.spec uses one reference image; appearance.spec assertions unconditional - compare/update-baseline-screenshots.sh: --port removed - tests/gal-regression/wasm/Makefile: links build-wasm/wxwidgets and carries wx-dom.js as a second pre-js — the gal-webgl suite (30 specs) now actually builds and runs here (it needed host-side boost+glm via scripts/deps; the bundle had been missing, timing the whole spec out) - tests: clickCanvas() dispatches via page.mouse (DOM widgets legitimately cover the canvas; locator actionability refused the click); the comprehensive spec drives wxChoice through its native <select> (browser-owned popup cannot be coordinate-clicked) - docs: README/CLAUDE.md/build.md script names and dirs; features/wx-dom-port README reframed (DOM is THE port), visual-notes bugs 26-28; FindwxWidgets.cmake config label drops 'wasmuniv' - wxwidgets submodule -> 9dbacc9448 (DOM-only port, fork diff shrunk) Gate: full wx e2e suite 292 passed / 1 skipped / 0 failed — first run ever with the gal-webgl specs green (28 scenarios + load + sequential). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 10:18:16 +02:00
set(_wx_selected_config "wasm-unicode-static-3.2" CACHE INTERNAL "")
set(wxWidgets_FIND_STYLE "unix" CACHE INTERNAL "")
# Set KICAD_WX_PORT to "wasm" - kiplatform will need our custom source files
set(KICAD_WX_PORT "wasm" CACHE STRING "wxWidgets port for WASM" FORCE)
# Pre-set PLATFORM_SRCS with our WASM implementation
# This will be used by kiplatform if it doesn't recognize the port
set(KIPLATFORM_WASM_SRCS "${SYSROOT}/../../../wasm/kiplatform/ui.cpp" CACHE PATH "WASM kiplatform sources")
# Get definitions
execute_process(
COMMAND "${wxWidgets_CONFIG_EXECUTABLE}" --cppflags
OUTPUT_VARIABLE _wx_cpp_flags
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REGEX MATCHALL "-D[^ ]+" wxWidgets_DEFINITIONS "${_wx_cpp_flags}")
# Set found
set(wxWidgets_FOUND TRUE)
# Create the use file path
set(wxWidgets_USE_FILE "${CMAKE_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
message(STATUS "Found wxWidgets ${wxWidgets_VERSION_STRING} for WASM")
message(STATUS " Include dirs: ${wxWidgets_INCLUDE_DIRS}")
message(STATUS " Library dirs: ${wxWidgets_LIBRARY_DIRS}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(wxWidgets
REQUIRED_VARS wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS
VERSION_VAR wxWidgets_VERSION_STRING
)
else()
# For non-WASM builds, use the standard FindwxWidgets
include(${CMAKE_ROOT}/Modules/FindwxWidgets.cmake OPTIONAL)
endif()