-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
66 lines (54 loc) · 2.07 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
cmake_minimum_required(VERSION 3.20)
project(accesskit-c)
option(ACCESSKIT_BUILD_HEADERS "Whether to build header files" OFF)
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.4.7
)
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()