blob: 4ac14b30f71c041bdefa8b153558cb0ac3a5ef54 [file] [log] [blame]
# 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/openxla/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)
# Must configure plugins before processing the compiler sources so that
# the static link list can be set.
iree_compiler_configure_plugins()
add_subdirectory(src)
# 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_dylib_depends GLOBAL PROPERTY IREE_COMPILER_DYLIB_DEPENDS)
if(_iree_compiler_dylib_depends)
add_dependencies(iree_compiler_API_SharedImpl ${_iree_compiler_dylib_depends})
endif()
endif()