1 From 8102ee2f83c3bd87e5b6aa405d04b5c3abc5ef3b Mon Sep 17 00:00:00 2001
2 From: Wenju He <wenju.he@intel.com>
3 Date: Wed, 17 May 2023 08:54:44 +0800
4 Subject: [PATCH] Revert to use add_llvm_library and revert linking LLVM
7 Add cmake option EXCLUDE_LIBS_FROM_ALL to remove a specific llvm library
10 This PR partially reverts 743bd15.
11 This PR addresses #401, #417, #418, #422, and brings back SONAME.
13 CMakeLists.txt | 73 +++++++++++---------------------------------------
14 1 file changed, 15 insertions(+), 58 deletions(-)
16 diff --git a/CMakeLists.txt b/CMakeLists.txt
17 index b1bde90..5b3c4b7 100644
20 @@ -292,21 +292,23 @@ else()
24 -add_library(${TARGET_NAME} SHARED
25 - ${TARGET_INCLUDE_FILES}
26 - ${TARGET_SOURCE_FILES}
27 - $<TARGET_OBJECTS:cl_headers>
30 -# Same CRT compile option are reqiured to avoid link errors on Windows.
31 -# MD and MDd are choosed by default for release and debug build in LLVM.
32 -# If users set MT or MTd flags, they also need to add the flags for
33 -# opencl-clang sources using a custom macro set_msvc_crt_flags.
34 -if(COMMAND set_msvc_crt_flags)
35 - set_msvc_crt_flags(${TARGET_NAME})
36 +set(EXCLUDE_LIBS_FROM_ALL "" CACHE STRING "Space-separated list of LLVM libraries to exclude from all")
37 +llvm_map_components_to_libnames(ALL_LLVM_LIBS all)
38 +if (NOT "${EXCLUDE_LIBS_FROM_ALL}" STREQUAL "")
39 + list(REMOVE_ITEM ALL_LLVM_LIBS ${EXCLUDE_LIBS_FROM_ALL})
41 +list(APPEND OPENCL_CLANG_LINK_LIBS ${ALL_LLVM_LIBS})
43 +add_llvm_library(${TARGET_NAME} SHARED
44 + ${TARGET_INCLUDE_FILES}
45 + ${TARGET_SOURCE_FILES}
46 + $<TARGET_OBJECTS:cl_headers>
48 -add_dependencies(${TARGET_NAME} CClangCompileOptions)
49 + DEPENDS CClangCompileOptions
52 + ${OPENCL_CLANG_LINK_LIBS}
56 # Enable compiler generation of Control Flow Guard security checks.
57 @@ -322,51 +324,6 @@ elseif(UNIX)
58 LINK_FLAGS " -Wl,--no-undefined")
61 -# Enable new IN_LIST operator.
62 -cmake_policy(SET CMP0057 NEW)
64 -if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
65 - list(APPEND OTHER_LIBRARIES LLVMNVPTXCodeGen LLVMNVPTXDesc LLVMNVPTXInfo)
67 -if ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD)
68 - list(APPEND OTHER_LIBRARIES LLVMAMDGPUCodeGen LLVMAMDGPUAsmParser LLVMAMDGPUDesc LLVMAMDGPUInfo)
71 -target_link_libraries( ${TARGET_NAME}
73 - ${OPENCL_CLANG_LINK_LIBS}
106 install(FILES opencl_clang.h
107 DESTINATION include/cclang
108 COMPONENT ${TARGET_NAME})