Skip to content

Commit

Permalink
Merge branch 'msvc/vst-rebase' (LMMS#4421)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-w committed Jul 7, 2018
2 parents 170a46e + f8f38a3 commit 846a2af
Show file tree
Hide file tree
Showing 164 changed files with 1,097 additions and 516 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
command: |
cd build
make install
make appimage
make appimage || (cat appimage.log && false)
cp ./lmms-*.AppImage /tmp/artifacts/
- store_artifacts:
path: /tmp/artifacts/
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@
[submodule "src/3rdparty/weakjack/weakjack"]
path = src/3rdparty/weakjack/weakjack
url = https://github.com/x42/weakjack.git
[submodule "src/3rdparty/mingw-std-threads"]
path = src/3rdparty/mingw-std-threads
url = https://github.com/meganz/mingw-std-threads.git
33 changes: 25 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ INCLUDE(CheckSubmodules)
INCLUDE(AddFileDependencies)
INCLUDE(CheckIncludeFiles)
INCLUDE(FindPkgConfig)
INCLUDE(GenerateExportHeader)

STRING(TOUPPER "${CMAKE_PROJECT_NAME}" PROJECT_NAME_UCASE)

Expand Down Expand Up @@ -46,7 +47,6 @@ ENDIF()
INCLUDE(VersionInfo)
INCLUDE(DetectMachine)


OPTION(WANT_ALSA "Include ALSA (Advanced Linux Sound Architecture) support" ON)
OPTION(WANT_CALF "Include CALF LADSPA plugins" ON)
OPTION(WANT_CAPS "Include C* Audio Plugin Suite (LADSPA plugins)" ON)
Expand Down Expand Up @@ -165,9 +165,14 @@ FIND_PACKAGE(Qt5Test)
SET(QT_QTTEST_LIBRARY Qt5::Test)

# check for libsndfile
PKG_CHECK_MODULES(SNDFILE REQUIRED sndfile>=1.0.18)
IF(NOT SNDFILE_FOUND)
MESSAGE(FATAL_ERROR "LMMS requires libsndfile1 and libsndfile1-dev >= 1.0.18 - please install, remove CMakeCache.txt and try again!")
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(SNDFILE REQUIRED sndfile>=1.0.18)
IF(NOT SNDFILE_FOUND)
MESSAGE(FATAL_ERROR "LMMS requires libsndfile1 and libsndfile1-dev >= 1.0.18 - please install, remove CMakeCache.txt and try again!")
ENDIF()
ELSE()
FIND_PACKAGE(LibSndFile 1.0.18 REQUIRED)
SET(SNDFILE_LIBRARIES sndfile-shared)
ENDIF()
# check if we can use SF_SET_COMPRESSION_LEVEL
IF(NOT SNDFILE_VERSION VERSION_LESS 1.0.26)
Expand Down Expand Up @@ -393,8 +398,13 @@ ENDIF(WANT_JACK)


# check for FFTW3F-library
PKG_CHECK_MODULES(FFTW3F REQUIRED fftw3f>=3.0.0)

IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(FFTW3F REQUIRED fftw3f>=3.0.0)
ELSE()
#currently find_package for fftw is broken in vcpkg. Replace this when fixed
FIND_PATH(FFTW3F_INCLUDE_DIRS fftw3.h)
FIND_LIBRARY(FFTW3F_LIBRARIES fftw3f)
ENDIF()

# check for FLTK
FIND_PACKAGE(FLTK)
Expand Down Expand Up @@ -476,10 +486,16 @@ ELSE()
ENDIF(WANT_DEBUG_FPE)

# check for libsamplerate
PKG_CHECK_MODULES(SAMPLERATE REQUIRED samplerate>=0.1.8)
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(SAMPLERATE REQUIRED samplerate>=0.1.8)
ELSE()
#TODO no cmake config support. Can we check the version some other way?
FIND_FILE(SAMPLERATE_INCLUDE_DIRS samplerate.h)
FIND_LIBRARY(SAMPLERATE_LIBRARIES libsamplerate-0)
ENDIF()

# set compiler flags
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|AppleClang")
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
SET(WERROR_FLAGS "-Wall -Werror=unused-function -Wno-sign-compare -Wno-strict-overflow")
OPTION(USE_WERROR "Add -werror to the build flags. Stops the build on warnings" OFF)
IF(${USE_WERROR})
Expand Down Expand Up @@ -699,4 +715,5 @@ MESSAGE(
"-----------------------------------------------------------------\n"
"\n\n")

SET(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "${BIN_DIR}")
INCLUDE(InstallRequiredSystemLibraries)
2 changes: 1 addition & 1 deletion cmake/build_win32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ fi
CMAKE_OPTS="-DCMAKE_PREFIX_PATH=$MINGW $CMAKE_OPTS"

# shellcheck disable=SC2086
cmake "$DIR/.." -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" -DCMAKE_MODULE_PATH="$DIR/../cmake/modules/" $CMAKE_OPTS
cmake "$DIR/.." -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" $CMAKE_OPTS
24 changes: 16 additions & 8 deletions cmake/linux/package_linux.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,32 @@ EOL

chmod +x "${APPDIR}usr/bin/lmms"

# Per https://github.com/probonopd/linuxdeployqt/issues/129
# Per https://github.com/probonopd/linuxdeployqt/issues/129
unset LD_LIBRARY_PATH

# Ensure linuxdeployqt can find shared objects
export LD_LIBRARY_PATH="${APPDIR}usr/lib/lmms/":$LD_LIBRARY_PATH

# Handle wine linking
if [ -d "@WINE_LIBRARY_FIX@" ]; then
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:@WINE_LIBRARY_FIX@:@WINE_LIBRARY_FIX@wine/
if [ -d "@WINE_32_LIBRARY_DIR@" ]; then
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LD_LIBRARY_PATH/wine/:@WINE_32_LIBRARY_DIR@:@WINE_32_LIBRARY_DIR@wine/
fi
if [ -d "@WINE_64_LIBRARY_DIR@" ]; then
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LD_LIBRARY_PATH/wine/:@WINE_64_LIBRARY_DIR@:@WINE_64_LIBRARY_DIR@wine/
fi

# Move executables so linuxdeployqt can find them
ZYNLIB="${APPDIR}usr/lib/lmms/RemoteZynAddSubFx"
VSTLIB="${APPDIR}usr/lib/lmms/RemoteVstPlugin.exe.so"
VSTLIB32="${APPDIR}usr/lib/lmms/RemoteVstPlugin32.exe.so"
VSTLIB64="${APPDIR}usr/lib/lmms/RemoteVstPlugin64.exe.so"

ZYNBIN="${APPDIR}usr/bin/RemoteZynAddSubFx"
VSTBIN="${APPDIR}usr/bin/RemoteVstPlugin.exe.so"
VSTBIN32="${APPDIR}usr/bin/RemoteVstPlugin32.exe.so"
VSTBIN64="${APPDIR}usr/bin/RemoteVstPlugin64.exe.so"

mv "$ZYNLIB" "$ZYNBIN"
mv "$VSTLIB" "$VSTBIN"
mv "$VSTLIB32" "$VSTBIN32"
mv "$VSTLIB64" "$VSTBIN64"

# Patch the desktop file
sed -i 's/.*Exec=.*/Exec=lmms.real/' "$DESKTOPFILE"
Expand All @@ -156,7 +162,8 @@ for file in "${APPDIR}usr/lib/lmms/"*.so; do
executables="${executables} -executable=$thisfile"
done
executables="${executables} -executable=${ZYNBIN}"
executables="${executables} -executable=${VSTBIN}"
executables="${executables} -executable=${VSTBIN32}"
executables="${executables} -executable=${VSTBIN64}"
executables="${executables} -executable=${APPDIR}usr/lib/lmms/ladspa/imp_1199.so"
executables="${executables} -executable=${APPDIR}usr/lib/lmms/ladspa/imbeq_1197.so"
executables="${executables} -executable=${APPDIR}usr/lib/lmms/ladspa/pitch_scale_1193.so"
Expand All @@ -171,7 +178,8 @@ success "Bundled and relinked dependencies"

# Link to original location so lmms can find them
ln -sr "$ZYNBIN" "$ZYNLIB"
ln -sr "$VSTBIN" "$VSTLIB"
ln -sr "$VSTBIN32" "$VSTLIB32"
ln -sr "$VSTBIN64" "$VSTLIB64"

# Remove wine library conflict
rm -f "${APPDIR}/usr/lib/libwine.so.1"
Expand Down
25 changes: 18 additions & 7 deletions cmake/modules/BuildPlugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
INCLUDE(GenQrc)

MACRO(BUILD_PLUGIN PLUGIN_NAME)
CMAKE_PARSE_ARGUMENTS(PLUGIN "" "" "MOCFILES;EMBEDDED_RESOURCES;UICFILES;LINK" ${ARGN})
CMAKE_PARSE_ARGUMENTS(PLUGIN "" "LINK;EXPORT_BASE_NAME" "MOCFILES;EMBEDDED_RESOURCES;UICFILES" ${ARGN})
SET(PLUGIN_SOURCES ${PLUGIN_UNPARSED_ARGUMENTS})

INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}/include")
Expand Down Expand Up @@ -50,19 +50,19 @@ MACRO(BUILD_PLUGIN PLUGIN_NAME)
SET(QT_LIBRARIES "${QT_OVERRIDE_LIBRARIES}")
ENDIF()

