fix Debian 8 Jessie and Ubuntu 14 Trusty compat
Fix some porting issues to make everything work on Debian 8 "Jessie" and Ubuntu 14 "Trusty": - set cmake minimum version to 2.8.12, this is the Ubuntu 14 version - combine C and C++ flags and add all of them using ADD_COMPILE_OPTIONS() without using generator expressions, which is a cmake 3.2 or so feature - add -fpermissive to force some non-const type casts to compile on older versions of gcc - add -std=c++11 for gcc to enable support on older versions of gcc - check that the compiler supports -fstack-protector-strong before adding it, older versions of gcc do not - fix the debian section of ./installdeps to include libpng-dev instead of libpng16-dev and add gettext for msginit etc. - fix compat checks in src/common/ffmpeg.cpp and src/wx/cmdevents.cpp to check for libavcodec >= 56 instead of > 56, the Debian Jessie version is exactly version 56 . With the one exception of AV_CODEC_FLAG_GLOBAL_HEADER which is defined in later versions.
This commit is contained in:
parent
fdc389c280
commit
34e408ccb7
|
@ -1,7 +1,7 @@
|
||||||
# The project's name is VBA-M it uses C and C++ code
|
# The project's name is VBA-M it uses C and C++ code
|
||||||
PROJECT(VBA-M C CXX)
|
PROJECT(VBA-M C CXX)
|
||||||
|
|
||||||
cmake_minimum_required( VERSION 3.3.2 )
|
cmake_minimum_required( VERSION 2.8.12 )
|
||||||
|
|
||||||
IF(CMAKE_BUILD_TYPE STREQUAL "")
|
IF(CMAKE_BUILD_TYPE STREQUAL "")
|
||||||
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build Type" FORCE)
|
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build Type" FORCE)
|
||||||
|
@ -286,57 +286,61 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
ENDIF(ENABLE_LTO)
|
ENDIF(ENABLE_LTO)
|
||||||
|
|
||||||
# common optimization flags
|
# common optimization flags
|
||||||
SET(MY_C_AND_CXX_OPT_FLAGS -O2 -mtune=generic -fomit-frame-pointer ${LTO_FLAG})
|
SET(MY_C_OPT_FLAGS -O2 -mtune=generic -fomit-frame-pointer ${LTO_FLAG})
|
||||||
|
|
||||||
# common debug flags
|
# common debug flags
|
||||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
SET(MY_C_AND_CXX_DBG_FLAGS -ggdb3 -Og)
|
SET(MY_C_DBG_FLAGS -ggdb3 -Og)
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(MY_C_AND_CXX_DBG_FLAGS -g)
|
SET(MY_C_DBG_FLAGS -g)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# common flags
|
# common flags
|
||||||
SET(MY_C_AND_CXX_FLAGS -pipe -fPIC -Wformat -Wformat-security -fstack-protector-strong --param ssp-buffer-size=4 -fexceptions -D_FORTIFY_SOURCE=2 -feliminate-unused-debug-types)
|
SET(MY_C_FLAGS -pipe -fPIC -fpermissive -Wformat -Wformat-security -fexceptions -D_FORTIFY_SOURCE=2 -feliminate-unused-debug-types)
|
||||||
|
|
||||||
SET(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_AND_CXX_FLAGS})
|
# check if SSP flags are supported
|
||||||
SET(MY_CXX_FLAGS ${MY_CXX_FLAGS} ${MY_C_AND_CXX_FLAGS})
|
INCLUDE(CheckCXXCompilerFlag)
|
||||||
|
CHECK_CXX_COMPILER_FLAG(-fstack-protector-strong F_STACK_PROTECTOR_STRONG_FLAG)
|
||||||
|
|
||||||
|
IF(F_STACK_PROTECTOR_STRONG_FLAG)
|
||||||
|
SET(MY_C_FLAGS ${MY_C_FLAGS} -fstack-protector-strong)
|
||||||
|
|
||||||
|
CHECK_CXX_COMPILER_FLAG("--param ssp-buffer-size=4" SSP_BUFFER_SIZE_FLAG)
|
||||||
|
|
||||||
|
IF(SSP_BUFFER_SIZE_FLAG)
|
||||||
|
SET(MY_C_FLAGS ${MY_C_FLAGS} --param ssp-buffer-size=4)
|
||||||
|
ENDIF()
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
# clang doesn't like -std=c++11 for non-C++ sources
|
||||||
|
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
SET(MY_C_FLAGS ${MY_C_FLAGS} -std=c++11)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
IF(MINGW)
|
IF(MINGW)
|
||||||
SET(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc)
|
SET(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc -static-libstdc++)
|
||||||
SET(MY_CXX_FLAGS ${MY_CXX_FLAGS} -static-libgcc -static-libstdc++)
|
|
||||||
ENDIF(MINGW)
|
ENDIF(MINGW)
|
||||||
|
|
||||||
IF(CMAKE_BUILD_TYPE STREQUAL Debug)
|
IF(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||||
SET(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_AND_CXX_DBG_FLAGS} -Wall -Wextra)
|
SET(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_DBG_FLAGS} -Wall -Wextra)
|
||||||
SET(MY_CXX_FLAGS ${MY_CXX_FLAGS} ${MY_C_AND_CXX_DBG_FLAGS} -Wall -Wextra)
|
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_AND_CXX_OPT_FLAGS} -Wno-error)
|
SET(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_OPT_FLAGS} -Wno-error)
|
||||||
SET(MY_CXX_FLAGS ${MY_CXX_FLAGS} ${MY_C_AND_CXX_OPT_FLAGS} -Wno-error)
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
FOREACH(C_COMPILE_FLAG ${MY_C_FLAGS})
|
FOREACH(C_COMPILE_FLAG ${MY_C_FLAGS})
|
||||||
ADD_COMPILE_OPTIONS($<$<COMPILE_LANGUAGE:C>:${C_COMPILE_FLAG}>)
|
ADD_COMPILE_OPTIONS(${C_COMPILE_FLAG})
|
||||||
ENDFOREACH()
|
|
||||||
|
|
||||||
FOREACH(CXX_COMPILE_FLAG ${MY_CXX_FLAGS})
|
|
||||||
ADD_COMPILE_OPTIONS($<$<COMPILE_LANGUAGE:CXX>:${CXX_COMPILE_FLAG}>)
|
|
||||||
ENDFOREACH()
|
ENDFOREACH()
|
||||||
|
|
||||||
# make a string of compile options to add to link flags
|
# make a string of compile options to add to link flags
|
||||||
UNSET(C_COMPILE_FLAGS_STR)
|
UNSET(C_COMPILE_FLAGS_STR)
|
||||||
UNSET(CXX_COMPILE_FLAGS_STR)
|
|
||||||
|
|
||||||
FOREACH(ARG ${MY_C_FLAGS})
|
FOREACH(ARG ${MY_C_FLAGS})
|
||||||
SET(C_COMPILE_FLAGS_STR "${C_COMPILE_FLAGS_STR} ${ARG}")
|
SET(C_COMPILE_FLAGS_STR "${C_COMPILE_FLAGS_STR} ${ARG}")
|
||||||
ENDFOREACH()
|
ENDFOREACH()
|
||||||
|
|
||||||
FOREACH(ARG ${MY_CXX_FLAGS})
|
|
||||||
SET(CXX_COMPILE_FLAGS_STR "${CXX_COMPILE_FLAGS_STR} ${ARG}")
|
|
||||||
ENDFOREACH()
|
|
||||||
|
|
||||||
# need all flags for linking, because of -flto etc.
|
# need all flags for linking, because of -flto etc.
|
||||||
SET(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${C_COMPILE_FLAGS_STR}")
|
SET(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${C_COMPILE_FLAGS_STR}")
|
||||||
SET(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${CXX_COMPILE_FLAGS_STR}")
|
SET(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${C_COMPILE_FLAGS_STR}")
|
||||||
|
|
||||||
# for the gcc -fstack-protector* flags we need libssp
|
# for the gcc -fstack-protector* flags we need libssp
|
||||||
# we also have to use the gcc- binutils for LTO to work
|
# we also have to use the gcc- binutils for LTO to work
|
||||||
|
|
|
@ -199,7 +199,7 @@ debian_installdeps() {
|
||||||
|
|
||||||
if [ -z "$target" ]; then
|
if [ -z "$target" ]; then
|
||||||
check sudo apt-get -qq update
|
check sudo apt-get -qq update
|
||||||
check sudo apt-get -qy install build-essential g++ nasm cmake zlib1g-dev libgl1-mesa-dev libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libgettextpo-dev libjpeg-dev libpng16-dev libtiff5-dev libsdl2-dev libsfml-dev libopenal-dev libwxgtk3.0-dev
|
check sudo apt-get -qy install build-essential g++ nasm cmake gettext zlib1g-dev libgl1-mesa-dev libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libgettextpo-dev libjpeg-dev libpng-dev libtiff5-dev libsdl2-dev libsfml-dev libopenal-dev libwxgtk3.0-dev
|
||||||
else
|
else
|
||||||
case "$target" in
|
case "$target" in
|
||||||
mingw-w64-i686)
|
mingw-w64-i686)
|
||||||
|
|
|
@ -58,12 +58,14 @@ static void avformat_free_context(AVFormatContext *ctx)
|
||||||
#ifndef PixelFormat
|
#ifndef PixelFormat
|
||||||
#define PixelFormat AVPixelFormat
|
#define PixelFormat AVPixelFormat
|
||||||
#endif
|
#endif
|
||||||
#if LIBAVCODEC_VERSION_MAJOR > 56
|
#if LIBAVCODEC_VERSION_MAJOR >= 56
|
||||||
#define CODEC_ID_NONE AV_CODEC_ID_NONE
|
#define CODEC_ID_NONE AV_CODEC_ID_NONE
|
||||||
#define CODEC_ID_PCM_S16LE AV_CODEC_ID_PCM_S16LE
|
#define CODEC_ID_PCM_S16LE AV_CODEC_ID_PCM_S16LE
|
||||||
#define CODEC_ID_PCM_S16BE AV_CODEC_ID_PCM_S16BE
|
#define CODEC_ID_PCM_S16BE AV_CODEC_ID_PCM_S16BE
|
||||||
#define CODEC_ID_PCM_U16LE AV_CODEC_ID_PCM_U16LE
|
#define CODEC_ID_PCM_U16LE AV_CODEC_ID_PCM_U16LE
|
||||||
#define CODEC_ID_PCM_U16BE AV_CODEC_ID_PCM_U16BE
|
#define CODEC_ID_PCM_U16BE AV_CODEC_ID_PCM_U16BE
|
||||||
|
#endif
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR > 56
|
||||||
#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
|
#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
|
||||||
#endif
|
#endif
|
||||||
#if LIBAVUTIL_VERSION_MAJOR > 54
|
#if LIBAVUTIL_VERSION_MAJOR > 54
|
||||||
|
@ -408,7 +410,7 @@ MediaRet MediaRecorder::AddFrame(const uint8_t *vid)
|
||||||
|
|
||||||
AVCodecContext *ctx = vid_st->codec;
|
AVCodecContext *ctx = vid_st->codec;
|
||||||
AVPacket pkt;
|
AVPacket pkt;
|
||||||
#if LIBAVCODEC_VERSION_MAJOR > 56
|
#if LIBAVCODEC_VERSION_MAJOR >= 56
|
||||||
int ret, got_packet = 0;
|
int ret, got_packet = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -448,7 +450,7 @@ MediaRet MediaRecorder::AddFrame(const uint8_t *vid)
|
||||||
pkt.data = f->data[0];
|
pkt.data = f->data[0];
|
||||||
pkt.size = linesize * ctx->height;
|
pkt.size = linesize * ctx->height;
|
||||||
} else {
|
} else {
|
||||||
#if LIBAVCODEC_VERSION_MAJOR > 56
|
#if LIBAVCODEC_VERSION_MAJOR >= 56
|
||||||
pkt.data = video_buf;
|
pkt.data = video_buf;
|
||||||
pkt.size = VIDEO_BUF_LEN;
|
pkt.size = VIDEO_BUF_LEN;
|
||||||
f->format = ctx->pix_fmt;
|
f->format = ctx->pix_fmt;
|
||||||
|
@ -486,7 +488,7 @@ MediaRet MediaRecorder::AddFrame(const uint8_t *vid)
|
||||||
return MRET_OK;
|
return MRET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LIBAVCODEC_VERSION_MAJOR > 56
|
#if LIBAVCODEC_VERSION_MAJOR >= 56
|
||||||
/* FFmpeg depricated avcodec_encode_audio.
|
/* FFmpeg depricated avcodec_encode_audio.
|
||||||
* It was removed completely in 3.0.
|
* It was removed completely in 3.0.
|
||||||
* This will at least get audio recording *working*
|
* This will at least get audio recording *working*
|
||||||
|
@ -560,7 +562,7 @@ MediaRet MediaRecorder::AddFrame(const uint16_t *aud)
|
||||||
}
|
}
|
||||||
while(len + in_audio_buf2 >= frame_len) {
|
while(len + in_audio_buf2 >= frame_len) {
|
||||||
av_init_packet(&pkt);
|
av_init_packet(&pkt);
|
||||||
#if LIBAVCODEC_VERSION_MAJOR > 56
|
#if LIBAVCODEC_VERSION_MAJOR >= 56
|
||||||
MediaRecorderEncodeAudio(ctx, &pkt, audio_buf, frame_len,
|
MediaRecorderEncodeAudio(ctx, &pkt, audio_buf, frame_len,
|
||||||
#else
|
#else
|
||||||
pkt.size = avcodec_encode_audio(ctx, audio_buf, frame_len,
|
pkt.size = avcodec_encode_audio(ctx, audio_buf, frame_len,
|
||||||
|
|
|
@ -113,7 +113,7 @@ SET(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_CMAKE_REQUIRED_DEFINITIONS})
|
||||||
# end of wx OpenGL check
|
# end of wx OpenGL check
|
||||||
|
|
||||||
FOREACH(CXX_COMPILE_FLAG ${wxWidgets_CXX_FLAGS})
|
FOREACH(CXX_COMPILE_FLAG ${wxWidgets_CXX_FLAGS})
|
||||||
ADD_COMPILE_OPTIONS($<$<COMPILE_LANGUAGE:CXX>:${CXX_COMPILE_FLAG}>)
|
ADD_COMPILE_OPTIONS(${CXX_COMPILE_FLAG})
|
||||||
ENDFOREACH()
|
ENDFOREACH()
|
||||||
|
|
||||||
#EXECUTE_PROCESS(COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --cxxflags)
|
#EXECUTE_PROCESS(COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --cxxflags)
|
||||||
|
|
|
@ -20,7 +20,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
// For compatibility with 3.0+ ffmpeg
|
// For compatibility with 3.0+ ffmpeg
|
||||||
#include <libavcodec/version.h>
|
#include <libavcodec/version.h>
|
||||||
#if LIBAVCODEC_VERSION_MAJOR > 56
|
#if LIBAVCODEC_VERSION_MAJOR >= 56
|
||||||
#define CODEC_ID_NONE AV_CODEC_ID_NONE
|
#define CODEC_ID_NONE AV_CODEC_ID_NONE
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue