Skip to content

Commit

Permalink
Link with libclang-cpp for out-of-tree build
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Sotkin <[email protected]>
  • Loading branch information
AlexeySotkin committed Apr 6, 2020
1 parent 7258431 commit 46d38e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ before_install:
llvm-${LLVM_VERSION}-dev
llvm-${LLVM_VERSION}-tools
libclang-${LLVM_VERSION}-dev
libclang-cpp${LLVM_VERSION}-dev

install:
- wget https://github.com/KhronosGroup/SPIRV-LLVM-Translator/releases/download/dev-build/SPIRV-LLVM-Translator-dev-build-linux-Release.zip -O /tmp/SPIRV-LLVM-Translator-dev-build-linux-${BUILD_TYPE}.zip
Expand Down
31 changes: 19 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,27 +206,22 @@ link_directories(
${LLVM_LIBRARY_DIRS}
)

set(ADDITIONAL_LIBS ${CMAKE_DL_LIBS})
set(OPENCL_CLANG_LINK_LIBS ${CMAKE_DL_LIBS})

if(NOT LLVMSPIRVLib IN_LIST LLVM_AVAILABLE_LIBS)
# SPIRV-LLVM-Translator is not included into LLVM as a component.
# So, we need to list it here explicitly as an external library
list(APPEND ADDITIONAL_LIBS LLVMSPIRVLib)
list(APPEND OPENCL_CLANG_LINK_LIBS LLVMSPIRVLib)
endif()

add_subdirectory(cl_headers)

set(LLVM_REQUIRES_EH ON)

add_llvm_library(${TARGET_NAME} SHARED
${TARGET_INCLUDE_FILES}
${TARGET_SOURCE_FILES}
$<TARGET_OBJECTS:cl_headers>

DEPENDS CClangCompileOptions
LINK_COMPONENTS
all
LINK_LIBS
if(USE_PREBUILT_LLVM)
list(APPEND OPENCL_CLANG_LINK_LIBS clang-cpp)
else(USE_PREBUILT_LLVM)
list(APPEND OPENCL_CLANG_LINK_LIBS
# The list of clang libraries is taken from clang makefile
# (build/tools/clang/tools/driver/CMakeFiles/clang.dir/link.txt)
# All duplicate libraries are there on purpose
Expand Down Expand Up @@ -258,7 +253,19 @@ add_llvm_library(${TARGET_NAME} SHARED
clangAST
clangLex
clangBasic
${ADDITIONAL_LIBS}
)
endif(USE_PREBUILT_LLVM)

add_llvm_library(${TARGET_NAME} SHARED
${TARGET_INCLUDE_FILES}
${TARGET_SOURCE_FILES}
$<TARGET_OBJECTS:cl_headers>

DEPENDS CClangCompileOptions
LINK_COMPONENTS
all
LINK_LIBS
${OPENCL_CLANG_LINK_LIBS}
)

# Configure resource file on Windows
Expand Down

0 comments on commit 46d38e3

Please sign in to comment.