aboutsummaryrefslogtreecommitdiff
path: root/libclc
diff options
context:
space:
mode:
authorFraser Cormack <fraser@codeplay.com>2024-04-16 16:46:37 +0100
committerFraser Cormack <fraser@codeplay.com>2024-04-18 07:01:13 +0100
commit0aeeff3059e79b86f55ed92a4488bdee8fa66e12 (patch)
tree3b0306a0df5cac5c2bfd3367dfa1586c9406579f /libclc
parent93d51194b1df8229268953ec94063fc4194a320b (diff)
downloadllvm-0aeeff3059e79b86f55ed92a4488bdee8fa66e12.zip
llvm-0aeeff3059e79b86f55ed92a4488bdee8fa66e12.tar.gz
llvm-0aeeff3059e79b86f55ed92a4488bdee8fa66e12.tar.bz2
[libclc] Allow building with pre-built tools
Building the libclc project in-tree with debug tools can be very slow. This commit adds an option for a user to specify a dierctory from which to import (e.g., release-built) tools. All tools required by the project must be imported from the same location, for simplicity. Original patch downstream authored by @jchlanda.
Diffstat (limited to 'libclc')
-rw-r--r--libclc/CMakeLists.txt33
1 files changed, 27 insertions, 6 deletions
diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 4442ff6..b0c29ed 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -50,11 +50,13 @@ if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DI
endif()
# Import required tools as targets
- foreach( tool IN ITEMS clang llvm-as llvm-link opt )
- find_program( LLVM_TOOL_${tool} ${tool} PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
- add_executable( libclc::${tool} IMPORTED GLOBAL )
- set_target_properties( libclc::${tool} PROPERTIES IMPORTED_LOCATION ${LLVM_TOOL_${tool}} )
- endforeach()
+ if( NOT EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} )
+ foreach( tool IN ITEMS clang llvm-as llvm-link opt )
+ find_program( LLVM_TOOL_${tool} ${tool} PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
+ add_executable( libclc::${tool} IMPORTED GLOBAL )
+ set_target_properties( libclc::${tool} PROPERTIES IMPORTED_LOCATION ${LLVM_TOOL_${tool}} )
+ endforeach()
+ endif()
else()
# In-tree configuration
set( LIBCLC_STANDALONE_BUILD FALSE )
@@ -68,8 +70,27 @@ else()
message(FATAL_ERROR "Clang is not enabled, but is required to build libclc in-tree")
endif()
+ if( NOT EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} )
+ foreach( tool IN ITEMS clang llvm-as llvm-link opt )
+ add_executable(libclc::${tool} ALIAS ${tool})
+ endforeach()
+ endif()
+endif()
+
+if( EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} )
+ message( WARNING "Using custom LLVM tools to build libclc: "
+ "${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR}, "
+ " ensure the tools are up to date." )
+ # Note - use a differently named variable than LLVM_TOOL_${tool} as above, as
+ # the variable name is used to cache the result of find_program. If we used
+ # the same name, a user wouldn't be able to switch a build between default
+ # and custom tools.
foreach( tool IN ITEMS clang llvm-as llvm-link opt )
- add_executable(libclc::${tool} ALIAS ${tool})
+ find_program( LLVM_CUSTOM_TOOL_${tool} ${tool}
+ PATHS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
+ add_executable( libclc::${tool} IMPORTED GLOBAL )
+ set_target_properties( libclc::${tool} PROPERTIES
+ IMPORTED_LOCATION ${LLVM_CUSTOM_TOOL_${tool}} )
endforeach()
endif()