2020-04-27 07:26:45 +08:00
|
|
|
cmake_minimum_required(VERSION 3.10)
|
|
|
|
|
|
|
|
if(POLICY CMP0068)
|
|
|
|
cmake_policy(SET CMP0068 NEW)
|
|
|
|
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(POLICY CMP0075)
|
|
|
|
cmake_policy(SET CMP0075 NEW)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(POLICY CMP0077)
|
|
|
|
cmake_policy(SET CMP0077 NEW)
|
|
|
|
endif()
|
|
|
|
|
2020-06-12 07:40:31 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Project setup and globals
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2020-04-27 08:55:15 +08:00
|
|
|
project(npcomp LANGUAGES CXX C)
|
2020-06-12 07:40:31 +08:00
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
2020-07-05 08:38:01 +08:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
2020-04-27 07:26:45 +08:00
|
|
|
|
2020-06-12 07:40:31 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Options and settings
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
option(NPCOMP_ENABLE_IREE "Enables the IREE backend (must configure location via IREE_DIR)." OFF)
|
|
|
|
set(NPCOMP_IREE_SRCDIR "" CACHE STRING "If building IREE, then setting this elects to build from a source directory (versus installed package)")
|
|
|
|
|
2020-07-02 12:28:04 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# MSVC defaults
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
add_compile_options(
|
|
|
|
$<$<CONFIG:>:/MD>
|
|
|
|
$<$<CONFIG:Debug>:/MD>
|
|
|
|
$<$<CONFIG:Release>:/MD>
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2020-06-12 07:40:31 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# MLIR/LLVM Configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
2020-04-27 07:26:45 +08:00
|
|
|
|
2020-06-12 07:40:31 +08:00
|
|
|
find_package(MLIR REQUIRED CONFIG)
|
2020-04-27 07:26:45 +08:00
|
|
|
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
|
|
|
|
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
|
|
|
|
include(TableGen)
|
|
|
|
include(AddLLVM)
|
|
|
|
include(AddMLIR)
|
|
|
|
include(HandleLLVMOptions)
|
|
|
|
include_directories(${LLVM_INCLUDE_DIRS})
|
|
|
|
include_directories(${MLIR_INCLUDE_DIRS})
|
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/include)
|
|
|
|
include_directories(${PROJECT_BINARY_DIR}/include)
|
|
|
|
link_directories(${LLVM_BUILD_LIBRARY_DIR})
|
|
|
|
add_definitions(${LLVM_DEFINITIONS})
|
2020-06-14 14:45:43 +08:00
|
|
|
set(NPCOMP_TABLEGEN_ARGS "")
|
2020-04-27 07:26:45 +08:00
|
|
|
|
2020-06-12 07:40:31 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# IREE configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2020-07-05 08:38:01 +08:00
|
|
|
function(npcomp_add_iree_src)
|
|
|
|
# TODO: Find a way to fix this upstream as globally demoting warnings
|
|
|
|
# like this is a really bad thing to be doing. Also, Abseil seems to try
|
|
|
|
# really hard to keep us from touching these so some still get through.
|
|
|
|
add_compile_options(-Wno-sign-compare -Wno-unused-template)
|
|
|
|
add_subdirectory("${NPCOMP_IREE_SRCDIR}" "iree" EXCLUDE_FROM_ALL)
|
|
|
|
endfunction()
|
|
|
|
|
2020-06-12 08:47:14 +08:00
|
|
|
if(NPCOMP_ENABLE_IREE)
|
2020-06-12 07:40:31 +08:00
|
|
|
add_compile_definitions(NPCOMP_ENABLE_IREE)
|
2020-06-14 14:45:43 +08:00
|
|
|
string(APPEND NPCOMP_TABLEGEN_ARGS "-DNPCOMP_ENABLE_IREE")
|
2020-06-12 07:40:31 +08:00
|
|
|
if(NPCOMP_IREE_SRCDIR)
|
|
|
|
message(STATUS "Depending on IREE source: ${NPCOMP_IREE_SRCDIR}")
|
2020-06-19 15:30:34 +08:00
|
|
|
set(IREE_BUILD_TESTS OFF CACHE BOOL "Override IREE setting" FORCE)
|
|
|
|
set(IREE_BUILD_SAMPLES OFF CACHE BOOL "Override IREE setting" FORCE)
|
|
|
|
set(IREE_BUILD_PYTHON_BINDINGS ON CACHE BOOL "Override IREE setting" FORCE)
|
2020-06-12 07:40:31 +08:00
|
|
|
set(IREE_MLIR_DEP_MODE "DISABLED" CACHE STRING "Override IREE setting")
|
2020-07-05 08:38:01 +08:00
|
|
|
npcomp_add_iree_src()
|
2020-06-12 07:40:31 +08:00
|
|
|
else()
|
|
|
|
find_package(IREE REQUIRED CONFIG)
|
|
|
|
endif()
|
2020-06-12 08:47:14 +08:00
|
|
|
|
|
|
|
message(STATUS "IREE INCLUDE DIRS: ${IREE_PUBLIC_INCLUDE_DIRS}")
|
|
|
|
include_directories("${IREE_PUBLIC_INCLUDE_DIRS}")
|
2020-06-12 07:40:31 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Python Configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
2020-04-27 06:50:23 +08:00
|
|
|
|
|
|
|
# TODO(laurenzo): Rationalize with how this is done elsewhere
|
|
|
|
find_package(PythonInterp REQUIRED)
|
|
|
|
find_package(PythonLibs REQUIRED)
|
|
|
|
message(STATUS "Found python include dirs: ${PYTHON_INCLUDE_DIRS}")
|
|
|
|
message(STATUS "Found ppython libraries: ${PYTHON_LIBRARIES}")
|
|
|
|
find_package(pybind11 CONFIG REQUIRED)
|
|
|
|
message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
|
|
|
|
|
2020-06-12 07:40:31 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Directory setup
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
set(MLIR_NPCOMP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(MLIR_NPCOMP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
2020-06-08 05:35:58 +08:00
|
|
|
add_custom_target(check-npcomp)
|
|
|
|
|
2020-04-27 06:50:23 +08:00
|
|
|
add_subdirectory(include/npcomp)
|
|
|
|
add_subdirectory(lib)
|
|
|
|
add_subdirectory(python)
|
2020-05-07 13:44:12 +08:00
|
|
|
add_subdirectory(python_native)
|
2020-06-08 05:29:39 +08:00
|
|
|
add_subdirectory(pytest)
|
2020-05-29 07:41:36 +08:00
|
|
|
add_subdirectory(runtime)
|
2020-04-27 08:55:15 +08:00
|
|
|
add_subdirectory(tools)
|
|
|
|
add_subdirectory(test)
|
2020-06-19 15:30:34 +08:00
|
|
|
|
|
|
|
if(NPCOMP_ENABLE_IREE)
|
|
|
|
add_subdirectory(backend_test/iree)
|
|
|
|
endif()
|