Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion enzyme/Enzyme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,20 @@ if (${ENZYME_EXTERNAL_SHARED_LIB})
add_dependencies(Enzyme-${LLVM_VERSION_MAJOR} BlasDeclarationsIncGen)
add_dependencies(Enzyme-${LLVM_VERSION_MAJOR} BlasTAIncGen)
add_dependencies(Enzyme-${LLVM_VERSION_MAJOR} BlasDiffUseIncGen)
target_link_libraries(Enzyme-${LLVM_VERSION_MAJOR} LLVM)

# This would be the desired way to link against LLVM components,
# however this function is bugged and does not work with `all`, see:
# https://github.com/llvm/llvm-project/issues/46347
#llvm_map_components_to_libnames(llvm_libs all)
# Therefore, manually invoke llvm-config
execute_process(COMMAND ${LLVM_TOOLS_BINARY_DIR}/llvm-config --libs all
OUTPUT_VARIABLE llvm_libraries)
string(STRIP "${llvm_libraries}" llvm_libraries)
# In theory, adding --libs should also add all the -l flags,
# but it isn't picked up correctly by clang, so we call target_link_libraries
set_target_properties(Enzyme-${LLVM_VERSION_MAJOR} PROPERTIES
LINK_FLAGS "`${LLVM_TOOLS_BINARY_DIR}/llvm-config --ldflags`")
target_link_libraries(Enzyme-${LLVM_VERSION_MAJOR} ${llvm_libraries})
install(TARGETS Enzyme-${LLVM_VERSION_MAJOR}
EXPORT EnzymeTargets
LIBRARY DESTINATION lib COMPONENT shlib
Expand Down
Loading