Skip to content

Commit b650390

Browse files
committed
[cmake] Use relative cmake binary dir for processing pass plugins.
https://reviews.llvm.org/D61446 introduced a new function to process pass plugins that used CMAKE_BINARY_DIR. This is problematic when LLVM is a subproject. Instead use LLVM_BINARY_DIR to get the right relative directory for cmake. Patch by Alan Baker <[email protected]> Reviewed By: Meinersbur Differential Revision: https://reviews.llvm.org/D72109
1 parent 8edf759 commit b650390

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ endfunction(add_llvm_pass_plugin)
883883
# Also correctly set lib dependencies between plugins and tools.
884884
function(process_llvm_pass_plugins)
885885
get_property(LLVM_EXTENSIONS GLOBAL PROPERTY LLVM_COMPILE_EXTENSIONS)
886-
file(WRITE "${CMAKE_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "//extension handlers\n")
886+
file(WRITE "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "//extension handlers\n")
887887
foreach(llvm_extension ${LLVM_EXTENSIONS})
888888
string(TOLOWER ${llvm_extension} llvm_extension_lower)
889889

@@ -893,23 +893,25 @@ function(process_llvm_pass_plugins)
893893
string(CONCAT llvm_extension_project ${llvm_extension_upper_first} ${llvm_extension_lower_tail})
894894

895895
if(LLVM_${llvm_extension_upper}_LINK_INTO_TOOLS)
896-
file(APPEND "${CMAKE_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "HANDLE_EXTENSION(${llvm_extension_project})\n")
896+
file(APPEND "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "HANDLE_EXTENSION(${llvm_extension_project})\n")
897897

898-
get_property(llvm_plugin_targets GLOBAL PROPERTY LLVM_PLUGIN_TARGETS)
899-
foreach(llvm_plugin_target ${llvm_plugin_targets})
900-
set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
901-
set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
902-
endforeach()
898+
get_property(llvm_plugin_targets GLOBAL PROPERTY LLVM_PLUGIN_TARGETS)
899+
foreach(llvm_plugin_target ${llvm_plugin_targets})
900+
set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
901+
set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
902+
endforeach()
903903
else()
904904
add_llvm_library(${llvm_extension_lower} MODULE obj.${llvm_extension_lower})
905905
endif()
906906

907907
endforeach()
908-
file(APPEND "${CMAKE_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "#undef HANDLE_EXTENSION\n")
908+
file(APPEND "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "#undef HANDLE_EXTENSION\n")
909909

910910
# only replace if there's an actual change
911-
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "${CMAKE_BINARY_DIR}/include/llvm/Support/Extension.def")
912-
file(REMOVE "${CMAKE_BINARY_DIR}/include/llvm/Support/Extension.def.tmp")
911+
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
912+
"${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp"
913+
"${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def")
914+
file(REMOVE "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp")
913915
endfunction()
914916

915917
function(export_executable_symbols target)

0 commit comments

Comments
 (0)