makefile only
This commit is contained in:
parent
125bd775b8
commit
0de0b2fa60
@ -1,35 +0,0 @@
|
||||
# Minimum CMake version required
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
# Project name, version, and description
|
||||
project(discord-bot VERSION 1.0 DESCRIPTION "A discord bot" LANGUAGES CXX) # Specify CXX language
|
||||
|
||||
# Temporarily removed to rule out interference from custom CMake modules.
|
||||
# If you have custom CMake modules here that you need, we can re-add this later.
|
||||
# list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
# Create an executable
|
||||
add_executable(${PROJECT_NAME}
|
||||
main.cpp
|
||||
)
|
||||
|
||||
# Include directories for your headers and D++ headers
|
||||
# This tells the compiler where to find #include <ImageProcessor.h> and #include <dpp/dpp.h>
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
# Ensure this path is correct if your D++ headers are NOT directly in ${CMAKE_CURRENT_SOURCE_DIR}/include/dpp
|
||||
# If dpp/dpp.h is found in ${CMAKE_CURRENT_SOURCE_DIR}/include/dpp, then the line below is correct.
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
# --- NEW: Direct Linker Injection using Generator Expression ---
|
||||
# This method tells CMake to ONLY pass the full path to the linker,
|
||||
# explicitly preventing it from being treated as a build target.
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
"$<LINK_ONLY:${CMAKE_CURRENT_SOURCE_DIR}/lib/libdpp.so.10.1.4>"
|
||||
)
|
||||
|
||||
# Set C++ version
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
CXX_STANDARD 20
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
)
|
||||
@ -1,7 +0,0 @@
|
||||
find_path(DPP_INCLUDE_DIR NAMES dpp/dpp.h HINTS ${DPP_ROOT_DIR})
|
||||
|
||||
find_library(DPP_LIBRARIES NAMES dpp "libdpp.a" HINTS ${DPP_ROOT_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(DPP DEFAULT_MSG DPP_LIBRARIES DPP_INCLUDE_DIR)
|
||||
92
makefile
Normal file
92
makefile
Normal file
@ -0,0 +1,92 @@
|
||||
|
||||
# Project configuration
|
||||
EXECUTABLE_NAME = discord-bot
|
||||
PLATFORM = $(shell uname)
|
||||
BUILD_TYPE ?= release# Default to release build if not specified
|
||||
|
||||
# Version configuration (can be overridden)
|
||||
DPP_VERSION ?= $(shell find ../DPP/build/library -name "libdpp.so.*.*.*" -type f | head -1 | sed 's/.*libdpp\.so\.//')
|
||||
# Conditional assignment for DPP_PATH based on whether DPP_VERSION was found or is empty
|
||||
# This logic assumes that if DPP_VERSION is found (not empty), it's a custom build (../DPP).
|
||||
# If DPP_VERSION is empty (meaning libdpp.so.*.*.* was not found in the custom build path),
|
||||
# we default to 'lib', assuming a system-wide or standard install location.
|
||||
ifeq ($(strip $(DPP_VERSION)),) # Check if DPP_VERSION is empty (no version found)
|
||||
DPP_PATH = ./lib # use .so file provided instead of the dpp source files
|
||||
# Define include directories for headers
|
||||
# -I<path> tells the compiler where to look for #include <file.h> or #include <dir/file.h>
|
||||
# We assume:
|
||||
# - Your own headers (like ImageProcessor.h) are in 'include/'
|
||||
# - STB headers are in 'include/stb/'
|
||||
# - D++ headers are in 'include/dpp/' (so dpp.h is found via include/dpp/dpp.h)
|
||||
INC_DIRS = -Iinclude -Idpp/
|
||||
LIB_PATHS = $(DPP_PATH)
|
||||
else
|
||||
# If DPP_VERSION has a value (a version was found), assume custom build path
|
||||
DPP_PATH = ../DPP
|
||||
DPP_BUILD_DIR = $(DPP_PATH)/build/library
|
||||
LIB_PATHS = $(DPP_BUILD_DIR)
|
||||
INC_DIRS = -Iinclude -I../dpp/
|
||||
endif
|
||||
|
||||
DPP_VERSION := $(or $(DPP_VERSION),10.1.4)# Fallback version if auto-detection fails
|
||||
|
||||
# Common paths
|
||||
OBJ_DIR = obj/$(PLATFORM)/$(BUILD_TYPE)
|
||||
BIN_DIR = bin/$(PLATFORM)/$(BUILD_TYPE)
|
||||
OUTPUT_FILE = $(BIN_DIR)/$(EXECUTABLE_NAME)
|
||||
|
||||
|
||||
|
||||
# Build type specific flags
|
||||
ifeq ($(BUILD_TYPE), debug)
|
||||
CPP_DEFINES = -D_DEBUG -DDL_USE_SHARED
|
||||
COMMON_FLAGS = $(ARCH_FLAGS) -fvisibility=hidden -g -O0 $(INCLUDE_PATHS)
|
||||
else
|
||||
CPP_DEFINES = -DNDEBUG=1 -DDL_USE_SHARED
|
||||
COMMON_FLAGS = $(ARCH_FLAGS) -fvisibility=hidden -O3 $(INCLUDE_PATHS)
|
||||
endif
|
||||
|
||||
# Language-specific flags
|
||||
C_FLAGS = $(COMMON_FLAGS) -std=c17
|
||||
CXX_FLAGS = $(COMMON_FLAGS) -std=c++17 -Wall -g $(INC_DIRS)
|
||||
|
||||
# Linker directive flags (L for library search path, l for library)
|
||||
# Need to link against the D++ library and pthread (common for C++ applications with threading)
|
||||
#LDFLAGS = -L$(LIB_PATHS) -ldpp -lpthread -Wl,-rpath=../../../$(LIB_PATHS)
|
||||
LDFLAGS = -L$(LIB_PATHS) -ldpp -lpthread -Wl,-rpath=../../../$(LIB_PATHS)
|
||||
|
||||
# List of object files for your executable
|
||||
# We've changed this back to use discord-bot.o as the source of the executable
|
||||
OBJECTS = $(OBJ_DIR)/discord-bot.o
|
||||
|
||||
# --- Main Target ---
|
||||
# 'all' is the default target that builds your executable
|
||||
all: $(OUTPUT_FILE)
|
||||
@echo "DPP_PATH: "$(DPP_PATH)
|
||||
@echo "Build complete."
|
||||
|
||||
# Rule to link the executable:
|
||||
# It depends on the object files and uses CXX to link them with specified libraries.
|
||||
$(OUTPUT_FILE): $(OBJECTS)
|
||||
@echo "Linking $(OUTPUT_FILE)..."
|
||||
@echo "LDFLAGS: $(LDFLAGS)"
|
||||
@mkdir -p $(@D) # Ensure the output binary directory exists (e.g., bin/Linux/release/)
|
||||
$(CXX) -o $@ $(OBJECTS) $(LDFLAGS)
|
||||
cp token.txt $(@D)
|
||||
|
||||
# Rule to compile the object file:
|
||||
# This takes your .cpp source file and compiles it into an object file (.o).
|
||||
$(OBJ_DIR)/$(EXECUTABLE_NAME).o: $(EXECUTABLE_NAME).cpp
|
||||
@echo "Compiling $< to $@"
|
||||
@mkdir -p $(@D) # Ensure the object directory exists (e.g., obj/Linux/release/)
|
||||
$(CXX) -c -o $@ $< $(CXX_FLAGS) $(CPP_DEFINES)
|
||||
|
||||
# --- Clean Target ---
|
||||
# Removes all generated build files and directories
|
||||
clean:
|
||||
@echo "Cleaning build directory..."
|
||||
$(RM) -r $(BIN_DIR)
|
||||
$(RM) -r $(OBJ_DIR)
|
||||
|
||||
# .PHONY specifies targets that are not actual files to prevent conflicts with file names
|
||||
.PHONY: all clean
|
||||
Loading…
x
Reference in New Issue
Block a user