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/animation.hpp" "src/assets/animation.cpp" "src/assets/mesh.hpp" "src/assets/mesh.cpp" "src/assets/sectordef.hpp" "src/assets/sectordef.cpp" "src/assets/skeleton.hpp" "src/assets/skeleton.cpp" "src/collision/trianglemesh.cpp" "src/game/entity.hpp" "src/game/entity.cpp" "src/game/meshinstance.hpp" "src/game/meshinstance.cpp" "src/game/player_input.hpp" "src/game/player.hpp" "src/game/player.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/uniform_buffer.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" "-sALLOW_MEMORY_GROWTH=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") add_subdirectory(bullet3) target_link_libraries(PortalGame PRIVATE BulletCollision LinearMath Bullet3Common) target_include_directories(PortalGame PRIVATE "bullet3/src")