entity destruction, etc.
This commit is contained in:
116
CMakeLists.txt
116
CMakeLists.txt
@@ -4,59 +4,83 @@ project(Letnik3Zadnja)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Include FetchContent to download SDL from source
|
||||
include(FetchContent)
|
||||
|
||||
# Download SDL3 from source
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
|
||||
GIT_TAG release-3.4.2
|
||||
)
|
||||
|
||||
# Download SDL3_image from source
|
||||
FetchContent_Declare(
|
||||
SDL3_image
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL_image.git
|
||||
GIT_TAG release-3.2.4
|
||||
)
|
||||
|
||||
# Download SDL3_ttf from source
|
||||
FetchContent_Declare(
|
||||
SDL3_ttf
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL_ttf.git
|
||||
GIT_TAG release-3.2.2
|
||||
)
|
||||
|
||||
# Download SDL3_mixer from source
|
||||
FetchContent_Declare(
|
||||
SDL3_mixer
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL_mixer.git
|
||||
GIT_TAG release-3.2.0
|
||||
)
|
||||
|
||||
# Work around PipeWire API mismatch on some Linux distributions.
|
||||
# Disable PipeWire backend in SDL; PulseAudio/ALSA backends remain available.
|
||||
set(SDL_PIPEWIRE OFF CACHE BOOL "Disable SDL PipeWire backend" FORCE)
|
||||
set(SDL_PIPEWIRE_SHARED OFF CACHE BOOL "Disable dynamic PipeWire loading in SDL" FORCE)
|
||||
|
||||
# Make SDL libraries available
|
||||
FetchContent_MakeAvailable(SDL3)
|
||||
FetchContent_MakeAvailable(SDL3_image)
|
||||
FetchContent_MakeAvailable(SDL3_ttf)
|
||||
FetchContent_MakeAvailable(SDL3_mixer)
|
||||
# Compile flags
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-unused-parameter -O2")
|
||||
|
||||
# Collect all source files from src/ and nested directories
|
||||
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "src/*.cpp")
|
||||
|
||||
# Compile flags
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-unused-parameter -O2")
|
||||
|
||||
# Create the executable
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
|
||||
# Include headers from include/
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE include)
|
||||
|
||||
# Link SDL3 and SDL3_image to the executable
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE SDL3::SDL3 SDL3_image::SDL3_image SDL3_ttf::SDL3_ttf SDL3_mixer::SDL3_mixer)
|
||||
# ------------------------------------------------------------
|
||||
# Platform-specific dependency handling
|
||||
# ------------------------------------------------------------
|
||||
|
||||
if(WIN32)
|
||||
|
||||
# Include FetchContent to download SDL libraries
|
||||
include(FetchContent)
|
||||
|
||||
# Download SDL3
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
|
||||
GIT_TAG release-3.4.2
|
||||
)
|
||||
|
||||
# Download SDL3_image
|
||||
FetchContent_Declare(
|
||||
SDL3_image
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL_image.git
|
||||
GIT_TAG release-3.2.4
|
||||
)
|
||||
|
||||
# Download SDL3_ttf
|
||||
FetchContent_Declare(
|
||||
SDL3_ttf
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL_ttf.git
|
||||
GIT_TAG release-3.2.2
|
||||
)
|
||||
|
||||
# Download SDL3_mixer
|
||||
FetchContent_Declare(
|
||||
SDL3_mixer
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL_mixer.git
|
||||
GIT_TAG release-3.2.0
|
||||
)
|
||||
|
||||
# Disable PipeWire backend (Linux-only but harmless here)
|
||||
set(SDL_PIPEWIRE OFF CACHE BOOL "Disable SDL PipeWire backend" FORCE)
|
||||
set(SDL_PIPEWIRE_SHARED OFF CACHE BOOL "Disable dynamic PipeWire loading in SDL" FORCE)
|
||||
|
||||
# Make SDL libraries available
|
||||
FetchContent_MakeAvailable(SDL3)
|
||||
FetchContent_MakeAvailable(SDL3_image)
|
||||
FetchContent_MakeAvailable(SDL3_ttf)
|
||||
FetchContent_MakeAvailable(SDL3_mixer)
|
||||
|
||||
else()
|
||||
|
||||
# macOS / Linux → use system-installed packages
|
||||
find_package(SDL3 REQUIRED)
|
||||
find_package(SDL3_image REQUIRED)
|
||||
find_package(SDL3_ttf REQUIRED)
|
||||
find_package(SDL3_mixer REQUIRED)
|
||||
|
||||
endif()
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Link SDL libraries
|
||||
# ------------------------------------------------------------
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
SDL3::SDL3
|
||||
SDL3_image::SDL3_image
|
||||
SDL3_ttf::SDL3_ttf
|
||||
SDL3_mixer::SDL3_mixer
|
||||
)
|
||||
Reference in New Issue
Block a user