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

Mostly CMake stuff #106

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b8d4188
VFileIO: Check XDG_DATA_DIRS properly
bb010g Jul 29, 2020
ac7a60c
Nix: Wrap a proper XDG system data directory in
bb010g Jul 29, 2020
5803fc1
OpenGL: Build clean with USE_OPENGL off.
bb010g Jul 29, 2020
6f4739b
SDL: Introduce USE_SDL option (required)
bb010g Jul 29, 2020
a6a04c8
SDL_gfx: Builds return (more features stubbed-out)
bb010g Jul 29, 2020
3bc4b93
Nix: Add `/shell.nix`
bb010g Jul 29, 2020
36eb4ae
CMake: Switch to upstream FindSQLite3
bb010g Jul 29, 2020
1c191c8
Only add subdirectories if necessary
skitt Jul 8, 2020
36f79c3
CMake: Minor refactoring & reformatting.
bb010g Jul 29, 2020
9b9ad83
CMake: Use IMPORTED targets
bb010g Jul 29, 2020
901f86d
CMake: Invoke target_sources from subdirectories
bb010g Jul 29, 2020
d188a03
CMake: Consistently format CMakeSources
bb010g Jul 29, 2020
7c18a8e
CMake: Use IMPORTED targets
bb010g Jul 29, 2020
2916470
CMake: Use IMPORTED targets
bb010g Jul 29, 2020
4839148
CMake: EXCLUDE_FROM_ALL vendored subdirectories
bb010g Jul 29, 2020
1a61d78
CMake: Use IMPORTED targets
bb010g Jul 29, 2020
c5087f1
CMake: No IMPORTED_LOCATION for INTERFACE targets
bb010g Jul 30, 2020
d9158e9
CMake: Blanket PREFER_SYSTEM & USE_SYSTEM options
bb010g Jul 31, 2020
dab1e2e
CMake: Fix vendored Lua includes
bb010g Jul 31, 2020
fb3f928
CI: Switch to Travis apt addon
bb010g Jul 30, 2020
75b08dc
CI: Switch to Travis homebrew addon
bb010g Jul 30, 2020
c0764e2
CI: Switch CMake to pinned 3.13.4
bb010g Jul 30, 2020
71db3e5
CI: MXE `make download` instead of APT repository
bb010g Jul 30, 2020
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ CTestTestfile.cmake

/[Bb]uild*/

## Direnv

/.envrc

## Nix

