github.com/johnnyeven/libtools@v0.0.0-20191126065708-61829c1adf46/third_party/mlir/CMakeLists.txt (about)

     1  # MLIR project.
     2  set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include ) # --src-root
     3  set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include ) # --includedir
     4  set(MLIR_TABLEGEN_EXE mlir-tblgen)
     5  
     6  set(MLIR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
     7  set(MLIR_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
     8  
     9  function(mlir_tablegen ofn)
    10    tablegen(MLIR ${ARGV} "-I${MLIR_MAIN_SRC_DIR}" "-I${MLIR_INCLUDE_DIR}")
    11    set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
    12        PARENT_SCOPE)
    13  endfunction()
    14  
    15  # TODO: This is to handle the current static registration, but should be
    16  # factored out a bit.
    17  function(whole_archive_link target)
    18    if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
    19      set(link_flags "-L${CMAKE_BINARY_DIR}/lib ")
    20      FOREACH(LIB ${ARGN})
    21        string(CONCAT link_flags ${link_flags} "-Wl,-force_load ${CMAKE_BINARY_DIR}/lib/lib${LIB}.a ")
    22      ENDFOREACH(LIB)
    23    elseif(MSVC)
    24      FOREACH(LIB ${ARGN})
    25        string(CONCAT link_flags ${link_flags} "/WHOLEARCHIVE:${LIB} ")
    26      ENDFOREACH(LIB)
    27    else()
    28      set(link_flags "-L${CMAKE_BINARY_DIR}/lib -Wl,--whole-archive,")
    29      FOREACH(LIB ${ARGN})
    30        string(CONCAT link_flags ${link_flags} "-l${LIB},")
    31      ENDFOREACH(LIB)
    32      string(CONCAT link_flags ${link_flags} "--no-whole-archive")
    33    endif()
    34    set_target_properties(${target} PROPERTIES LINK_FLAGS ${link_flags})
    35  endfunction(whole_archive_link)
    36  
    37  # Build the CUDA conversions and run according tests if the NVPTX backend
    38  # is available
    39  if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
    40    set(MLIR_CUDA_CONVERSIONS_ENABLED 1)
    41  else()
    42    set(MLIR_CUDA_CONVERSIONS_ENABLED 0)
    43  endif()
    44  
    45  set(MLIR_CUDA_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir CUDA runner")
    46  
    47  include_directories( "include")
    48  include_directories( ${MLIR_INCLUDE_DIR})
    49  
    50  add_subdirectory(include/mlir)
    51  add_subdirectory(lib)
    52  add_subdirectory(tools)
    53  add_subdirectory(unittests)
    54  add_subdirectory(test)
    55  
    56  if( LLVM_INCLUDE_EXAMPLES )
    57    add_subdirectory(examples)
    58  endif()