everything
This commit is contained in:
parent
79fa59c3aa
commit
8998bc3936
19 changed files with 855 additions and 7504 deletions
|
|
@ -5,48 +5,80 @@ set(CMAKE_CXX_STANDARD 20)
|
|||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(glfw3 3.3 QUIET)
|
||||
|
||||
if(NOT glfw3_FOUND)
|
||||
message(STATUS "glfw3 not found via find_package")
|
||||
if(WIN32)
|
||||
set(GLFW_LIB "${CMAKE_CURRENT_SOURCE_DIR}/vendor/glfw/libglfw3.a")
|
||||
else()
|
||||
message(FATAL_ERROR "GLFW not found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(Engine2026
|
||||
# ------------------------------------------------------------------------------
|
||||
# 1. Source and Header Files
|
||||
# ------------------------------------------------------------------------------
|
||||
set(SOURCES
|
||||
main.cpp
|
||||
vendor/glad/glad.c
|
||||
vendor/stb/stb_image.cpp
|
||||
)
|
||||
|
||||
set(HEADERS
|
||||
engine/shader.h
|
||||
engine/texture.h
|
||||
engine/mesh.h
|
||||
vendor/glad/glad.c
|
||||
engine/camera.h
|
||||
game/game.cpp
|
||||
game/game.h
|
||||
)
|
||||
|
||||
target_include_directories(Engine2026 PRIVATE
|
||||
# Create the executable
|
||||
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# 2. Include Directories
|
||||
# ------------------------------------------------------------------------------
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vendor
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vendor/assimp/include
|
||||
)
|
||||
|
||||
if(glfw3_FOUND)
|
||||
target_link_libraries(Engine2026 PRIVATE glfw OpenGL::GL)
|
||||
else()
|
||||
target_link_libraries(Engine2026 PRIVATE
|
||||
${GLFW_LIB}
|
||||
opengl32
|
||||
gdi32
|
||||
user32
|
||||
)
|
||||
endif()
|
||||
# ------------------------------------------------------------------------------
|
||||
# 3. Dependencies & Linking
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# Copy assets to build dir
|
||||
add_custom_command(
|
||||
TARGET Engine2026 POST_BUILD
|
||||
# -- OpenGL --
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::GL)
|
||||
|
||||
# -- GLFW (Built from source) --
|
||||
# Turn off extra GLFW targets to speed up your compile times
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
|
||||
# Add the GLFW source directory.
|
||||
# NOTE: This automatically handles all underlying OS dependencies (gdi32, X11, Cocoa, etc.)
|
||||
add_subdirectory(vendor/glfw)
|
||||
|
||||
# Link the GLFW target
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE glfw)
|
||||
|
||||
# -- Assimp (Built from source) --
|
||||
# Turn off extra Assimp targets to speed up compile times
|
||||
set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE BOOL "" FORCE)
|
||||
|
||||
# Add the Assimp source directory
|
||||
add_subdirectory(vendor/assimp)
|
||||
# Link the GLFW and Assimp targets
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE glfw assimp)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# 4. Asset Synchronization (Runs Every Single Compile)
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
add_custom_target(refresh_assets
|
||||
# Step 1: Wipe the assets folder using a static configuration path
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_CURRENT_BINARY_DIR}/assets"
|
||||
# Step 2: Copy them fresh
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/assets
|
||||
$<TARGET_FILE_DIR:Engine2026>/assets
|
||||
COMMENT "Copying assets to output directory"
|
||||
)
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/assets"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/assets"
|
||||
COMMENT "Force-syncing assets to build directory..."
|
||||
)
|
||||
|
||||
# This now safely runs BEFORE the executable compiles, without the dependency loop
|
||||
add_dependencies(${PROJECT_NAME} refresh_assets)
|
||||
Loading…
Add table
Add a link
Reference in a new issue