Cmake findPackage OpenGL fails with mesa installed

Hey there,

I hope this is the right place for my question. This is about using the findPackage expression of cmake. I have to work on a Project which is using cmake. This CPP Project depends on glut and opengl:

find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)

To satisfy theese dependencys Im working inside a nix shell with the following script:

with import <nixpkgs> {};
pkgs.stdenv.mkDerivation rec {
  name = "dev-env";
  buildInputs = with pkgs; [
    mesa
    freeglut
    cmake
  ];
  LD_LIBRARY_PATH = with pkgs; "${freeglut}/lib";
}

Glut does not seem to cause a lot of trouble, but OpenGL wont be detected if I am getting this right.

CMake Error at /nix/store/iza9ycb82dp9g7b27zprb7xmpnqpyp9y-cmake-3.16.3/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY
  OPENGL_INCLUDE_DIR)
Call Stack (most recent call first):
  /nix/store/iza9ycb82dp9g7b27zprb7xmpnqpyp9y-cmake-3.16.3/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /nix/store/iza9ycb82dp9g7b27zprb7xmpnqpyp9y-cmake-3.16.3/share/cmake-3.16/Modules/FindOpenGL.cmake:397 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:6 (find_package)

Thanks in advance for your help!

2 Likes