@@ -152,16 +152,28 @@ if (${ENZYME_EXTERNAL_SHARED_LIB})
152
152
# This would be the desired way to link against LLVM components,
153
153
# however this function is bugged and does not work with `all`, see:
154
154
# https://github.com/llvm/llvm-project/issues/46347
155
- #llvm_map_components_to_libnames(llvm_libs all )
155
+ #llvm_map_components_to_libnames(llvm_libraries Passes )
156
156
# Therefore, manually invoke llvm-config
157
+ if (EXISTS "${LLVM_TOOLS_BINARY_DIR} /llvm-config" )
158
+ message (STATUS "Using llvm-config from ${LLVM_TOOLS_BINARY_DIR} " )
159
+ else ()
160
+ message (SEND_ERROR "llvm-config not found in ${LLVM_TOOLS_BINARY_DIR} " )
161
+ endif ()
157
162
execute_process (COMMAND ${LLVM_TOOLS_BINARY_DIR} /llvm-config --libs all
158
163
OUTPUT_VARIABLE llvm_libraries)
159
164
string (STRIP "${llvm_libraries} " llvm_libraries)
165
+ message (STATUS "Linking against LLVM libraries: ${llvm_libraries} " )
160
166
# In theory, adding --libs should also add all the -l flags,
161
167
# but it isn't picked up correctly by clang, so we call target_link_libraries
162
- set_target_properties (Enzyme-${LLVM_VERSION_MAJOR} PROPERTIES
163
- LINK_FLAGS "`${LLVM_TOOLS_BINARY_DIR} /llvm-config --ldflags`" )
164
- target_link_libraries (Enzyme-${LLVM_VERSION_MAJOR} ${llvm_libraries} )
168
+ execute_process (COMMAND ${LLVM_TOOLS_BINARY_DIR} /llvm-config --ldflags
169
+ OUTPUT_VARIABLE llvm_ldflags)
170
+ string (STRIP "${llvm_ldflags} " llvm_ldflags)
171
+ message (STATUS "Linking against LLVM ldflags: ${llvm_ldflags} " )
172
+ set_target_properties (Enzyme-${LLVM_VERSION_MAJOR} PROPERTIES LINK_FLAGS ${llvm_ldflags} )
173
+ target_link_libraries (Enzyme-${LLVM_VERSION_MAJOR} PRIVATE ${llvm_libraries} )
174
+
175
+ llvm_map_components_to_libnames(llvm_librariess Passes Support)
176
+ target_link_libraries (Enzyme-${LLVM_VERSION_MAJOR} PRIVATE ${llvm_librariess} )
165
177
endif ()
166
178
install (TARGETS Enzyme-${LLVM_VERSION_MAJOR}
167
179
EXPORT EnzymeTargets
0 commit comments