Hello! I’m new to all this. I have a very simple toy SDL2 app I’m making to learn how to use nix. I’m on NixOS. The project is a flake that uses CMake; I must be doing something abnormal, because when I try to run nix develop && cmake .
, cmake fails with this error, which I haven’t been able to find online:
-- The C compiler identification is GNU 9.5.0
-- The CXX compiler identification is GNU 9.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /nix/store/qa00jx7v8r3z6kaqhc8kg3bybk801pwp-gcc-wrapper-9.5.0/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /nix/store/qa00jx7v8r3z6kaqhc8kg3bybk801pwp-gcc-wrapper-9.5.0/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:6 (find_package):
Found package configuration file:
/nix/store/pl6vn3iqs7icf2czwblf1kmkyqr5xx0i-SDL2-2.28.5-dev/lib/cmake/SDL2/sdl2-config.cmake
but it set SDL2_FOUND to FALSE so package "SDL2" is considered to be NOT
FOUND.
What is happening, and what should I do?
Here is my flake.nix:
{
description = "A simple SDL app, written in C";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
# This is the list of architectures that work with this project
systems = [
"x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"
];
perSystem = { config, self', inputs', pkgs, system, ... }: {
# devShells.default describes the default shell with C++, cmake, boost,
# and catch2
devShells.default = pkgs.mkShell {
packages = with pkgs; [
# C++ Compiler is already part of stdenv
cmake
gcc9
SDL2
SDL2.dev
];
};
};
};
}
Here is my CMakeLists.txt (more or less a carbon copy of the template given by the SDL wiki):
cmake_minimum_required(VERSION 3.20)
project(SDLApp)
find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2)
find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2main)
add_executable(SDLApp main.c)
if(TARGET SDL2::SDL2main)
target_link_libraries(SDLApp PRIVATE SDL2::SDL2main)
endif()
target_link_libraries(SDLApp PRIVATE SDL2::SDL2)
Thanks in advance?