Skip to content

Commit

Permalink
Make sure Mac and Linux builds have SDL2 available.
Browse files Browse the repository at this point in the history
Currently Windows gets this from vcpkg. Mac will get it from Homebrew,
and the GitHub linux builders will just install it with apt-get.

This might not be the perfect solution (having to install Homebrew is a pain,
GitHub Actions has an ancient SDL2), but it gets all the common platforms
running for now without much fuss.
  • Loading branch information
icculus committed Apr 30, 2024
1 parent 913d82a commit 815628b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
run: |
sudo apt update
sudo apt install -y --no-install-recommends \
ninja-build cmake g++ libgtest-dev libsdl1.2-dev libsdl-image1.2-dev libncurses-dev zlib1g-dev
ninja-build cmake g++ libgtest-dev libsdl2-dev libncurses-dev zlib1g-dev
- name: Configure CMake
env:
Expand Down
3 changes: 1 addition & 2 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Homebrew dependencies to build Descent3

# SDL
brew "sdl12-compat"
brew "sdl2_image"
brew "sdl2"

brew "cmake"
brew "googletest"
Expand Down
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,18 @@ if(UNIX)
find_package(SDL2 REQUIRED)
find_package(Curses REQUIRED)
find_package(OpenGL REQUIRED)
message("SDL2 Include Dir is " ${SDL2_INCLUDE_DIR})
# Some versions of the SDL2 find_package set SDL2_INCLUDE_DIR and some set a plural SDL2_INCLUDE_DIRS. Check both.
message("SDL2 Include Dir is ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS}")
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
message("Building for Linux")
add_compile_definitions(__LINUX__ LINUX _MAX_PATH=260 _MAX_FNAME=256 _REENRANT __32BIT__ HAVEALLOCA_H _USE_OGL_ACTIVE_TEXTURES)
set(PLATFORM_INCLUDES "lib/linux" ${SDL2_INCLUDE_DIR})
set(PLATFORM_INCLUDES "lib/linux" ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
message("Building for MAC OSX")
add_compile_definitions(__LINUX__ LINUX _MAX_PATH=260 _MAX_FNAME=256 _REENRANT MACOSX=1 _USE_OGL_ACTIVE_TEXTURES)
set(PLATFORM_INCLUDES "lib/linux" ${SDL2_INCLUDE_DIR} "/usr/X11/include") # !!! FIXME: why X11?
set(PLATFORM_INCLUDES "lib/linux" ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS} "/usr/X11/include") # !!! FIXME: why X11?
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
list(APPEND CMAKE_LIBRARY_PATH "lib/win" "lib/win/directx")
add_compile_options("$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:CXX>>:/EHsc;/RTC1;/W3;/nologo;/c;/Zi;/TP;/errorReport:prompt>")
Expand Down

0 comments on commit 815628b

Please sign in to comment.