Skip to content

Commit d439aa0

Browse files
authored
Revert to use add_llvm_library and revert linking LLVM libraries (#439)
Add cmake option EXCLUDE_LIBS_FROM_ALL to remove a specific llvm library from llvm 'all'. This PR partially reverts 743bd15. This PR addresses #401, #417, #418, #422, and brings back SONAME.
1 parent 321e3b9 commit d439aa0

File tree

1 file changed

+15
-58
lines changed

1 file changed

+15
-58
lines changed

CMakeLists.txt

Lines changed: 15 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,23 @@ else()
292292
)
293293
endif()
294294

295-
add_library(${TARGET_NAME} SHARED
296-
${TARGET_INCLUDE_FILES}
297-
${TARGET_SOURCE_FILES}
298-
$<TARGET_OBJECTS:cl_headers>
299-
)
300-
301-
# Same CRT compile option are reqiured to avoid link errors on Windows.
302-
# MD and MDd are choosed by default for release and debug build in LLVM.
303-
# If users set MT or MTd flags, they also need to add the flags for
304-
# opencl-clang sources using a custom macro set_msvc_crt_flags.
305-
if(COMMAND set_msvc_crt_flags)
306-
set_msvc_crt_flags(${TARGET_NAME})
295+
set(EXCLUDE_LIBS_FROM_ALL "" CACHE STRING "Space-separated list of LLVM libraries to exclude from all")
296+
llvm_map_components_to_libnames(ALL_LLVM_LIBS all)
297+
if (NOT "${EXCLUDE_LIBS_FROM_ALL}" STREQUAL "")
298+
list(REMOVE_ITEM ALL_LLVM_LIBS ${EXCLUDE_LIBS_FROM_ALL})
307299
endif()
300+
list(APPEND OPENCL_CLANG_LINK_LIBS ${ALL_LLVM_LIBS})
301+
302+
add_llvm_library(${TARGET_NAME} SHARED
303+
${TARGET_INCLUDE_FILES}
304+
${TARGET_SOURCE_FILES}
305+
$<TARGET_OBJECTS:cl_headers>
308306

309-
add_dependencies(${TARGET_NAME} CClangCompileOptions)
307+
DEPENDS CClangCompileOptions
308+
309+
LINK_LIBS
310+
${OPENCL_CLANG_LINK_LIBS}
311+
)
310312

311313
if (WIN32)
312314
# Enable compiler generation of Control Flow Guard security checks.
@@ -322,51 +324,6 @@ elseif(UNIX)
322324
LINK_FLAGS " -Wl,--no-undefined")
323325
endif(WIN32)
324326

325-
# Enable new IN_LIST operator.
326-
cmake_policy(SET CMP0057 NEW)
327-
set(OTHER_LIBRARIES)
328-
if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
329-
list(APPEND OTHER_LIBRARIES LLVMNVPTXCodeGen LLVMNVPTXDesc LLVMNVPTXInfo)
330-
endif()
331-
if ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD)
332-
list(APPEND OTHER_LIBRARIES LLVMAMDGPUCodeGen LLVMAMDGPUAsmParser LLVMAMDGPUDesc LLVMAMDGPUInfo)
333-
endif()
334-
335-
target_link_libraries( ${TARGET_NAME}
336-
LINK_PRIVATE
337-
${OPENCL_CLANG_LINK_LIBS}
338-
LLVMX86CodeGen
339-
LLVMX86AsmParser
340-
LLVMX86Desc
341-
LLVMX86Info
342-
LLVMX86Disassembler
343-
LLVMAnalysis
344-
LLVMCodeGen
345-
LLVMCore
346-
LLVMipo
347-
LLVMInstCombine
348-
LLVMInstrumentation
349-
LLVMMC
350-
LLVMMCParser
351-
LLVMObjCARCOpts
352-
LLVMOption
353-
LLVMScalarOpts
354-
LLVMSupport
355-
LLVMTransformUtils
356-
LLVMVectorize
357-
LLVMAsmPrinter
358-
LLVMSelectionDAG
359-
LLVMMCDisassembler
360-
LLVMProfileData
361-
LLVMObject
362-
LLVMBitWriter
363-
LLVMIRReader
364-
LLVMAsmParser
365-
LLVMTarget
366-
LLVMBitReader
367-
${OTHER_LIBRARIES}
368-
)
369-
370327
install(FILES opencl_clang.h
371328
DESTINATION include/cclang
372329
COMPONENT ${TARGET_NAME})

0 commit comments

Comments
 (0)