From d9e4a0874dd22e409c7bd615c206309f2f45cd71 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Sat, 31 Aug 2019 22:58:59 +0000 Subject: [PATCH] build fixes: ffmpeg, xbrz, travis, C++ version Fix the cmake ffmpeg detection and make it not print the detection messages twice. Add `-D__STDC_FORMAT_MACROS` to compiler flags, some versions of ffmpeg require this. Redefine `static_assert(x)` to the `static_assert(x, msg)` form in `xbrz.cpp`. This is a C++17 feature and some versions of gcc wrongly set `__cpp_static_assert` even though they do not support it. Also we want to stick to C++11 for the time being, until there is consensus to support a newer a version. For that reason, change the MSVC flag `/std:c++latest` to `/std:c++11` as well. Remove `-DENABLE_OPENAL=ON` and `-DENABLE_LINK=ON` from travis config, as these are now automatic. In `installdeps` remove the hacks for supporting the `https://` apt url for mxe and use an `http://` url instead. This works perfectly on Ubuntu 14 (trusty). Signed-off-by: Rafael Kitover --- .travis.yml | 8 ++++---- CMakeLists.txt | 23 +++++++++++++---------- installdeps | 31 +------------------------------ src/filters/xBRZ/xbrz.cpp | 4 +++- 4 files changed, 21 insertions(+), 45 deletions(-) diff --git a/.travis.yml b/.travis.yml index 70d20554..c3e77ba6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ matrix: script: - mkdir build - cd build - - cmake .. -DENABLE_SDL=ON -DENABLE_OPENAL=ON + - cmake .. -DENABLE_SDL=ON - make -j2 - xvfb-run ./visualboyadvance-m --help cache: @@ -31,7 +31,7 @@ matrix: script: - mkdir build - cd build - - /usr/lib/mxe/usr/bin/x86_64-w64-mingw32.static-cmake .. -DENABLE_SDL=ON -DENABLE_OPENAL=ON + - /usr/lib/mxe/usr/bin/x86_64-w64-mingw32.static-cmake .. -DENABLE_SDL=ON - make -j2 cache: directories: @@ -45,7 +45,7 @@ matrix: script: - mkdir build - cd build - - /usr/lib/mxe/usr/bin/i686-w64-mingw32.static-cmake .. -DENABLE_SDL=ON -DENABLE_OPENAL=ON + - /usr/lib/mxe/usr/bin/i686-w64-mingw32.static-cmake .. -DENABLE_SDL=ON - make -j2 cache: directories: @@ -72,7 +72,7 @@ matrix: script: - mkdir build - cd build - - cmake .. -DENABLE_SDL=ON -DENABLE_OPENAL=ON -DENABLE_LINK=ON + - cmake .. -DENABLE_SDL=ON - make -j2 # - ./visualboyadvance-m.app/Contents/MacOS/visualboyadvance-m --help cache: diff --git a/CMakeLists.txt b/CMakeLists.txt index 791d3ca5..259a79b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,17 +121,16 @@ set(FFMPEG_DEFAULT OFF) find_package(PkgConfig) if(PKGCONFIG_FOUND) - set(FFMPEG_DEFAULT ON) + set(FFMPEG_DEFAULT ON) - foreach(ffmpeg_lib libavcodec libavformat libswscale libavutil libswresample) - unset(FFMPEG_LIB) - pkg_check_modules(FFMPEG_LIB ${ffmpeg_lib}) + foreach(ffmpeg_lib libavcodec libavformat libswscale libavutil libswresample) + pkg_check_modules(FFMPEG_LIB_${ffmpeg_lib} ${ffmpeg_lib} QUIET) - if(NOT FFMPEG_LIB_FOUND) - set(FFMPEG_DEFAULT OFF) - break() - endif() - endforeach() + if(NOT FFMPEG_LIB_${ffmpeg_lib}_FOUND) + set(FFMPEG_DEFAULT OFF) + break() + endif() + endforeach() endif() option(ENABLE_FFMPEG "Enable ffmpeg A/V recording" ${FFMPEG_DEFAULT}) @@ -326,6 +325,8 @@ include(GNUInstallDirs) add_definitions(-DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DHAVE_ZLIB_H -DFINAL_VERSION -DSDL -DUSE_OPENGL -DSYSCONF_INSTALL_DIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}" -DWITH_LIRC=${WITHLIRC}) add_definitions(-DPKGDATADIR="${CMAKE_INSTALL_FULL_DATADIR}/vbam" -DPACKAGE=) +add_definitions(-D__STDC_FORMAT_MACROS) + if(ENABLE_LINK) # IPC linking code needs sem_timedwait which can be either in librt or pthreads if(NOT WIN32) @@ -557,6 +558,8 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) add_compile_options(${C_COMPILE_FLAG}) endforeach() + include(CheckCXXCompilerFlag) + set(MY_CXX_FLAGS -std=gnu++11 -fexceptions) foreach(ARG ${MY_CXX_FLAGS}) @@ -611,7 +614,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${MY_C_LINKER_FLAGS_STR}") set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${MY_C_LINKER_FLAGS_STR}") elseif(MSVC) - add_compile_options(/std:c++latest) + add_compile_options(/std:c++11) if(CMAKE_BUILD_TYPE STREQUAL Debug) add_compile_options(/W4) diff --git a/installdeps b/installdeps index bc542b63..13051fc2 100755 --- a/installdeps +++ b/installdeps @@ -318,43 +318,14 @@ debian_installdeps() { ;; esac - # if on the travis ubuntu trusty, add xenial sources for newer gnutls - # otherwise the mxe pkg server does not work - if [ -n "$TRAVIS" ]; then - if grep -q trusty /etc/apt/sources.list 2>/dev/null; then - sudo sh -c "sed 's/trusty/xenial/g' /etc/apt/sources.list > /etc/apt/sources.list.d/xenial.list" - fi - fi - - sudo apt-get -qq -y update - - curl_gnutls_lib=$(apt-cache search libcurl | grep -E '^libcurl[0-9]+-gnutls - ' | sed 's/ - .*//' | sort | tail -1) - - sudo apt-get -qy install apt apt-transport-https ca-certificates $curl_gnutls_lib curl - - # this is necessary to upgrade libcurl from trusty to xenial on travis - sudo apt-get -qy -f install - debian_rel=trusty - - apt_ssl_exceptions=/etc/apt/apt.conf.d/80ssl-exceptions - - if ! grep -Eq '(pkg|mirror)\.mxe\.cc' $apt_ssl_exceptions 2>/dev/null; then - sudo sh -c "cat >> $apt_ssl_exceptions" < $mxe_apt_sources" + echo "deb http://pkg.mxe.cc/repos/apt $debian_rel main" | sudo -- sh -c "cat > $mxe_apt_sources" sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C6BF758A33A3A276 || : else error "$mxe_apt_sources exists but mxe packages are not found in apt, either delete it or fix it" diff --git a/src/filters/xBRZ/xbrz.cpp b/src/filters/xBRZ/xbrz.cpp index c6dc14ea..6c118b71 100644 --- a/src/filters/xBRZ/xbrz.cpp +++ b/src/filters/xBRZ/xbrz.cpp @@ -21,8 +21,10 @@ #include //std::sqrt #include "xbrz_tools.h" -using namespace xbrz; +// some gcc versions lie about having this C++17 feature +#define static_assert(x) static_assert(x, "assertion failed") +using namespace xbrz; namespace {