From bba072d54e7d99f544774ad70a03915ee11b48cc Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 27 Nov 2017 21:26:03 +0100 Subject: [PATCH] VST build fixes --- cmake/linux/winegcc_wrapper.in | 63 +++++++++++++++++++ cmake/modules/FindWine.cmake | 13 +++- plugins/vst_base/CMakeLists.txt | 20 +++--- .../vst_base/RemoteVstPlugin/CMakeLists.txt | 2 +- plugins/vst_base/RemoteVstPlugin/winegcc | 49 --------------- plugins/vst_base/VstPlugin.cpp | 4 +- src/core/RemotePlugin.cpp | 2 +- 7 files changed, 90 insertions(+), 63 deletions(-) create mode 100755 cmake/linux/winegcc_wrapper.in delete mode 100755 plugins/vst_base/RemoteVstPlugin/winegcc diff --git a/cmake/linux/winegcc_wrapper.in b/cmake/linux/winegcc_wrapper.in new file mode 100755 index 000000000..5894c593d --- /dev/null +++ b/cmake/linux/winegcc_wrapper.in @@ -0,0 +1,63 @@ +#!/bin/sh +# Wrapper script for winegcc to remove .exe file ending automatically +# appended by winebuild. +# Usage: winegcc + +set -e + +args="$@" + +# Find output name, link mode and architecture +while [ $# -gt 0 ]; do + key="$1" + + case $key in + -o) + output=$2 + shift + ;; + -c) + no_link=true + ;; + -m32) + win32=true + ;; + *) + + ;; + esac + + shift +done + +if [ -z "$output" ]; then + # If -c is used without specifying an output name, GCC defaults to "a.out". + if [ "$no_link" != true ]; then + output="a.out" + no_move=true + fi +fi + +# Some Wine distributions can't find their own headers. WINE_INCLUDE_DIR provided +# by FindWine.cmake +extra_args="-I@WINE_INCLUDE_DIR@" + +# Apply -m32 library fix if necessary +if [ "$win32" = true ] && [ "$no_link" != true ]; then + extra_args="$extra_args @WINE_32_FLAGS@" +fi + +# Run winegcc +export WINEBUILD=@WINE_BUILD@ +@WINE_CXX@ $extra_args $args + +if [ "$no_move" = true ] || [ "$no_link" = true ]; then + exit 0 +fi + +if [ ! -e "$output.exe" ]; then + echo "Fatal error in winegcc wrapper: No output file \"$output.exe\" found." + exit 1 +fi + +mv $output.exe $output diff --git a/cmake/modules/FindWine.cmake b/cmake/modules/FindWine.cmake index 9967dd9ba..13443b297 100644 --- a/cmake/modules/FindWine.cmake +++ b/cmake/modules/FindWine.cmake @@ -9,11 +9,12 @@ LIST(APPEND CMAKE_PREFIX_PATH /opt/wine-stable /opt/wine-devel /opt/wine-staging /usr/lib/wine/) -FIND_PATH(WINE_INCLUDE_DIR windows/windows.h PATH_SUFFIXES wine wine/wine) +FIND_PATH(WINE_INCLUDE_DIR wine/exception.h PATH_SUFFIXES wine) FIND_LIBRARY(WINE_LIBRARY NAMES wine PATH_SUFFIXES wine i386-linux-gnu/wine) FIND_PROGRAM(WINE_CXX NAMES wineg++ winegcc winegcc64 winegcc32 winegcc-stable PATHS /usr/lib/wine) +FIND_PROGRAM(WINE_BUILD NAMES winebuild) SET(WINE_INCLUDE_DIRS ${WINE_INCLUDE_DIR} ) SET(WINE_LIBRARIES ${WINE_LIBRARY} ) @@ -41,4 +42,12 @@ ENDFOREACH() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Wine DEFAULT_MSG WINE_CXX WINE_LIBRARIES WINE_INCLUDE_DIRS) -mark_as_advanced(WINE_INCLUDE_DIR WINE_LIBRARY) +mark_as_advanced(WINE_INCLUDE_DIR WINE_LIBRARY WINE_CXX WINE_BUILD) + +IF(WINE_LIBRARY_FIX) + SET(WINE_32_FLAGS "-L${WINE_LIBRARY_FIX}wine/ -L${WINE_LIBRARY_FIX}") +ENDIF() + +# Create winegcc wrapper +configure_file(${CMAKE_CURRENT_LIST_DIR}/../linux/winegcc_wrapper.in winegcc_wrapper @ONLY) +SET(WINEGCC "${CMAKE_CURRENT_BINARY_DIR}/winegcc_wrapper") diff --git a/plugins/vst_base/CMakeLists.txt b/plugins/vst_base/CMakeLists.txt index a355f87ff..5091b7cbf 100644 --- a/plugins/vst_base/CMakeLists.txt +++ b/plugins/vst_base/CMakeLists.txt @@ -7,6 +7,10 @@ INCLUDE(ExternalProject) ADD_SUBDIRECTORY(vstbase) +IF(LMMS_BUILD_LINUX AND WANT_VST_NOWINE) + RETURN() +ENDIF() + SET(LMMS_BINARY_DIR ${CMAKE_BINARY_DIR}) SET(LMMS_SOURCE_DIR ${CMAKE_SOURCE_DIR}) @@ -25,7 +29,6 @@ SET(EXTERNALPROJECT_CMAKE_ARGS # build 32 bit version of RemoteVstPlugin IF(LMMS_BUILD_WIN64 AND MSVC) - SET(MSVC_VER ${CMAKE_CXX_COMPILER_VERSION}) IF(MSVC_VER VERSION_GREATER 19.0 OR MSVC_VER VERSION_EQUAL 19.0) @@ -53,24 +56,25 @@ IF(LMMS_BUILD_WIN64 AND MSVC) ) ELSEIF(LMMS_BUILD_WIN32) ADD_SUBDIRECTORY(RemoteVstPlugin) -ELSEIF(LMMS_BUILD_LINUX AND NOT WANT_VST_NOWINE) +ELSEIF(LMMS_BUILD_LINUX) ExternalProject_Add(RemoteVstPlugin32 - ${EXTERNALPROJECT_ARGS} + "${EXTERNALPROJECT_ARGS}" CMAKE_ARGS ${EXTERNALPROJECT_CMAKE_ARGS} - -DCMAKE_CXX_COMPILER=${CMAKE_CURRENT_LIST_DIR}/RemoteVstPlugin/winegcc - -DCMAKE_CXX_FLAGS="-m32" + -DCMAKE_CXX_COMPILER=${WINEGCC} + "-DCMAKE_CXX_FLAGS=-m32 -mwindows" ) ENDIF() # build 64 bit version of RemoteVstPlugin IF(LMMS_BUILD_WIN64) ADD_SUBDIRECTORY(RemoteVstPlugin) -ELSEIF(LMMS_BUILD_LINUX AND NOT WANT_VST_NOWINE) +ELSEIF(LMMS_BUILD_LINUX) ExternalProject_Add(RemoteVstPlugin64 - ${EXTERNALPROJECT_ARGS} + "${EXTERNALPROJECT_ARGS}" CMAKE_ARGS ${EXTERNALPROJECT_CMAKE_ARGS} - -DCMAKE_CXX_COMPILER=${CMAKE_CURRENT_LIST_DIR}/RemoteVstPlugin/winegcc + -DCMAKE_CXX_COMPILER=${WINEGCC} + "-DCMAKE_CXX_FLAGS=-m64 -mwindows" ) ENDIF() diff --git a/plugins/vst_base/RemoteVstPlugin/CMakeLists.txt b/plugins/vst_base/RemoteVstPlugin/CMakeLists.txt index e5a27313f..9c43f436c 100644 --- a/plugins/vst_base/RemoteVstPlugin/CMakeLists.txt +++ b/plugins/vst_base/RemoteVstPlugin/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0.0) +cmake_minimum_required(VERSION 3.1) project(RemoteVstPlugin LANGUAGES CXX) set(CMAKE_CXX_STANDARD 11) diff --git a/plugins/vst_base/RemoteVstPlugin/winegcc b/plugins/vst_base/RemoteVstPlugin/winegcc deleted file mode 100755 index 018fb5ff7..000000000 --- a/plugins/vst_base/RemoteVstPlugin/winegcc +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Wrapper script for winegcc to remove .exe file ending automatically -# appended by winebuild. -# Usage: winegcc - -set -e - -args="$@" - -# Find output name -POSITIONAL=() -while [ $# -gt 0 ]; do - key="$1" - - case $key in - -o) - output=$2 - shift - ;; - -c) - no_link=true - ;; - *) - - ;; - esac - - shift -done - -if [ -z "$output" ]; then - if [ "$no_link" != true ]; then - output="a.out" - no_move=true - fi -# echo "Fatal error in winegcc wrapper: Can't find output file name in args." -# exit 1 -fi - -wineg++ $args - -if [ -z "$no_link" ] && [ "$no_move" != true ]; then - if [ ! -e "$output.exe" ]; then - echo "Fatal error in winegcc wrapper: No output file \"$output.exe\" found." - exit 1 - fi - - mv $output.exe $output -fi diff --git a/plugins/vst_base/VstPlugin.cpp b/plugins/vst_base/VstPlugin.cpp index e5323fb9d..6096a0d49 100644 --- a/plugins/vst_base/VstPlugin.cpp +++ b/plugins/vst_base/VstPlugin.cpp @@ -81,14 +81,14 @@ VstPlugin::VstPlugin( const QString & _plugin ) : { setSplittedChannels( true ); -#ifdef LMMS_HOST_X86_64 +#ifdef LMMS_BUILD_WIN64 tryLoad( "RemoteVstPlugin64" ); if( m_badDllFormat ) { m_badDllFormat = false; #endif tryLoad( "RemoteVstPlugin32" ); -#ifdef LMMS_HOST_X86_64 +#ifdef LMMS_BUILD_WIN64 } #endif diff --git a/src/core/RemotePlugin.cpp b/src/core/RemotePlugin.cpp index 7b10ed50b..408b8631f 100644 --- a/src/core/RemotePlugin.cpp +++ b/src/core/RemotePlugin.cpp @@ -123,7 +123,7 @@ RemotePlugin::RemotePlugin() : connect( &m_process, SIGNAL( finished( int, QProcess::ExitStatus ) ), this, SLOT( processFinished( int, QProcess::ExitStatus ) ) ); - connect( &m_process, SIGNAL( errorOccured( QProcess::ProcessError ) ), + connect( &m_process, SIGNAL( errorOccurred( QProcess::ProcessError ) ), this, SLOT( processErrored( QProcess::ProcessError ) ) ); }