|
1 | | -set(LLVM_LINK_COMPONENTS |
2 | | - ${LLVM_TARGETS_TO_BUILD} |
3 | | - BinaryFormat |
4 | | - Core |
5 | | - Object |
6 | | - OrcJit |
7 | | - Support |
8 | | -) |
9 | | -# FIXME: Investigate why this needs to be conditionally included. |
10 | | -if ("LLVMFrontendDriver" IN_LIST LLVM_AVAILABLE_LIBS) |
11 | | - list(APPEND LLVM_LINK_COMPONENTS FrontendDriver) |
12 | | -endif() |
13 | | -if ("LLVMOrcDebugging" IN_LIST LLVM_AVAILABLE_LIBS) |
14 | | - list(APPEND LLVM_LINK_COMPONENTS OrcDebugging) |
15 | | -endif() |
| 1 | +if(EMSCRIPTEN) |
| 2 | + set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) |
| 3 | + set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1") |
| 4 | + set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1") |
| 5 | + set(CMAKE_STRIP FALSE) |
16 | 6 |
|
17 | | -set(DLM |
18 | | - DynamicLibraryManager.cpp |
19 | | - DynamicLibraryManagerSymbol.cpp |
20 | | - Paths.cpp |
21 | | -) |
22 | | -if (USE_CLING) |
23 | | - set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${DLM}) |
24 | | - set(DLM) |
25 | | -endif(USE_CLING) |
26 | | -if (USE_REPL) |
27 | | - #Use DML optional sources |
28 | | -endif(USE_REPL) |
| 7 | + add_llvm_library(clangCppInterOp |
| 8 | + SHARED |
29 | 9 |
|
30 | | -if (USE_CLING) |
31 | | - set(cling_clang_interp clingInterpreter) |
32 | | -endif() |
33 | | -if (USE_REPL) |
34 | | - set(cling_clang_interp clangInterpreter) |
35 | | -endif() |
| 10 | + CppInterOp.cpp |
| 11 | + CXCppInterOp.cpp |
| 12 | + DynamicLibraryManager.cpp |
| 13 | + DynamicLibraryManagerSymbol.cpp |
| 14 | + Paths.cpp |
36 | 15 |
|
37 | | -set(link_libs |
38 | | - ${cling_clang_interp} |
39 | | - clangAST |
40 | | - clangBasic |
41 | | - clangFrontend |
42 | | - clangLex |
43 | | - clangSema |
| 16 | + # Additional libraries from Clang and LLD |
| 17 | + LINK_LIBS |
| 18 | + clangInterpreter |
| 19 | + ) |
| 20 | +else() |
| 21 | + set(LLVM_LINK_COMPONENTS |
| 22 | + ${LLVM_TARGETS_TO_BUILD} |
| 23 | + BinaryFormat |
| 24 | + Core |
| 25 | + Object |
| 26 | + OrcJit |
| 27 | + Support |
44 | 28 | ) |
| 29 | + # FIXME: Investigate why this needs to be conditionally included. |
| 30 | + if ("LLVMFrontendDriver" IN_LIST LLVM_AVAILABLE_LIBS) |
| 31 | + list(APPEND LLVM_LINK_COMPONENTS FrontendDriver) |
| 32 | + endif() |
| 33 | + if ("LLVMOrcDebugging" IN_LIST LLVM_AVAILABLE_LIBS) |
| 34 | + list(APPEND LLVM_LINK_COMPONENTS OrcDebugging) |
| 35 | + endif() |
45 | 36 |
|
46 | | - if(NOT WIN32) |
47 | | - list(APPEND link_libs dl) |
48 | | - endif() |
| 37 | + set(DLM |
| 38 | + DynamicLibraryManager.cpp |
| 39 | + DynamicLibraryManagerSymbol.cpp |
| 40 | + Paths.cpp |
| 41 | + ) |
| 42 | + if (USE_CLING) |
| 43 | + set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${DLM}) |
| 44 | + set(DLM) |
| 45 | + endif(USE_CLING) |
| 46 | + if (USE_REPL) |
| 47 | + #Use DML optional sources |
| 48 | + endif(USE_REPL) |
49 | 49 |
|
50 | | -# Get rid of libLLVM-X.so which is appended to the list of static libraries. |
51 | | -if (LLVM_LINK_LLVM_DYLIB) |
52 | | - set(new_libs ${link_libs}) |
53 | | - set(libs ${new_libs}) |
54 | | - while(NOT "${new_libs}" STREQUAL "") |
55 | | - foreach(lib ${new_libs}) |
56 | | - if(TARGET ${lib}) |
57 | | - get_target_property(transitive_libs ${lib} INTERFACE_LINK_LIBRARIES) |
58 | | - if (NOT transitive_libs) |
59 | | - continue() |
60 | | - endif() |
61 | | - foreach(transitive_lib ${transitive_libs}) |
62 | | - get_target_property(lib_type ${transitive_lib} TYPE) |
63 | | - if("${lib_type}" STREQUAL "STATIC_LIBRARY") |
64 | | - list(APPEND static_transitive_libs ${transitive_lib}) |
65 | | - else() |
66 | | - # Filter our libLLVM.so and friends. |
| 50 | + if (USE_CLING) |
| 51 | + set(cling_clang_interp clingInterpreter) |
| 52 | + endif() |
| 53 | + if (USE_REPL) |
| 54 | + set(cling_clang_interp clangInterpreter) |
| 55 | + endif() |
| 56 | + |
| 57 | + set(link_libs |
| 58 | + ${cling_clang_interp} |
| 59 | + clangAST |
| 60 | + clangBasic |
| 61 | + clangFrontend |
| 62 | + clangLex |
| 63 | + clangSema |
| 64 | + ) |
| 65 | + |
| 66 | + if(NOT WIN32) |
| 67 | + list(APPEND link_libs dl) |
| 68 | + endif() |
| 69 | + |
| 70 | + # Get rid of libLLVM-X.so which is appended to the list of static libraries. |
| 71 | + if (LLVM_LINK_LLVM_DYLIB) |
| 72 | + set(new_libs ${link_libs}) |
| 73 | + set(libs ${new_libs}) |
| 74 | + while(NOT "${new_libs}" STREQUAL "") |
| 75 | + foreach(lib ${new_libs}) |
| 76 | + if(TARGET ${lib}) |
| 77 | + get_target_property(transitive_libs ${lib} INTERFACE_LINK_LIBRARIES) |
| 78 | + if (NOT transitive_libs) |
67 | 79 | continue() |
68 | 80 | endif() |
69 | | - if(NOT ${transitive_lib} IN_LIST libs) |
70 | | - list(APPEND newer_libs ${transitive_lib}) |
71 | | - list(APPEND libs ${transitive_lib}) |
72 | | - endif() |
73 | | - endforeach(transitive_lib) |
74 | | - # Update the target properties with the list of only static libraries. |
75 | | - set_target_properties(${lib} PROPERTIES INTERFACE_LINK_LIBRARIES "${static_transitive_libs}") |
76 | | - set(static_transitive_libs "") |
77 | | - endif() |
78 | | - endforeach(lib) |
79 | | - set(new_libs ${newer_libs}) |
80 | | - set(newer_libs "") |
81 | | - endwhile() |
82 | | - # We just got rid of the libLLVM.so and other components shipped as shared |
83 | | - # libraries, we need to make up for the missing dependency. |
84 | | - list(APPEND LLVM_LINK_COMPONENTS |
85 | | - Coverage |
86 | | - FrontendHLSL |
87 | | - LTO |
88 | | - ) |
89 | | - # We will need to append the missing dependencies to pull in the right |
90 | | - # LLVM library dependencies. |
91 | | - list(APPEND link_libs |
92 | | - clangCodeGen |
93 | | - clangStaticAnalyzerCore |
94 | | - ) |
95 | | -endif(LLVM_LINK_LLVM_DYLIB) |
| 81 | + foreach(transitive_lib ${transitive_libs}) |
| 82 | + get_target_property(lib_type ${transitive_lib} TYPE) |
| 83 | + if("${lib_type}" STREQUAL "STATIC_LIBRARY") |
| 84 | + list(APPEND static_transitive_libs ${transitive_lib}) |
| 85 | + else() |
| 86 | + # Filter our libLLVM.so and friends. |
| 87 | + continue() |
| 88 | + endif() |
| 89 | + if(NOT ${transitive_lib} IN_LIST libs) |
| 90 | + list(APPEND newer_libs ${transitive_lib}) |
| 91 | + list(APPEND libs ${transitive_lib}) |
| 92 | + endif() |
| 93 | + endforeach(transitive_lib) |
| 94 | + # Update the target properties with the list of only static libraries. |
| 95 | + set_target_properties(${lib} PROPERTIES INTERFACE_LINK_LIBRARIES "${static_transitive_libs}") |
| 96 | + set(static_transitive_libs "") |
| 97 | + endif() |
| 98 | + endforeach(lib) |
| 99 | + set(new_libs ${newer_libs}) |
| 100 | + set(newer_libs "") |
| 101 | + endwhile() |
| 102 | + # We just got rid of the libLLVM.so and other components shipped as shared |
| 103 | + # libraries, we need to make up for the missing dependency. |
| 104 | + list(APPEND LLVM_LINK_COMPONENTS |
| 105 | + Coverage |
| 106 | + FrontendHLSL |
| 107 | + LTO |
| 108 | + ) |
| 109 | + # We will need to append the missing dependencies to pull in the right |
| 110 | + # LLVM library dependencies. |
| 111 | + list(APPEND link_libs |
| 112 | + clangCodeGen |
| 113 | + clangStaticAnalyzerCore |
| 114 | + ) |
| 115 | + endif(LLVM_LINK_LLVM_DYLIB) |
96 | 116 |
|
97 | | -add_llvm_library(clangCppInterOp |
98 | | - DISABLE_LLVM_LINK_LLVM_DYLIB |
99 | | - CppInterOp.cpp |
100 | | - CXCppInterOp.cpp |
101 | | - ${DLM} |
102 | | - LINK_LIBS |
103 | | - ${link_libs} |
104 | | - ) |
| 117 | + add_llvm_library(clangCppInterOp |
| 118 | + DISABLE_LLVM_LINK_LLVM_DYLIB |
| 119 | + CppInterOp.cpp |
| 120 | + CXCppInterOp.cpp |
| 121 | + ${DLM} |
| 122 | + LINK_LIBS |
| 123 | + ${link_libs} |
| 124 | + ) |
| 125 | +endif() |
105 | 126 |
|
106 | 127 | string(REPLACE ";" "\;" _VER CPPINTEROP_VERSION) |
107 | 128 | set_source_files_properties(CppInterOp.cpp PROPERTIES COMPILE_DEFINITIONS |
|
0 commit comments