Skip to content

Conversation

@leoauri
Copy link

@leoauri leoauri commented Aug 31, 2024

Support use as library for building on MacOS. Uses CMake for build

Only tested on Mac...
Feedback welcome :)

Closes #3

@leoauri
Copy link
Author

leoauri commented Aug 31, 2024

Replaces the hidapi with a submodule.

@SilverTuxedo
Copy link
Owner

Thank you for your contribution!

I fixed the solution files and some headers for this to still compile under Windows. Can you make sure you can still build this on Mac?

@leoauri
Copy link
Author

leoauri commented Sep 10, 2024

Hm. Actually, before the commit it compiled for me, now it doesn't:

.../JoyConBridge/src/JoyConBridge/exceptions.cpp:2:10: fatal error: 'hidapi/hidapi.h' file not found
#include "hidapi/hidapi.h"
         ^~~~~~~~~~~~~~~~~

@leoauri
Copy link
Author

leoauri commented Sep 10, 2024

Does this work for you?

@leoauri
Copy link
Author

leoauri commented Oct 1, 2024

Another thing is that, if I include this, I still have to bundle the hidapi library manually. I just did it like this:

if (APPLE) 
    # Loads dylibs from bundle
    set_target_properties(MyTarget PROPERTIES
        BUILD_WITH_INSTALL_RPATH FALSE
        LINK_FLAGS "-Wl,-rpath,@loader_path/"
    )
    add_custom_command(
        TARGET MyTarget
        POST_BUILD
        COMMAND cp "${CMAKE_BINARY_DIR}/JoyConBridge/src/JoyConBridge/hidapi/src/mac/*.dylib"
        "${CMAKE_BINARY_DIR}/MyTarget_artefacts/${CMAKE_BUILD_TYPE}/path/to/target/Contents/MacOS/"
        COMMENT "Copy HIDAPI dylibs target"
    )
endif()

Otherwise, the built artefact is not distributable.

There's probably a more robust way though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use on macOS

2 participants