diff --git a/CMakeLists.txt b/CMakeLists.txt index d0f4423b..b81f5cda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # The project's name is VBA-M it uses C and C++ code PROJECT(VBA-M C CXX) -cmake_minimum_required( VERSION 3.3.2 ) +cmake_minimum_required( VERSION 2.8.12 ) IF(CMAKE_BUILD_TYPE STREQUAL "") 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) # 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 IF(CMAKE_COMPILER_IS_GNUCXX) - SET(MY_C_AND_CXX_DBG_FLAGS -ggdb3 -Og) + SET(MY_C_DBG_FLAGS -ggdb3 -Og) ELSE() - SET(MY_C_AND_CXX_DBG_FLAGS -g) + SET(MY_C_DBG_FLAGS -g) ENDIF() # 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}) - SET(MY_CXX_FLAGS ${MY_CXX_FLAGS} ${MY_C_AND_CXX_FLAGS}) + # check if SSP flags are supported + 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) - SET(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc) - SET(MY_CXX_FLAGS ${MY_CXX_FLAGS} -static-libgcc -static-libstdc++) + SET(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc -static-libstdc++) ENDIF(MINGW) IF(CMAKE_BUILD_TYPE STREQUAL Debug) - SET(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_AND_CXX_DBG_FLAGS} -Wall -Wextra) - SET(MY_CXX_FLAGS ${MY_CXX_FLAGS} ${MY_C_AND_CXX_DBG_FLAGS} -Wall -Wextra) + SET(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_DBG_FLAGS} -Wall -Wextra) ELSE() - SET(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_AND_CXX_OPT_FLAGS} -Wno-error) - SET(MY_CXX_FLAGS ${MY_CXX_FLAGS} ${MY_C_AND_CXX_OPT_FLAGS} -Wno-error) + SET(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_OPT_FLAGS} -Wno-error) ENDIF() FOREACH(C_COMPILE_FLAG ${MY_C_FLAGS}) - ADD_COMPILE_OPTIONS($<$:${C_COMPILE_FLAG}>) - ENDFOREACH() - - FOREACH(CXX_COMPILE_FLAG ${MY_CXX_FLAGS}) - ADD_COMPILE_OPTIONS($<$:${CXX_COMPILE_FLAG}>) + ADD_COMPILE_OPTIONS(${C_COMPILE_FLAG}) ENDFOREACH() # make a string of compile options to add to link flags UNSET(C_COMPILE_FLAGS_STR) - UNSET(CXX_COMPILE_FLAGS_STR) FOREACH(ARG ${MY_C_FLAGS}) SET(C_COMPILE_FLAGS_STR "${C_COMPILE_FLAGS_STR} ${ARG}") 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. 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 # we also have to use the gcc- binutils for LTO to work diff --git a/installdeps b/installdeps index df5ed763..1391e143 100755 --- a/installdeps +++ b/installdeps @@ -199,7 +199,7 @@ debian_installdeps() { if [ -z "$target" ]; then 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 case "$target" in mingw-w64-i686) diff --git a/src/common/ffmpeg.cpp b/src/common/ffmpeg.cpp index 5f0f27a3..e0db8d22 100644 --- a/src/common/ffmpeg.cpp +++ b/src/common/ffmpeg.cpp @@ -58,12 +58,14 @@ static void avformat_free_context(AVFormatContext *ctx) #ifndef PixelFormat #define PixelFormat AVPixelFormat #endif -#if LIBAVCODEC_VERSION_MAJOR > 56 +#if LIBAVCODEC_VERSION_MAJOR >= 56 #define CODEC_ID_NONE AV_CODEC_ID_NONE #define CODEC_ID_PCM_S16LE AV_CODEC_ID_PCM_S16LE #define CODEC_ID_PCM_S16BE AV_CODEC_ID_PCM_S16BE #define CODEC_ID_PCM_U16LE AV_CODEC_ID_PCM_U16LE #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 #endif #if LIBAVUTIL_VERSION_MAJOR > 54 @@ -408,7 +410,7 @@ MediaRet MediaRecorder::AddFrame(const uint8_t *vid) AVCodecContext *ctx = vid_st->codec; AVPacket pkt; -#if LIBAVCODEC_VERSION_MAJOR > 56 +#if LIBAVCODEC_VERSION_MAJOR >= 56 int ret, got_packet = 0; #endif @@ -448,7 +450,7 @@ MediaRet MediaRecorder::AddFrame(const uint8_t *vid) pkt.data = f->data[0]; pkt.size = linesize * ctx->height; } else { -#if LIBAVCODEC_VERSION_MAJOR > 56 +#if LIBAVCODEC_VERSION_MAJOR >= 56 pkt.data = video_buf; pkt.size = VIDEO_BUF_LEN; f->format = ctx->pix_fmt; @@ -486,7 +488,7 @@ MediaRet MediaRecorder::AddFrame(const uint8_t *vid) return MRET_OK; } -#if LIBAVCODEC_VERSION_MAJOR > 56 +#if LIBAVCODEC_VERSION_MAJOR >= 56 /* FFmpeg depricated avcodec_encode_audio. * It was removed completely in 3.0. * 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) { av_init_packet(&pkt); - #if LIBAVCODEC_VERSION_MAJOR > 56 + #if LIBAVCODEC_VERSION_MAJOR >= 56 MediaRecorderEncodeAudio(ctx, &pkt, audio_buf, frame_len, #else pkt.size = avcodec_encode_audio(ctx, audio_buf, frame_len, diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index 852d676c..c53ecf51 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -113,7 +113,7 @@ SET(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_CMAKE_REQUIRED_DEFINITIONS}) # end of wx OpenGL check FOREACH(CXX_COMPILE_FLAG ${wxWidgets_CXX_FLAGS}) - ADD_COMPILE_OPTIONS($<$:${CXX_COMPILE_FLAG}>) + ADD_COMPILE_OPTIONS(${CXX_COMPILE_FLAG}) ENDFOREACH() #EXECUTE_PROCESS(COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --cxxflags) diff --git a/src/wx/cmdevents.cpp b/src/wx/cmdevents.cpp index 55124451..a8c27ac8 100644 --- a/src/wx/cmdevents.cpp +++ b/src/wx/cmdevents.cpp @@ -20,7 +20,7 @@ extern "C" { } // For compatibility with 3.0+ ffmpeg #include -#if LIBAVCODEC_VERSION_MAJOR > 56 +#if LIBAVCODEC_VERSION_MAJOR >= 56 #define CODEC_ID_NONE AV_CODEC_ID_NONE #endif #endif