[cmake] Export driver template to fix standalone build

Export the driver-template.cpp.in file so that tools using
GENERATE_DRIVER work in standalone builds (currently only relevant
for clang). I've given the file an llvm- prefix, as we're now
searching for the file in CMAKE_MODULE_PATH.

Differential Revision: https://reviews.llvm.org/D127384
This commit is contained in:
Nikita Popov 2022-06-09 10:24:52 +02:00
parent c10921fa1a
commit 6bc8163c79
3 changed files with 10 additions and 4 deletions

View File

@ -892,9 +892,14 @@ macro(add_llvm_executable name)
if (ARG_GENERATE_DRIVER)
string(REPLACE "-" "_" TOOL_NAME ${name})
configure_file(
${LLVM_MAIN_SRC_DIR}/cmake/driver-template.cpp.in
${CMAKE_CURRENT_BINARY_DIR}/${name}-driver.cpp)
foreach(path ${CMAKE_MODULE_PATH})
if(EXISTS ${path}/llvm-driver-template.cpp.in)
configure_file(
${path}/llvm-driver-template.cpp.in
${CMAKE_CURRENT_BINARY_DIR}/${name}-driver.cpp)
break()
endif()
endforeach()
list(APPEND ALL_FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}-driver.cpp)

View File

@ -173,7 +173,8 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
PATTERN LLVMConfigExtensions.cmake EXCLUDE
PATTERN LLVMConfigVersion.cmake EXCLUDE
PATTERN LLVM-Config.cmake EXCLUDE
PATTERN GetHostTriple.cmake EXCLUDE)
PATTERN GetHostTriple.cmake EXCLUDE
PATTERN llvm-driver-template.cpp.in)
if (NOT LLVM_ENABLE_IDE)
# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS