]>
Commit | Line | Data |
---|---|---|
91f591af JP |
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 | |
5 | libraries | |
6 | ||
7 | Add cmake option EXCLUDE_LIBS_FROM_ALL to remove a specific llvm library | |
8 | from llvm 'all'. | |
9 | ||
10 | This PR partially reverts 743bd15. | |
11 | This PR addresses #401, #417, #418, #422, and brings back SONAME. | |
12 | --- | |
13 | CMakeLists.txt | 73 +++++++++++--------------------------------------- | |
14 | 1 file changed, 15 insertions(+), 58 deletions(-) | |
15 | ||
16 | diff --git a/CMakeLists.txt b/CMakeLists.txt | |
17 | index b1bde90..5b3c4b7 100644 | |
18 | --- a/CMakeLists.txt | |
19 | +++ b/CMakeLists.txt | |
20 | @@ -292,21 +292,23 @@ else() | |
21 | ) | |
22 | endif() | |
23 | ||
24 | -add_library(${TARGET_NAME} SHARED | |
25 | - ${TARGET_INCLUDE_FILES} | |
26 | - ${TARGET_SOURCE_FILES} | |
27 | - $<TARGET_OBJECTS:cl_headers> | |
28 | -) | |
29 | - | |
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}) | |
40 | endif() | |
41 | +list(APPEND OPENCL_CLANG_LINK_LIBS ${ALL_LLVM_LIBS}) | |
42 | + | |
43 | +add_llvm_library(${TARGET_NAME} SHARED | |
44 | + ${TARGET_INCLUDE_FILES} | |
45 | + ${TARGET_SOURCE_FILES} | |
46 | + $<TARGET_OBJECTS:cl_headers> | |
47 | ||
48 | -add_dependencies(${TARGET_NAME} CClangCompileOptions) | |
49 | + DEPENDS CClangCompileOptions | |
50 | + | |
51 | + LINK_LIBS | |
52 | + ${OPENCL_CLANG_LINK_LIBS} | |
53 | + ) | |
54 | ||
55 | if (WIN32) | |
56 | # Enable compiler generation of Control Flow Guard security checks. | |
57 | @@ -322,51 +324,6 @@ elseif(UNIX) | |
58 | LINK_FLAGS " -Wl,--no-undefined") | |
59 | endif(WIN32) | |
60 | ||
61 | -# Enable new IN_LIST operator. | |
62 | -cmake_policy(SET CMP0057 NEW) | |
63 | -set(OTHER_LIBRARIES) | |
64 | -if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD) | |
65 | - list(APPEND OTHER_LIBRARIES LLVMNVPTXCodeGen LLVMNVPTXDesc LLVMNVPTXInfo) | |
66 | -endif() | |
67 | -if ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD) | |
68 | - list(APPEND OTHER_LIBRARIES LLVMAMDGPUCodeGen LLVMAMDGPUAsmParser LLVMAMDGPUDesc LLVMAMDGPUInfo) | |
69 | -endif() | |
70 | - | |
71 | -target_link_libraries( ${TARGET_NAME} | |
72 | - LINK_PRIVATE | |
73 | - ${OPENCL_CLANG_LINK_LIBS} | |
74 | - LLVMX86CodeGen | |
75 | - LLVMX86AsmParser | |
76 | - LLVMX86Desc | |
77 | - LLVMX86Info | |
78 | - LLVMX86Disassembler | |
79 | - LLVMAnalysis | |
80 | - LLVMCodeGen | |
81 | - LLVMCore | |
82 | - LLVMipo | |
83 | - LLVMInstCombine | |
84 | - LLVMInstrumentation | |
85 | - LLVMMC | |
86 | - LLVMMCParser | |
87 | - LLVMObjCARCOpts | |
88 | - LLVMOption | |
89 | - LLVMScalarOpts | |
90 | - LLVMSupport | |
91 | - LLVMTransformUtils | |
92 | - LLVMVectorize | |
93 | - LLVMAsmPrinter | |
94 | - LLVMSelectionDAG | |
95 | - LLVMMCDisassembler | |
96 | - LLVMProfileData | |
97 | - LLVMObject | |
98 | - LLVMBitWriter | |
99 | - LLVMIRReader | |
100 | - LLVMAsmParser | |
101 | - LLVMTarget | |
102 | - LLVMBitReader | |
103 | - ${OTHER_LIBRARIES} | |
104 | - ) | |
105 | - | |
106 | install(FILES opencl_clang.h | |
107 | DESTINATION include/cclang | |
108 | COMPONENT ${TARGET_NAME}) |