Use dynamic libraries when linking LLVM on Linux

This commit is contained in:
Jack Andersen 2018-04-02 14:42:43 -10:00
parent 1d761d5160
commit c5e71f7569
1 changed files with 49 additions and 26 deletions

View File

@ -15,15 +15,37 @@ include(FindLLVM.cmake)
if(NOT LLVM_FOUND) if(NOT LLVM_FOUND)
message(STATUS "Unable to locate LLVM installation; skipping atdna") message(STATUS "Unable to locate LLVM installation; skipping atdna")
else() else()
find_library(LLVMDEMANGLE_LIB LLVMDemangle HINTS "${LLVM_ROOT_DIR}/lib")
find_library(LLVMBINARYFORMAT_LIB LLVMBinaryFormat HINTS "${LLVM_ROOT_DIR}/lib") if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if (NOT LLVMDEMANGLE_LIB) option(ATDNA_DYNAMIC_LLVM "Use dynamic library targets when linking LLVM" ON)
else()
option(ATDNA_DYNAMIC_LLVM "Use dynamic library targets when linking LLVM" OFF)
endif()
if(ATDNA_DYNAMIC_LLVM)
list(APPEND LLVM_LIBS
clangFrontend
clangTooling
clangDriver
clangSerialization
clangParse
clangSema
clangAnalysis
clangEdit
clangAST
clangLex
clangBasic
LLVM)
else()
find_library(LLVMDEMANGLE_LIB LLVMDemangle HINTS "${LLVM_ROOT_DIR}/lib")
find_library(LLVMBINARYFORMAT_LIB LLVMBinaryFormat HINTS "${LLVM_ROOT_DIR}/lib")
if (NOT LLVMDEMANGLE_LIB)
set(LLVMDEMANGLE_LIB "") set(LLVMDEMANGLE_LIB "")
endif() endif()
if (NOT LLVMBINARYFORMAT_LIB) if (NOT LLVMBINARYFORMAT_LIB)
set(LLVMBINARYFORMAT_LIB "") set(LLVMBINARYFORMAT_LIB "")
endif() endif()
list(APPEND LLVM_LIBS list(APPEND LLVM_LIBS
clangFrontend clangFrontend
clangTooling clangTooling
clangDriver clangDriver
@ -44,6 +66,7 @@ list(APPEND LLVM_LIBS
LLVMProfileData LLVMProfileData
LLVMSupport LLVMSupport
${LLVMDEMANGLE_LIB}) ${LLVMDEMANGLE_LIB})
endif()
string(FIND ${LLVM_VERSION_STRING} "svn" SVN_FILTER_IDX) string(FIND ${LLVM_VERSION_STRING} "svn" SVN_FILTER_IDX)
if(NOT SVN_FILTER_IDX EQUAL -1) if(NOT SVN_FILTER_IDX EQUAL -1)