summaryrefslogtreecommitdiffstats
path: root/contrib/kann/CMakeLists.txt
blob: ba38e14c8f9e8b5ab957575139ac202b73fe330d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
SET(LIBKANNSRC	kautodiff.c kann.c)

IF(ENABLE_FULL_DEBUG MATCHES "OFF")
    if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
    endif ()
ENDIF()

ADD_LIBRARY(rspamd-kann SHARED ${LIBKANNSRC})

ProcessPackage(BLAS OPTIONAL LIBRARY openblas blas
        INCLUDE cblas.h INCLUDE_SUFFIXES include/openblas
        include/blas
        ROOT ${BLAS_ROOT_DIR}
        LIB_OUTPUT BLAS_REQUIRED_LIBRARIES)
IF(WITH_BLAS)
    MESSAGE(STATUS "Use openblas to accelerate kann")
    IF(NOT BLAS_INCLUDE)
        FIND_FILE(HAVE_CBLAS_H HINTS "${RSPAMD_SEARCH_PATH}"
            NAMES cblas.h
            DOC "Path to cblas.h header")
        IF(NOT HAVE_CBLAS_H)
            MESSAGE(STATUS "Blas header cblas.h has not been found, use internal workaround")
        ELSE()
            ADD_DEFINITIONS(-DHAVE_CBLAS_H)
        ENDIF()
    ELSE()
        ADD_DEFINITIONS(-DHAVE_CBLAS_H)
    ENDIF()

    TARGET_LINK_LIBRARIES(rspamd-kann  ${BLAS_REQUIRED_LIBRARIES})
    ADD_DEFINITIONS(-DHAVE_CBLAS)
ENDIF(WITH_BLAS)

INSTALL(TARGETS rspamd-kann LIBRARY DESTINATION ${RSPAMD_LIBDIR})