CLion "Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)" when building an application

When I use the nix-shell (with cmake, etc.) for building https://github.com/pbek/QOwnNotes, I’ve no issues using “cmake && make” in the terminal.

When I use Clion in the nix-shell, I get a cmake error:

CMake Error at /nix/store/9d67jcm1wj09wqgffh8v5mkgil9psnrw-cmake-3.25.3/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)
Call Stack (most recent call first):
  /nix/store/9d67jcm1wj09wqgffh8v5mkgil9psnrw-cmake-3.25.3/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /nix/store/9d67jcm1wj09wqgffh8v5mkgil9psnrw-cmake-3.25.3/share/cmake-3.25/Modules/FindX11.cmake:481 (find_package_handle_standard_args)
  src/libraries/qhotkey/CMakeLists.txt:39 (find_package)

I’ve no issues using cmake in the nix-shell in the terminal.

Any ideas why the IDE doesn’t seem to find the paths?

I already have all kind of stuff in my shell.nix for that project:

{ pkgs ? import <nixpkgs> {} }:
  pkgs.mkShell {
    # nativeBuildInputs is usually what you want -- tools you need to run
    nativeBuildInputs = [
      pkgs.qt5.qtbase.dev
      pkgs.qt5.qmake
      pkgs.qt5.qtx11extras
      pkgs.qt5.qtwebsockets
      pkgs.qt5.qtdeclarative
      pkgs.qt5.qtsvg
      pkgs.xorg.libX11
      pkgs.xorg.libX11.dev
      pkgs.xorg.libxcb.dev
    ];
}

I played around with the build settings and cmake settings. It worked in the end. :sweat_smile:

I’m running into the same error. Could you please share what exactly made it work?

Hm, I can’t even remember what I changed in my build settings.
Currently, I run clion inside this nix-shell: https://github.com/pbek/nixcfg/blob/3efe7e514e7a2bcc9c633427e29660695c843bb0/files/shells/qt5.nix

And this is my CMakeLists.txt: https://github.com/pbek/QOwnNotes/blob/6043c299130a763f58d598a606a267a34387dfd7/src/CMakeLists.txt