-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add CMake support to C bindings (#247)
Co-authored-by: Matt Campbell <mattcampbell@pobox.com>
- Loading branch information
1 parent
022ef04
commit 3f556c9
Showing
16 changed files
with
287 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ default-members = [ | |
"common", | ||
"consumer", | ||
"platforms/winit", | ||
"bindings/c", | ||
] | ||
|
||
[profile.release] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[target.aarch64-apple-darwin] | ||
rustflags = [ | ||
"-C", "link-arg=-Wl,-install_name,@rpath/libaccesskit.dylib", | ||
] | ||
|
||
[target.x86_64-apple-darwin] | ||
rustflags = [ | ||
"-C", "link-arg=-Wl,-install_name,@rpath/libaccesskit.dylib", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
|
||
include | ||
build | ||
include | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
cmake_minimum_required(VERSION 3.20) | ||
|
||
project(accesskit_c) | ||
|
||
option(ACCESSKIT_BUILD_HEADERS "Whether to build header files" ON) | ||
option(ACCESSKIT_BUILD_LIBRARIES "Whether to build libraries" ON) | ||
|
||
if (ACCESSKIT_BUILD_LIBRARIES) | ||
include(FetchContent) | ||
|
||
FetchContent_Declare( | ||
Corrosion | ||
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git | ||
GIT_TAG v0.3.5 | ||
) | ||
FetchContent_MakeAvailable(Corrosion) | ||
|
||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) | ||
set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) | ||
corrosion_import_crate(MANIFEST_PATH Cargo.toml) | ||
endif() | ||
|
||
if (ACCESSKIT_BUILD_HEADERS) | ||
find_program(RUSTUP rustup) | ||
find_program(CBINDGEN cbindgen) | ||
find_program(CLANG_FORMAT clang-format) | ||
|
||
add_custom_target(headers ALL | ||
COMMAND ${RUSTUP} run nightly ${CBINDGEN} --crate accesskit_c --output accesskit.hpp "${CMAKE_SOURCE_DIR}" | ||
COMMAND ${CLANG_FORMAT} -i accesskit.hpp | ||
COMMAND ${CMAKE_COMMAND} -E rename accesskit.hpp accesskit.h | ||
BYPRODUCTS accesskit.h | ||
) | ||
|
||
if (ACCESSKIT_BUILD_LIBRARIES) | ||
add_dependencies(cargo-prebuild_accesskit headers) | ||
endif() | ||
endif() | ||
|
||
include("accesskit.cmake") | ||
|
||
if (ACCESSKIT_BUILD_HEADERS) | ||
install(FILES | ||
"${CMAKE_CURRENT_BINARY_DIR}/accesskit.h" | ||
DESTINATION "${ACCESSKIT_INCLUDE_DIR}" | ||
) | ||
endif() | ||
|
||
if (ACCESSKIT_BUILD_LIBRARIES) | ||
install(FILES | ||
"$<TARGET_PROPERTY:accesskit-static,IMPORTED_LOCATION>" | ||
DESTINATION "${ACCESSKIT_LIBRARIES_DIR}/static" | ||
) | ||
|
||
install(FILES | ||
"$<TARGET_PROPERTY:accesskit-shared,IMPORTED_LOCATION>" | ||
"$<$<STREQUAL:${_accesskit_toolchain},msvc>:${CMAKE_CURRENT_BINARY_DIR}/accesskit.pdb>" | ||
DESTINATION "${ACCESSKIT_LIBRARIES_DIR}/shared" | ||
) | ||
install(FILES | ||
"$<$<NOT:$<STREQUAL:$<TARGET_PROPERTY:accesskit-shared,IMPORTED_IMPLIB>,>>:$<TARGET_PROPERTY:accesskit-shared,IMPORTED_IMPLIB>>" | ||
RENAME "libaccesskit.a" | ||
DESTINATION "${ACCESSKIT_LIBRARIES_DIR}/shared" | ||
) | ||
endif() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.