Ralith / openxrs

OpenXR bindings for Rust
Apache License 2.0
281 stars 59 forks source link

"requires target 'jsoncpp_interface' that is not in any export set" #148

Closed valentinegb closed 1 month ago

valentinegb commented 10 months ago

I have added openxr as a dependency to my project like so:

[dependencies]
openxr = { version = "0.17.1", features = ["static"] }

cargo build results in this error:

error: failed to run custom build command for `openxr-sys v0.9.3`

Caused by:
  process didn't exit successfully: `/Users/valentinebriese/Developer/bevy-openxr/target/debug/build/openxr-sys-2b99eab513ccc729/build-script-build` (exit status: 101)
  --- stdout
  CMAKE_TOOLCHAIN_FILE_aarch64-apple-darwin = None
  CMAKE_TOOLCHAIN_FILE_aarch64_apple_darwin = None
  HOST_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_aarch64-apple-darwin = None
  CMAKE_GENERATOR_aarch64_apple_darwin = None
  HOST_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_aarch64-apple-darwin = None
  CMAKE_PREFIX_PATH_aarch64_apple_darwin = None
  HOST_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_aarch64-apple-darwin = None
  CMAKE_aarch64_apple_darwin = None
  HOST_CMAKE = None
  CMAKE = None
  running: cd "/Users/valentinebriese/Developer/bevy-openxr/target/debug/build/openxr-sys-cfd644a5713c7f7b/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/Users/valentinebriese/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openxr-sys-0.9.3/OpenXR-SDK" "-DCMAKE_OSX_ARCHITECTURES=arm64" "-DBUILD_API_LAYERS=OFF" "-DBUILD_TESTS=OFF" "-DOpenGL_GL_PREFERENCE=GLVND" "-DDYNAMIC_LOADER=OFF" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_PREFIX=/Users/valentinebriese/Developer/bevy-openxr/target/debug/build/openxr-sys-cfd644a5713c7f7b/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -arch arm64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -arch arm64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -arch arm64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Release"
  -- Enabling OpenGL support
  -- Enabling Vulkan support
  -- Could NOT find glslc, using precompiled .spv files
  -- Found and will use pre-generated xr_generated_dispatch_table.h in source tree
  -- Found and will use pre-generated xr_generated_dispatch_table.c in source tree
  -- Found and will use pre-generated xr_generated_loader.hpp in source tree
  -- Found and will use pre-generated xr_generated_loader.cpp in source tree
  -- Configuring done (0.3s)
  -- Generating done (0.0s)

  --- stderr
  CMake Deprecation Warning at CMakeLists.txt:24 (cmake_minimum_required):
    Compatibility with CMake < 3.5 will be removed from a future version of
    CMake.

    Update the VERSION argument <min> value or use a ...<max> suffix to tell
    CMake that the project does not need compatibility with older versions.

  CMake Warning (dev) at CMakeLists.txt:27 (find_package):
    Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
    are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
    the cmake_policy command to set the policy and suppress this warning.

  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at src/loader/CMakeLists.txt:48 (add_library):
    Policy CMP0063 is not set: Honor visibility properties for all target
    types.  Run "cmake --help-policy CMP0063" for policy details.  Use the
    cmake_policy command to set the policy and suppress this warning.

    Target "openxr_loader" of type "STATIC_LIBRARY" has the following
    visibility properties set for C:

      C_VISIBILITY_PRESET

    For compatibility CMake is not honoring them for this target.
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Error: install(EXPORT "openxr_loader_export" ...) includes target "openxr_loader" which requires target "jsoncpp_interface" that is not in any export set.
  CMake Error in src/loader/CMakeLists.txt:
    export called with target "openxr_loader" which requires target
    "jsoncpp_interface" that is not in any export set.

  CMake Generate step failed.  Build files cannot be regenerated correctly.
  thread 'main' panicked at /Users/valentinebriese/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5:

  command did not execute successfully, got: exit status: 1

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

I am on a 2020 M1 MacBook Air running macOS 14.3 Beta (23D5033f).

Ralith commented 10 months ago

That looks like an issue with the upstream build system on macOS. Can you reproduce the issue in a fresh clone of https://github.com/KhronosGroup/OpenXR-SDK? If so, please open an issue on that repository.

Otherwise, can you reproduce it on the release-1.0.25 tag, but not on main? If so, then you can probably work around the issue by using a git dep on this crate, and we should make a new release.

valentinegb commented 10 months ago

Same thing on main. I've cloned the SDK but realized there aren't any instructions for building on Mac, is it not currently possible?

valentinegb commented 10 months ago

I copied the commands that were executed by the build script and ran them on the fresh clone, got the same output.

valentinegb commented 10 months ago

Found these directions and they seem to work on the fresh clone.

Ralith commented 10 months ago

Interesting. What are the exact commands the build script runs in your environment? I'm not much of a cmake expert, but this feels like it's probably bad practice somewhere in the cmake crate or the upstream build system...

valentinegb commented 10 months ago

It's the line in the output I gave in the original comment that starts with running:

running: cd "/Users/valentinebriese/Developer/bevy-openxr/target/debug/build/openxr-sys-cfd644a5713c7f7b/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/Users/valentinebriese/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openxr-sys-0.9.3/OpenXR-SDK" "-DCMAKE_OSX_ARCHITECTURES=arm64" "-DBUILD_API_LAYERS=OFF" "-DBUILD_TESTS=OFF" "-DOpenGL_GL_PREFERENCE=GLVND" "-DDYNAMIC_LOADER=OFF" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_PREFIX=/Users/valentinebriese/Developer/bevy-openxr/target/debug/build/openxr-sys-cfd644a5713c7f7b/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -arch arm64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -arch arm64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -arch arm64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Release"

I modified this slightly to use the directory of the fresh clone, and created the out/build subdirectory beforehand.

Ralith commented 10 months ago

Right, thanks. I'm guessing the cmake crate doesn't use xcode because it wants to have minimal dependencies and avoid idiosyncrasy, and upstream OpenXR only tests the Xcode generator. I think the most practical fix would be to get the upstream build working with whatever the default generator is. I'm not equipped to work on that myself, but you can work around the issue by placing your hand-built libopenxr in the linker search path somewhere and using the linked feature of this crate in the mean time.