diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 21:30:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 21:30:40 +0000 |
commit | 133a45c109da5310add55824db21af5239951f93 (patch) | |
tree | ba6ac4c0a950a0dda56451944315d66409923918 /clang-plugin/CMakeLists.txt | |
parent | Initial commit. (diff) | |
download | rspamd-upstream.tar.xz rspamd-upstream.zip |
Adding upstream version 3.8.1.upstream/3.8.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'clang-plugin/CMakeLists.txt')
-rw-r--r-- | clang-plugin/CMakeLists.txt | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/clang-plugin/CMakeLists.txt b/clang-plugin/CMakeLists.txt new file mode 100644 index 0000000..0d61c79 --- /dev/null +++ b/clang-plugin/CMakeLists.txt @@ -0,0 +1,42 @@ + +IF (ENABLE_CLANG_PLUGIN MATCHES "ON") + # Clang plugin for static analysis + PROJECT(RspamdClangPlugin CXX) + 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) + + 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_package(Clang REQUIRED) + + set(clang_libs clang) + + message(STATUS "Found LibClang in: ${CLANG_INSTALL_PREFIX}") + include_directories(${CLANG_INCLUDE_DIRS}) + + SET(CLANGPLUGINSRC plugin.cc printf_check.cc) + + ADD_LIBRARY(rspamd-clang SHARED ${CLANGPLUGINSRC}) + IF (SANITIZE) + set (CMAKE_C_FLAGS "") + set (CMAKE_CXX_FLAGS "") + set (CMAKE_EXE_LINKER_FLAGS "") + ENDIF() + + + find_library(found_LLVM LLVM HINTS ${LLVM_LIBRARY_DIRS}) + if(found_LLVM) + target_link_libraries(rspamd-clang PRIVATE ${LLVM}) + else() + # XXX not tested yet + llvm_map_components_to_libnames(llvm_libs support core) + target_link_libraries(rspamd-clang PRIVATE ${llvm_libs}) + endif() + + target_link_libraries(rspamd-clang PRIVATE ${clang_libs}) +ENDIF() |