From d7f95f0fbfda5c7b42c53f8c370a27176de7afd4 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Tue, 15 Nov 2022 16:05:47 +0100 Subject: [PATCH] Configured start of project --- .gitignore | 2 ++ .gitmodules | 3 +++ CMakeLists.txt | 10 ++++++++++ Makefile | 37 +++++++++++++++++++++++++++++++++++++ crow | 1 + src/main.cpp | 12 ++++++++++++ 6 files changed, 65 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 100644 Makefile create mode 160000 crow create mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6654b8d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +compile_commands.json diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..29c223e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "crow"] + path = crow + url = https://github.com/CrowCpp/Crow diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4a2efbe --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.24) +project(lander C CXX) + +set(CMAKE_C_STANDARD 17) + +add_subdirectory(crow) +include_directories(crow/include) + +add_executable(lander src/main.cpp) +target_link_libraries(lander PUBLIC Crow) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..10a9384 --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +# =====CONFIG===== +BUILD_DIR := ./build +SRC_DIR := ./src +TEST_DIR := test +CORES != nproc + +SRCS := $(shell find '$(SRC_DIR)' -iname '*.c') + + +# =====RECIPES===== +all: build + +.PHONY: cmake +cmake: $(BUILD_DIR)/Debug/Makefile +$(BUILD_DIR)/Debug/Makefile: CMakeLists.txt + @ cmake -B'$(BUILD_DIR)/Debug' -DCMAKE_EXPORT_COMPILE_COMMANDS=1 . + @ ln -sf '$(BUILD_DIR)/Debug/compile_commands.json' compile_commands.json + +.PHONY: build +build: cmake + @ make -C '$(BUILD_DIR)/Debug' + +.PHONY: run +run: build + @ ./build/Debug/lander + +.PHONY: clean +clean: + @ rm -rf '$(BUILD_DIR)' compile_commands.json + +.PHONY: lint +lint: + @ clang-format --Werror -n $(SRCS) + +.PHONY: format +format: + @ clang-format -i $(SRCS) diff --git a/crow b/crow new file mode 160000 index 0000000..edf12f6 --- /dev/null +++ b/crow @@ -0,0 +1 @@ +Subproject commit edf12f699ec3bf6f751cf73cb97f32919e48ca6e diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..f343c67 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,12 @@ +#include "crow.h" + +int main() +{ + crow::SimpleApp app; + + CROW_ROUTE(app, "/")([](){ + return "Hello world"; + }); + + app.port(18080).multithreaded().run(); +}