Compare commits

...

3 Commits

Author SHA1 Message Date
37a4a0c30b
chore: setup Singleton project 2024-03-14 09:37:08 +01:00
fa1221c69e
chore: add cmake modules 2024-03-14 09:33:23 +01:00
49c3a5b3b8
chore: add nix flake 2024-03-14 09:32:25 +01:00
9 changed files with 145 additions and 0 deletions

9
.envrc Normal file
View File

@ -0,0 +1,9 @@
use flake .nix
dotenv_if_exists
if on_git_branch; then
echo
git status --short --branch
echo
git fetch
fi

61
.nix/flake.lock Normal file
View File

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1710222005,
"narHash": "sha256-irXySffHz7b82dZIme6peyAu+8tTJr1zyxcfUPhqUrg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9a9a7552431c4f1a3b2eee9398641babf7c30d0e",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

24
.nix/flake.nix Normal file
View File

@ -0,0 +1,24 @@
{
description = "A basic flake with a shell";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShell = pkgs.mkShell {
nativeBuildInputs = [ pkgs.bashInteractive ];
buildInputs = with pkgs; [
# building
gcc
cmake
ninja
sccache
];
};
}
);
}

21
Singleton/CMakeLists.txt Normal file
View File

@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.20)
project(
Singleton
VERSION 0.1.0
LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../cmake")
include(ExportCompileCommands)
include(sccache)
add_executable(Singleton main.cpp)
target_compile_features(Singleton PUBLIC cxx_std_20)
set_target_properties(
Singleton
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")

4
Singleton/bootstrap.sh Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
cmake -S . -B .build -G Ninja -D CMAKE_EXPORT_COMPILE_COMMANDS=ON
ln -s .build/compile_commands.json

3
Singleton/build.sh Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env sh
cmake --build .build

9
Singleton/main.cpp Normal file
View File

@ -0,0 +1,9 @@
#include <cstdlib>
#include <iostream>
int main(int argc, char *argv[]) {
std::cout << "Singleton" << std::endl;
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,8 @@
set(CMAKE_EXPORT_COMPILE_COMMANDS
ON
CACHE BOOL "Export compile commands database")
if(CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
endif()

6
cmake/sccache.cmake Normal file
View File

@ -0,0 +1,6 @@
find_program(SCCACHE_FOUND sccache)
if(SCCACHE_FOUND)
set(CMAKE_C_COMPILER_LAUNCHER sccache)
set(CMAKE_CXX_COMPILER_LAUNCHER sccache)
endif()