[llvm] 6bc8163 - [cmake] Export driver template to fix standalone build
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 10 00:51:09 PDT 2022
Author: Nikita Popov
Date: 2022-06-10T09:50:23+02:00
New Revision: 6bc8163c79fd82369f4930db66b836d8f9098569
URL: https://github.com/llvm/llvm-project/commit/6bc8163c79fd82369f4930db66b836d8f9098569
DIFF: https://github.com/llvm/llvm-project/commit/6bc8163c79fd82369f4930db66b836d8f9098569.diff
LOG: [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
Added:
llvm/cmake/modules/llvm-driver-template.cpp.in
Modified:
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/CMakeLists.txt
Removed:
llvm/cmake/driver-template.cpp.in
################################################################################
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 7e7b801efebff..8e1385e90b82d 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -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)
diff --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt
index 0a7d84fe1c9bd..c77d30c82de9a 100644
--- a/llvm/cmake/modules/CMakeLists.txt
+++ b/llvm/cmake/modules/CMakeLists.txt
@@ -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
diff --git a/llvm/cmake/driver-template.cpp.in b/llvm/cmake/modules/llvm-driver-template.cpp.in
similarity index 100%
rename from llvm/cmake/driver-template.cpp.in
rename to llvm/cmake/modules/llvm-driver-template.cpp.in
More information about the llvm-commits
mailing list