Skip to content

Commit 31a5dcb

Browse files
authored
Fix embedded builds of IREE. (iree-org#15761) (iree-org#15768)
Use PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR to represent path relative to the top of IREE instead of the CMAKE_* counterpart. This fixes builds where IREE is embedded into another project. Thanks @dpackwood for raising the issue.
1 parent f44e076 commit 31a5dcb

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

build_tools/bazel_to_cmake/bazel_to_cmake_converter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,20 @@ def _normalize_label(self, src):
130130
# ':') or in other packages (leading '//'). We map that to paths by:
131131
# - dropping any leading ':' as in:
132132
# ':generated.c' -> 'generated.c'
133-
# - replacing any leading '//' by '${CMAKE_SOURCE_DIR}/' or
134-
# '${CMAKE_BINARY_DIR}/' and any internal ':' by '/', as in:
133+
# - replacing any leading '//' by '${PROJECT_SOURCE_DIR}/' or
134+
# '${PROJECT_BINARY_DIR}/' and any internal ':' by '/', as in:
135135
# '//path/to/package:source.c'
136-
# -> '${CMAKE_SOURCE_DIR}/path/to/package/source.c'
136+
# -> '${PROJECT_SOURCE_DIR}/path/to/package/source.c'
137137
# '//path/to/package:generated.c'
138-
# -> '${CMAKE_BINARY_DIR}/path/to/package/generated.c'
138+
# -> '${PROJECT_BINARY_DIR}/path/to/package/generated.c'
139139
pkg_root_relative_label = src.startswith("//")
140140
src = src.lstrip("/").lstrip(":").replace(":", "/")
141141
if not pkg_root_relative_label:
142142
return src
143143
elif os.path.exists(os.path.join(self._build_dir, src)):
144-
return f"${{CMAKE_SOURCE_DIR}}/{src}"
144+
return f"${{PROJECT_SOURCE_DIR}}/{src}"
145145
else:
146-
return f"${{CMAKE_BINARY_DIR}}/{src}"
146+
return f"${{PROJECT_BINARY_DIR}}/{src}"
147147

148148
def _convert_srcs_block(self, srcs, is_generated=False, block_name="SRCS"):
149149
if not srcs:

runtime/src/iree/builtins/ukernel/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ iree_bitcode_library(
117117
ARCH
118118
wasm_32
119119
INTERNAL_HDRS
120-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
120+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
121121
"internal_headers_filegroup.stamp"
122122
SRCS
123123
"mmt4d.c"
@@ -135,7 +135,7 @@ iree_bitcode_library(
135135
ARCH
136136
wasm_64
137137
INTERNAL_HDRS
138-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
138+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
139139
"internal_headers_filegroup.stamp"
140140
SRCS
141141
"mmt4d.c"
@@ -151,10 +151,10 @@ iree_c_embed_data(
151151
NAME
152152
embed_ukernel_bitcode
153153
SRCS
154-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/arch/arm_64/ukernel_bitcode_arm_64.bc"
155-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/arch/arm_64/ukernel_bitcode_arm_64_entry_points.bc"
156-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/arch/x86_64/ukernel_bitcode_x86_64.bc"
157-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/arch/x86_64/ukernel_bitcode_x86_64_entry_points.bc"
154+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/arch/arm_64/ukernel_bitcode_arm_64.bc"
155+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/arch/arm_64/ukernel_bitcode_arm_64_entry_points.bc"
156+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/arch/x86_64/ukernel_bitcode_x86_64.bc"
157+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/arch/x86_64/ukernel_bitcode_x86_64_entry_points.bc"
158158
"ukernel_bitcode_32bit_base.bc"
159159
"ukernel_bitcode_64bit_base.bc"
160160
DEPS

runtime/src/iree/builtins/ukernel/arch/arm_64/CMakeLists.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ iree_bitcode_library(
1919
ARCH
2020
wasm_64
2121
INTERNAL_HDRS
22-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
23-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
22+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
23+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
2424
"common_arm_64.h"
2525
"common_arm_64_entry_point.h"
2626
"mmt4d_arm_64_internal.h"
@@ -39,8 +39,8 @@ iree_bitcode_library(
3939
ARCH
4040
arm_64
4141
INTERNAL_HDRS
42-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
43-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
42+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
43+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
4444
"common_arm_64.h"
4545
"common_arm_64_entry_point.h"
4646
"mmt4d_arm_64_internal.h"
@@ -58,8 +58,8 @@ iree_bitcode_library(
5858
ARCH
5959
arm_64
6060
INTERNAL_HDRS
61-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
62-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
61+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
62+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
6363
"common_arm_64.h"
6464
"common_arm_64_entry_point.h"
6565
"mmt4d_arm_64_internal.h"
@@ -77,8 +77,8 @@ iree_bitcode_library(
7777
ARCH
7878
arm_64
7979
INTERNAL_HDRS
80-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
81-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
80+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
81+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
8282
"common_arm_64.h"
8383
"common_arm_64_entry_point.h"
8484
"mmt4d_arm_64_internal.h"
@@ -96,8 +96,8 @@ iree_bitcode_library(
9696
ARCH
9797
arm_64
9898
INTERNAL_HDRS
99-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
100-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
99+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
100+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
101101
"common_arm_64.h"
102102
"common_arm_64_entry_point.h"
103103
"mmt4d_arm_64_internal.h"
@@ -115,8 +115,8 @@ iree_bitcode_library(
115115
ARCH
116116
arm_64
117117
INTERNAL_HDRS
118-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
119-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
118+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
119+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
120120
"common_arm_64.h"
121121
"common_arm_64_entry_point.h"
122122
"mmt4d_arm_64_internal.h"
@@ -134,8 +134,8 @@ iree_bitcode_library(
134134
ARCH
135135
arm_64
136136
INTERNAL_HDRS
137-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
138-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
137+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
138+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
139139
"common_arm_64.h"
140140
"common_arm_64_entry_point.h"
141141
"mmt4d_arm_64_internal.h"

runtime/src/iree/builtins/ukernel/arch/x86_64/CMakeLists.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ iree_bitcode_library(
1919
ARCH
2020
wasm_64
2121
INTERNAL_HDRS
22-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
23-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
22+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
23+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
2424
"common_x86_64.h"
2525
"common_x86_64_entry_point.h"
2626
"mmt4d_x86_64_internal.h"
@@ -39,8 +39,8 @@ iree_bitcode_library(
3939
ARCH
4040
x86_64
4141
INTERNAL_HDRS
42-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
43-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
42+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
43+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
4444
"common_x86_64.h"
4545
"common_x86_64_entry_point.h"
4646
"mmt4d_x86_64_internal.h"
@@ -63,8 +63,8 @@ iree_bitcode_library(
6363
ARCH
6464
x86_64
6565
INTERNAL_HDRS
66-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
67-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
66+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
67+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
6868
"common_x86_64.h"
6969
"common_x86_64_entry_point.h"
7070
"mmt4d_x86_64_internal.h"
@@ -92,8 +92,8 @@ iree_bitcode_library(
9292
ARCH
9393
x86_64
9494
INTERNAL_HDRS
95-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
96-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
95+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
96+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
9797
"common_x86_64.h"
9898
"common_x86_64_entry_point.h"
9999
"mmt4d_x86_64_internal.h"
@@ -120,8 +120,8 @@ iree_bitcode_library(
120120
ARCH
121121
x86_64
122122
INTERNAL_HDRS
123-
"${CMAKE_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
124-
"${CMAKE_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
123+
"${PROJECT_BINARY_DIR}/runtime/src/iree/builtins/ukernel/internal_headers_filegroup.stamp"
124+
"${PROJECT_BINARY_DIR}/runtime/src/iree/schemas/cpu_data_headers_filegroup.stamp"
125125
"common_x86_64.h"
126126
"common_x86_64_entry_point.h"
127127
"mmt4d_x86_64_internal.h"

0 commit comments

Comments
 (0)