file(GLOB_RECURSE PPLNN_X86_SRC src/ppl/nn/engines/x86/*.cc)
list(APPEND PPLNN_SOURCES ${PPLNN_X86_SRC})

add_subdirectory(src/ppl/nn/engines/x86/impls)
list(APPEND PPLNN_LINK_LIBRARIES pplkernelx86_static)

set(PPLNN_USE_X86 ON)
list(APPEND PPLNN_COMPILE_DEFINITIONS PPLNN_USE_X86)

if(PPLNN_ENABLE_SANITIZE_OPTIONS)
    if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
        set(__ASAN_FLAGS__ "-fsanitize=undefined -fsanitize=address -fsanitize=leak -fno-omit-frame-pointer")
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${__ASAN_FLAGS__}")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${__ASAN_FLAGS__}")
        unset(__ASAN_FLAGS__)
        if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
            add_link_options("-static-libasan")
        endif()
    else()
        message(FATAL_ERROR "UNSUPPORTED: `PPLNN_USE_SANITIZE` is ON when using compiler `${CMAKE_CXX_COMPILER_ID}`.")
    endif()
endif()
