Skip to content

Commit 4baae16

Browse files
committed
[pseudo] Fix pseudo-gen usage when cross-compiling
Use the LLVM build system's cross-compilation support for the tool, so that the build works for both host and cross-compilation scenarios. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D126397
1 parent 504736c commit 4baae16

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

clang-tools-extra/pseudo/include/CMakeLists.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
# The cxx.bnf grammar file
22
set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx.bnf)
33

4+
# Using CMAKE_CROSSCOMPILING and not LLVM_USE_HOST_TOOLS because the latter is
5+
# also set for LLVM_OPTIMIZED_TABLEGEN, which we don't care about here.
6+
if(CMAKE_CROSSCOMPILING)
7+
build_native_tool(pseudo-gen pseudo_gen)
8+
set(pseudo_gen_target "${pseudo_gen}")
9+
else()
10+
set(pseudo_gen $<TARGET_FILE:pseudo-gen>)
11+
set(pseudo_gen_target pseudo-gen)
12+
endif()
13+
414
# Generate inc files.
515
set(cxx_symbols_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXSymbols.inc)
616
add_custom_command(OUTPUT ${cxx_symbols_inc}
7-
COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/pseudo-gen"
17+
COMMAND "${pseudo_gen}"
818
--grammar ${cxx_bnf}
919
--emit-symbol-list
1020
-o ${cxx_symbols_inc}
1121
COMMENT "Generating nonterminal symbol file for cxx grammar..."
12-
DEPENDS pseudo-gen
22+
DEPENDS ${pseudo_gen_target}
1323
VERBATIM)
1424

1525
set(cxx_bnf_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXBNF.inc)
1626
add_custom_command(OUTPUT ${cxx_bnf_inc}
17-
COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/pseudo-gen"
27+
COMMAND "${pseudo_gen}"
1828
--grammar ${cxx_bnf}
1929
--emit-grammar-content
2030
-o ${cxx_bnf_inc}
2131
COMMENT "Generating bnf string file for cxx grammar..."
22-
DEPENDS pseudo-gen
32+
DEPENDS ${pseudo_gen_target}
2333
VERBATIM)
2434

2535
# add_custom_command does not create a new target, we need to deine a target

0 commit comments

Comments
 (0)