From e8b77084dfaaa211913acaec871e8f9fc0cedd88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mr=C3=A1zek?= Date: Fri, 14 Apr 2017 01:15:03 +0200 Subject: FindwxWidgets: Verify existence of libraries reported by wx-config When the Ubuntu package `libwxgtk3-dev` is not installed, FindwxWidgets succeeds even the required libraries are not actually found. The reason for that is that `wx-config` does not perform any kind of check and uses hard-coded values. This affects e.g. KiCAD build process and makes it fail with a confusing error message [1]. The solution is to check for presence of every library file obtained from `wx-config`. [1] https://bugs.launchpad.net/kicad/+bug/1630020 --- Modules/FindwxWidgets.cmake | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index bc906e5..af4daf0 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -893,6 +893,28 @@ else() endif() endif() +# Check that all libraries are present, as wx-config does not check it +set(_wx_lib_missing "") +foreach(_wx_lib_ ${wxWidgets_LIBRARIES}) + if("${_wx_lib_}" MATCHES "^-l(.*)") + set(_wx_lib_name "${CMAKE_MATCH_1}") + unset(_wx_lib_found CACHE) + find_library(_wx_lib_found NAMES ${_wx_lib_name} HINTS ${wxWidgets_LIBRARY_DIRS}) + if(_wx_lib_found STREQUAL _wx_lib_found-NOTFOUND) + list(APPEND _wx_lib_missing ${_wx_lib_name}) + endif() + unset(_wx_lib_found CACHE) + endif() +endforeach() + +if (_wx_lib_missing) + string(REPLACE ";" " " _wx_lib_missing "${_wx_lib_missing}") + DBG_MSG_V("wxWidgets not found due to following missing libraries: ${_wx_lib_missing}") + set(wxWidgets_FOUND FALSE) + unset(wxWidgets_LIBRARIES) +endif() +unset(_wx_lib_missing) + # Check if a specfic version was requested by find_package(). if(wxWidgets_FOUND) find_file(_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH) -- cgit v0.12