Skip to content

Commit c2534f4

Browse files
committed
Fix headers generation
1 parent 2074e56 commit c2534f4

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

bindings/c/CMakeLists.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ cmake_minimum_required(VERSION 3.20)
22

33
project(accesskit_c)
44

5+
SET(ACCESSKIT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
56
SET(ACCESSKIT_IN_REPO ON)
6-
if (NOT EXISTS(${CMAKE_SOURCE_DIR}/lib))
7+
if (EXISTS(${CMAKE_SOURCE_DIR}/lib))
78
SET(ACCESSKIT_IN_REPO OFF)
89
if (WIN32)
910
if (MINGW)
@@ -20,19 +21,19 @@ if (NOT EXISTS(${CMAKE_SOURCE_DIR}/lib))
2021
endif()
2122
endif()
2223
endif()
23-
endif()
24-
SET(ACCESSKIT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
25-
26-
if (${ACCESSKIT_IN_REPO})
27-
include(ExternalProject)
24+
else()
2825
add_subdirectory(corrosion)
2926
corrosion_import_crate(MANIFEST_PATH Cargo.toml)
3027

28+
find_program(RUSTUP rustup)
29+
find_program(CBINDGEN cbindgen)
30+
find_program(CLANG_FORMAT clang-format)
31+
3132
add_custom_target(headers
32-
COMMAND rustup run nightly cbindgen --crate accesskit_c --output "${ACCESSKIT_INCLUDE_DIR}/accesskit.hpp" "${CMAKE_SOURCE_DIR}"
33-
COMMAND clang-format -i "${ACCESSKIT_INCLUDE_DIR}/accesskit.hpp"
33+
COMMAND ${RUSTUP} run nightly ${CBINDGEN} --crate accesskit_c --output "${ACCESSKIT_INCLUDE_DIR}/accesskit.hpp" "${CMAKE_SOURCE_DIR}"
34+
COMMAND ${CLANG_FORMAT} -i "${ACCESSKIT_INCLUDE_DIR}/accesskit.hpp"
3435
COMMAND ${CMAKE_COMMAND} -E rename "${ACCESSKIT_INCLUDE_DIR}/accesskit.hpp" "${ACCESSKIT_INCLUDE_DIR}/accesskit.h"
35-
DEPENDS "${ACCESSKIT_INCLUDE_DIR}/accesskit.h"
36+
BYPRODUCTS "${ACCESSKIT_INCLUDE_DIR}/accesskit.h"
3637
)
3738

3839
add_dependencies(cargo-prebuild_accesskit headers)

0 commit comments

Comments
 (0)