CMake export/include is broken for macOS Framework build #492

Open
opened 2023-01-02 07:08:37 -06:00 by Youw · 0 comments
Youw commented 2023-01-02 07:08:37 -06:00 (Migrated from github.com)

A rare combination of building HIDAPI on macOS as a standalone package (potentially to be installed somewhere in the system) but as a macOS Framework (as opposed to just Shared/Dylib library) have a hidapi::include CMake target broken.

NOTE: for a subdirectory variant of the build - there is no issues. It only happenes when HIDAPI is built (and installed) as a standalone project and then used as a CMake package (with find_package).

There is two reasons for that:

  • when building Framework on macOS - CMake places public headers inside the framework, and not in the CMAKE_INSTALL_INCLUDEDIR;
  • when CMake export scripts are generated, the Framework is not linked according to macOS/clang best practices (e.g. with -L <path to framework> + -framework hidapi, which would add the Framework include path automatically, but it linked directly to the Framework binary (i.e. hidapi.framework/Contents/hidapi);

At the end, we need to figure a workaround for HIDAPI - either fix hidapi::include target manually, or manually fix the hidapi::darwin target for Framework build, or both.

NOTE2: it is a shame CMake doesn't properly supports this scenario of-the-box and I couldn't find any WIP in this direction.
The workaround on HIDAPI side is our best shot at getting it work properly (and, potentially as a public example for other projects).

A rare combination of building HIDAPI on macOS as a standalone package (potentially to be installed somewhere in the system) but as a macOS Framework (as opposed to just Shared/Dylib library) have a `hidapi::include` CMake target broken. NOTE: for a `subdirectory` variant of the build - there is no issues. It only happenes when HIDAPI is built (and installed) as a standalone project and then used as a CMake package (with `find_package`). There is two reasons for that: - when building Framework on macOS - CMake places public headers inside the framework, and not in the `CMAKE_INSTALL_INCLUDEDIR`; - when CMake export scripts are generated, the Framework is not linked according to macOS/clang best practices (e.g. with `-L <path to framework>` + `-framework hidapi`, which would add the Framework include path automatically, but it linked directly to the Framework binary (i.e. `hidapi.framework/Contents/hidapi`); At the end, we need to figure a workaround for HIDAPI - either fix `hidapi::include` target manually, or manually fix the `hidapi::darwin` target for Framework build, or both. NOTE2: it is a shame CMake doesn't properly supports this scenario of-the-box and I couldn't find any WIP in this direction. The workaround on HIDAPI side is our best shot at getting it work properly (and, potentially as a public example for other projects).
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi#492
No description provided.