build: set wxWidgets_DIR with vcpkg

When using vcpkg as the toolchain, pass NO_DEFAULT_PATH to
find_package(wxWidgets ...) so that the default cmake
FindwxWidgets.cmake is not included.

Set wxWidgets_DIR to the
<vcpkg-root>/installed/<triplet>/share/wxwidgets vcpkg port directory
for the subsequent find_package() calls to find the port-installed
wxWidgetsConfig.cmake file.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2024-03-27 03:02:33 +00:00
parent 98b51910eb
commit 23e1573442
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
1 changed files with 10 additions and 2 deletions

View File

@ -320,9 +320,17 @@ endif()
if(VBAM_STATIC) if(VBAM_STATIC)
set(wxWidgets_USE_STATIC ON) set(wxWidgets_USE_STATIC ON)
endif() endif()
find_package(wxWidgets COMPONENTS xrc xml html adv net core base gl)
unset(wx_find_extra)
if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
set(wx_find_extra NO_DEFAULT_PATH)
set(wxWidgets_DIR "${VCPKG_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/share/wxwidgets")
endif()
find_package(wxWidgets COMPONENTS xrc xml html adv net core base gl ${wx_find_extra})
if(NOT wxWidgets_FOUND) if(NOT wxWidgets_FOUND)
find_package(wxWidgets COMPONENTS xrc xml html adv net core base REQUIRED) find_package(wxWidgets COMPONENTS xrc xml html adv net core base ${wx_find_extra} REQUIRED)
target_compile_definitions(visualboyadvance-m PRIVATE NO_OGL) target_compile_definitions(visualboyadvance-m PRIVATE NO_OGL)
endif() endif()