mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2025-12-06 09:07:21 +01:00
feat: add cpp template
This commit is contained in:
parent
6da0fcbb1b
commit
baeb65234b
10 changed files with 94 additions and 86 deletions
1
templates/cpp/.envrc
Normal file
1
templates/cpp/.envrc
Normal file
|
|
@ -0,0 +1 @@
|
|||
use flake
|
||||
12
templates/cpp/.gitignore
vendored
Normal file
12
templates/cpp/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
CMakeUserPresets.json
|
||||
9
templates/cpp/CMakeLists.txt
Normal file
9
templates/cpp/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
project(name)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
install(TARGETS name DESTINATION bin)
|
||||
62
templates/cpp/flake.nix
Normal file
62
templates/cpp/flake.nix
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
# heavily inspired by https://github.com/nulladmin1/nix-flake-templates/blob/main/cpp-cmake/flake.nix
|
||||
{
|
||||
description = "C++ Flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
systems.url = "github:nix-systems/default";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ self
|
||||
, nixpkgs
|
||||
, systems
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
forEachSystem = nixpkgs.lib.genAttrs (import systems);
|
||||
pkgsFor = forEachSystem (system: import nixpkgs { inherit system; });
|
||||
|
||||
pname = "name";
|
||||
in
|
||||
{
|
||||
formatter = forEachSystem (system: pkgsFor.${system}.nixpgks-fmt);
|
||||
|
||||
devShells = forEachSystem (system: {
|
||||
default = pkgsFor.${system}.mkShell {
|
||||
packages = with pkgsFor.${system}; [
|
||||
libllvm
|
||||
cmake
|
||||
gtest
|
||||
cppcheck
|
||||
valgrind
|
||||
doxygen
|
||||
clang-tools
|
||||
# cudatoolkit
|
||||
];
|
||||
};
|
||||
});
|
||||
|
||||
packages = forEachSystem (system: {
|
||||
default = pkgsFor.${system}.stdenv.mkDerivation {
|
||||
inherit pname;
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = with pkgsFor.${system}; [
|
||||
cmake
|
||||
];
|
||||
buildInputs = with pkgsFor.${system}; [
|
||||
gtest
|
||||
];
|
||||
};
|
||||
});
|
||||
|
||||
apps = forEachSystem (system: {
|
||||
default = {
|
||||
type = "app";
|
||||
program = "${self.packages.${system}.default}/bin/${pname}";
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
1
templates/cpp/src/CMakeLists.txt
Normal file
1
templates/cpp/src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
add_executable(name name.cpp name.cpp)
|
||||
7
templates/cpp/src/name.cpp
Normal file
7
templates/cpp/src/name.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
cout << "Hello, world!" << endl;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue