summaryrefslogtreecommitdiffstats
path: root/clang-plugin/CMakeLists.txt
blob: eae7642353a6bce13cad67d2b266afc752a7d1ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
    # Clang plugin for static analysis
    if (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
        MESSAGE(FATAL_ERROR "Cannot build clang plugin when compiler is not clang")
    endif ()

    SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}")
    ENABLE_LANGUAGE(CXX)
    FIND_PACKAGE(LLVM REQUIRED)

    SET(CLANGPLUGINSRC plugin.cc printf_check.cc)

    ADD_LIBRARY(rspamd-clang SHARED ${CLANGPLUGINSRC})
    SET_TARGET_PROPERTIES(rspamd-clang PROPERTIES
            COMPILE_FLAGS "${LLVM_CXX_FLAGS} ${LLVM_CPP_FLAGS} ${LLVM_C_FLAGS}"
            INCLUDE_DIRECTORIES ${LIBCLANG_INCLUDE_DIR}
            LINKER_LANGUAGE CXX)
    TARGET_LINK_LIBRARIES(rspamd-clang ${LIBCLANG_LIBRARIES})
    LINK_DIRECTORIES(${LLVM_LIBRARY_DIRS})
ENDIF()