Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix some details for macOS
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Jul 4, 2023
1 parent 066a029 commit ae4f575
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Expand Up @@ -14,7 +14,6 @@ env:
PAWPAW_VERSION: 70160711d2efec286d417b63a073a8f2012346f6

jobs:
# macOS native universal build
macos_universal:
runs-on: macos-11
steps:
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Expand Up @@ -113,6 +113,11 @@ if(APPLE)
add_custom_command(TARGET Chibi POST_BUILD
COMMAND cp "${QtPluginsDir}/styles/libqmacstyle.dylib" "$<TARGET_BUNDLE_DIR:Chibi>/Contents/PlugIns/styles/"
)
add_custom_command(TARGET Chibi POST_BUILD
COMMAND cp "${CMAKE_CURRENT_BINARY_DIR}/carla/lib/carla-bridge-native"
"${CMAKE_CURRENT_BINARY_DIR}/carla/lib/carla-discovery-native"
"$<TARGET_BUNDLE_DIR:Chibi>/Contents/MacOS/"
)
add_custom_command(TARGET Chibi POST_BUILD
COMMAND macdeployqt $<TARGET_BUNDLE_DIR:Chibi> -dmg
)
Expand Down
23 changes: 23 additions & 0 deletions main.cpp
Expand Up @@ -20,6 +20,29 @@
#include <QtWidgets/QApplication>
#include <QtWidgets/QMessageBox>

#ifdef CARLA_OS_MAC
# include <dlfcn.h>
// override for custom location
const char* carla_get_library_folder()
{
struct _ {
static std::string getExecutableDir()
{
Dl_info dlinfo = {};
dladdr(reinterpret_cast<const void*>(::carla_get_library_folder), &dlinfo);

if (const char* const lastsep = std::strrchr(dlinfo.dli_fname, '/'))
return std::string(dlinfo.dli_fname, lastsep - dlinfo.dli_fname);

return {};
}
};

static std::string path(_::getExecutableDir());
return path.c_str();
}
#endif

CARLA_BACKEND_USE_NAMESPACE;

int main(int argc, char *argv[])
Expand Down

0 comments on commit ae4f575

Please sign in to comment.