Skip to content

Instantly share code, notes, and snippets.

@Osse
Created December 30, 2024 10:21
Show Gist options
  • Save Osse/d40fc9cbc7072a9e4d502e9fa21ca72c to your computer and use it in GitHub Desktop.
Save Osse/d40fc9cbc7072a9e4d502e9fa21ca72c to your computer and use it in GitHub Desktop.
compile_commands.json
build
.cache
out
cmake_minimum_required(VERSION 3.28)
project(mylib)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
set(CMAKE_CXX_STANDARD 20)
add_library(mylib mylib.cpp)
target_include_directories(mylib PUBLIC "${CMAKE_CURRENT_LIST_DIR}/include")
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 22
},
"configurePresets": [
{
"hidden": true,
"name": "base",
"generator": "Ninja",
"binaryDir": "build/${presetName}"
},
{
"name": "Debug",
"inherits": "base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "Release",
"inherits": "base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
]
}
#include <iostream>
#include "mylib.h"
int main(int argc, char *argv[])
{
Thing t(5);
t.output(std::string_view("lol"));
return 0;
}
#include "include/mylib.h"
std::string_view Thing::prefix() const
{
return std::string_view("hello: ");
}
#include <iostream>
#include <string_view>
struct Thing {
public:
Thing(int i) : i(i) {}
template<typename T>
void output(T t) const {
std::cout << prefix() << t << '\n';
}
private:
std::string_view prefix() const;
int i;
};
#!/bin/bash
while true; do
rm -rf ~/.cache/cmake_tools_nvim/homeossedevdep* build
nvim main/main.cpp || break
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment