ref: e9859d736b3526f5a326b37ed30e50e079de9363
parent: 556e135c4b3d3da37343b0c38202e18dd7df7ab1
author: Tanguy Fautre <tanguy@fautre.com>
date: Fri Feb 21 16:56:02 EST 2020
Do not use vcpkg on Linux, instead rely on distro packages instead.
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -9,6 +9,10 @@
steps:
- uses: actions/checkout@v2
+ - name: Install Ubuntu dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install libenet-dev libsdl2-mixer-dev
- name: Compile vcpkg dependencies
run: ./vcpkg_linux.sh
- name: Compile Duke3D
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,9 +50,22 @@
endif()
find_package(ENet REQUIRED)
-find_path(SDL2_INCLUDE_DIR SDL2/SDL.h NO_SYSTEM_ENVIRONMENT_PATH)
find_package(SDL2 CONFIG REQUIRED)
-find_package(SDL2-mixer CONFIG REQUIRED)
+
+if (WIN32)
+ # On Windows we can use vcpkg to build all the dependencies.
+ find_path(SDL2_INCLUDE_DIR SDL2/SDL.h NO_SYSTEM_ENVIRONMENT_PATH)
+ find_package(SDL2-mixer CONFIG REQUIRED)
+ set(SDL2_ALL_LIBRARIES SDL2::SDL2main SDL2::SDL2-static SDL2::SDL2_mixer)
+endif()
+
+if (UNIX)
+ # On Linux we have to rely on the package system (e.g. apt-get).
+ # Otherwise we are likely to be missing some SDL-mixer components (e.g. proper MIDI sound support).
+ find_path(SDL2_INCLUDE_DIR SDL2/SDL.h)
+ find_package(SDL2Mixer REQUIRED)
+ set(SDL2_ALL_LIBRARIES ${SDL2_LIBRARIES} ${SDL2Mixer_LIBRARIES})
+endif()
add_subdirectory(Engine)
add_subdirectory(Game)
--- a/Game/CMakeLists.txt
+++ b/Game/CMakeLists.txt
@@ -123,6 +123,6 @@
)
set_target_properties(${project_name} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
-target_link_libraries(${project_name} PRIVATE Engine ${ENET_LIBRARIES} SDL2::SDL2main SDL2::SDL2-static SDL2::SDL2_mixer)
+target_link_libraries(${project_name} PRIVATE Engine ${ENET_LIBRARIES} ${SDL2_ALL_LIBRARIES})
set_target_properties(${project_name} PROPERTIES OUTPUT_NAME "ChocoDuke3D${project_suffix}")
set_target_properties(${project_name} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
--- a/README.md
+++ b/README.md
@@ -40,9 +40,11 @@
```
**Linux (GCC Makefile)** [![Linux CI Status](https://github.com/GPSnoopy/BelgianChocolateDuke3D/workflows/Linux%20CI/badge.svg)](https://github.com/GPSnoopy/BelgianChocolateDuke3D/actions?query=workflow%3A%22Linux+CI%22)
+
+Here we do not use vcpkg but instead rely on the distro packages for ENet and SDL2. Unfortunately vcpkg SDL2 (and mixer) still depends on dev packages to be installed, and the MIDI subsystem is not correctly configured.
+
```bash
-> sudo apt-get install libsdl2-mixer-dev
-> ./vcpkg_linux.sh
+> sudo apt-get install libenet-dev libsdl2-mixer-dev
> ./build_linux.sh
```
--- a/build_linux.sh
+++ b/build_linux.sh
@@ -3,5 +3,5 @@
mkdir --parents build/linux
cd build/linux
-cmake -D CMAKE_BUILD_TYPE=Release -D VCPKG_TARGET_TRIPLET=x64-linux -D CMAKE_TOOLCHAIN_FILE=../vcpkg.linux/scripts/buildsystems/vcpkg.cmake ../..
+cmake -D CMAKE_BUILD_TYPE=Release ../..
make -j
--- /dev/null
+++ b/cmake/FindSDL2Mixer.cmake
@@ -1,0 +1,32 @@
+# OpenClonk, http://www.openclonk.org
+#
+# Copyright (c) 2016, The OpenClonk Team and contributors
+#
+# Distributed under the terms of the ISC license; see accompanying file
+# "COPYING" for details.
+#
+# "Clonk" is a registered trademark of Matthes Bender, used with permission.
+# See accompanying file "TRADEMARK" for details.
+#
+# To redistribute this file separately, substitute the full license texts
+# for the above references.
+
+# Locate SDL_Mixer 2.
+# This module defines
+# SDL2Mixer_INCLUDE_DIRS - a list of directories that need to be added to the include path
+# SDL2Mixer_LIBRARIES - a list of libraries to link against to use SDL2
+# SDL2Mixer_FOUND - if false, SDL2 cannot be used
+
+
+find_path(SDL2Mixer_INCLUDE_DIR SDL_mixer.h PATH_SUFFIXES SDL2 HINTS ENV SDL2DIR)
+mark_as_advanced(SDL2Mixer_INCLUDE_DIR)
+find_library(SDL2Mixer_LIBRARY SDL2_mixer HINTS ENV SDL2DIR)
+mark_as_advanced(SDL2Mixer_LIBRARY)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(SDL2Mixer REQUIRED_VARS SDL2Mixer_LIBRARY SDL2Mixer_INCLUDE_DIR SDL2_LIBRARIES SDL2_INCLUDE_DIRS)
+
+if (SDL2Mixer_FOUND)
+ set(SDL2Mixer_LIBRARIES ${SDL2Mixer_LIBRARY} ${SDL2_LIBRARIES})
+ set(SDL2Mixer_INCLUDE_DIRS ${SDL2Mixer_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
+endif()
\ No newline at end of file
--- a/vcpkg_linux.sh
+++ /dev/null
@@ -1,14 +1,0 @@
-#!/bin/bash
-set -e
-
-mkdir -p build
-cd build
-git clone https://github.com/Microsoft/vcpkg.git vcpkg.linux
-cd vcpkg.linux
-git checkout 2020.01
-./bootstrap-vcpkg.sh
-
-./vcpkg install \
- enet:x64-linux \
- sdl2:x64-linux \
- sdl2-mixer:x64-linux