Commit b7fe6119 by Hu Shiwen Committed by Tianqi Chen

use auto source_group (#146)

parent b47a1248
......@@ -45,20 +45,11 @@ else(MSVC)
set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
endif(MSVC)
tvm_source_group("Include\\tvm" GLOB "include/tvm/*.h")
tvm_source_group("Include\\tvm\\runtime" GLOB "include/tvm/runtime/*.h")
tvm_source_group("Source\\lang" GLOB "src/lang/*.cc")
tvm_source_group("Source\\api" GLOB "src/api/*.cc")
tvm_source_group("Source\\arithmetic" GLOB "src/arithmetic/*.cc")
tvm_source_group("Source\\schedule" GLOB "src/schedule/*.cc")
tvm_source_group("Source\\codegen" GLOB "src/codegen/*.cc")
tvm_source_group("Source\\codegen\\llvm" GLOB "src/codegen/llvm/*.cc")
tvm_source_group("Source\\codegen\\stack_vm" GLOB "src/codegen/stack_vm/*.cc")
tvm_source_group("Source\\pass" GLOB "src/pass/*.cc")
tvm_source_group("Source\\op" GLOB "src/op/*.cc")
tvm_source_group("Source\\runtime" GLOB "src/runtime/*.cc")
tvm_source_group("Source\\runtime\\cuda" GLOB "src/runtime/cuda/*.cc")
tvm_source_group("Source\\runtime\\opencl" GLOB "src/runtime/opencl/*.cc")
# add source group
FILE(GLOB_RECURSE GROUP_SOURCE "src/*.cc" "HalideIR/src/*.cpp")
FILE(GLOB_RECURSE GROUP_Include "src/*.h" "include/*.h" "HalideIR/src/*.h")
assign_source_group("Source" ${GROUP_SOURCE})
assign_source_group("Include" ${GROUP_Include})
file(GLOB COMPILER_SRCS
src/api/*.cc
......@@ -141,6 +132,7 @@ else()
set(CMAKE_SHARED_LIBRARY_PREFIX "")
endif()
list(APPEND RUNTIME_SRCS ${GROUP_Include})
add_library(libtvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS})
add_library(libtvm_runtime SHARED ${RUNTIME_SRCS})
target_link_libraries(libtvm ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS})
......
# Usage:
# tvm_source_group(<group> GLOB[_RECURSE] <globbing_expression>)
function(tvm_source_group group)
cmake_parse_arguments(TVM_SOURCE_GROUP "" "" "GLOB;GLOB_RECURSE" ${ARGN})
if(TVM_SOURCE_GROUP_GLOB)
file(GLOB srcs1 ${TVM_SOURCE_GROUP_GLOB})
source_group(${group} FILES ${srcs1})
endif()
if(TVM_SOURCE_GROUP_GLOB_RECURSE)
file(GLOB_RECURSE srcs2 ${TVM_SOURCE_GROUP_GLOB_RECURSE})
source_group(${group} FILES ${srcs2})
endif()
endfunction()
#######################################################
# An option that the user can select. Can accept condition to control when option is available for user.
# Usage:
......@@ -52,4 +37,17 @@ function(tvm_option variable description value)
else()
unset(${variable} CACHE)
endif()
endfunction()
\ No newline at end of file
endfunction()
function(assign_source_group group)
foreach(_source IN ITEMS ${ARGN})
if (IS_ABSOLUTE "${_source}")
file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
else()
set(_source_rel "${_source}")
endif()
get_filename_component(_source_path "${_source_rel}" PATH)
string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
source_group("${group}\\${_source_path_msvc}" FILES "${_source}")
endforeach()
endfunction(assign_source_group)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment