aboutsummaryrefslogtreecommitdiffstats
path: root/clang-plugin/CMakeLists.txt
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-21 12:19:12 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-21 12:19:12 +0100
commit03eabb4c570d30b30d2406fe4ce40d5073be2861 (patch)
tree095be91d174497d39c9ef52d14e5f202c2c2ebd5 /clang-plugin/CMakeLists.txt
parenta59844f720d2ae42a5832e56c80877d5edd664e0 (diff)
downloadrspamd-03eabb4c570d30b30d2406fe4ce40d5073be2861.tar.gz
rspamd-03eabb4c570d30b30d2406fe4ce40d5073be2861.zip
[Minor] Clang-Plugin: Fix build
Diffstat (limited to 'clang-plugin/CMakeLists.txt')
-rw-r--r--clang-plugin/CMakeLists.txt59
1 files changed, 23 insertions, 36 deletions
diff --git a/clang-plugin/CMakeLists.txt b/clang-plugin/CMakeLists.txt
index 62a1d68f5..5b81a7dc5 100644
--- a/clang-plugin/CMakeLists.txt
+++ b/clang-plugin/CMakeLists.txt
@@ -1,48 +1,25 @@
IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
# Clang plugin for static analysis
+ PROJECT(RspamdClangPlugin)
if (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
MESSAGE(FATAL_ERROR "Cannot build clang plugin when compiler is not clang")
endif ()
+ FIND_PACKAGE(LLVM REQUIRED CONFIG)
- LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
- ENABLE_LANGUAGE(CXX)
- FIND_PACKAGE(LLVM REQUIRED)
- MESSAGE(STATUS "Trying to find libclang for llvm version ${LLVM_PACKAGE_VERSION}")
- SET(libclang_llvm_header_search_paths
- # LLVM Debian/Ubuntu nightly packages: http://llvm.org/apt/
- "/usr/lib/llvm-${LLVM_PACKAGE_VERSION}/include/"
- # LLVM MacPorts
- "/opt/local/libexec/llvm-${LLVM_PACKAGE_VERSION}/include"
- # LLVM Homebrew
- "/usr/local/Cellar/llvm/${LLVM_PACKAGE_VERSION}/include"
- # LLVM Homebrew/versions
- "/usr/local/lib/llvm-${LLVM_PACKAGE_VERSION}/include"
- # FreeBSD ports versions
- "/usr/local/llvm${LLVM_PACKAGE_VERSION}/include"
- "${LLVM_INCLUDE_DIRS}"
- )
-
- SET(libclang_llvm_lib_search_paths
- # LLVM Debian/Ubuntu nightly packages: http://llvm.org/apt/
- "/usr/lib/llvm-${LLVM_PACKAGE_VERSION}/lib/"
- # LLVM MacPorts
- "/opt/local/libexec/llvm-${LLVM_PACKAGE_VERSION}/lib"
- # LLVM Homebrew
- "/usr/local/Cellar/llvm/${LLVM_PACKAGE_VERSION}/lib"
- # LLVM Homebrew/versions
- "/usr/local/lib/llvm-${LLVM_PACKAGE_VERSION}/lib"
- # FreeBSD ports versions
- "/usr/local/llvm${LLVM_PACKAGE_VERSION}/lib"
- "${LLVM_LIBRARY_DIRS}"
- )
+ MESSAGE(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
+ MESSAGE(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
+ INCLUDE_DIRECTORIES(${LLVM_INCLUDE_DIRS})
+ ADD_DEFINITIONS(${LLVM_DEFINITIONS})
find_path(LIBCLANG_INCLUDE_DIR clang-c/Index.h
- PATHS ${libclang_llvm_header_search_paths}
- PATH_SUFFIXES LLVM/include #Windows package from http://llvm.org/releases/
+ PATHS ${LLVM_INCLUDE_DIRS}
DOC "The path to the directory that contains clang-c/Index.h")
- find_library(LIBCLANG_LIBRARY NAMES libclang.imp libclang clang
- PATHS ${libclang_llvm_lib_search_paths}
- PATH_SUFFIXES LLVM/lib #Windows package from http://llvm.org/releases/
+
+ find_library(LIBCLANG_LIBRARY
+ NAMES
+ libclang
+ clang
+ PATHS ${LLVM_LIBRARY_DIRS}
DOC "The file that corresponds to the libclang library.")
get_filename_component(LIBCLANG_LIBRARY_DIR ${LIBCLANG_LIBRARY} PATH)
@@ -50,6 +27,16 @@ IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
set(LIBCLANG_LIBRARIES ${LIBCLANG_LIBRARY})
set(LIBCLANG_INCLUDE_DIRS ${LIBCLANG_INCLUDE_DIR})
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(LibClang DEFAULT_MSG
+ LIBCLANG_LIBRARY LIBCLANG_INCLUDE_DIR)
+
+ mark_as_advanced(LIBCLANG_INCLUDE_DIR LIBCLANG_LIBRARY)
+
+ if (NOT LIBCLANG_FOUND)
+ MESSAGE(FATAL_ERROR "Libclang is required to build clang plugin")
+ endif()
+
SET(CLANGPLUGINSRC plugin.cc printf_check.cc)
ADD_LIBRARY(rspamd-clang SHARED ${CLANGPLUGINSRC})