Skip to content
Permalink
Browse files

wx 2.8 compat fixes, centos support, cmake fixes

Add support for RHEL/centos to installdeps. There is no SFML package.

Add some string compatibility stuff so that everything builds on wx 2.8
unicode builds.

TODO: add travis slaves for 2.8, with and without unicode

Disable the game frame spacer code on 2.8 because it does not work (the
frame does not expand.)

cmake improvements:

- set ENABLE_LTO=OFF for Debug builds by default

- set ENABLE_LINK=OFF if SFML cannot be found and continue

- use better logic for finding wx utilities wx-config and wxrc

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Closes #395
Closes #297
  • Loading branch information
rkitover committed Mar 28, 2019
1 parent b69fced commit 2097b5aaa59ee5f13a654b0a22d1f9c3687c985f
Showing with 413 additions and 155 deletions.
  1. +16 −5 CMakeLists.txt
  2. +2 −2 README.md
  3. +188 −2 installdeps
  4. +65 −10 src/wx/CMakeLists.txt
  5. +18 −18 src/wx/cmdevents.cpp
  6. +29 −30 src/wx/guiinit.cpp
  7. +1 −1 src/wx/openal.cpp
  8. +24 −24 src/wx/opts.cpp
  9. +29 −22 src/wx/panel.cpp
  10. +11 −11 src/wx/sys.cpp
  11. +1 −1 src/wx/viewers.cpp
  12. +1 −1 src/wx/viewsupt.h
  13. +28 −28 src/wx/wxvbam.cpp
@@ -116,8 +116,9 @@ option(ENABLE_FFMPEG "Enable ffmpeg A/V recording" ${FFMPEG_DEFAULT})

set(LTO_DEFAULT ON)

if(WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND AMD64)
# lto produces buggy binaries for 64 bit win32
# lto produces buggy binaries for 64 bit win32
# and we generally don't want it when debugging because it makes linking slow
if((WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND AMD64) OR CMAKE_BUILD_TYPE MATCHES Debug)
set(LTO_DEFAULT OFF)
endif()

@@ -168,7 +169,7 @@ endif()
include_directories(${CMAKE_BINARY_DIR})
configure_file("${CMAKE_SOURCE_DIR}/src/version.h.in" "${CMAKE_BINARY_DIR}/version.h" @ONLY)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DDEBUG)
else()
add_definitions(-DNDEBUG)
@@ -196,7 +197,11 @@ endif()

# Look for some dependencies using CMake scripts
find_package(ZLIB REQUIRED)

set(OpenGL_GL_PREFERENCE GLVND)

find_package(OpenGL REQUIRED)

find_package(PNG REQUIRED)

if(EXISTS /etc/redhat-release)
@@ -220,7 +225,13 @@ if(ENABLE_LINK)
if(WIN32 AND ((NOT (MINGW AND MSYS)) OR CMAKE_TOOLCHAIN_FILE MATCHES mxe) AND NOT CMAKE_TOOLCHAIN_FILE MATCHES vcpkg)
set(SFML_STATIC_LIBRARIES TRUE)
endif()
find_package(SFML 2 COMPONENTS network system REQUIRED)

find_package(SFML 2 COMPONENTS network system)

if(NOT SFML_FOUND)
message(WARNING "SFML not found, LINK will be disabled")
set(ENABLE_LINK NO)
endif()
endif()

# set the standard libraries all ports use
@@ -479,7 +490,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc -static-libstdc++)
endif()

