diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index ddc034801b..5af8bcdd6b 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -139,6 +139,8 @@ foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) if (NOT APPLE OR NOT ${${EXTERNAL}_UPPERCASE} MATCHES "SIXENSE") target_link_libraries(${TARGET_NAME} ${${${EXTERNAL}_UPPERCASE}_LIBRARIES}) + elseif (APPLE) + add_definitions(-DSIXENSE_LIB_FILENAME=\"${${${EXTERNAL}_UPPERCASE}_LIBRARY_RELEASE}\") endif () endif () endforeach() diff --git a/interface/src/devices/SixenseManager.cpp b/interface/src/devices/SixenseManager.cpp index c3d694d06c..5fe2b9969c 100644 --- a/interface/src/devices/SixenseManager.cpp +++ b/interface/src/devices/SixenseManager.cpp @@ -96,15 +96,29 @@ void SixenseManager::initialize() { #ifdef __APPLE__ if (!_sixenseLibrary) { - const QString SIXENSE_LIBRARY_NAME = "libsixense_x64.dylib"; - _sixenseLibrary = new QLibrary(SIXENSE_LIBRARY_NAME); + + +#ifdef SIXENSE_LIB_FILENAME + _sixenseLibrary = new QLibrary(SIXENSE_LIB_FILENAME); +#else + const QString SIXENSE_LIBRARY_NAME = "libsixense_x64"; + QFileInfo frameworkSixenseLibrary = QCoreApplication::applicationDirPath() + "../Frameworks/" + + SIXENSE_LIBRARY_NAME; + + _sixenseLibrary = new QLibrary(frameworkSixenseLibrary.fileName()); +#endif + } + + if (_sixenseLibrary->load()){ + qDebug() << "Loaded sixense library for hydra support -" << _sixenseLibrary->fileName(); + } else { + qDebug() << "Sixense library at" << _sixenseLibrary->fileName() << "failed to load." + << "Continuing without hydra support."; + return; } - qDebug() << "Initializing sixense library for hydra support - libsixense_x64.dylib load state is" - << _sixenseLibrary->isLoaded(); SixenseBaseFunction sixenseInit = (SixenseBaseFunction) _sixenseLibrary->resolve("sixenseInit"); #endif - sixenseInit(); _isInitialized = true;