Commit b7fe6119 by Hu Shiwen Committed by Tianqi Chen

use auto source_group (#146)

parent b47a1248
...@@ -45,20 +45,11 @@ else(MSVC) ...@@ -45,20 +45,11 @@ else(MSVC)
set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS}) set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
endif(MSVC) endif(MSVC)
tvm_source_group("Include\\tvm" GLOB "include/tvm/*.h") # add source group
tvm_source_group("Include\\tvm\\runtime" GLOB "include/tvm/runtime/*.h") FILE(GLOB_RECURSE GROUP_SOURCE "src/*.cc" "HalideIR/src/*.cpp")
tvm_source_group("Source\\lang" GLOB "src/lang/*.cc") FILE(GLOB_RECURSE GROUP_Include "src/*.h" "include/*.h" "HalideIR/src/*.h")
tvm_source_group("Source\\api" GLOB "src/api/*.cc") assign_source_group("Source" ${GROUP_SOURCE})
tvm_source_group("Source\\arithmetic" GLOB "src/arithmetic/*.cc") assign_source_group("Include" ${GROUP_Include})
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")
file(GLOB COMPILER_SRCS file(GLOB COMPILER_SRCS
src/api/*.cc src/api/*.cc
...@@ -141,6 +132,7 @@ else() ...@@ -141,6 +132,7 @@ else()
set(CMAKE_SHARED_LIBRARY_PREFIX "") set(CMAKE_SHARED_LIBRARY_PREFIX "")
endif() endif()
list(APPEND RUNTIME_SRCS ${GROUP_Include})
add_library(libtvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS}) add_library(libtvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS})
add_library(libtvm_runtime SHARED ${RUNTIME_SRCS}) add_library(libtvm_runtime SHARED ${RUNTIME_SRCS})
target_link_libraries(libtvm ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS}) 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. # An option that the user can select. Can accept condition to control when option is available for user.
# Usage: # Usage:
...@@ -53,3 +38,16 @@ function(tvm_option variable description value) ...@@ -53,3 +38,16 @@ function(tvm_option variable description value)
unset(${variable} CACHE) unset(${variable} CACHE)
endif() endif()
endfunction() 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