Skip to content

Commit

Permalink
Add Carla support for Windows (#5713)
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf authored Oct 29, 2020
1 parent 090b5a7 commit c23c1b7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
19 changes: 14 additions & 5 deletions plugins/carlabase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@ if(LMMS_HAVE_WEAKCARLA)
${CMAKE_CURRENT_SOURCE_DIR}/carla/source/utils
${CMAKE_CURRENT_SOURCE_DIR}/carla/source/backend
)
ADD_LIBRARY(carla_native-plugin SHARED DummyCarla.cpp)
TARGET_INCLUDE_DIRECTORIES(carla_native-plugin PUBLIC ${CARLA_INCLUDE_DIRS})
INSTALL(TARGETS carla_native-plugin

IF(LMMS_BUILD_WIN32)
# use carla.dll
SET(CMAKE_SHARED_LIBRARY_PREFIX "")
SET(CARLA_NATIVE_LIB carla)
ELSE()
# use libcarla_native-plugin
SET(CARLA_NATIVE_LIB carla_native-plugin)
ENDIF()
ADD_LIBRARY(${CARLA_NATIVE_LIB} SHARED DummyCarla.cpp)
TARGET_INCLUDE_DIRECTORIES(${CARLA_NATIVE_LIB} PUBLIC ${CARLA_INCLUDE_DIRS})
INSTALL(TARGETS ${CARLA_NATIVE_LIB}
LIBRARY DESTINATION "${PLUGIN_DIR}/optional"
RUNTIME DESTINATION "${PLUGIN_DIR}/optional"
)
SET(CARLA_LIBRARIES carla_native-plugin)
SET(CARLA_LIBRARIES ${CARLA_NATIVE_LIB})
# Set parent scope variables so carlarack and carlapatchbay can see them
SET(CARLA_LIBRARIES ${CARLA_LIBRARIES} PARENT_SCOPE)
endif()
Expand All @@ -45,6 +54,6 @@ if(LMMS_HAVE_CARLA OR LMMS_HAVE_WEAKCARLA)
INSTALL_RPATH_USE_LINK_PATH TRUE
INSTALL_RPATH "${CARLA_RPATH}")
IF(LMMS_HAVE_WEAKCARLA)
ADD_DEPENDENCIES(carlabase carla_native-plugin)
ADD_DEPENDENCIES(carlabase ${CARLA_NATIVE_LIB})
ENDIF()
endif()
28 changes: 17 additions & 11 deletions plugins/carlabase/carla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,14 @@ CarlaInstrument::CarlaInstrument(InstrumentTrack* const instrumentTrack, const D
fHost.uiParentId = 0;

// carla/resources contains PyQt scripts required for launch
QString dllName(carla_get_library_filename());
QString resourcesPath;
QDir path(carla_get_library_folder());
#if defined(CARLA_OS_LINUX)
// parse prefix from dll filename
QDir path = QFileInfo(dllName).dir();
path.cdUp();
path.cdUp();
resourcesPath = path.absolutePath() + "/share/carla/resources";
#elif defined(CARLA_OS_MAC)
QString resourcesPath = path.absolutePath() + "/share/carla/resources";
#else
// parse prefix from dll filename
QDir path = QFileInfo(dllName).dir();
resourcesPath = path.absolutePath() + "/resources";
#elif defined(CARLA_OS_WIN32) || defined(CARLA_OS_WIN64)
// not yet supported
QString resourcesPath = path.absolutePath() + "/resources";
#endif
fHost.resourceDir = strdup(resourcesPath.toUtf8().constData());
fHost.get_buffer_size = host_get_buffer_size;
Expand Down Expand Up @@ -444,8 +438,20 @@ CarlaInstrumentView::~CarlaInstrumentView()

void CarlaInstrumentView::toggleUI(bool visible)
{
if (fHandle != NULL && fDescriptor->ui_show != NULL)
if (fHandle != NULL && fDescriptor->ui_show != NULL) {
// TODO: remove when fixed upstream
// change working path to location of carla.dll to avoid conflict with lmms
#if defined(CARLA_OS_WIN32) || defined(CARLA_OS_WIN64)
if (visible) {
QString backupDir = QDir::currentPath();
QDir::setCurrent(carla_get_library_folder());
fDescriptor->ui_show(fHandle, true);
QDir::setCurrent(backupDir);
return;
}
#endif
fDescriptor->ui_show(fHandle, visible);
}
}

void CarlaInstrumentView::uiClosed()
Expand Down

0 comments on commit c23c1b7

Please sign in to comment.