CMake could not find wxWidgets on Windows

2019-07-18 11:12发布

问题:

I have the following snippet in my CMakeLists.txt, as described in wxWidgets wiki

set(wxWidgets_ROOT_DIR libs/wxWidgets)
set(wxWidgets_CONFIGURATION mswu)
find_package(wxWidgets REQUIRED
        COMPONENTS core base adv)
include(${wxWidgets_USE_FILE})

libs/wxWidgets is a git submodule. On Ubuntu 16.04, the project builds and works. The submodule description is:

[submodule "libs/wxWidgets"]
    path = libs/wxWidgets
    url = https://github.com/wxWidgets/wxWidgets
    branch = WX_3_0_3_BRANCH

However, having the same code on Windows doesn't work, with error like:

CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
      Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES
  wxWidgets_INCLUDE_DIRS)
Call Stack (most recent call first):
  C:/Program Files (x86)/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files (x86)/CMake/share/cmake-3.9/Modules/FindwxWidgets.cmake:953 (find_package_handle_standard_args)
  CMakeLists.txt:8 (find_package)

Other wxWidgets installation from official site, including zip and Windows Installer are tried, but yeilding the same error.

This question might be related, but it has no acceptable answers.