Integrate cmake & reorganize files

This commit is contained in:
Sirzechs Lucifer committed 2024-08-28 17:32:52 +03:30
1 parent 28e436aabf
commit 7ee1bfcecf
28 files changed
+77 -72

No files matched your search

+3 -1
View File
@@ -33,4 +33,6 @@
*.bin
temp
build
build
.idea
/cmake-build-debug/
+34
View File
@@ -0,0 +1,34 @@
cmake_minimum_required(VERSION 3.22)
project(nipovpn)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Set the compilation flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -ggdb")
# Set the preprocessor flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MMD -MP")
# https://cmake.org/cmake/help/latest/module/FindBoost.html
find_package(Boost REQUIRED COMPONENTS system regex)
# /usr/local/lib/cmake/yaml-cpp/yaml-cpp-config.cmake
# declared variables: YAML_CPP_INCLUDE_DIR & YAML_CPP_LIBRARY_DIR
find_package(yaml-cpp REQUIRED)
# https://cmake.org/cmake/help/v3.6/module/FindOpenSSL.html
find_package(OpenSSL REQUIRED)
add_subdirectory(core)
add_subdirectory(server)
add_subdirectory(agent)
#add_custom_target(deb
# COMMAND ${CMAKE_COMMAND} -E echo "Creating Debian package..."
# COMMAND dpkg-deb --build ${DEBIANDIR} ${DEBFILE}
# COMMENT "Building Debian package"
#)
-71
View File
@@ -1,71 +0,0 @@
# Pre-compiler and Compiler flags
CXX_FLAGS := -Wall -Wextra -std=c++20 -ggdb
PRE_FLAGS := -MMD -MP
# Project directory structure
BIN := nipovpn/usr/bin
SRC := src
LIB := lib
INC := include
DEBIANDIR := nipovpn
DEBDIR := files/deb
DEBFILE := $(DEBDIR)/nipovpn.deb
MAINFILE := $(SRC)/main.cpp
# Build directories and output
TARGET := $(BIN)/nipovpn
BUILD := build
# Library search directories and flags
EXT_LIB :=
LDFLAGS := -lyaml-cpp -lssl -lcrypto
LDPATHS := $(addprefix -L,$(LIB) $(EXT_LIB))
# Include directories
INC_DIRS := $(INC) $(shell find $(SRC) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
# Construct build output and dependency filenames
SRCS := $(shell find $(SRC) -name *.cpp)
OBJS := $(subst $(SRC)/,$(BUILD)/,$(addsuffix .o,$(basename $(SRCS))))
DEPS := $(OBJS:.o=.d)
# Build task
build: all
# Main task
all: format $(TARGET)
# Build package
deb: deb
format:
clang-format --style=Google -i src/*
# Task producing target from built files
$(TARGET): $(OBJS)
@echo "Building..."
mkdir -p $(dir $@)
$(CXX) $(OBJS) -o $@ $(LDPATHS) $(LDFLAGS)
# Compile all cpp files
$(BUILD)/%.o: $(SRC)/%.cpp
mkdir -p $(dir $@)
$(CXX) $(CXX_FLAGS) $(PRE_FLAGS) $(INC_FLAGS) -c -o $@ $< $(LDPATHS) $(LDFLAGS)
# Create deb file
.PHONY: deb
deb:
@echo "Creating deb file..."
dpkg-deb --build $(DEBIANDIR)/ $(DEBFILE)
# Clean task
.PHONY: clean
clean:
@echo "Clearing..."
rm -rf $(BUILD)
rm -rf $(BIN)
rm -fr $(DEBFILE)
# Include all dependencies
-include $(DEPS)
View File
Whitespace-only changes.
+40
View File
@@ -0,0 +1,40 @@
set(CORE_TARGET nipovpn_core)
set(CMAKE_CXX_STANDARD 20)
set(CORE_TARGET_HEADERS
src/agenthandler.hpp
src/config.hpp
src/general.hpp
src/http.hpp
src/log.hpp
src/runner.hpp
src/serverhandler.hpp
src/tcpclient.hpp
src/tcpconnection.hpp
src/tcpserver.hpp
)
set(CORE_TARGET_SOURCES
src/agenthandler.cpp
src/config.cpp
src/http.cpp
src/log.cpp
src/runner.cpp
src/serverhandler.cpp
src/tcpclient.cpp
src/tcpconnection.cpp
src/tcpserver.cpp
)
add_executable(${CORE_TARGET} src/main.cpp ${CORE_TARGET_SOURCES})
# Add directories
target_include_directories(${CORE_TARGET} PUBLIC ${Boost_INCLUDE_DIRS})
target_include_directories(${CORE_TARGET} PUBLIC ${YAML_CPP_INCLUDE_DIR})
target_include_directories(${CORE_TARGET} PUBLIC ${OPENSSL_INCLUDE_DIR})
# linking dependencies
target_link_libraries(${CORE_TARGET} ${Boost_LIBRARIES})
target_link_libraries(${CORE_TARGET} ${YAML_CPP_LIBRARIES})
target_link_libraries(${CORE_TARGET} ${OPENSSL_LIBRARIES})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
View File
Whitespace-only changes.