anakin.cmake 2.1 KB
Newer Older
Y
Yan Chunwei 已提交
1 2 3 4 5 6 7 8 9
if (NOT WITH_ANAKIN)
  return()
endif()

set(ANAKIN_INSTALL_DIR "${THIRD_PARTY_PATH}/install/anakin" CACHE PATH
  "Anakin install path." FORCE)
set(ANAKIN_INCLUDE "${ANAKIN_INSTALL_DIR}" CACHE STRING "root of Anakin header files")
set(ANAKIN_LIBRARY "${ANAKIN_INSTALL_DIR}" CACHE STRING "path of Anakin library")

10
set(ANAKIN_COMPILE_EXTRA_FLAGS 
C
cuichaowen 已提交
11
    -Wno-error=unused-but-set-variable -Wno-unused-but-set-variable
12 13 14 15 16 17 18 19 20 21
    -Wno-error=unused-variable -Wno-unused-variable 
    -Wno-error=format-extra-args -Wno-format-extra-args
    -Wno-error=comment -Wno-comment 
    -Wno-error=format -Wno-format 
    -Wno-error=switch -Wno-switch
    -Wno-error=return-type -Wno-return-type 
    -Wno-error=non-virtual-dtor -Wno-non-virtual-dtor
    -Wno-sign-compare
    -Wno-reorder 
    -Wno-error=cpp)
Y
Yan Chunwei 已提交
22

C
cuichaowen 已提交
23
set(ANAKIN_LIBRARY_URL "https://github.com/pangge/Anakin/releases/download/Version0.1.0/anakin.tar.gz")
Y
Yan Chunwei 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

# A helper function used in Anakin, currently, to use it, one need to recursively include
# nearly all the header files.
function(fetch_include_recursively root_dir)
    if (IS_DIRECTORY ${root_dir})
        include_directories(${root_dir})
    endif()

    file(GLOB ALL_SUB RELATIVE ${root_dir} ${root_dir}/*)
    foreach(sub ${ALL_SUB})
        if (IS_DIRECTORY ${root_dir}/${sub})
            fetch_include_recursively(${root_dir}/${sub})
        endif()
    endforeach()
endfunction()

Y
Yan Chunwei 已提交
40 41 42 43 44
if (NOT EXISTS "${ANAKIN_INSTALL_DIR}")
    # download library
    message(STATUS "Download Anakin library from ${ANAKIN_LIBRARY_URL}")
    execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
    execute_process(COMMAND bash -c "rm -rf ${ANAKIN_INSTALL_DIR}/*")
C
cuichaowen 已提交
45
    execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; wget --no-check-certificate -q ${ANAKIN_LIBRARY_URL}")
Y
Yan Chunwei 已提交
46
    execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
C
cuichaowen 已提交
47
    execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; tar xzf anakin.tar.gz")
Y
Yan Chunwei 已提交
48
endif()
Y
Yan Chunwei 已提交
49 50 51 52 53 54 55

if (WITH_ANAKIN)
    message(STATUS "Anakin for inference is enabled")
    message(STATUS "Anakin is set INCLUDE:${ANAKIN_INCLUDE} LIBRARY:${ANAKIN_LIBRARY}")
    fetch_include_recursively(${ANAKIN_INCLUDE})
    link_directories(${ANAKIN_LIBRARY})
endif()