Compare commits
No commits in common. "3e3122bc129f4dfadaabeab3640a1e1141131494" and "d85e4e2bdc0733a31297eed3ded193a8e8f9bc86" have entirely different histories.
3e3122bc12
...
d85e4e2bdc
|
|
@ -1,3 +1,2 @@
|
||||||
build/
|
|
||||||
.cache/
|
.cache/
|
||||||
.ccls-cache/
|
a.out
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 3.23)
|
|
||||||
|
|
||||||
project(template)
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
||||||
|
|
||||||
#string(REPLACE ":" ";" INCLUDE_LIST $ENV{CMAKE_STDLIB})
|
|
||||||
#include_directories($ENV{CMAKE_STDLIB})
|
|
||||||
|
|
||||||
add_executable(template)
|
|
||||||
|
|
||||||
target_sources(template
|
|
||||||
PRIVATE
|
|
||||||
main.cpp
|
|
||||||
)
|
|
||||||
18
README.org
18
README.org
|
|
@ -1,2 +1,16 @@
|
||||||
* Nix C++ Dev Template
|
* NixOS C++ Dev Template
|
||||||
Basic C++ CMake template with Nix
|
Having issues getting clangd to detect std header files despite clang++ and g++ having no issues. So this template/workaround solves this.
|
||||||
|
|
||||||
|
I assume this is due to some wrapper script nonsense.
|
||||||
|
|
||||||
|
As a workaround I use bear to generate the necessary paths/arguments to get clangd to pick these up.
|
||||||
|
|
||||||
|
#+BEGIN_SRC
|
||||||
|
bear -- clang++ main.cpp
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
In the generated compile_commands.json. There is a command for generating the main project but also a temporary object file.
|
||||||
|
|
||||||
|
I assume this is more weird wrapper stuff (Bear does not support nixos clang wrappers)
|
||||||
|
|
||||||
|
You need to move the cxx_isystem related flags as these are where the c++ stdlibs are kept. Also just rename them to isystem otherwise they dont work for whatever reason.
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
build/compile_commands.json
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
14
default.nix
14
default.nix
|
|
@ -1,14 +0,0 @@
|
||||||
with (import <nixpkgs> {});
|
|
||||||
|
|
||||||
clangStdenv.mkDerivation {
|
|
||||||
name = "template";
|
|
||||||
nativeBuildInputs = with pkgs; [
|
|
||||||
cmake
|
|
||||||
|
|
||||||
clang-tools
|
|
||||||
clang
|
|
||||||
];
|
|
||||||
|
|
||||||
# Workaround as Clangd cannot see std header files, so include set of files manually just for Clangd
|
|
||||||
CXXFLAGS = "-isystem${pkgs.gcc.cc}/include/c++/14.3.0 -isystem${pkgs.gcc.cc}/include/c++/14.3.0/x86_64-unknown-linux-gnu -isystem${pkgs.glibc.dev}/include";
|
|
||||||
}
|
|
||||||
4
main.cpp
4
main.cpp
|
|
@ -1,6 +1,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <print>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
std::cout << "Hello, world!" << std::endl;
|
std::println("Hello, world!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue