Check required libraries in FindwxWidgets.cmake

Both official one and KiCad one version of FindwxWidgets.cmake do not check if
all the required components are part of the wxWidgets build. This couses trouble
on Ubuntu when user misses libwxgtk3.0-dev package - CMake succeeds, build does
not.

This fix was accepted also to the CMake 3.9 upstream
(https://gitlab.kitware.com/cmake/cmake/merge_requests/704).

Fixes: lp:1630020
* https://bugs.launchpad.net/kicad/+bug/1630020
This commit is contained in:
Jan Mrázek 2017-03-19 20:26:53 +01:00 committed by Wayne Stambaugh
parent 5013ea2e8e
commit ade263f30d
1 changed files with 22 additions and 0 deletions

View File

@ -141,6 +141,7 @@
# #
# Miguel A. Figueroa-Villanueva (miguelf at ieee dot org). # Miguel A. Figueroa-Villanueva (miguelf at ieee dot org).
# Jan Woetzel (jw at mip.informatik.uni-kiel.de). # Jan Woetzel (jw at mip.informatik.uni-kiel.de).
# Jan Mrázek (email at honzamrazek.cz)
# #
# Based on previous works of: # Based on previous works of:
# Jan Woetzel (FindwxWindows.cmake), # Jan Woetzel (FindwxWindows.cmake),
@ -880,6 +881,27 @@ else()
endif() endif()
endif() endif()
# Check that all libraries are present, as wx-config does not check it
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()
# Check if a specfic version was requested by find_package(). # Check if a specfic version was requested by find_package().
if(wxWidgets_FOUND) if(wxWidgets_FOUND)
find_file(_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH) find_file(_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH)