blob: 2ac9f5e9356c40d762af7446687fee16da9c1355 [file] [log] [blame]
Stella Laurenzoc35d8e92023-12-28 21:41:56 -08001iree_setup_c_src_root(
2 PACKAGE_ROOT_PREFIX iree::compiler::bindings::c
3 DEFAULT_EXPORT_SET Compiler
4 DEFAULT_INSTALL_COMPONENT IREEDevLibraries-Compiler
5)
Stella Laurenzo15c306f2023-12-28 19:03:20 -08006
7### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_ABOVE_THIS_LINE ###
Stella Laurenzo309dc5b2023-02-22 23:07:43 -08008################################################################################
9# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
Geoffrey Martin-Noble8626fdb2023-03-17 09:47:15 -070010# compiler/bindings/c/BUILD.bazel #
Stella Laurenzo309dc5b2023-02-22 23:07:43 -080011# #
12# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
13# CMake-only content. #
14# #
15# To disable autogeneration for this file entirely, delete this header. #
16################################################################################
17
18iree_add_all_subdirs()
19
20iree_cc_library(
21 NAME
22 headers
23 HDRS
24 "iree/compiler/api_support.h"
25 "iree/compiler/embedding_api.h"
26 "iree/compiler/loader.h"
Stella Laurenzo15c306f2023-12-28 19:03:20 -080027 "iree/compiler/mlir_interop.h"
Stella Laurenzo309dc5b2023-02-22 23:07:43 -080028 "iree/compiler/tool_entry_points_api.h"
Stella Laurenzo15c306f2023-12-28 19:03:20 -080029 DEPS
30 IREELLVMIncludeSetup
Stella Laurenzo309dc5b2023-02-22 23:07:43 -080031 INCLUDES
32 "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>"
33 "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/.>"
34 PUBLIC
35)
36
37iree_cc_library(
38 NAME
39 loader
40 SRCS
41 "iree/compiler/loader/handle_symbols.inc"
42 "iree/compiler/loader/loader.cpp"
43 DEPS
44 ${CMAKE_DL_LIBS}
45 ::headers
46 PUBLIC
47)
48
49### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
50
51# TODO: Make this test work with Bazel once that is more solid.
52
53if(IREE_HAVE_DYNAMIC_LIBRARY_LOADING)
54 # Dynamic library loading enabled.
55 if(IREE_BUILD_COMPILER AND IREE_BUILD_TESTS)
56 iree_cc_test(
57 NAME
58 loader_test
59 SRCS
60 "iree/compiler/loader/loader_test.c"
61 ARGS
Stella Laurenzo6dd9de82023-03-07 19:02:25 -080062 "$<TARGET_FILE:iree::compiler::API::SharedImpl>"
Stella Laurenzo309dc5b2023-02-22 23:07:43 -080063 DEPS
64 ::loader
65 )
66
67 # Must be a build dependency but not a library dep (we depend on it at
68 # runtime).
69 # TODO: Find a better way to do this.
70 add_dependencies(
71 iree_compiler_bindings_c_loader_test
Stella Laurenzo6dd9de82023-03-07 19:02:25 -080072 iree::compiler::API::SharedImpl
Stella Laurenzo309dc5b2023-02-22 23:07:43 -080073 )
74 endif()
75else()
76 # Dynamic library loading not available. Exclude loader from all.
77 message(STATUS "Disabling compiler loader (platform does not support library loading)")
78 iree_cc_library_exclude_from_all(loader TRUE)
79endif()
Stella Laurenzo15c306f2023-12-28 19:03:20 -080080
81# Install public mlir-c headers (since we export them from our library).
82# Scan the MLIR_INCLUDE_DIRS and install any that contains mlir-c. This
83# will work for both bundled and installed LLVM.
84# We could filter this, but it is just some C headers and easier to include
85# them all.
86foreach(_d ${MLIR_INCLUDE_DIRS})
87 if(EXISTS "${_d}/mlir-c")
88 install(
89 DIRECTORY "${_d}/mlir-c"
90 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
91 COMPONENT IREEDevLibraries-Compiler
92 EXCLUDE_FROM_ALL
Scott Todd62efaee2024-05-31 13:33:55 -070093 )
Stella Laurenzo15c306f2023-12-28 19:03:20 -080094 endif()
95endforeach()