CMakeLists.txt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Additional interop for things like macros and inlined functions.
  2. add_library(rust_wrapper STATIC rust_wrapper.c)
  3. target_link_libraries(rust_wrapper crypto)
  4. # Generate architecture-specific wrappers.
  5. set(WRAPPER_TARGET ${CMAKE_CURRENT_BINARY_DIR}/src/wrapper_${RUST_BINDINGS}.rs)
  6. set(COMMAND ${BINDGEN_EXECUTABLE} "wrapper.h"
  7. -o ${WRAPPER_TARGET}
  8. --no-derive-default
  9. --enable-function-attribute-detection
  10. --use-core
  11. --size_t-is-usize
  12. --default-macro-constant-type="signed"
  13. --rustified-enum="point_conversion_form_t"
  14. --allowlist-file=".*/include/openssl/.*\\.h"
  15. --allowlist-file=".*/rust_wrapper\\.h"
  16. -- # these are LLVM arg passthroughs
  17. -I../include
  18. # https://doc.rust-lang.org/nightly/rustc/platform-support.html
  19. --target=${RUST_BINDINGS})
  20. set(INCLUDES "include!(\"wrapper_${RUST_BINDINGS}.rs\");\n")
  21. add_custom_target(
  22. bindgen_rust_${RUST_BINDINGS}
  23. ALL
  24. ${COMMAND}
  25. BYPRODUCTS ${WRAPPER_TARGET}
  26. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  27. )
  28. # move files into build directory
  29. configure_file("src/lib.rs" "src/lib.rs")
  30. if(NOT BUILD_SHARED_LIBS)
  31. configure_file("build.rs" "build.rs" COPYONLY)
  32. endif()
  33. configure_file("Cargo.toml" "Cargo.toml" COPYONLY)