CMakeLists.txt 2.1 KB
Newer Older
1
add_definitions(-DIR_LIBRARY)
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
set_property(GLOBAL PROPERTY IR_TARGETS "")
set_property(GLOBAL PROPERTY IR_MODULES "")
function(ir_library TARGET_NAME)
  set(options STATIC static SHARED shared INTERFACE interface)
  set(oneValueArgs "")
  set(multiValueArgs SRCS DEPS)
  cmake_parse_arguments(ir_library "${options}" "${oneValueArgs}"
                        "${multiValueArgs}" ${ARGN})
  set(OBJ_LIB ir_${TARGET_NAME})
  add_library(${OBJ_LIB} OBJECT ${ir_library_SRCS})

  if(ir_library_SHARED OR ir_library_shared) # build *.so
    cc_library(
      ${TARGET_NAME} SHARED
      SRCS $<TARGET_OBJECTS:${OBJ_LIB}>
      DEPS ${ir_library_DEPS})
  elseif(ir_library_INTERFACE OR ir_library_interface)
    cc_library(
      ${TARGET_NAME} INTERFACE
      SRCS $<TARGET_OBJECTS:${OBJ_LIB}>
      DEPS ${ir_library_DEPS})
  else()
    cc_library(
      ${TARGET_NAME}
      SRCS $<TARGET_OBJECTS:${OBJ_LIB}>
      DEPS ${ir_library_DEPS})
    set_property(GLOBAL APPEND PROPERTY IR_MODULES $<TARGET_OBJECTS:${OBJ_LIB}>)

    get_property(ir_targets GLOBAL PROPERTY IR_TARGETS)
    set(ir_targets ${ir_targets} ${TARGET_NAME})
    set_property(GLOBAL PROPERTY IR_TARGETS "${ir_targets}")

  endif()
endfunction()

37
add_subdirectory(core)
38
add_subdirectory(pass)
39
add_subdirectory(pattern_rewrite)
40
add_subdirectory(builtin_transforms)
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

if(WIN32)
  if(WITH_SHARED_IR)
    set(IR_NAME
        ir.dll
        CACHE INTERNAL "" FORCE)
  else()
    set(IR_NAME
        ir.lib
        CACHE INTERNAL "" FORCE)
  endif()
elseif(APPLE)
  if(WITH_SHARED_IR)
    set(IR_NAME
        libir.dylib
        CACHE INTERNAL "" FORCE)
  else()
    set(IR_NAME
        libir.a
        CACHE INTERNAL "" FORCE)
  endif()
else()
  if(WITH_SHARED_IR)
    set(IR_NAME
        libir.so
        CACHE INTERNAL "" FORCE)
  else()
    set(IR_NAME
        libir.a
        CACHE INTERNAL "" FORCE)
  endif()
endif()

set(IR_LIB
    "${CMAKE_CURRENT_BINARY_DIR}/${IR_NAME}"
    CACHE FILEPATH "IR Library" FORCE)

get_property(ir_modules GLOBAL PROPERTY IR_MODULES)
if(WITH_SHARED_IR)
  add_library(ir SHARED ${ir_modules})
else()
  add_library(ir STATIC ${ir_modules})
endif()