/result*
82 changes: 75 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,93 @@ dist: bionic
matrix:
include:
- os: linux
dist: bionic
install: ".travis/linux/deps.sh"
dist: bionic # 18.04 LTS
script: ".travis/linux/build.sh"
addons:
apt:
update: true
packages:
- curl
- libbz2-dev
- libcurl3-openssl-dev
- libgl1-mesa-dev
- libglu1-mesa-dev
- libjpeg-dev
- liblua5.1-0-dev
- libpng-dev
- libsdl-mixer1.2-dev
- libsdl-net1.2-dev
- libsdl-ttf2.0-dev
- libsdl1.2-dev
- libsqlite3-dev
- libxdg-basedir-dev
- libxml2-dev
- ninja-build
- rpm
- zlib1g-dev
before_install:
- ( shopt dotglob; sudo rm -rf /usr/local/cmake/* )
- >-
curl --retry 2 --retry-delay 30 'https://cmake.org/files/v3.13/cmake-3.13.4-Linux-x86_64.tar.gz' |
sudo tar -xz -C /usr/local/cmake --strip-components 1

- os: osx
osx_image: xcode10.1 # =10.13/high sierra
install: ".travis/macos/deps.sh"
script: ".travis/macos/build.sh"
addons:
homebrew:
update: true
packages:
- bzip2
- cmake
- curl
- gettext
- jpeg
- libpng
- libxml2
- ninja
- sdl
- sdl_mixer
- sdl_net
- sdl_ttf
- sqlite3
- zlib
cache:
directories:
- $HOME/Library/Caches/Homebrew
before_cache:
- brew cleanup

- os: linux
dist: bionic
name: "Linux MXE"
install: ".travis/linux-mxe/deps.sh"
- name: "Linux MXE"
os: linux
dist: bionic # 18.04 LTS
script: ".travis/linux-mxe/build.sh"
env:
- MXE_PATH="/usr/lib/mxe"
- MXE_HOST="x86_64-pc-linux-gnu"
- MXE_TARGET="i686-w64-mingw32.shared"
- PATH="$MXE_PATH/usr/bin:$PATH"
- MXE_HOST_PFX="$MXE_PATH/usr/$MXE_HOST/bin/$MXE_TARGET"
- MXE_CROSS_PFX="$MXE_PATH/usr/bin/$MXE_TARGET"
- WINEARCH="win32"
# add the MXE DLLs to Wine's path
- WINEPATH="$MXE_PATH/usr/$MXE_TARGET/bin${WINEPATH:+:$WINEPATH}"
before_install:
- sudo git clone "https://github.com/mxe/mxe" "$MXE_PATH"
- (cd "$MXE_PATH" && sudo make MXE_TARGETS="$MXE_TARGET"
download-{bzip2,cmake,curl,gcc,gettext,jpeg,libpng,libxml2,lzma,nsis,pkgconf,sdl,sdl_mixer,sdl_net,sdl_ttf,smpeg2,sqlite,zlib})
addons:
apt:
update: true
sources:
# for xvfb
- sourceline: 'deb http://archive.ubuntu.com/ubuntu bionic universe'
- sourceline: 'deb http://archive.ubuntu.com/ubuntu bionic-updates universe'
packages:
- ninja-build
- wine-stable
- wine32
- xvfb

deploy:
provider: releases
Expand Down
52 changes: 9 additions & 43 deletions .travis/linux-mxe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,19 @@

set -ex

# needed for cmake to find some programs
export PATH="/usr/lib/mxe/usr/bin:$PATH"

mkdir build && cd build
mkdir -p /tmp/xmoto

MXE_PATH=/usr/lib/mxe
MXE_TARGET="i686-w64-mingw32.shared"

is_broken_symlink() {
if [ -L "$1" ] && [ ! -e "$1" ]; then
return 0
else
return 1
fi
}

relink() {
for prog in "$@"; do
if is_broken_symlink "$MXE_HOST_PFX-$prog"; then
sudo rm "$MXE_HOST_PFX-$prog"
sudo ln -s "$MXE_CROSS_PFX-$prog" "$MXE_HOST_PFX-$prog"
fi
done
}

MXE_HOST_PFX="$MXE_PATH/usr/x86_64-pc-linux-gnu/bin/$MXE_TARGET"
MXE_CROSS_PFX="$MXE_PATH/usr/bin/$MXE_TARGET"

# add the mxe DLLs to wine's path
export WINEPATH="$MXE_PATH/usr/$MXE_TARGET/bin${WINEPATH:+:${WINEPATH}}"
export WINEARCH=win32
mkdir -p /tmp/xminstall

echo "MXE_PATH: $MXE_PATH"
echo "MXE HOST PREFIX: $MXE_HOST_PFX"
echo "MXE CROSS PREFIX: $MXE_CROSS_PFX"
echo "WINEPATH: $WINEPATH"

relink "gcc" "g++"
"$MXE_TARGET-cmake" -D CMAKE_INSTALL_PREFIX=/tmp/xminstall \
-D XMOTO_PACK=manual \
-D CMAKE_BUILD_TYPE=Release -G Ninja ..

"$MXE_CROSS_PFX-cmake" \
-DCMAKE_INSTALL_PREFIX=/tmp/xmoto \
-DCMAKE_BUILD_TYPE=Release \
-DXMOTO_PACK=manual ..

make -j"$(nproc)"
ninja

Xvfb :0 -screen 0 1024x768x16 &
xvfb_pid=$!
Expand All @@ -57,7 +24,7 @@ sleep 5
echo "pidof Xvfb:"
pidof Xvfb

make xmoto_pack
ninja xmoto_pack

# not that any reasonable PID 1 responds to SIGTERM anyway ;)
if [ "$xvfb_pid" -gt 1 ]; then
Expand All @@ -67,10 +34,10 @@ fi
# aaand if the graceful termination doesn't work..
jobs -p | xargs -r kill -9

#make install
#ninja install

"$MXE_CROSS_PFX"-cpack -G "NSIS"
"$MXE_CROSS_PFX"-cpack -G "ZIP"
"$MXE_TARGET"-cpack -G "NSIS"
"$MXE_TARGET"-cpack -G "ZIP"

fix_pkg_name() {
if [ -z "$1" ] || [ -z "$2" ]; then
Expand All @@ -88,4 +55,3 @@ for pkg in xmoto-*.exe; do fix_pkg_name "$pkg" "win32-setup"; done
mkdir artifacts
mv xmoto-*.exe artifacts/
mv xmoto-*.zip artifacts/

17 changes: 0 additions & 17 deletions .travis/linux-mxe/deps.sh

This file was deleted.

5 changes: 2 additions & 3 deletions .travis/linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -ex

mkdir build && cd build
mkdir -p /tmp/xminstall
cmake -DCMAKE_INSTALL_PREFIX=/tmp/xminstall \
-DCMAKE_BUILD_TYPE=Release -G Ninja ..
cmake -D CMAKE_INSTALL_PREFIX=/tmp/xminstall \
-D CMAKE_BUILD_TYPE=Release -G Ninja ..
ninja
ninja xmoto_pack
ninja install
Expand All @@ -16,4 +16,3 @@ cpack -G "RPM"
mkdir artifacts
mv xmoto-*.deb artifacts/
mv xmoto-*.rpm artifacts/

12 changes: 0 additions & 12 deletions .travis/linux/deps.sh

This file was deleted.

5 changes: 2 additions & 3 deletions .travis/macos/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -ex

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release \
-DBUILD_MACOS_BUNDLE=ON -G Ninja ..
cmake -D BUILD_MACOS_BUNDLE=ON \
-D CMAKE_BUILD_TYPE=Release -G Ninja ..
ninja

# Homebrew on Catalina (10.15) sets inconsistent permissions on dylibs
Expand All @@ -14,4 +14,3 @@ sudo \

mkdir artifacts
mv xmoto-*.dmg artifacts/

15 changes: 0 additions & 15 deletions .travis/macos/deps.sh

This file was deleted.

10 changes: 10 additions & 0 deletions CMake/FindLuaTargets.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if(LUA_FOUND AND NOT TARGET Lua::Lua)
add_library(Lua::Lua UNKNOWN IMPORTED)
set_target_properties(Lua::Lua PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}"
IMPORTED_LOCATION "${LUA_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${LUA_LIBRARIES}"
VERSION "${LUA_VERSION_STRING}"
)
endif()

58 changes: 58 additions & 0 deletions CMake/FindSDLTargets.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
if(SDL_FOUND AND NOT TARGET SDL::SDL)
add_library(SDL::SDL INTERFACE IMPORTED)
set_target_properties(SDL::SDL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${SDL_LIBRARY}"
# VERSION "${SDL_VERSION_STRING}"
)
endif()

if(SDL_GFX_FOUND AND NOT TARGET SDL::SDL_gfx)
add_library(SDL::SDL_gfx UNKNOWN IMPORTED)
set_target_properties(SDL::SDL_gfx PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_GFX_INCLUDE_DIRS}"
IMPORTED_LOCATION "${SDL_GFX_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${SDL_GFX_LIBRARIES}"
VERSION "${SDL_GFX_VERSION_STRING}"
)
endif()

if(SDL_MIXER_FOUND AND NOT TARGET SDL::SDL_mixer)
add_library(SDL::SDL_mixer UNKNOWN IMPORTED)
set_target_properties(SDL::SDL_mixer PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_MIXER_INCLUDE_DIRS}"
IMPORTED_LOCATION "${SDL_MIXER_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${SDL_MIXER_LIBRARIES}"
VERSION "${SDL_MIXER_VERSION_STRING}"
)
endif()

if(SDL_NET_FOUND AND NOT TARGET SDL::SDL_net)
add_library(SDL::SDL_net UNKNOWN IMPORTED)
set_target_properties(SDL::SDL_net PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_NET_INCLUDE_DIRS}"
IMPORTED_LOCATION "${SDL_NET_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${SDL_NET_LIBRARIES}"
VERSION "${SDL_NET_VERSION_STRING}"
)
endif()

if(SDL_SOUND_FOUND AND NOT TARGET SDL::SDL_sound)
add_library(SDL::SDL_sound UNKNOWN IMPORTED)
set_target_properties(SDL::SDL_sound PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_SOUND_INCLUDE_DIRS}"
IMPORTED_LOCATION "${SDL_SOUND_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${SDL_SOUND_LIBRARIES}"
VERSION "${SDL_SOUND_VERSION_STRING}"
)
endif()

if(SDL_TTF_FOUND AND NOT TARGET SDL::SDL_ttf)
add_library(SDL::SDL_ttf UNKNOWN IMPORTED)
set_target_properties(SDL::SDL_ttf PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_TTF_INCLUDE_DIRS}"
IMPORTED_LOCATION "${SDL_TTF_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${SDL_TTF_LIBRARIES}"
VERSION "${SDL_TTF_VERSION_STRING}"
)
endif()