nix: set CMake version to 3.30.4

This commit is contained in:
Matias 2024-10-11 16:22:11 +01:00
parent a42efe2c82
commit 1b49477c4e
No known key found for this signature in database
GPG key ID: ED35A6AC65A06B69
6 changed files with 36 additions and 15 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
out/

View file

@ -1,11 +1,17 @@
cmake_minimum_required(VERSION 3.28) cmake_minimum_required(VERSION 3.28)
project(ModulesHelloWorld CXX)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library(lib) # enable modules support
target_sources(lib PUBLIC FILE_SET CXX_MODULES FILES lib.cxx) set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "0e5b6991-d74f-4b3d-a41c-cf096e0b2508")
add_executable(hellomodules main.cxx) project(gooey LANGUAGES CXX)
target_link_libraries(hellomodules lib)
set(CMAKE_CXX_MODULE_STD ON)
add_subdirectory(game)
add_executable(gooey src/main.cxx)
target_link_libraries(gooey game)

View file

@ -11,7 +11,8 @@
}: }:
flake-utils.lib.eachDefaultSystem (system: let flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs.llvmPackages_19) stdenv; stdenv = pkgs.llvmPackages_19.libcxxStdenv;
cmake-version = "3.30.4";
gooey = stdenv.mkDerivation { gooey = stdenv.mkDerivation {
pname = "gooey"; pname = "gooey";
@ -19,10 +20,18 @@
# inherit system; # inherit system;
src = ./.; src = ./.;
buildInputs = [ nativeBuildInputs = [
pkgs.cmake (pkgs.cmake.overrideAttrs {
version = "3.30.4";
src = pkgs.fetchurl {
url = "https://cmake.org/files/v${pkgs.lib.versions.majorMinor cmake-version}/cmake-${cmake-version}.tar.gz";
hash = "sha256-x1nJcnTx56qq/LHw0mH53pvzpdbst+LfYWMkpG/nBLI=";
};
})
pkgs.ninja pkgs.ninja
];
buildInputs = [
(pkgs.callPackage ./nix/SDL3.nix {}) (pkgs.callPackage ./nix/SDL3.nix {})
pkgs.llvmPackages_19.clang-tools pkgs.llvmPackages_19.clang-tools
]; ];
@ -42,7 +51,7 @@
}; };
in { in {
packages.default = gooey; packages.default = gooey;
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell.override {inherit stdenv;} {
name = "gooey"; name = "gooey";
inputsFrom = [gooey]; inputsFrom = [gooey];
CMAKE_GENERATOR = "Ninja"; CMAKE_GENERATOR = "Ninja";

4
game/CMakeLists.txt Normal file
View file

@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.28)
add_library(game)
target_sources(game PUBLIC FILE_SET CXX_MODULES FILES src/game.cxx)

View file

@ -1,8 +1,9 @@
// Global module fragment, where #includes can happen // Global module fragment, where #includes can happen
module; module;
#include <iostream>
export module lib; import std;
export module game;
export class lib export class lib
{ {
@ -17,5 +18,5 @@ lib::~lib() = default;
void lib::helloworld() void lib::helloworld()
{ {
std::cout << "Hello world!" << std::endl; std::print("Hello world!\n");
} }

View file

@ -1,4 +1,4 @@
import lib; import game;
int main() int main()
{ {