Switch to cmake and cc-ls

This commit is contained in:
Curt Spark 2025-11-20 01:29:00 +00:00
parent d85e4e2bdc
commit aba50e7300
6 changed files with 45 additions and 26 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
build/
.cache/
a.out
.ccls-cache/

18
CMakeLists.txt Normal file
View File

@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.23)
project(discern)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#string(REPLACE ":" ";" INCLUDE_LIST $ENV{CMAKE_LIBRARY_PATH})
#include_directories(${INCLUDE_LIST})
add_executable(discern)
target_sources(discern
PRIVATE
main.cpp
)

View File

@ -1,20 +0,0 @@
[
{
"arguments": [
"/run/current-system/sw/bin/clang++",
"-std=c++23",
"-resource-dir",
"/nix/store/k2s6xfca52n25yb8b6f58i87kszp3m7g-clang-wrapper-21.1.2/resource-root",
"-idirafter",
"/nix/store/dqgfdpr53ldqmdfmginb1z6kzslkzsdl-glibc-2.40-66-dev/include",
"-isystem",
"/nix/store/68ndh04pl2hhhizsarvzwa9cnlp7zj3d-gcc-14.3.0/include/c++/14.3.0",
"-isystem",
"/nix/store/68ndh04pl2hhhizsarvzwa9cnlp7zj3d-gcc-14.3.0/include/c++/14.3.0/x86_64-unknown-linux-gnu",
"-c",
"main.cpp"
],
"directory": "/home/cspark/Projects/CPP/hello_world",
"file": "/home/cspark/Projects/CPP/hello_world/main.cpp"
}
]

1
compile_commands.json Symbolic link
View File

@ -0,0 +1 @@
build/compile_commands.json

8
default.nix Normal file
View File

@ -0,0 +1,8 @@
with (import <nixpkgs> {});
pkgs.mkShell {
name = "C++ Study Repository";
buildInputs = with pkgs; [
cmake
];
}

View File

@ -1,6 +1,17 @@
#include <iostream>
#include <print>
#include <string>
#include <iostream>
typedef struct foo {
uint8_t test;
int one() {
return 1;
};
} foo;
int main() {
std::println("Hello, world!");
foo ok;
std::cout << std::to_string(ok.one()) << std::endl;
}

6
run.sh
View File

@ -1,7 +1,7 @@
#!/bin/sh
rm a.out
cmake -B build --fresh
clang++ -std=c++23 main.cpp
cmake --build build
./a.out
./build/discern