brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · a4d0aa5 Raw
75 lines · plain
1# Building libclang-cpp.so fails if LLVM_ENABLE_PIC=Off2if (NOT LLVM_ENABLE_PIC)3  return()4endif()5 6get_property(clang_libs GLOBAL PROPERTY CLANG_STATIC_LIBS)7 8foreach (lib ${clang_libs})9  if(XCODE)10    # Xcode doesn't support object libraries, so we have to trick it into11    # linking the static libraries instead.12    list(APPEND _DEPS "-force_load" ${lib})13  else()14    list(APPEND _OBJECTS $<TARGET_OBJECTS:obj.${lib}>)15  endif()16  if (BUILD_SHARED_LIBS)17    # If we are building static libraries, then we don't need to add the static18    # libraries as a dependency, because we are already linking against the19    # individual object files.20    list(APPEND _DEPS $<TARGET_PROPERTY:${lib},INTERFACE_LINK_LIBRARIES>)21  endif()22 23  # clang libraries are redundant since we are linking all the individual24  # object files into libclang-cpp.so, so filter them out from _DEPS.25  # This avoids problems with LLVM global data when building with26  # BUILD_SHARED_LIBS=ON27  # FIXME: We could use list(FILTER) with cmake >= 3.628  # FIXME: With cmake >= 3.15 we could use the generator expression29  # $<FILTER:list,INCLUDE|EXCLUDE,regex>30  get_target_property(interface ${lib} LINK_LIBRARIES)31  if (interface)32    foreach(lib ${interface})33      if (NOT ${lib} MATCHES "^clang")34        list(APPEND _DEPS ${lib})35      endif()36    endforeach()37  endif()38endforeach ()39 40if (CLANG_LINK_CLANG_DYLIB)41  set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN)42endif()43 44if (HAIKU)45  list(APPEND _DEPS network)46endif()47 48add_clang_library(clang-cpp49                  SHARED50                  ${INSTALL_WITH_TOOLCHAIN}51                  clang-shlib.cpp52                  ${_OBJECTS}53                  LINK_LIBS54                  ${_DEPS})55 56configure_file(simple_version_script.map.in simple_version_script.map)57 58if (CMAKE_SYSTEM_NAME STREQUAL "Linux")59  target_link_options(clang-cpp PRIVATE LINKER:--version-script,${CMAKE_CURRENT_BINARY_DIR}/simple_version_script.map)60endif()61 62# Optimize function calls for default visibility definitions to avoid PLT and63# reduce dynamic relocations.64if (NOT APPLE AND LLVM_LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)65  target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)66endif()67if (MINGW OR CYGWIN)68  # The clang-cpp DLL is supposed to export all symbols (except for ones69  # that are explicitly hidden). Normally, this is what happens anyway, but70  # if there are symbols that are marked explicitly as dllexport, we'd only71  # export them and nothing else. Therefore, add --export-all-symbols to72  # make sure we export all symbols despite potential dllexports.73  target_link_options(clang-cpp PRIVATE LINKER:--export-all-symbols)74endif()75