Stella Laurenzo | 309dc5b | 2023-02-22 23:07:43 -0800 | [diff] [blame] | 1 | # Copyright 2023 The IREE Authors |
| 2 | # |
| 3 | # Licensed under the Apache License v2.0 with LLVM Exceptions. |
| 4 | # See https://llvm.org/LICENSE.txt for license information. |
| 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Stella Laurenzo | 41a2ceb | 2022-04-29 12:49:36 -0700 | [diff] [blame] | 6 | |
Stanley Winata | d413a7e | 2023-10-04 10:40:32 -0700 | [diff] [blame] | 7 | # On Windows, DLLs go to the runtime directory and import |
| 8 | # libraries go to the lib directory. |
| 9 | # TODO: We should really be dumping binaries into bin/ not |
| 10 | # tools/. This must line up with binaries built this way because |
| 11 | # DLLs must be in the same directory as the binary. |
Scott Todd | 3f51a55 | 2024-04-19 11:00:27 -0700 | [diff] [blame] | 12 | # See: https://github.com/iree-org/iree/issues/11297 |
Stanley Winata | d413a7e | 2023-10-04 10:40:32 -0700 | [diff] [blame] | 13 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/tools") |
| 14 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") |
| 15 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") |
| 16 | if(WIN32) |
| 17 | set(IREE_COMPILER_DYLIB_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") |
| 18 | set(IREE_COMPILER_DYLIB_INSTALL_PREFIX "bin/") |
| 19 | else() |
| 20 | set(IREE_COMPILER_DYLIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") |
| 21 | set(IREE_COMPILER_DYLIB_INSTALL_PREFIX "lib/") |
| 22 | endif() |
| 23 | |
Stella Laurenzo | 309dc5b | 2023-02-22 23:07:43 -0800 | [diff] [blame] | 24 | # Always build the C bindings, since the API is available apart from |
| 25 | # actually building the compiler. |
| 26 | add_subdirectory(bindings/c) |
Stella Laurenzo | 41a2ceb | 2022-04-29 12:49:36 -0700 | [diff] [blame] | 27 | |
Stella Laurenzo | 309dc5b | 2023-02-22 23:07:43 -0800 | [diff] [blame] | 28 | # The compiler implementation is gated on the global setting. |
| 29 | if(IREE_BUILD_COMPILER) |
Stella Laurenzo | 2eb6862 | 2023-11-10 17:04:46 -0800 | [diff] [blame] | 30 | # Force enable BUILD_SHARED_LIBS for the compiler if instructed. |
| 31 | set(_IREE_ORIG_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) |
| 32 | if(IREE_COMPILER_BUILD_SHARED_LIBS) |
| 33 | set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) |
| 34 | endif() |
| 35 | |
Stella Laurenzo | c6092c4 | 2023-03-25 19:55:37 -0700 | [diff] [blame] | 36 | # Must configure plugins before processing the compiler sources so that |
| 37 | # the static link list can be set. |
Stella Laurenzo | 2eb6862 | 2023-11-10 17:04:46 -0800 | [diff] [blame] | 38 | iree_include_cmake_plugin_dirs( |
| 39 | LOG_LABEL |
| 40 | compiler |
| 41 | BINARY_DIR |
| 42 | "${IREE_BINARY_DIR}/compiler/plugins" |
| 43 | PLUGIN_CMAKE_FILE |
| 44 | "iree_compiler_plugin.cmake" |
| 45 | ) |
Stella Laurenzo | 309dc5b | 2023-02-22 23:07:43 -0800 | [diff] [blame] | 46 | add_subdirectory(src) |
Stella Laurenzo | 41a2ceb | 2022-04-29 12:49:36 -0700 | [diff] [blame] | 47 | |
Stella Laurenzo | 2eb6862 | 2023-11-10 17:04:46 -0800 | [diff] [blame] | 48 | # Reset BUILD_SHARED_LIBS. |
| 49 | set(BUILD_SHARED_LIBS ${_IREE_ORIG_BUILD_SHARED_LIBS} CACHE BOOL "" FORCE) |
| 50 | |
Stella Laurenzo | 309dc5b | 2023-02-22 23:07:43 -0800 | [diff] [blame] | 51 | # Copy Python packaging files to the build dir so that we can install from |
| 52 | # there. |
| 53 | if(IREE_BUILD_PYTHON_BINDINGS) |
| 54 | configure_file(pyproject.toml pyproject.toml COPYONLY) |
| 55 | configure_file(setup.py setup.py @ONLY) |
Stella Laurenzo | 6dd9de8 | 2023-03-07 19:02:25 -0800 | [diff] [blame] | 56 | add_subdirectory(bindings/python) |
Stella Laurenzo | 309dc5b | 2023-02-22 23:07:43 -0800 | [diff] [blame] | 57 | endif() |
Stanley Winata | d413a7e | 2023-10-04 10:40:32 -0700 | [diff] [blame] | 58 | |
| 59 | # Post processing. |
Ben Vanik | eb49f72 | 2024-04-24 13:16:13 -0700 | [diff] [blame] | 60 | get_property(_iree_compiler_depends GLOBAL PROPERTY IREE_COMPILER_DEPENDS) |
| 61 | if(_iree_compiler_depends) |
| 62 | add_dependencies(iree_compiler_API_SharedImpl ${_iree_compiler_depends}) |
| 63 | add_dependencies(iree_compiler_API_StaticImpl ${_iree_compiler_depends}) |
Stanley Winata | d413a7e | 2023-10-04 10:40:32 -0700 | [diff] [blame] | 64 | endif() |
Stella Laurenzo | 41a2ceb | 2022-04-29 12:49:36 -0700 | [diff] [blame] | 65 | endif() |