65 lines
1.8 KiB
CMake
65 lines
1.8 KiB
CMake
cmake_minimum_required(VERSION 2.8)
|
|
project(triton)
|
|
include(CTest)
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
# Options
|
|
option(BUILD_TESTS "Build C++ Triton tests" ON)
|
|
option(BUILD_PYTHON_MODULE "Build Python Triton bindings" OFF)
|
|
|
|
# LLVM
|
|
find_package(LLVM REQUIRED CONFIG)
|
|
include_directories(${LLVM_INCLUDE_DIRS})
|
|
add_definitions(${LLVM_DEFINITIONS})
|
|
llvm_map_components_to_libnames(llvm_libs all)
|
|
|
|
# Default build type
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
message(STATUS "Default build type: Release")
|
|
set(CMAKE_BUILD_TYPE "Release")
|
|
endif()
|
|
|
|
# Compiler flags
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_CXXFLAGS} -std=c++11")
|
|
|
|
# Tests
|
|
if(BUILD_TESTS)
|
|
message(STATUS "Adding C++ tests")
|
|
add_subdirectory(tests)
|
|
endif()
|
|
|
|
# Python module
|
|
if(BUILD_PYTHON_MODULE)
|
|
message(STATUS "Adding Python module")
|
|
# PyBind11 wrapper source file
|
|
file(GLOB_RECURSE PYTHON_SRC python/src/tensorflow.cc)
|
|
if(TF_LIBS)
|
|
# extra tensorflow ops (e.g., alloc_empty)
|
|
# update directories
|
|
link_directories(${TF_LIB_DIRS})
|
|
include_directories(python/src/ ${PYTHON_INCLUDE_DIRS} ${TF_INCLUDE_DIRS})
|
|
# get sources
|
|
file(GLOB_RECURSE EXTRA_TF_OPS_SRC python/src/tensorflow/*.cc)
|
|
add_library(extra_tf_ops SHARED ${EXTRA_TF_OPS_SRC})
|
|
# create target
|
|
target_link_libraries(extra_tf_ops triton ${TF_LIBS})
|
|
target_compile_definitions(extra_tf_ops PRIVATE "-D_GLIBCXX_USE_CXX11_ABI=${TF_ABI}")
|
|
endif()
|
|
endif()
|
|
|
|
|
|
# Triton
|
|
file(GLOB_RECURSE LIBTRITON_SRC lib/*.cc)
|
|
add_library(triton SHARED ${LIBTRITON_SRC} ${PYTHON_SRC})
|
|
target_link_libraries(triton LLVM)
|
|
|
|
# Warning level
|
|
#if(MSVC)
|
|
# target_compile_options(triton PRIVATE /W4)
|
|
#else()
|
|
# target_compile_options(triton PRIVATE -Wno-unused-parameter -Wall -Wextra -pedantic)
|
|
#endif()
|
|
|
|
|