Initial commit - some engine bugs stopping compiling

This commit is contained in:
Will
2026-03-29 15:52:42 +01:00
commit 3d573a200e
361 changed files with 332759 additions and 0 deletions

113
CMakeLists.txt Normal file
View File

@@ -0,0 +1,113 @@
cmake_minimum_required(VERSION 3.25)
project(ModernEngine LANGUAGES CXX C) # Add C for glad.c
# Use the latest C++ standard (C++23)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Add compile flags for modern C++
if(MSVC)
add_compile_options(/W4)
else()
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# Find required packages
find_package(PkgConfig REQUIRED)
find_package(OpenGL REQUIRED)
# Find GLFW via pkg-config
pkg_check_modules(GLFW REQUIRED glfw3)
link_directories(${GLFW_LIBRARY_DIRS})
# Find GLM (Homebrew or system)
find_package(glm REQUIRED)
if(NOT DEFINED GLM_INCLUDE_DIRS)
find_path(GLM_INCLUDE_DIRS
glm/glm.hpp
PATHS /opt/homebrew/include /usr/local/include ${CMAKE_PREFIX_PATH}
NO_DEFAULT_PATH
)
endif()
if(NOT GLM_INCLUDE_DIRS)
message(FATAL_ERROR "Could not find glm headers (glm/glm.hpp). Install with 'brew install glm'.")
endif()
message(STATUS "Using GLM include dir: ${GLM_INCLUDE_DIRS}")
# GLAD setup - check multiple possible locations
set(GLAD_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
set(GLAD_SOURCE_CANDIDATES
${CMAKE_SOURCE_DIR}/src/glad.c
${CMAKE_SOURCE_DIR}/external/glad/src/glad.c
${CMAKE_SOURCE_DIR}/glad/src/glad.c
)
# Find GLAD source file
set(GLAD_SOURCE "")
foreach(candidate ${GLAD_SOURCE_CANDIDATES})
if(EXISTS ${candidate})
set(GLAD_SOURCE ${candidate})
message(STATUS "Found GLAD source: ${GLAD_SOURCE}")
break()
endif()
endforeach()
if(NOT GLAD_SOURCE)
message(FATAL_ERROR "Could not find glad.c in any of the expected locations: ${GLAD_SOURCE_CANDIDATES}")
endif()
# Collect engine source files (exclude glad.c from glob to avoid duplication)
file(GLOB_RECURSE ENGINE_SOURCES
${CMAKE_SOURCE_DIR}/src/*.cpp
)
# Remove glad.c from ENGINE_SOURCES if it was included by glob
list(FILTER ENGINE_SOURCES EXCLUDE REGEX ".*glad\\.c$")
# Create executable target
add_executable(${PROJECT_NAME}
${ENGINE_SOURCES}
${GLAD_SOURCE}
)
# Include directories
target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_SOURCE_DIR}/include # For glad.h
${GLFW_INCLUDE_DIRS}
${GLM_INCLUDE_DIRS}
)
# Link libraries and macOS frameworks
target_link_libraries(${PROJECT_NAME}
PRIVATE
OpenGL::GL
${GLFW_LIBRARIES}
)
# macOS-specific frameworks
if(APPLE)
target_link_libraries(${PROJECT_NAME}
PRIVATE
"-framework Cocoa"
"-framework IOKit"
"-framework CoreVideo"
"-framework QuartzCore"
)
endif()
# Copy assets to build directory if assets exist
if(EXISTS ${CMAKE_SOURCE_DIR}/assets)
file(COPY ${CMAKE_SOURCE_DIR}/assets DESTINATION ${CMAKE_BINARY_DIR})
endif()
# Windows-specific properties
if(WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES
WIN32_EXECUTABLE TRUE
)
endif()
# Debug information
message(STATUS "Engine sources found: ${ENGINE_SOURCES}")
message(STATUS "GLAD source: ${GLAD_SOURCE}")