imgui compilation

This commit is contained in:
Sebastien Bourdeauducq 2023-08-22 23:24:17 +08:00
commit 1c7bb39121
5 changed files with 95 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.o
microsa

35
Makefile Normal file
View File

@ -0,0 +1,35 @@
EXE = microsa
SOURCES = main.cpp
SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
CXXFLAGS += -g -Wall -Wformat -O2
LIBS =
LIBS += -lGL `pkg-config --static --libs glfw3`
CXXFLAGS += `pkg-config --cflags glfw3`
CFLAGS = $(CXXFLAGS)
##---------------------------------------------------------------------
## BUILD RULES
##---------------------------------------------------------------------
%.o:%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
%.o:$(IMGUI_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
%.o:$(IMGUI_DIR)/backends/%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
all: $(EXE)
$(EXE): $(OBJS)
$(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
clean:
rm -f $(EXE) $(OBJS)

27
flake.lock Normal file
View File

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1692525914,
"narHash": "sha256-MUgZ9/9mE/EbEQA6JPdcQHkjoR5fgvaKhpy6UO67uEc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "475d5ae2c4cb87b904545bdb547af05681198fcc",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

25
flake.nix Normal file
View File

@ -0,0 +1,25 @@
{
description = "Micro Optical Spectrum Analyzer";
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-23.05;
outputs = { self, nixpkgs }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
in {
devShell.x86_64-linux = pkgs.mkShell {
name = "microsa-dev-shell";
buildInputs = [
pkgs.gnumake
pkgs.gcc
pkgs.pkg-config
pkgs.wayland
pkgs.glfw-wayland
pkgs.libffi
];
shellHook = ''
export IMGUI_DIR=${pkgs.imgui}/include/imgui
'';
};
};
}

6
main.cpp Normal file
View File

@ -0,0 +1,6 @@
#include <stdio.h>
int main(int, char**) {
printf("hello\n");
return 0;
}