if(CMAKE_BUILD_TYPE STREQUAL Debug)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_DBG_FLAGS} -Wall -Wextra)
else()
set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_OPT_FLAGS} -Wno-error)
@@ -60,8 +60,8 @@ cmake ..
make -j`nproc`
```

`./installdeps` is supported on MSys2, Linux (Debian/Ubuntu, Fedora, Arch or
Solus) and Mac OS X (homebrew, macports or fink.)
`./installdeps` is supported on MSys2, Linux (Debian/Ubuntu, Fedora, Arch,
Solus and RHEL/CentOS) and Mac OS X (homebrew, macports or fink.)

The Ninja cmake generator is also now supported, including on msys2 and Visual Studio.

@@ -155,6 +155,8 @@ linux_installdeps() {
debian_installdeps
elif [ -f /etc/fedora-release ]; then
fedora_installdeps
elif [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
rhel_installdeps
elif [ -f /etc/arch-release ]; then
archlinux_installdeps
elif [ -f /etc/solus-release ]; then
@@ -407,7 +409,7 @@ fedora_installdeps() {
fi

# non-multiarch packages first
check sudo dnf -y --nogpgcheck --best --allowerasing install gcc gcc-c++ make cmake ccache git nasm redhat-rpm-config pkgconfig ccache
check sudo dnf -y --nogpgcheck --best --allowerasing install gcc gcc-c++ make cmake ccache git nasm redhat-rpm-config pkgconfig ccache ninja-build

# try to install multiarch libgcc, glibc-devel and pkgconfig if available
if [ -n "$amd64" ]; then
@@ -427,7 +429,7 @@ fedora_installdeps() {
# this is sometimes necessary for rawhide
set -- --exclude='glibc32*'
fi
for pkg in zlib-devel mesa-libGL-devel ffmpeg-devel gettext-devel libpng-devel SDL2-devel SFML-devel openal-soft-devel wxGTK3-devel gtk2-devel gtk3-devel; do
for pkg in zlib-devel mesa-libGL-devel ffmpeg-devel gettext-devel libpng-devel SDL2-devel SFML-devel openal-soft-devel wxGTK3-devel gtk3-devel; do
case $pkg in
*ffmpeg*)
[ -n "$no_ffmpeg" ] && continue
@@ -535,6 +537,190 @@ fedora_installdeps() {
build_instructions
}

rhel_installdeps() {
rhel=1
ffmpeg=ffmpeg-devel
no_ffmpeg=
rpms_installed=

check_cross
installing

warning=

rhel_release=$(rpm -E %rhel)
tries=3
curdir=$(pwd)

# this source is necessary for mingw packages on rhel, and may be for other things in the future
check sudo yum -y install epel-release

# make sure rpmfusion is installed for ffmpeg
while [ $tries -gt 0 ]; do
mkdir -p "${tmp}/fusion"
cd "${tmp}/fusion"
if ! curl -fLO https://download1.rpmfusion.org/free/el/rpmfusion-free-release-${rhel_release}.noarch.rpm; then
rhel_release=$((rhel_release - 1))
tries=$((tries - 1))
continue
fi
if ! curl -fLO https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-${rhel_release}.noarch.rpm; then
tries=0
break
fi
# check if already installed
if rpm -q rpmfusion-free-release-${rhel_release} >/dev/null 2>&1 && rpm -q rpmfusion-nonfree-release-${rhel_release} >/dev/null 2>&1; then
info_msg 'rpmfusion already installed, good'
break
fi
# otherwise try to install
if ! sudo rpm --nodeps -Uvh ./rpmfusion-*.rpm; then
tries=0
break
fi
break
done
cd "$curdir"
if [ $tries -eq 0 ]; then
warning 'installing rpmfusion repos failed, continuing without ffmpeg'
no_ffmpeg=1
cmake_flags="$cmake_flags -DENABLE_FFMPEG=NO"
fi

# non-multiarch packages first
CMAKE=cmake3
check sudo yum -y install gcc gcc-c++ make cmake3 ccache git nasm redhat-rpm-config pkgconfig ccache ninja-build

# try to install multiarch libgcc, glibc-devel and pkgconfig if available
if [ -n "$amd64" ]; then
for pkg in pkgconfig libgcc glibc-devel; do
if [ "$target" = m32 ]; then
sudo yum -y install "$pkg".i686
else
sudo yum -y install "$pkg".x86_64
fi
done
fi

set --
if [ -z "$target" -o "$target" = m32 ]; then
# try to install both 64 bit and 32 bit versions on 64 bit hosts (see below)
if [ -n "$amd64" ]; then
# this is sometimes necessary for rawhide
set -- --exclude='glibc32*'
fi

warning='RHEL does not currently have SFML packages, LINK support will be disabled'
cmake_flags="$cmake_flags -DENABLE_LINK=NO"

for pkg in zlib-devel mesa-libGL-devel ffmpeg-devel gettext-devel libpng-devel SDL2-devel openal-soft-devel wxGTK3-devel gtk3-devel wxGTK-devel; do
case $pkg in
*ffmpeg*)
[ -n "$no_ffmpeg" ] && continue
;;
esac

if [ -n "$amd64" ]; then
if [ "$target" = m32 ]; then
set -- "$@" "${pkg}.i686"
else
set -- "$@" "${pkg}.x86_64"
fi
else
set -- "$@" "$pkg"
fi
done

# redhat has a bug where all necessary -devel packages are not pulled in for 32 bit direct -devel deps
# this hack adds them to the list
if [ -n "$amd64" -a "$target" = m32 ]; then
info_msg 'Calculating dependencies, this will take a while..'
curdeps=
newdeps=$@
while [ "$curdeps" != "$newdeps" ]; do
curdeps=$newdeps
set -- $(echo "$@" $(repoquery --deplist "$@" 2>/dev/null | sed -n 's/\.x86_64$/.i686/; s/^ *provider: *\([^ ]*-devel-.*\)$/\1/p' | sort -u) | sed 's/ */\n/g' | sort -u)
newdeps=$@
printf '%s' .
done

echo
info_msg 'Done'

## install the RPMs with rpm --force get around file conflicts

host_rpms=$(echo "$@" | sed 's/\.i686//g')

# first update the host arch versions to reduce chances of conflicts
check sudo yum -y install $host_rpms

oldcwd=$PWD
mkdir "$tmp/rpms"
cd "$tmp/rpms"

check sudo yum -y download "$@"

# first try installing with yum to pull in deps
check sudo yum -y --skip-broken install *.rpm

# follow up with rpm --force to ignore conflicts
check sudo rpm -Uvh --force *.rpm

rm -f *.rpm

# reinstall the host rpms to make sure any overwritten files are the host version
check sudo yum -y download $host_rpms

check sudo yum -y --skip-broken install *.rpm

check sudo rpm -Uvh --force *.rpm

cd "$oldcwd"
rm -rf "$tmp/rpms"

ffmpeg=ffmpeg-devel.i686

rpms_installed=1
fi
else # mingw build
set -- "$@" pkgconfig
case "$target" in
mingw-w64-i686)
target=mingw32
cmake_flags="$cmake_flags -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-MinGW-w64-i686.cmake -DENABLE_LINK=NO"
;;
mingw-w64-x86_64)
target=mingw64
cmake_flags="$cmake_flags -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-MinGW-w64-x86_64.cmake -DENABLE_LINK=NO"
;;
*)
error 'unknown cross target (this should not happen)'
;;
esac
# install static deps
for pkg in zlib gettext libpng SDL2 wxWidgets; do
set -- "$@" "${target}-${pkg}-static"
done
# install deps that are not available as static
for pkg in openal-soft; do
set -- "$@" "${target}-${pkg}"
done

warning='SFML is required for LINK support, RHEL/EPEL does not currently have a MinGW SFML package, if you want LINK support you will need to install it manually'
fi

[ -z "$rpms_installed" ] && check sudo yum -y install "$@"

if ! rpm -q $ffmpeg >/dev/null 2>&1; then
warning 'ffmpeg failed to install (probably due to conflicts)'
cmake_flags="$cmake_flags -DENABLE_FFMPEG=NO"
fi

[ -n "$warning" ] && warning "$warning"

build_instructions
}

suse_installdeps() {
suse=1
check_cross

0 comments on commit 2097b5a

Please sign in to comment.
You can’t perform that action at this time.