only update non-libLLVM.so case
diff --git a/enzyme/Enzyme/CMakeLists.txt b/enzyme/Enzyme/CMakeLists.txt
index 513b47d..b3565f2 100644
--- a/enzyme/Enzyme/CMakeLists.txt
+++ b/enzyme/Enzyme/CMakeLists.txt
@@ -146,19 +146,23 @@
add_dependencies(Enzyme-${LLVM_VERSION_MAJOR} BlasTAIncGen)
add_dependencies(Enzyme-${LLVM_VERSION_MAJOR} BlasDiffUseIncGen)
- # 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})
+ if (${LLVM_BUILD_LLVM_DYLIB})
+ target_link_libraries(Enzyme-${LLVM_VERSION_MAJOR} LLVM)
+ else()
+ # 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})
+ endif()
install(TARGETS Enzyme-${LLVM_VERSION_MAJOR}
EXPORT EnzymeTargets
LIBRARY DESTINATION lib COMPONENT shlib