Mercurial > hg > CbC > CbC_llvm
comparison tools/llvm-shlib/CMakeLists.txt @ 120:1172e4bd9c6f
update 4.0.0
author | mir3636 |
---|---|
date | Fri, 25 Nov 2016 19:14:25 +0900 |
parents | 7d135dc70f03 |
children | 803732b1fca8 |
comparison
equal
deleted
inserted
replaced
101:34baf5011add | 120:1172e4bd9c6f |
---|---|
1 # This tool creates a shared library from the LLVM libraries. Generating this | 1 # This tool creates a shared library from the LLVM libraries. Generating this |
2 # library is enabled by setting LLVM_BUILD_LLVM_DYLIB=yes on the CMake | 2 # library is enabled by setting LLVM_BUILD_LLVM_DYLIB=yes on the CMake |
3 # commandline. By default the shared library only exports the LLVM C API. | 3 # commandline. By default the shared library only exports the LLVM C API. |
4 | |
5 add_definitions( -DLLVM_VERSION_INFO=\"${PACKAGE_VERSION}\" ) | |
6 | 4 |
7 set(SOURCES | 5 set(SOURCES |
8 libllvm.cpp | 6 libllvm.cpp |
9 ) | 7 ) |
10 | 8 |
11 llvm_map_components_to_libnames(LIB_NAMES ${LLVM_DYLIB_COMPONENTS}) | 9 llvm_map_components_to_libnames(LIB_NAMES ${LLVM_DYLIB_COMPONENTS}) |
12 | 10 |
13 if(LLVM_LINK_LLVM_DYLIB) | 11 if(LLVM_LINK_LLVM_DYLIB AND LLVM_DYLIB_EXPORTED_SYMBOL_FILE) |
14 if(LLVM_DYLIB_EXPORTED_SYMBOL_FILE) | 12 message(WARNING "Using LLVM_LINK_LLVM_DYLIB with LLVM_DYLIB_EXPORTED_SYMBOL_FILE may not work. Use at your own risk.") |
15 message(WARNING "Using LLVM_LINK_LLVM_DYLIB with LLVM_DYLIB_EXPORTED_SYMBOL_FILE may not work. Use at your own risk.") | 13 endif() |
14 | |
15 # libLLVM.so should not have any dependencies on any other LLVM | |
16 # shared libraries. When using the "all" pseudo-component, | |
17 # LLVM_AVAILABLE_LIBS is added to the dependencies, which may | |
18 # contain shared libraries (e.g. libLTO). | |
19 # | |
20 # Also exclude libLLVMTableGen for the following reasons: | |
21 # - it is only used by internal *-tblgen utilities; | |
22 # - it pollutes the global options space. | |
23 foreach(lib ${LIB_NAMES}) | |
24 get_target_property(t ${lib} TYPE) | |
25 if("${lib}" STREQUAL "LLVMTableGen") | |
26 elseif("x${t}" STREQUAL "xSTATIC_LIBRARY") | |
27 list(APPEND FILTERED_LIB_NAMES ${lib}) | |
16 endif() | 28 endif() |
17 | 29 endforeach() |
18 # libLLVM.so should not have any dependencies on any other LLVM | 30 set(LIB_NAMES ${FILTERED_LIB_NAMES}) |
19 # shared libraries. When using the "all" pseudo-component, | |
20 # LLVM_AVAILABLE_LIBS is added to the dependencies, which may | |
21 # contain shared libraries (e.g. libLTO). | |
22 # | |
23 # Also exclude libLLVMTableGen for the following reasons: | |
24 # - it is only used by internal *-tblgen utilities; | |
25 # - it pollutes the global options space. | |
26 foreach(lib ${LIB_NAMES}) | |
27 get_target_property(t ${lib} TYPE) | |
28 if("${lib}" STREQUAL "LLVMTableGen") | |
29 elseif("x${t}" STREQUAL "xSTATIC_LIBRARY") | |
30 list(APPEND FILTERED_LIB_NAMES ${lib}) | |
31 endif() | |
32 endforeach() | |
33 set(LIB_NAMES ${FILTERED_LIB_NAMES}) | |
34 endif() | |
35 | 31 |
36 if(LLVM_DYLIB_EXPORTED_SYMBOL_FILE) | 32 if(LLVM_DYLIB_EXPORTED_SYMBOL_FILE) |
37 set(LLVM_EXPORTED_SYMBOL_FILE ${LLVM_DYLIB_EXPORTED_SYMBOL_FILE}) | 33 set(LLVM_EXPORTED_SYMBOL_FILE ${LLVM_DYLIB_EXPORTED_SYMBOL_FILE}) |
38 add_custom_target(libLLVMExports DEPENDS ${LLVM_EXPORTED_SYMBOL_FILE}) | 34 add_custom_target(libLLVMExports DEPENDS ${LLVM_EXPORTED_SYMBOL_FILE}) |
39 endif() | 35 endif() |
40 | 36 |
41 add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES}) | 37 add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES}) |
42 | 38 |
43 list(REMOVE_DUPLICATES LIB_NAMES) | 39 list(REMOVE_DUPLICATES LIB_NAMES) |
44 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") # FIXME: It should be "GNU ld for elf" | 40 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR MINGW) # FIXME: It should be "GNU ld for elf" |
45 # GNU ld doesn't resolve symbols in the version script. | 41 # GNU ld doesn't resolve symbols in the version script. |
46 set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive) | 42 set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive) |
47 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") | 43 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") |
48 set(LIB_NAMES -Wl,-all_load ${LIB_NAMES}) | 44 set(LIB_NAMES -Wl,-all_load ${LIB_NAMES}) |
49 endif() | 45 endif() |