find_package unable to find X11 on Ubuntu 20.04
I am using a recent version of CMake on Ubuntu 20.04, and it is unable to locate X11:
find_package(X11 REQUIRED)
fails with:
CMake Error at ~/tools/cmake-v3.20.0-rc4/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find X11 (missing: X11_X11_LIB)
Call Stack (most recent call first):
~/tools/cmake-v3.20.0-rc4/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
~/tools/cmake-v3.20.0-rc4/share/cmake-3.20/Modules/FindX11.cmake:457 (find_package_handle_standard_args)
...:126 (find_package)
I'm almost certain that I have all of the relevant X11 packages installed; I did various web searches and I installed all of the packages that they recommended, including libx11-dev, and various others. Also, I have a desktop installed on each of the distros that I tried on, which I believe pulls in most of the X11 stuff anyway. My X11 binaries are located here:
$ cd /usr/lib/x86_64-linux-gnu
$ fd x11
X11
X11/rstart/commands/x11
X11/rstart/commands/x11r6
X11/rstart/contexts/x11
X11/rstart/contexts/x11r6
caca/libx11_plugin.so
caca/libx11_plugin.so.0
caca/libx11_plugin.so.0.0.0
cmake/Qt5Gui/Qt5Gui_QEglFSX11IntegrationPlugin.cmake
girepository-1.0/GdkX11-3.0.typelib
libX11-xcb.a
libX11-xcb.so
libX11-xcb.so.1
libX11-xcb.so.1.0.0
libX11.a
libX11.so
libX11.so.6
libX11.so.6.3.0
libgdk-x11-2.0.so.0
libgdk-x11-2.0.so.0.2400.32
libgtk-x11-2.0.so.0
libgtk-x11-2.0.so.0.2400.32
libxkbcommon-x11.so.0
libxkbcommon-x11.so.0.0.0
mutter-6/ClutterX11-6.typelib
pkgconfig/x11-xcb.pc
pkgconfig/x11.pc
qt5/mkspecs/features/unix/x11.prf
qt5/mkspecs/features/unix/x11inc.prf
qt5/mkspecs/features/unix/x11lib.prf
qt5/mkspecs/features/unix/x11sm.prf
qt5/mkspecs/unsupported/qnx-X11-g++
qt5/plugins/egldeviceintegrations/libqeglfs-x11-integration.so
I also tried specifying HINTS
in the find_package
command to direct it to the various paths above, but when I do that it complains that it cannot find an X11Config.cmake or x11-config.cmake
file. Any idea what is wrong here? I tried with the CMake version on my system, which is version 3.16.3, and also tried with a more recent version that I built:
cmake --version
cmake version 3.20.0-rc4
but same error both ways.