IF ("${PLUGIN_LINK}" STREQUAL "SHARED")
ADD_LIBRARY(${PLUGIN_NAME} SHARED ${PLUGIN_SOURCES} ${plugin_MOC_out} ${RCC_OUT})
ELSE ()
ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES} ${plugin_MOC_out} ${RCC_OUT})
ENDIF ()
IF (NOT PLUGIN_LINK)
SET(PLUGIN_LINK "MODULE")
ENDIF()

ADD_LIBRARY(${PLUGIN_NAME} ${PLUGIN_LINK} ${PLUGIN_SOURCES} ${plugin_MOC_out} ${RCC_OUT})

TARGET_LINK_LIBRARIES(${PLUGIN_NAME} Qt5::Widgets Qt5::Xml)

IF(LMMS_BUILD_WIN32)
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} lmms)
ENDIF(LMMS_BUILD_WIN32)

INSTALL(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION "${PLUGIN_DIR}")
INSTALL(TARGETS ${PLUGIN_NAME} DESTINATION "${PLUGIN_DIR}")

IF(LMMS_BUILD_APPLE)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LINK_FLAGS "-bundle_loader \"${CMAKE_BINARY_DIR}/lmms\"")
Expand All @@ -74,5 +74,16 @@ MACRO(BUILD_PLUGIN PLUGIN_NAME)
ENDIF()

SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${RCC_OUT} ${plugin_MOC_out}")

IF(NOT PLUGIN_EXPORT_BASE_NAME)
SET(PLUGIN_EXPORT_BASE_NAME "PLUGIN")
ENDIF()

GENERATE_EXPORT_HEADER(${PLUGIN_NAME}
BASE_NAME ${PLUGIN_EXPORT_BASE_NAME}
)
TARGET_INCLUDE_DIRECTORIES(${PLUGIN_NAME}
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
)
ENDMACRO(BUILD_PLUGIN)

33 changes: 33 additions & 0 deletions cmake/modules/CheckCXXPreprocessor.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

macro(CHECK_CXX_PREPROCESSOR VAR DIRECTIVE)
string(RANDOM DEFINED_KEY)
string(RANDOM UNDEFINED_KEY)

set(TMP_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/CxxTmp/src.cpp")
SET(SRC "
#if ${DIRECTIVE}
#error ${DEFINED_KEY}
#else
#error ${UNDEFINED_KEY}
#endif
")
file(WRITE ${TMP_FILENAME} "${SRC}")
try_compile(RESULT_VAR
${CMAKE_CURRENT_BINARY_DIR}
${TMP_FILENAME}
OUTPUT_VARIABLE OUTPUT_VAR
)

if(OUTPUT_VAR MATCHES ${DEFINED_KEY})
set(${VAR} ON)
elseif(OUTPUT_VAR MATCHES ${UNDEFINED_KEY})
set(${VAR} OFF)
else()
message(FATAL_ERROR "Can't determine if \"${DIRECTIVE}\" is true.")
endif()
endmacro()


macro(CHECK_CXX_DEFINE VAR DEFINE)
CHECK_CXX_PREPROCESSOR(${VAR} "defined(${DEFINE})")
endmacro()
4 changes: 2 additions & 2 deletions cmake/modules/DetectMachine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ MESSAGE("PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
SET(LMMS_HOST_X86 FALSE)
SET(LMMS_HOST_X86_64 FALSE)

IF(NOT DEFINED WIN64)
STRING(REGEX MATCH "86_64|amd64|AMD64" WIN64 "${CMAKE_SYSTEM_PROCESSOR}")
IF(NOT DEFINED WIN64 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(WIN64 ON)
ENDIF()

IF(WIN32)
Expand Down
28 changes: 23 additions & 5 deletions cmake/modules/FindWine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@

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_LIBRARY(WINE_LIBRARY NAMES wine PATH_SUFFIXES wine i386-linux-gnu/wine)

FIND_PATH(WINE_INCLUDE_DIR wine/exception.h PATH_SUFFIXES wine)
FIND_PROGRAM(WINE_CXX
NAMES wineg++ winegcc winegcc64 winegcc32 winegcc-stable
PATHS /usr/lib/wine)
FIND_PROGRAM(WINE_BUILD NAMES winebuild)

SET(_ARCHITECTURE ${CMAKE_LIBRARY_ARCHITECTURE})

FIND_LIBRARY(WINE_LIBRARY NAMES wine PATH_SUFFIXES wine i386-linux-gnu/wine)

SET(CMAKE_LIBRARY_ARCHITECTURE ${_ARCHITECTURE})

SET(WINE_INCLUDE_DIRS ${WINE_INCLUDE_DIR} )
SET(WINE_LIBRARIES ${WINE_LIBRARY} )
Expand All @@ -24,6 +31,10 @@ STRING(REPLACE " " ";" WINEBUILD_FLAGS "${WINEBUILD_OUTPUT}")

FOREACH(FLAG ${WINEBUILD_FLAGS})
IF("${FLAG}" MATCHES "libwinecrt0.a.*")
STRING(REGEX REPLACE "/wine/libwinecrt0.a.*" "" FLAG "${FLAG}")

SET(WINE_64_LIBRARY_DIR "${FLAG}/")

# Debian systems
STRING(REPLACE "/lib/x86_64-" "/lib/i386-" FLAG "${FLAG}")
# Fedora systems
Expand All @@ -33,12 +44,19 @@ FOREACH(FLAG ${WINEBUILD_FLAGS})
# WineHQ (/opt/wine-stable, /opt/wine-devel, /opt/wine-staging)
STRING(REPLACE "/lib64/wine/" "/lib/wine/" FLAG "${FLAG}")

STRING(REGEX REPLACE "/wine/libwinecrt0.a.*" "" WINE_LIBRARY_FIX "${FLAG}")
SET(WINE_LIBRARY_FIX "${WINE_LIBRARY_FIX}/")
SET(WINE_32_LIBRARY_DIR "${FLAG}/")
ENDIF()
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_32_LIBRARY_DIR)
SET(WINE_32_FLAGS "-L${WINE_32_LIBRARY_DIR}wine/ -L${WINE_32_LIBRARY_DIR}")
ENDIF()

# Create winegcc wrapper
configure_file(${CMAKE_CURRENT_LIST_DIR}/winegcc_wrapper.in winegcc_wrapper @ONLY)
SET(WINEGCC "${CMAKE_CURRENT_BINARY_DIR}/winegcc_wrapper")
63 changes: 63 additions & 0 deletions cmake/modules/winegcc_wrapper.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/sh
# Wrapper script for winegcc to remove .exe file ending automatically
# appended by winebuild.
# See FindWine.cmake for usage

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
6 changes: 5 additions & 1 deletion cmake/nsis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/cmake/nsis/nsis_branding.bmp")
IF(MSVC)
STRING(REPLACE "/" "\\\\" CPACK_PACKAGE_ICON ${CPACK_PACKAGE_ICON})
ENDIF(MSVC)
SET(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/cmake/nsis/lmms.ico")
SET(CPACK_NSIS_INSTALLED_ICON_NAME "${CMAKE_PROJECT_NAME}.exe" PARENT_SCOPE)
SET(CPACK_NSIS_DISPLAY_NAME "${PROJECT_NAME_UCASE} ${VERSION}" PARENT_SCOPE)
Expand All @@ -8,7 +11,8 @@ SET(CPACK_NSIS_CONTACT "${PROJECT_EMAIL}" PARENT_SCOPE)
SET(CPACK_PACKAGE_EXECUTABLES "${CMAKE_PROJECT_NAME}.exe;${PROJECT_NAME_UCASE}" PARENT_SCOPE)
SET(CPACK_NSIS_MENU_LINKS "${CMAKE_PROJECT_NAME}.exe;${PROJECT_NAME_UCASE}" PARENT_SCOPE)
SET(CPACK_NSIS_DEFINES "
!include ${CMAKE_SOURCE_DIR}/cmake/nsis/FileAssociation.nsh
!addincludedir ${CMAKE_SOURCE_DIR}/cmake/nsis
!include FileAssociation.nsh
!include LogicLib.nsh
!include WinVer.nsh")
SET(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${VERSION}-win32")
Expand Down
2 changes: 2 additions & 0 deletions cmake/toolchains/Ubuntu-MinGW-W64-64.cmake
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
SET(CMAKE_TOOLCHAIN_FILE_32 "${CMAKE_CURRENT_LIST_DIR}/Ubuntu-MinGW-W64-32.cmake")

INCLUDE(${CMAKE_CURRENT_LIST_DIR}/common/Win64.cmake)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/common/Ubuntu-MinGW-W64.cmake)
Loading

0 comments on commit 846a2af

Please sign in to comment.