Skip to content

Commit

Permalink
Initial support for winegcc on ARM64
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Feb 5, 2025
1 parent 6a0a4cd commit 5d4f0cc
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 37 deletions.
91 changes: 66 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ IF(LMMS_BUILD_APPLE)
SET(STATUS_ALSA "<not supported on this platform>")
SET(STATUS_OSS "<not supported on this platform>")
SET(STATUS_PULSEAUDIO "<not supported on this platform>")
SET(STATUS_VST "<not supported on this platform>")
SET(STATUS_APPLEMIDI "OK")
ELSE(LMMS_BUILD_APPLE)
SET(STATUS_APPLEMIDI "<not supported on this platform>")
Expand Down Expand Up @@ -562,39 +563,79 @@ ENDIF(WANT_SNDIO)

# check for WINE
if(WANT_VST)
if((WANT_VST_32 OR WANT_VST_64) AND NOT LMMS_BUILD_WIN32)
set(LMMS_HAVE_VST true) # native
if(LMMS_BUILD_WIN32)
# Windows: No special compiler needed
set(LMMS_HAVE_VST_32 true)
if(LMMS_BULD_WIN64)
set(LMMS_HAVE_VST_64 true)
endif()
elseif(WANT_VST_32 OR WANT_VST_64)
# Linux, etc: Test winegcc
find_package(Wine)
include(CheckWineGcc)
if(WANT_VST_32)
CheckWineGcc(-m32 "${WINEGCC}" winegcc_working)
if(winegcc_working)
set(LMMS_HAVE_VST_32 true)
endif()
endif()
if(WANT_VST_64)
if(LMMS_HOST_X86_64)
CheckWineGcc(-m64 "${WINEGCC}" winegcc_working)
else()
CheckWineGcc("" "${WINEGCC}" winegcc_working)
endif()
if(winegcc_working)
set(LMMS_HAVE_VST_${_bits} true)
endif()
endif()
endif()
macro(check_vst bits)
if(NOT WANT_VST_${bits})
set(STATUS_VST_${bits} "Not built, as requested")
elseif(LMMS_BUILD_WIN32)
set(STATUS_VST_${bits} "OK")
set(LMMS_HAVE_VST_${bits} TRUE)
elseif(NOT WINE_FOUND)
set(STATUS_VST_${bits} "not found, please install (lib)wine-dev (or similar) - 64 bit systems additionally need gcc-multilib and g++-multilib")

# Summarize our results
if(LMMS_HAVE_VST)
if(LMMS_BUILD_LINUX)
set(STATUS_VST "OK (native)")
else()
set(STSTUS_VST "OK")
endif()
if(LMMS_HAVE_VST_32)
set(STATUS_VST_32 "OK")
else()
CheckWineGcc("${bits}" "${WINEGCC}" WINEGCC_WORKING)
if(WINEGCC_WORKING)
set(LMMS_HAVE_VST_${bits} TRUE)
if(WINE_LIBRARY_FIX)
set(STATUS_VST_${bits} "OK, with workaround linking ${WINE_LIBRARY_FIX}")
else()
set(STATUS_VST_${bits} "OK")
endif()
set(STATUS_VST_32 "not found, please install wine-dev:i386, gcc-multilib, g++-multilib")
endif()
if(LMMS_HAVE_VST_64)
set(STATUS_VST_64 "OK")
else()
if(LMMS_BUILD_WIN32)
# Special messaging for win32
set(STATUS_VST_64 "<not supported on this platform>")
else()
set(STATUS_VST_${bits} "winegcc fails to compile ${bits}-bit binaries, please make sure you have ${bits}-bit GCC libraries")
set(STATUS_VST_64 "not found, please install wine-dev")
endif()
endif()
endmacro()
check_vst(32)
check_vst(64)
if(LMMS_HAVE_VST_32 OR LMMS_HAVE_VST_64 OR LMMS_BUILD_LINUX)
set(LMMS_HAVE_VST TRUE)
set(STATUS_VST "OK")
else()
set(STATUS_VST "No hosts selected and available")
set(STATUS_VST "not built as requested")
endif()

# Handle overrides
if(NOT WANT_VST_32)
set(STATUS_VST_32 "not built as requested")
set(LMMS_HAVE_VST_32 false)
endif()
if(NOT WANT_VST_64)
set(STATUS_VST_64 "not built as requested")
set(LMMS_HAVE_VST_64 false)
endif()
else()
if(STATUS_VST)
# Clone set statuses
set(STATUS_VST_32 "${STATUS_VST}")
set(STATUS_VST_64 "${STATUS_VST}")
else()
set(STATUS_VST "not built as requested")
set(STATUS_VST_32 "not built as requested")
set(STATUS_VST_64 "not built as requested")
endif()
endif()

Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/CheckWineGcc.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
INCLUDE(CheckCXXSourceCompiles)

