Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable vcpkg for all platforms on CI #242

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember if I asked before but libsdl2-dev, zlib & spdlog should now be provided by VCPKG ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, they should. I can change those when I update the PR to add the README

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>
Lgt2x marked this conversation as resolved.
Show resolved Hide resolved
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",
Lgt2x marked this conversation as resolved.
Show resolved Hide resolved
"features": ["x11","wayland"],
"platform": "linux"
},
{
"name": "sdl2",
"version>=": "2.30.1",
"platform": "!linux"
}
]
}