-
Notifications
You must be signed in to change notification settings - Fork 637
/
CMakeLists.txt
65 lines (58 loc) · 2.38 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
# Copyright 2023 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# On Windows, DLLs go to the runtime directory and import
# libraries go to the lib directory.
# TODO: We should really be dumping binaries into bin/ not
# tools/. This must line up with binaries built this way because
# DLLs must be in the same directory as the binary.
# See: https://github.com/iree-org/iree/issues/11297
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/tools")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
if(WIN32)
set(IREE_COMPILER_DYLIB_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(IREE_COMPILER_DYLIB_INSTALL_PREFIX "bin/")
else()
set(IREE_COMPILER_DYLIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
set(IREE_COMPILER_DYLIB_INSTALL_PREFIX "lib/")
endif()
# Always build the C bindings, since the API is available apart from
# actually building the compiler.
add_subdirectory(bindings/c)
# The compiler implementation is gated on the global setting.
if(IREE_BUILD_COMPILER)
# Force enable BUILD_SHARED_LIBS for the compiler if instructed.
set(_IREE_ORIG_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
if(IREE_COMPILER_BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
endif()
# Must configure plugins before processing the compiler sources so that
# the static link list can be set.
iree_include_cmake_plugin_dirs(
LOG_LABEL
compiler
BINARY_DIR
"${IREE_BINARY_DIR}/compiler/plugins"
PLUGIN_CMAKE_FILE
"iree_compiler_plugin.cmake"
)
add_subdirectory(src)
# Reset BUILD_SHARED_LIBS.
set(BUILD_SHARED_LIBS ${_IREE_ORIG_BUILD_SHARED_LIBS} CACHE BOOL "" FORCE)
# Copy Python packaging files to the build dir so that we can install from
# there.
if(IREE_BUILD_PYTHON_BINDINGS)
configure_file(pyproject.toml pyproject.toml COPYONLY)
configure_file(setup.py setup.py @ONLY)
add_subdirectory(bindings/python)
endif()
# Post processing.
get_property(_iree_compiler_depends GLOBAL PROPERTY IREE_COMPILER_DEPENDS)
if(_iree_compiler_depends)
add_dependencies(iree_compiler_API_SharedImpl ${_iree_compiler_depends})
add_dependencies(iree_compiler_API_StaticImpl ${_iree_compiler_depends})
endif()
endif()