FUNCTION(CheckWineGcc BITNESS WINEGCC_EXECUTABLE RESULT)
FUNCTION(CheckWineGcc MPLATFORM WINEGCC_EXECUTABLE RESULT)
FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/winegcc_test.cxx" "
#include <iostream>
#define USE_WS_PREFIX
Expand All @@ -9,7 +9,7 @@ FUNCTION(CheckWineGcc BITNESS WINEGCC_EXECUTABLE RESULT)
return 0;
}
")
EXECUTE_PROCESS(COMMAND ${WINEGCC_EXECUTABLE} "-m${BITNESS}"
EXECUTE_PROCESS(COMMAND ${WINEGCC_EXECUTABLE} "${MPLATFORM}"
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/winegcc_test.cxx"
"-o" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/winegcc_test"
OUTPUT_QUIET ERROR_QUIET
Expand Down
29 changes: 20 additions & 9 deletions cmake/modules/DetectMachine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,33 +115,44 @@ ELSE()
ENDIF()

IF(IS_X86)
MESSAGE("-- Target host is 32 bit, Intel")
SET(LMMS_HOST_X86 TRUE)
ELSEIF(IS_X86_64)
MESSAGE("-- Target host is 64 bit, Intel")
SET(LMMS_HOST_X86_64 TRUE)
ELSEIF(IS_ARM32)
MESSAGE("-- Target host is 32 bit, ARM")
SET(LMMS_HOST_ARM32 TRUE)
ELSEIF(IS_ARM64)
MESSAGE("-- Target host is 64 bit, ARM")
SET(LMMS_HOST_ARM64 TRUE)
ELSEIF(IS_RISCV32)
MESSAGE("-- Target host is 32 bit, RISC-V")
SET(LMMS_HOST_RISCV32 TRUE)
ELSEIF(IS_RISCV64)
MESSAGE("-- Target host is 64 bit, RISC-V")
SET(LMMS_HOST_RISCV64 TRUE)
ELSEIF(IS_PPC32)
MESSAGE("-- Target host is 32 bit, PPC")
SET(LMMS_HOST_PPC32 TRUE)
ELSEIF(IS_PPC64)
MESSAGE("-- Target host is 64 bit, PPC")
SET(LMMS_HOST_PPC64 TRUE)
ELSE()
MESSAGE("Can't identify target host. Assuming 32 bit platform.")
MESSAGE(AUTHOR_WARNING "Can't identify target host. Assuming 64-bit, Intel platform.")
ENDIF()

if(IS_X86 OR IS_ARM32 OR IS_RISCV32 OR IS_PPC32)
set(LMMS_HOST_BITNESS 32)
else()
set(LMMS_HOST_BITNESS 64)
endif()

if(IS_ARM32 OR IS_ARM64)
set(LMMS_HOST_FAMILY ARM)
elseif(IS_PPC32 OR IS_PPC64)
set(LMMS_HOST_FAMILY PowerPC)
elseif(IS_RISCV32 OR IS_RISCV64)
set(LMMS_HOST_FAMILY RISC-V)
else()
set(LMMS_HOST_FAMILY Intel)
endif()

message(STATUS "-- Target host is ${LMMS_HOST_BITNESS}-bit, ${LMMS_HOST_FAMILY}")


IF(CMAKE_INSTALL_LIBDIR)
SET(LIB_DIR "${CMAKE_INSTALL_LIBDIR}")
ELSE(CMAKE_INSTALL_LIBDIR)
Expand Down
5 changes: 4 additions & 1 deletion plugins/VstBase/RemoteVstPlugin64.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
IF(LMMS_BUILD_WIN64)
ADD_SUBDIRECTORY(RemoteVstPlugin)
ELSEIF(LMMS_BUILD_LINUX)
if(LMMS_HOST_X86_64)
set(CXX_FLAGS -m64)
endif()
ExternalProject_Add(RemoteVstPlugin64
"${EXTERNALPROJECT_ARGS}"
CMAKE_ARGS
"${EXTERNALPROJECT_CMAKE_ARGS}"
"-DCMAKE_CXX_COMPILER=${WINEGCC}"
"-DCMAKE_CXX_FLAGS=-m64"
"-DCMAKE_CXX_FLAGS=${CXX_FLAGS}"
)
INSTALL(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/../RemoteVstPlugin64" "${CMAKE_CURRENT_BINARY_DIR}/../RemoteVstPlugin64.exe.so" DESTINATION "${PLUGIN_DIR}")
ENDIF()

0 comments on commit 5d4f0cc

Please sign in to comment.