updated TSE to be able to use SDL3
This commit is contained in:
193
CMakeLists.txt
193
CMakeLists.txt
@@ -4,6 +4,28 @@ cmake_minimum_required(VERSION 3.31)
|
||||
#project name
|
||||
project(TSE-RTS)
|
||||
|
||||
# backend selection
|
||||
option(USE_GLFW "Build with GLFW backend" OFF)
|
||||
option(USE_SDL3 "Build with SDL3 backend" OFF)
|
||||
|
||||
# default backend: GLFW
|
||||
if(NOT USE_GLFW AND NOT USE_SDL3)
|
||||
set(USE_GLFW ON)
|
||||
endif()
|
||||
|
||||
# forbid enabling both at once
|
||||
if(USE_GLFW AND USE_SDL3)
|
||||
message(FATAL_ERROR "USE_GLFW and USE_SDL3 cannot both be ON. Select exactly one backend.")
|
||||
endif()
|
||||
|
||||
if(USE_GLFW)
|
||||
message(STATUS "Window backend: GLFW")
|
||||
endif()
|
||||
|
||||
if(USE_SDL3)
|
||||
message(STATUS "Window backend: SDL3")
|
||||
endif()
|
||||
|
||||
#cpp settings
|
||||
find_program(CLANG_C NAMES clang)
|
||||
find_program(CLANG_CXX NAMES clang++)
|
||||
@@ -28,8 +50,15 @@ add_subdirectory(TSE/TSE_Base)
|
||||
add_subdirectory(TSE/TSE_Math)
|
||||
add_subdirectory(TSE/TSE_Core)
|
||||
add_subdirectory(TSE/TSE_Editor)
|
||||
add_subdirectory(TSE/TSE_GlfwImpl)
|
||||
add_subdirectory(TSE/TSE_GlfwOpenGlImpl)
|
||||
add_subdirectory(TSE/TSE_OpenGlImpl)
|
||||
|
||||
if(USE_GLFW)
|
||||
add_subdirectory(TSE/TSE_GlfwImpl)
|
||||
endif()
|
||||
|
||||
if(USE_SDL3)
|
||||
add_subdirectory(TSE/TSE_Sdl3Impl)
|
||||
endif()
|
||||
|
||||
#source files
|
||||
file(GLOB CPP_SOURCE
|
||||
@@ -43,73 +72,127 @@ file(GLOB CPP_SOURCE
|
||||
"${PROJECT_SOURCE_DIR}/TSE-RTS/src/*/*/*/*.c"
|
||||
)
|
||||
|
||||
#includes
|
||||
include_directories(${PROJECT_SOURCE_DIR}/TSE-RTS/src)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/TSE-RTS/include)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_Math/src)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_Core/src)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_Base/src)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_Base/include)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_Editor/src)
|
||||
|
||||
#includes Glfw
|
||||
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/src)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/include)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwOpenGlImpl/src)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwOpenGlImpl/include)
|
||||
|
||||
#project def
|
||||
add_executable(TSE-RTS ${CPP_SOURCE})
|
||||
|
||||
if (WIN32)
|
||||
if(DEBUG)
|
||||
set(DEBUGSPEC
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/FreeImageLib.d.lib"
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/box2dd.lib"
|
||||
# includes
|
||||
target_include_directories(TSE-RTS PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/TSE-RTS/src
|
||||
${PROJECT_SOURCE_DIR}/TSE-RTS/include
|
||||
${PROJECT_SOURCE_DIR}/TSE/TSE_Math/src
|
||||
${PROJECT_SOURCE_DIR}/TSE/TSE_Core/src
|
||||
${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include
|
||||
${PROJECT_SOURCE_DIR}/TSE/TSE_Base/src
|
||||
${PROJECT_SOURCE_DIR}/TSE/TSE_Base/include
|
||||
${PROJECT_SOURCE_DIR}/TSE/TSE_Editor/src
|
||||
${PROJECT_SOURCE_DIR}/TSE/TSE_OpenGlImpl/src
|
||||
${PROJECT_SOURCE_DIR}/TSE/TSE_OpenGlImpl/include
|
||||
)
|
||||
|
||||
if(USE_GLFW)
|
||||
target_include_directories(TSE-RTS PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/src
|
||||
${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/include
|
||||
)
|
||||
endif()
|
||||
|
||||
if(USE_SDL3)
|
||||
target_include_directories(TSE-RTS PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/TSE/TSE_Sdl3Impl/src
|
||||
${PROJECT_SOURCE_DIR}/TSE/TSE_Sdl3Impl/include
|
||||
)
|
||||
endif()
|
||||
|
||||
# compile definitions for active backend
|
||||
if(USE_GLFW)
|
||||
target_compile_definitions(TSE-RTS PRIVATE TSE_WINDOW_BACKEND_GLFW)
|
||||
endif()
|
||||
|
||||
if(USE_SDL3)
|
||||
target_compile_definitions(TSE-RTS PRIVATE TSE_WINDOW_BACKEND_SDL3)
|
||||
endif()
|
||||
|
||||
# external libs
|
||||
set(LIB_SOURCE "")
|
||||
set(BACKEND_LIBS "")
|
||||
set(BACKEND_TARGETS "")
|
||||
|
||||
if(WIN32)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(DEBUGSPEC
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/FreeImageLib.d.lib"
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/box2dd.lib"
|
||||
)
|
||||
else()
|
||||
set(DEBUGSPEC
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/FreeImageLib.r.lib"
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/box2d.lib"
|
||||
set(DEBUGSPEC
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/FreeImageLib.r.lib"
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/box2d.lib"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(LIB_SOURCE
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/include/glfw3.lib"
|
||||
# "${PROJECT_SOURCE_DIR}/../TSE.Core/lib/freetype.lib"
|
||||
"${DEBUGSPEC}"
|
||||
${DEBUGSPEC}
|
||||
)
|
||||
|
||||
if(USE_GLFW)
|
||||
list(APPEND LIB_SOURCE
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/include/glfw3.lib"
|
||||
)
|
||||
list(APPEND BACKEND_TARGETS TSE_GlfwImpl)
|
||||
endif()
|
||||
|
||||
if(USE_SDL3)
|
||||
list(APPEND LIB_SOURCE
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Sdl3Impl/include/SDL3.lib"
|
||||
)
|
||||
list(APPEND BACKEND_TARGETS TSE_Sdl3Impl)
|
||||
endif()
|
||||
|
||||
else()
|
||||
set(LIB_SOURCE
|
||||
# "${PROJECT_SOURCE_DIR}/../TSE.Core/lib/libfreetype.a"
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/libfreeimage.a"
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/include/libglfw3.a"
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/libbox2d.a"
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/libfreeimage.a"
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/libbox2d.a"
|
||||
)
|
||||
|
||||
if(USE_GLFW)
|
||||
list(APPEND LIB_SOURCE
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/include/libglfw3.a"
|
||||
)
|
||||
list(APPEND BACKEND_TARGETS TSE_GlfwImpl)
|
||||
endif()
|
||||
|
||||
if(USE_SDL3)
|
||||
list(APPEND LIB_SOURCE
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Sdl3Impl/include/libSDL3.a"
|
||||
)
|
||||
list(APPEND BACKEND_TARGETS TSE_Sdl3Impl)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# link
|
||||
if(WIN32)
|
||||
target_link_libraries(TSE-RTS PUBLIC
|
||||
TSE_Base
|
||||
TSE_Math
|
||||
TSE_Core
|
||||
${BACKEND_TARGETS}
|
||||
TSE_OpenGlImpl
|
||||
TSE_Editor
|
||||
${LIB_SOURCE}
|
||||
)
|
||||
else()
|
||||
target_link_libraries(TSE-RTS PUBLIC
|
||||
TSE_Editor
|
||||
TSE_OpenGlImpl
|
||||
${BACKEND_TARGETS}
|
||||
TSE_Core
|
||||
TSE_Math
|
||||
TSE_Base
|
||||
${LIB_SOURCE}
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(TSE-RTS PUBLIC
|
||||
TSE_Base
|
||||
TSE_Math
|
||||
TSE_Core
|
||||
TSE_GlfwImpl
|
||||
TSE_GlfwOpenGlImpl
|
||||
TSE_Editor
|
||||
${LIB_SOURCE})
|
||||
else()
|
||||
target_link_libraries(TSE-RTS PUBLIC
|
||||
TSE_Editor
|
||||
TSE_GlfwOpenGlImpl
|
||||
TSE_GlfwImpl
|
||||
TSE_Core
|
||||
TSE_Math
|
||||
TSE_Base
|
||||
${LIB_SOURCE})
|
||||
endif()
|
||||
|
||||
#flags
|
||||
# flags
|
||||
target_compile_options(TSE-RTS PRIVATE -march=native)
|
||||
|
||||
set(TARGET_DIR "${PROJECT_SOURCE_DIR}/bin")
|
||||
|
||||
Reference in New Issue
Block a user