85 lines
2.4 KiB
CMake
85 lines
2.4 KiB
CMake
cmake_minimum_required(VERSION 3.15)
|
|
project(PortalGame)
|
|
|
|
# Enable C++20
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
# Add src directory
|
|
add_executable(PortalGame
|
|
"src/main.cpp"
|
|
"src/app.hpp"
|
|
"src/app.cpp"
|
|
"src/gl.hpp"
|
|
"src/utils.hpp"
|
|
"src/assets/sectordef.hpp"
|
|
"src/assets/sectordef.cpp"
|
|
"src/assets/mesh.hpp"
|
|
"src/assets/mesh.cpp"
|
|
"src/collision/capsule_triangle_sweep.hpp"
|
|
"src/collision/capsule_triangle_sweep.cpp"
|
|
"src/collision/trianglemesh.cpp"
|
|
"src/game/sector.hpp"
|
|
"src/game/sector.cpp"
|
|
"src/game/world.hpp"
|
|
"src/game/world.cpp"
|
|
"src/gfx/buffer_object.cpp"
|
|
"src/gfx/buffer_object.hpp"
|
|
"src/gfx/renderer.hpp"
|
|
"src/gfx/renderer.cpp"
|
|
"src/gfx/shader.hpp"
|
|
"src/gfx/shader.cpp"
|
|
"src/gfx/shader_sources.hpp"
|
|
"src/gfx/shader_sources.cpp"
|
|
"src/gfx/texture.cpp"
|
|
"src/gfx/texture.hpp"
|
|
"src/gfx/vertex_array.cpp"
|
|
"src/gfx/vertex_array.hpp"
|
|
)
|
|
|
|
# Include directories
|
|
target_include_directories(PortalGame PRIVATE
|
|
"src"
|
|
)
|
|
|
|
# Platform-specific SDL2 handling
|
|
if (CMAKE_SYSTEM_NAME STREQUAL Emscripten)
|
|
|
|
# Emscripten provides SDL2 via its system libraries
|
|
message(STATUS "Target platform: WebAssembly (Emscripten)")
|
|
set(CMAKE_EXECUTABLE_SUFFIX ".html") # Optional: build HTML page
|
|
|
|
target_compile_options(PortalGame PRIVATE
|
|
"-sUSE_SDL=2"
|
|
"-sNO_DISABLE_EXCEPTION_CATCHING=1"
|
|
)
|
|
|
|
target_link_options(PortalGame PRIVATE
|
|
"-sUSE_SDL=2"
|
|
"-sASYNCIFY"
|
|
"-sUSE_WEBGL2=1"
|
|
"-sNO_DISABLE_EXCEPTION_CATCHING=1"
|
|
"--shell-file" "${CMAKE_SOURCE_DIR}/shell.html"
|
|
"--preload-file" "${CMAKE_SOURCE_DIR}/assets/@/"
|
|
)
|
|
|
|
else()
|
|
message(STATUS "Target platform: Native")
|
|
# Native platform
|
|
# find_package(SDL2 REQUIRED)
|
|
# SDL2 build options to avoid unwanted components
|
|
set(SDL_TEST OFF CACHE BOOL "" FORCE)
|
|
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
|
set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
|
add_subdirectory(external/SDL)
|
|
target_include_directories(PortalGame PRIVATE "external/SDL/include")
|
|
target_link_libraries(PortalGame PRIVATE SDL2main SDL2-static)
|
|
|
|
add_subdirectory(external/glad)
|
|
target_link_libraries(PortalGame PRIVATE glad)
|
|
|
|
endif()
|
|
|
|
add_subdirectory(external/glm)
|
|
target_link_libraries(PortalGame PRIVATE glm)
|
|
target_include_directories(PortalGame PRIVATE "external/stb") |