2019-03-30 13:10:12 +08:00
|
|
|
# MLIR project.
|
2019-07-24 11:09:11 +08:00
|
|
|
set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include ) # --src-root
|
2019-03-30 13:10:12 +08:00
|
|
|
set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include ) # --includedir
|
|
|
|
set(MLIR_TABLEGEN_EXE mlir-tblgen)
|
|
|
|
|
|
|
|
set(MLIR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(MLIR_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
|
|
|
function(mlir_tablegen ofn)
|
|
|
|
tablegen(MLIR ${ARGV} "-I${MLIR_MAIN_SRC_DIR}" "-I${MLIR_INCLUDE_DIR}")
|
|
|
|
set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
|
|
|
|
PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# TODO: This is to handle the current static registration, but should be
|
|
|
|
# factored out a bit.
|
|
|
|
function(whole_archive_link target)
|
2019-04-02 01:17:45 +08:00
|
|
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
2019-04-24 07:39:15 +08:00
|
|
|
set(link_flags "-L${CMAKE_BINARY_DIR}/lib ")
|
2019-04-02 01:17:45 +08:00
|
|
|
FOREACH(LIB ${ARGN})
|
2019-04-24 07:39:15 +08:00
|
|
|
string(CONCAT link_flags ${link_flags} "-Wl,-force_load ${CMAKE_BINARY_DIR}/lib/lib${LIB}.a ")
|
2019-04-02 01:17:45 +08:00
|
|
|
ENDFOREACH(LIB)
|
2019-05-30 04:47:24 +08:00
|
|
|
elseif(MSVC)
|
|
|
|
FOREACH(LIB ${ARGN})
|
|
|
|
string(CONCAT link_flags ${link_flags} "/WHOLEARCHIVE:${LIB} ")
|
|
|
|
ENDFOREACH(LIB)
|
2019-04-02 01:17:45 +08:00
|
|
|
else()
|
2019-04-21 01:45:59 +08:00
|
|
|
set(link_flags "-L${CMAKE_BINARY_DIR}/lib -Wl,--whole-archive,")
|
2019-04-02 01:17:45 +08:00
|
|
|
FOREACH(LIB ${ARGN})
|
|
|
|
string(CONCAT link_flags ${link_flags} "-l${LIB},")
|
|
|
|
ENDFOREACH(LIB)
|
|
|
|
string(CONCAT link_flags ${link_flags} "--no-whole-archive")
|
|
|
|
endif()
|
2019-03-30 13:10:12 +08:00
|
|
|
set_target_properties(${target} PROPERTIES LINK_FLAGS ${link_flags})
|
|
|
|
endfunction(whole_archive_link)
|
|
|
|
|
2019-06-26 20:16:11 +08:00
|
|
|
# Build the CUDA conversions and run according tests if the NVPTX backend
|
|
|
|
# is available
|
|
|
|
if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
|
|
|
|
set(MLIR_CUDA_CONVERSIONS_ENABLED 1)
|
|
|
|
else()
|
|
|
|
set(MLIR_CUDA_CONVERSIONS_ENABLED 0)
|
|
|
|
endif()
|
|
|
|
|
2019-07-04 22:49:52 +08:00
|
|
|
set(MLIR_CUDA_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir CUDA runner")
|
|
|
|
|
2019-03-30 13:10:12 +08:00
|
|
|
include_directories( "include")
|
|
|
|
include_directories( ${MLIR_INCLUDE_DIR})
|
|
|
|
|
|
|
|
add_subdirectory(include/mlir)
|
|
|
|
add_subdirectory(lib)
|
|
|
|
add_subdirectory(tools)
|
|
|
|
add_subdirectory(unittests)
|
|
|
|
add_subdirectory(test)
|
2019-04-03 01:02:07 +08:00
|
|
|
|
|
|
|
if( LLVM_INCLUDE_EXAMPLES )
|
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|