From 43e16ce94539a622fa6eb5d8e7d1c2b9e17f2312 Mon Sep 17 00:00:00 2001 From: zontreck Date: Tue, 30 Jul 2024 16:33:29 -0700 Subject: [PATCH] Move source files to utils --- .gitignore | 4 +++- CMakeLists.txt | 6 +++--- Makefile | 16 +++++----------- src/CMakeLists.txt | 1 - src/{ => utils}/Progress.cpp | 0 src/{ => utils}/Progress.h | 0 6 files changed, 11 insertions(+), 16 deletions(-) delete mode 100644 src/CMakeLists.txt rename src/{ => utils}/Progress.cpp (100%) rename src/{ => utils}/Progress.h (100%) diff --git a/.gitignore b/.gitignore index c795b05..850ad16 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -build \ No newline at end of file +build +*.o +*.so \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ff1354..5e3e19c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,10 +8,10 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) # Add source files -file(GLOB SOURCES "src/*.cpp") +file(GLOB SOURCES "src/utils/*.cpp" "src/nbt/*.cpp") -# Add an executable target -add_executable(ac ${SOURCES}) +# Add an shared library target +add_library(ac SHARED ${SOURCES}) # Optionally, if you have any additional include directories or libraries, add them here: # target_include_directories(ac PRIVATE ${CMAKE_SOURCE_DIR}/include) diff --git a/Makefile b/Makefile index b9e8d4c..98810c4 100644 --- a/Makefile +++ b/Makefile @@ -3,22 +3,16 @@ CXX = g++ CXXFLAGS = -std=c++17 -Wall -Wextra # Source files and target executable -SRCS = $(wildcard src/*.cpp) -OBJS = $(SRCS:.cpp=.o) -TARGET = ac # Build target -all: $(TARGET) +all: clean build -$(TARGET): $(OBJS) - $(CXX) $(CXXFLAGS) -o $@ $(OBJS) - -# Build object files -%.o: %.cpp - $(CXX) $(CXXFLAGS) -c $< -o $@ +build: + mkdir build + cd build && cmake .. && make && mv libac.so .. # Clean up build artifacts clean: - rm -f $(TARGET) $(OBJS) + rm -rf build .PHONY: all clean diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 9949342..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_library(ac SHARED Progress.cpp Progress.h) \ No newline at end of file diff --git a/src/Progress.cpp b/src/utils/Progress.cpp similarity index 100% rename from src/Progress.cpp rename to src/utils/Progress.cpp diff --git a/src/Progress.h b/src/utils/Progress.h similarity index 100% rename from src/Progress.h rename to src/utils/Progress.h