diff --git a/.gitattributes b/.gitattributes index a9c1b2e..d9ffdee 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,10 +1,17 @@ -# Default: normalize all text files to LF +# Default: normalize text files to LF on commit * text=auto eol=lf -# Windows-only scripts: keep CRLF on Windows checkouts -*.ps1 text eol=crlf -*.bat text eol=crlf -*.cmd text eol=crlf +# Explicitly mark binary files so Git never touches their line endings +*.so binary +*.so.* binary +*.a binary +*.dll binary +*.lib binary +*.exe binary +*.dylib binary -# Explicitly force LF for shell scripts regardless of platform -*.sh text eol=lf +# Scripts +*.sh text eol=lf +*.ps1 text eol=crlf +*.bat text eol=crlf +*.cmd text eol=crlf diff --git a/CMakeLists.txt b/CMakeLists.txt index 7abec81..167743e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,6 @@ cmake_minimum_required(VERSION 3.18) project(GameEngine VERSION 0.1.0 LANGUAGES C CXX) -set(CMAKE_CXX_STANDARD 23) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - # --- Validate preset variables --- if(NOT DEFINED SDL_LINK_TYPE OR NOT SDL_LINK_TYPE MATCHES "^(static|dynamic)$") message(FATAL_ERROR "SDL_LINK_TYPE must be 'static' or 'dynamic'. Use a CMake preset.") @@ -19,11 +16,14 @@ message(STATUS "Build config: PLATFORM=${PLATFORM}, SDL_LINK_TYPE=${SDL_LINK_TYP include(cmake/SDLSetup.cmake) #include(cmake/SDLMixerSetup.cmake) -# --- Apply Linux dynamic RPATH globally so all targets can find shared libs -# at runtime. SDL_LINUX_RPATH is appended to by each Setup module. +# --- On Linux with dynamic linking, set an $ORIGIN-relative RPATH so the +# binary can find shared libs next to itself without needing LD_LIBRARY_PATH. +# SDL_LINUX_RPATH is still used at build time so the dev build works in-place. if(DEFINED SDL_LINUX_RPATH) message(STATUS "Setting CMAKE_BUILD_RPATH to: ${SDL_LINUX_RPATH}") set(CMAKE_BUILD_RPATH "${SDL_LINUX_RPATH}") + set(CMAKE_INSTALL_RPATH "$ORIGIN") + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH OFF) endif() # --- Subdirectories --- diff --git a/cmake/SDLSetup.cmake b/cmake/SDLSetup.cmake index 39d3ce2..3315256 100644 --- a/cmake/SDLSetup.cmake +++ b/cmake/SDLSetup.cmake @@ -28,16 +28,6 @@ endif() message(STATUS "SDL_TARGET resolved to: ${SDL_TARGET}") -# On Windows with dynamic linking, copy the DLL next to the executable -if(SDL_LINK_TYPE STREQUAL "dynamic" AND WIN32) - add_custom_target(copy_sdl_dll ALL - COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ - "${CMAKE_BINARY_DIR}/game/$" - COMMENT "Copying SDL3.dll to output directory" - ) -endif() - # On Linux with dynamic linking, embed the absolute path to the prebuilt lib # directory in the binary's RPATH. prebuilt/linux is built in-place on the # Linux remote so this path is always valid there. diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 3f85ca2..177958f 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -2,6 +2,8 @@ add_library(engine STATIC src/Engine.cpp ) +target_compile_features(engine PUBLIC cxx_std_23) + target_include_directories(engine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src diff --git a/engine/src/Engine.hpp b/engine/include/Engine.hpp similarity index 92% rename from engine/src/Engine.hpp rename to engine/include/Engine.hpp index 50e9667..6f70f09 100644 --- a/engine/src/Engine.hpp +++ b/engine/include/Engine.hpp @@ -1 +1 @@ -#pragma once +#pragma once diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index b43ba37..5382dfe 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -2,8 +2,21 @@ add_executable(game "src/main.cpp" ) +target_compile_features(game PRIVATE cxx_std_23) + target_link_libraries(game PRIVATE engine) +# On Windows with dynamic linking, copy SDL3.dll next to the game executable. +# $ always resolves correctly regardless of build layout. +if(WIN32 AND SDL_LINK_TYPE STREQUAL "dynamic") + add_custom_command(TARGET game POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $ + COMMENT "Copying SDL3.dll to game output directory" + ) +endif() + # On Windows, use the WINDOWS subsystem (no console) for release only if(WIN32) if(CMAKE_BUILD_TYPE STREQUAL "Release") diff --git a/game/src/__main.cpp b/game/src/__main.cpp deleted file mode 100644 index 048fdb3..0000000 --- a/game/src/__main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "Engine.h" -#include - -int main(int argc, char* argv[]) -{ - Engine engine; - - if (!engine.Init()) - return 1; - - engine.Shutdown(); - return 0; -} \ No newline at end of file