Some project structure fixes
This commit is contained in:
21
.gitattributes
vendored
21
.gitattributes
vendored
@@ -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
|
||||
|
||||
@@ -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 ---
|
||||
|
||||
@@ -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
|
||||
$<TARGET_FILE:SDL3::SDL3>
|
||||
"${CMAKE_BINARY_DIR}/game/$<TARGET_FILE_NAME:SDL3::SDL3>"
|
||||
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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
# $<TARGET_FILE_DIR:game> 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
|
||||
$<TARGET_FILE:SDL3::SDL3>
|
||||
$<TARGET_FILE_DIR:game>
|
||||
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")
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#include "Engine.h"
|
||||
#include <SDL3/SDL_main.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
Engine engine;
|
||||
|
||||
if (!engine.Init())
|
||||
return 1;
|
||||
|
||||
engine.Shutdown();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user