Skip to content

Commit

Permalink
enable vcpkg for all platforms on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcnor committed May 6, 2024
1 parent 0e69bf4 commit 0845cb0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,32 @@ jobs:
# Install packages from Homebrew
brew bundle install
# `autopoint`, `gperf` tools needed for another package, probably wayland dependencies
- name: Install Linux dependencies
if: ${{ matrix.os.preset == 'linux' }}
run: |
sudo apt update
sudo apt install -y --no-install-recommends \
ninja-build cmake g++ libgtest-dev libsdl2-dev libncurses-dev zlib1g-dev libspdlog-dev
ninja-build cmake g++ libgtest-dev libsdl2-dev libncurses-dev zlib1g-dev libspdlog-dev \
libx11-dev libxft-dev libxext-dev \
libwayland-dev libxkbcommon-dev libegl1-mesa-dev \
libibus-1.0-dev \
autopoint gperf
- name: Configure CMake
- uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: "326d8b43e365352ba3ccadf388d989082fe0f2a6"

- name: Configure and build
uses: lukka/run-cmake@v10
env:
CC: ${{ matrix.os.cc }}
CXX: ${{ matrix.os.cxx }}
VCPKG_ROOT: C:/vcpkg
run: cmake --preset ${{ matrix.os.preset }} -DBUILD_TESTING=ON -DENABLE_LOGGER=ON

- name: Build ${{ matrix.build_type }}
run: cmake --build --preset ${{ matrix.os.preset }} --config ${{ matrix.build_type }} --verbose
with:
configurePreset: ${{matrix.os.preset}}
configurePresetAdditionalArgs: "['-DBUILD_TESTING=ON', '-DENABLE_LOGGER=ON']"
buildPreset: ${{matrix.os.preset}}
buildPresetAdditionalArgs: "['--config ${{matrix.build_type}}', '--verbose']"

- name: Run ${{ matrix.build_type }} Unittests
run: ctest --preset ${{ matrix.os.preset }} -C ${{ matrix.build_type }}
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ add_custom_target(get_git_hash ALL
DEPENDS ${PROJECT_BINARY_DIR}/Descent3/d3_version.h
)

find_package(SDL2 CONFIG REQUIRED)
if(UNIX)
set(D3_GAMEDIR "~/Descent3/")

add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-Wno-multichar;${BITS};${EXTRA_CXX_FLAGS}>")
add_compile_options("$<$<COMPILE_LANGUAGE:C>:${BITS}>")

find_package(SDL2 REQUIRED)
find_package(Curses REQUIRED)
find_package(OpenGL REQUIRED)
# Some versions of the SDL2 find_package set SDL2_INCLUDE_DIR and some set a plural SDL2_INCLUDE_DIRS. Check both.
Expand Down
6 changes: 3 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
{
"name": "defaults",
"hidden": true,
"binaryDir": "${sourceDir}/builds/${presetName}"
"binaryDir": "${sourceDir}/builds/${presetName}",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
},
{
"name": "win",
Expand All @@ -15,8 +16,7 @@
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"architecture": "Win32",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
"architecture": "Win32"
},
{
"name": "mac",
Expand Down
6 changes: 4 additions & 2 deletions Descent3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,12 @@ if(WIN32)
endif()

if(UNIX AND NOT APPLE)
set(PLATFORM_LIBS linux dd_lnxsound ddvid_lnx lnxcontroller ddio_lnx SDL2::SDL2 m ${CMAKE_DL_LIBS} ${CURSES_LIBRARIES})
set(PLATFORM_LIBS linux dd_lnxsound ddvid_lnx lnxcontroller ddio_lnx m ${CMAKE_DL_LIBS} ${CURSES_LIBRARIES})
set(PLATFORM_CPPS loki_utils.c lnxmain.cpp)
endif()

if(APPLE)
set(PLATFORM_LIBS linux dd_lnxsound ddvid_lnx lnxcontroller ddio_lnx SDL2::SDL2 ${CURSES_LIBRARIES})
set(PLATFORM_LIBS linux dd_lnxsound ddvid_lnx lnxcontroller ddio_lnx ${CURSES_LIBRARIES})
set(PLATFORM_CPPS loki_utils.c lnxmain.cpp)
set(CMAKE_EXE_LINKER_FLAGS "-framework IOKit -framework Cocoa -framework OpenGL -framework Carbon")
endif()
Expand All @@ -300,6 +300,8 @@ add_executable(Descent3
)
target_link_libraries(Descent3
2dlib AudioEncode bitmap cfile czip d3music ddebug ddio_common libmve libacm
$<TARGET_NAME_IF_EXISTS:SDL2::SDL2main>
$<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static>
fix grtext manage mem misc model module movie stream_audio
music networking physics renderer rtperformance sndlib ui unzip vecmat md5
${PLATFORM_LIBS})
Expand Down
15 changes: 13 additions & 2 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
{
"builtin-baseline": "000d1bda1ffa95a73e0b40334fa4103d6f4d3d48",
"builtin-baseline": "326d8b43e365352ba3ccadf388d989082fe0f2a6",
"dependencies": [
"spdlog",
"gtest",
"zlib"
"zlib",
{
"name": "sdl2",
"version>=": "2.30.1",
"features": ["wayland"],
"platform": "linux"
},
{
"name": "sdl2",
"version>=": "2.30.1",
"platform": "!linux"
}
]
}

0 comments on commit 0845cb0

Please sign in to comment.