You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/04/18 23:16:24 UTC

[GitHub] [tvm] tkonolige commented on a diff in pull request #10958: modify CMakeLists.txt and *.cmake in folder cmake to generate debuggable workspace and projects

tkonolige commented on code in PR #10958:
URL: https://github.com/apache/tvm/pull/10958#discussion_r852469823


##########
cmake/libs/Libbacktrace.cmake:
##########
@@ -68,3 +68,6 @@ set_property(TARGET libbacktrace
   PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/lib/libbacktrace.a)
 # create include directory so cmake doesn't complain
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include)
+
+
+link_directories("${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libbacktrace/lib")

Review Comment:
   This shouldn't be necessary as the `libbacktrace` target directly references the static library.



##########
cmake/modules/ClangFlags.cmake:
##########
@@ -82,8 +82,8 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
       -Wno-gnu-anonymous-struct
       -Wno-nested-anon-types
     )
-  target_compile_options(tvm_objs PRIVATE $<$<COMPILE_LANGUAGE:CXX>: ${warning_opts}>)
-  target_compile_options(tvm_runtime_objs PRIVATE $<$<COMPILE_LANGUAGE:CXX>: ${warning_opts}>)
+  target_compile_options(tvm PRIVATE $<$<COMPILE_LANGUAGE:CXX>: ${warning_opts}>)
+  target_compile_options(tvm_runtime PRIVATE $<$<COMPILE_LANGUAGE:CXX>: ${warning_opts}>)

Review Comment:
   This causes the warning options to only be used when linking not when compiling. I don't think that is the behavior we want.



##########
cmake/modules/CUDA.cmake:
##########
@@ -29,9 +29,9 @@ if(USE_CUDA)
     message(FATAL_ERROR "Cannot find CUDA, USE_CUDA=" ${USE_CUDA})
   endif()
   message(STATUS "Build with CUDA ${CUDA_VERSION} support")
-  tvm_file_glob(GLOB RUNTIME_CUDA_SRCS src/runtime/cuda/*.cc)
+  tvm_file_glob(GLOB RUNTIME_CUDA_SRCS ${CMAKE_CURRENT_LIST_DIR}/../../src/runtime/cuda/*.cc)

Review Comment:
   I think you could use https://cmake.org/cmake/help/latest/variable/PROJECT_SOURCE_DIR.html to avoid having to go up directories.



##########
cmake/modules/Logging.cmake:
##########
@@ -35,21 +26,30 @@ if("${USE_LIBBACKTRACE}" STREQUAL "AUTO")
   message(STATUS "Autoset: USE_LIBBACKTRACE=" ${USE_LIBBACKTRACE} " in " ${CMAKE_SYSTEM_NAME})
 endif()
 
+if (USE_LIBBACKTRACE)
+    set(current_dir ${CMAKE_CURRENT_LIST_DIR})
+endif ()
 
-if(USE_LIBBACKTRACE)
-  message(STATUS "Building with libbacktrace...")
-  include(cmake/libs/Libbacktrace.cmake)
-  target_link_libraries(tvm PRIVATE libbacktrace)
-  target_link_libraries(tvm_runtime PRIVATE libbacktrace)
-  add_dependencies(tvm_runtime_objs libbacktrace)
-  # pre 3.12 versions of cmake cannot propagate include directories from imported targets so we set them manually
-  target_include_directories(tvm PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include")
-  target_include_directories(tvm_objs PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include")
-  target_include_directories(tvm_runtime PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include")
-  target_include_directories(tvm_runtime_objs PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include")
-  target_compile_definitions(tvm_objs PRIVATE TVM_USE_LIBBACKTRACE=1)
-  target_compile_definitions(tvm_runtime_objs PRIVATE TVM_USE_LIBBACKTRACE=1)
-else()
-  target_compile_definitions(tvm_objs PRIVATE TVM_USE_LIBBACKTRACE=0)
-  target_compile_definitions(tvm_runtime_objs PRIVATE TVM_USE_LIBBACKTRACE=0)
-endif()
+set(backtrace_defined OFF CACHE BOOL "backtrace defined indicator")
+
+macro(use_backtrace package)
+  if (USE_LIBBACKTRACE)
+    message(STATUS "Building with libbacktrace...")

Review Comment:
   Seems like this will be printed multiple times. Could we avoid that?



##########
cmake/modules/Logging.cmake:
##########
@@ -35,21 +26,30 @@ if("${USE_LIBBACKTRACE}" STREQUAL "AUTO")
   message(STATUS "Autoset: USE_LIBBACKTRACE=" ${USE_LIBBACKTRACE} " in " ${CMAKE_SYSTEM_NAME})
 endif()
 
+if (USE_LIBBACKTRACE)
+    set(current_dir ${CMAKE_CURRENT_LIST_DIR})
+endif ()
 
-if(USE_LIBBACKTRACE)
-  message(STATUS "Building with libbacktrace...")
-  include(cmake/libs/Libbacktrace.cmake)
-  target_link_libraries(tvm PRIVATE libbacktrace)
-  target_link_libraries(tvm_runtime PRIVATE libbacktrace)
-  add_dependencies(tvm_runtime_objs libbacktrace)
-  # pre 3.12 versions of cmake cannot propagate include directories from imported targets so we set them manually
-  target_include_directories(tvm PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include")
-  target_include_directories(tvm_objs PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include")
-  target_include_directories(tvm_runtime PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include")
-  target_include_directories(tvm_runtime_objs PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include")
-  target_compile_definitions(tvm_objs PRIVATE TVM_USE_LIBBACKTRACE=1)
-  target_compile_definitions(tvm_runtime_objs PRIVATE TVM_USE_LIBBACKTRACE=1)
-else()
-  target_compile_definitions(tvm_objs PRIVATE TVM_USE_LIBBACKTRACE=0)
-  target_compile_definitions(tvm_runtime_objs PRIVATE TVM_USE_LIBBACKTRACE=0)
-endif()
+set(backtrace_defined OFF CACHE BOOL "backtrace defined indicator")
+
+macro(use_backtrace package)
+  if (USE_LIBBACKTRACE)
+    message(STATUS "Building with libbacktrace...")
+    if (NOT backtrace_defined)
+        include(${current_dir}/../libs/Libbacktrace.cmake)
+        set(backtrace_defined ON CACHE BOOL "backtrace defined indicator" FORCE)
+    endif()
+    
+    target_link_libraries(${package} PRIVATE backtrace)
+    if ("${package}" STREQUAL "tvm_runtime")
+        target_link_libraries(tvm_runtime backtrace)

Review Comment:
   A little confused as to why `tvm_runtime` gets special behavior here. It does not match the previous behavior. Could you explain?



##########
cmake/modules/Logging.cmake:
##########
@@ -35,21 +26,30 @@ if("${USE_LIBBACKTRACE}" STREQUAL "AUTO")
   message(STATUS "Autoset: USE_LIBBACKTRACE=" ${USE_LIBBACKTRACE} " in " ${CMAKE_SYSTEM_NAME})
 endif()
 
+if (USE_LIBBACKTRACE)
+    set(current_dir ${CMAKE_CURRENT_LIST_DIR})
+endif ()
 
-if(USE_LIBBACKTRACE)
-  message(STATUS "Building with libbacktrace...")
-  include(cmake/libs/Libbacktrace.cmake)
-  target_link_libraries(tvm PRIVATE libbacktrace)
-  target_link_libraries(tvm_runtime PRIVATE libbacktrace)
-  add_dependencies(tvm_runtime_objs libbacktrace)

Review Comment:
   This line needs to be kept because `tvm_runtime_objs` depends on header files generated by libbacktrace.



##########
src/CMakeLists.txt:
##########
@@ -0,0 +1,659 @@
+cmake_minimum_required(VERSION 3.2)
+
+set(PRJ_NAME "tvm")
+project(${PRJ_NAME} C CXX)
+
+if (${CMAKE_PARENT_LIST_FILE} STREQUAL ${CMAKE_CURRENT_LIST_FILE})
+    set(PROJECT_IS_TOP_LEVEL ON)
+else ()
+    set(PROJECT_IS_TOP_LEVEL OFF)
+endif ()
+
+if (PROJECT_IS_TOP_LEVEL)
+    # Utility functions
+    include(../cmake/utils/Utils.cmake)
+    include(../cmake/utils/Summary.cmake)
+    include(../cmake/utils/FindCUDA.cmake)
+    include(../cmake/utils/FindOpenCL.cmake)
+    include(../cmake/utils/FindVulkan.cmake)
+    include(../cmake/utils/FindLLVM.cmake)
+    include(../cmake/utils/FindROCM.cmake)
+    include(../cmake/utils/FindEthosN.cmake)
+
+    if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
+        include(${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
+    else()
+        if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../config.cmake)
+            include(${CMAKE_CURRENT_SOURCE_DIR}/../config.cmake)
+        endif()
+    endif()
+
+    # NOTE: do not modify this file to change option values.
+    # You can create a config.cmake at build folder
+    # and add set(OPTION VALUE) to override these build options.
+    # Alernatively, use cmake -DOPTION=VALUE through command-line.
+    tvm_option(USE_CUDA "Build with CUDA" OFF)
+    tvm_option(USE_OPENCL "Build with OpenCL" OFF)
+    tvm_option(USE_VULKAN "Build with Vulkan" OFF)
+
+
+    # Whether to use spirv-tools.and SPIRV-Headers from Khronos github or gitlab.
+    #
+    # Possible values:
+    # - OFF: not to use
+    # - /path/to/install: path to your khronis spirv-tools and SPIRV-Headers installation directory
+    #
+    tvm_option(USE_KHRONOS_SPIRV "Whether to use spirv-tools.and SPIRV-Headers from Khronos github or gitlab" OFF)
+    tvm_option(USE_SPIRV_KHR_INTEGER_DOT_PRODUCT "whether enable SPIRV_KHR_DOT_PRODUCT" OFF)
+    tvm_option(USE_METAL "Build with Metal" OFF)
+    tvm_option(USE_ROCM "Build with ROCM" OFF)
+    tvm_option(ROCM_PATH "The path to rocm" /opt/rocm)
+    tvm_option(USE_HEXAGON_DEVICE "Build with Hexagon device support in TVM runtime" OFF)
+    tvm_option(USE_HEXAGON_SDK "Path to the Hexagon SDK root (required for Hexagon support in TVM runtime or for building TVM runtime for Hexagon)" /path/to/sdk)
+    tvm_option(USE_HEXAGON_RPC "Enable Hexagon RPC using minRPC implementation over Android." OFF)
+    tvm_option(USE_RPC "Build with RPC" ON)
+    tvm_option(USE_THREADS "Build with thread support" ON)
+    tvm_option(USE_LLVM "Build with LLVM, can be set to specific llvm-config path" OFF)
+    tvm_option(USE_STACKVM_RUNTIME "Include stackvm into the runtime" OFF)
+    tvm_option(USE_GRAPH_EXECUTOR "Build with tiny graph executor" ON)
+    tvm_option(USE_GRAPH_EXECUTOR_CUDA_GRAPH "Build with tiny graph executor with CUDA Graph for GPUs" OFF)
+    tvm_option(USE_AOT_EXECUTOR "Build with AOT executor" ON)
+    tvm_option(USE_PROFILER "Build profiler for the VM and graph executor" ON)
+    tvm_option(USE_OPENMP "Build with OpenMP thread pool implementation" OFF)
+    tvm_option(USE_RELAY_DEBUG "Building Relay in debug mode..." OFF)
+    tvm_option(USE_RTTI "Build with RTTI" ON)
+    tvm_option(USE_MSVC_MT "Build with MT" OFF)
+    tvm_option(USE_MICRO "Build with Micro TVM support" OFF)
+    tvm_option(INSTALL_DEV "Install compiler infrastructure" OFF)
+    tvm_option(HIDE_PRIVATE_SYMBOLS "Compile with -fvisibility=hidden." OFF)
+    tvm_option(USE_TF_TVMDSOOP "Build with TensorFlow TVMDSOOp" OFF)
+    tvm_option(USE_PT_TVMDSOOP "Build with PyTorch TVMDSOOp" OFF)
+    tvm_option(USE_FALLBACK_STL_MAP "Use TVM's POD compatible Map" OFF)
+    tvm_option(USE_ETHOSN "Build with Arm(R) Ethos(TM)-N" OFF)
+    tvm_option(USE_CMSISNN "Build with Arm CMSIS-NN" OFF)
+    tvm_option(INDEX_DEFAULT_I64 "Defaults the index datatype to int64" ON)
+    tvm_option(USE_LIBBACKTRACE "Build libbacktrace to supply linenumbers on stack traces" AUTO)
+    tvm_option(BUILD_STATIC_RUNTIME "Build static version of libtvm_runtime" OFF)
+    tvm_option(USE_PAPI "Use Performance Application Programming Interface (PAPI) to read performance counters" OFF)
+    tvm_option(USE_GTEST "Use GoogleTest for C++ sanity tests" AUTO)
+    tvm_option(USE_CUSTOM_LOGGING "Use user-defined custom logging, tvm::runtime::detail::LogFatalImpl and tvm::runtime::detail::LogMessageImpl must be implemented" OFF)
+    tvm_option(USE_ALTERNATIVE_LINKER "Use 'mold' or 'lld' if found when invoking compiler to link artifact" AUTO)
+
+    # 3rdparty libraries
+    tvm_option(DLPACK_PATH "Path to DLPACK" "../3rdparty/dlpack/include")
+    tvm_option(DMLC_PATH "Path to DMLC" "../3rdparty/dmlc-core/include")
+    tvm_option(RANG_PATH "Path to RANG" "../3rdparty/rang/include")
+    tvm_option(COMPILER_RT_PATH "Path to COMPILER-RT" "../3rdparty/compiler-rt")
+    tvm_option(PICOJSON_PATH "Path to PicoJSON" "../3rdparty/picojson")
+    
+    # Contrib library options
+    tvm_option(USE_BYODT_POSIT "Build with BYODT software emulated posit custom datatype" OFF)
+    tvm_option(USE_BLAS "The blas library to be linked" none)
+    tvm_option(USE_MKL "MKL root path when use MKL blas" OFF)
+    tvm_option(USE_MKLDNN "Build with MKLDNN" OFF)
+    tvm_option(USE_DNNL_CODEGEN "Enable MKLDNN (DNNL) codegen" OFF)
+    tvm_option(USE_CUDNN "Build with cuDNN" OFF)
+    tvm_option(USE_CUBLAS "Build with cuBLAS" OFF)
+    tvm_option(USE_CUTLASS "Build with CUTLASS" OFF)
+    tvm_option(USE_THRUST "Build with Thrust" OFF)
+    tvm_option(USE_MIOPEN "Build with ROCM:MIOpen" OFF)
+    tvm_option(USE_ROCBLAS "Build with ROCM:RoCBLAS" OFF)
+    tvm_option(USE_SORT "Build with sort support" ON)
+    tvm_option(USE_NNPACK "Build with nnpack support" OFF)
+    tvm_option(USE_LIBTORCH "Build with libtorch support" OFF)
+    tvm_option(USE_RANDOM "Build with random support" ON)
+    tvm_option(USE_MICRO_STANDALONE_RUNTIME "Build with micro.standalone_runtime support" OFF)
+    tvm_option(USE_CPP_RPC "Build CPP RPC" OFF)
+    tvm_option(USE_IOS_RPC "Build iOS RPC" OFF)
+    tvm_option(USE_TFLITE "Build with tflite support" OFF)
+    tvm_option(USE_TENSORFLOW_PATH "TensorFlow root path when use TFLite" none)
+    tvm_option(USE_COREML "Build with coreml support" OFF)
+    tvm_option(USE_BNNS "Build with BNNS support" OFF)
+    tvm_option(USE_TARGET_ONNX "Build with ONNX Codegen support" OFF)
+    tvm_option(USE_ARM_COMPUTE_LIB "Build with Arm Compute Library" OFF)
+    tvm_option(USE_ARM_COMPUTE_LIB_GRAPH_EXECUTOR "Build with Arm Compute Library graph executor" OFF)
+    tvm_option(USE_TENSORRT_CODEGEN "Build with TensorRT Codegen support" OFF)
+    tvm_option(USE_TENSORRT_RUNTIME "Build with TensorRT runtime" OFF)
+    tvm_option(USE_RUST_EXT "Build with Rust based compiler extensions, STATIC, DYNAMIC, or OFF" OFF)
+    tvm_option(USE_VITIS_AI "Build with VITIS-AI Codegen support" OFF)
+    tvm_option(SUMMARIZE "Print CMake option summary after configuring" OFF)
+
+    # include directories
+    include_directories(${CMAKE_INCLUDE_PATH})
+    include_directories("../include")
+    include_directories(SYSTEM ${DLPACK_PATH})
+    include_directories(SYSTEM ${DMLC_PATH})
+    include_directories(SYSTEM ${RANG_PATH})
+    include_directories(SYSTEM ${COMPILER_RT_PATH})
+    include_directories(SYSTEM ${PICOJSON_PATH})
+
+    # initial variables
+    set(TVM_LINKER_LIBS "")
+    set(TVM_RUNTIME_LINKER_LIBS "")
+
+    # Check if this is being run on its own or as a subdirectory for another project
+    # If we update to CMake 2.21+, we can use PROJECT_IS_TOP_LEVEL instead
+    get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY)
+
+    if(NOT IS_SUBPROJECT AND NOT DEFINED "${CMAKE_EXPORT_COMPILE_COMMANDS}")
+    # If not set manually, change the default to ON
+    set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+    endif()
+
+    # Generic compilation options
+    if(MSVC)
+    add_definitions(-DWIN32_LEAN_AND_MEAN)
+    add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+    add_definitions(-D_SCL_SECURE_NO_WARNINGS)
+    add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
+    add_definitions(-DNOMINMAX)
+    # regeneration does not work well with msbuild custom rules.
+    set(CMAKE_SUPPRESS_REGENERATION ON)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /bigobj")
+
+    # MSVC already errors on undefined symbols, no additional flag needed.
+    set(TVM_NO_UNDEFINED_SYMBOLS "")
+
+    if(USE_MSVC_MT)
+        foreach(flag_var
+            CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+            CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+        if(${flag_var} MATCHES "/MD")
+            string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
+        endif(${flag_var} MATCHES "/MD")
+        endforeach(flag_var)
+    endif()
+    # Disable common MSVC warnings
+    # Integer conversion warnings(e.g. int64 to int)
+    add_compile_options(/wd4244)
+    add_compile_options(/wd4267)
+    # Signed unsigned constant comparison
+    add_compile_options(/wd4018)
+    # Aligned alloc may not met(need c++17)
+    add_compile_options(/wd4316)
+    # unreferenced local variables(usually in exception catch)
+    add_compile_options(/wd4101)
+    # always inline keyword not necessary
+    add_compile_options(/wd4180)
+    # DLL interface warning in c++
+    add_compile_options(/wd4251)
+    # destructor was implicitly defined as deleted
+    add_compile_options(/wd4624)
+    # unary minus operator applied to unsigned type, result still unsigned
+    add_compile_options(/wd4146)
+    # 'inline': used more than once
+    add_compile_options(/wd4141)
+    # unknown pragma
+    add_compile_options(/wd4068)
+    else(MSVC)
+    set(WARNING_FLAG -Wall)
+    if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
+        message(STATUS "Build in Debug mode")
+        set(CMAKE_C_FLAGS "-O0 -g ${WARNING_FLAG} -fPIC ${CMAKE_C_FLAGS}")
+        set(CMAKE_CXX_FLAGS "-O0 -g ${WARNING_FLAG} -fPIC ${CMAKE_CXX_FLAGS}")
+        set(CMAKE_CUDA_FLAGS "-O0 -g -Xcompiler=-Wall -Xcompiler=-fPIC ${CMAKE_CUDA_FLAGS}")
+    else()
+        set(CMAKE_C_FLAGS "-O2 ${WARNING_FLAG} -fPIC ${CMAKE_C_FLAGS}")
+        set(CMAKE_CXX_FLAGS "-O2 ${WARNING_FLAG} -fPIC ${CMAKE_CXX_FLAGS}")
+        set(CMAKE_CUDA_FLAGS "-O2 -Xcompiler=-Wall -Xcompiler=-fPIC ${CMAKE_CUDA_FLAGS}")
+        set(TVM_VISIBILITY_FLAG "")
+        if (HIDE_PRIVATE_SYMBOLS)
+        message(STATUS "Hide private symbols...")
+        set(TVM_VISIBILITY_FLAG "-fvisibility=hidden")
+        endif(HIDE_PRIVATE_SYMBOLS)
+    endif ()
+    if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
+        CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
+        set(CMAKE_CXX_FLAGS "-faligned-new ${CMAKE_CXX_FLAGS}")
+    endif()
+
+    # ld option to warn if symbols are undefined (e.g. libtvm_runtime.so
+    # using symbols only present in libtvm.so).  Not needed for MSVC,
+    # since this is already the default there.
+    if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "iOS")
+        set(TVM_NO_UNDEFINED_SYMBOLS "-Wl,-undefined,error")
+    else()
+        set(TVM_NO_UNDEFINED_SYMBOLS "-Wl,--no-undefined")
+    endif()
+    message(STATUS "Forbidding undefined symbols in shared library, using ${TVM_NO_UNDEFINED_SYMBOLS} on platform ${CMAKE_SYSTEM_NAME}")
+
+    # Detect if we're compiling for Hexagon.
+    set(TEST_FOR_HEXAGON_CXX
+        "#ifndef __hexagon__"
+        "#error"
+        "#endif"
+        "int main() {}"
+        # Define _start_main to avoid linking errors with -fPIC.
+        "extern \"C\" void _start_main() {}")
+    set(TEST_FOR_HEXAGON_DIR
+        "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp")
+    set(TEST_FOR_HEXAGON_FILE "${TEST_FOR_HEXAGON_DIR}/test_for_hexagon.cc")
+    string(REPLACE ";" "\n" TEST_FOR_HEXAGON_CXX_TEXT "${TEST_FOR_HEXAGON_CXX}")
+    file(WRITE "${TEST_FOR_HEXAGON_FILE}" "${TEST_FOR_HEXAGON_CXX_TEXT}")
+    try_compile(BUILD_FOR_HEXAGON "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}"
+                "${TEST_FOR_HEXAGON_FILE}")
+    file(REMOVE "${TEST_FOR_HEXAGON_FILE}")
+    if(BUILD_FOR_HEXAGON)
+        message(STATUS "Building for Hexagon")
+    endif()
+
+    # Detect if we're compiling for Android.
+    set(TEST_FOR_ANDROID_CXX
+        "#ifndef __ANDROID__"
+        "#error"
+        "#endif"
+        "int main() {}")
+    set(TEST_FOR_ANDROID_DIR
+        "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp")
+    set(TEST_FOR_ANDROID_FILE "${TEST_FOR_ANDROID_DIR}/test_for_android.cc")
+    string(REPLACE ";" "\n" TEST_FOR_ANDROID_CXX_TEXT "${TEST_FOR_ANDROID_CXX}")
+    file(WRITE "${TEST_FOR_ANDROID_FILE}" "${TEST_FOR_ANDROID_CXX_TEXT}")
+    try_compile(BUILD_FOR_ANDROID "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}"
+                "${TEST_FOR_ANDROID_FILE}")
+    file(REMOVE "${TEST_FOR_ANDROID_FILE}")
+    if(BUILD_FOR_ANDROID)
+        message(STATUS "Building for Android")
+    endif()
+    endif(MSVC)
+endif ()
+
+# Hexagon has dlopen built into QuRT (no need for static library).
+if(NOT BUILD_FOR_HEXAGON)
+  list(APPEND TVM_RUNTIME_LINKER_LIBS ${CMAKE_DL_LIBS})
+endif()
+
+# add source group
+tvm_file_glob(GLOB_RECURSE GROUP_SOURCE "*.cc")
+tvm_file_glob(GLOB_RECURSE GROUP_INCLUDE "*.h" "../include/*.h")
+assign_source_group("Source" ${GROUP_SOURCE})
+assign_source_group("Include" ${GROUP_INCLUDE})
+
+# Source file lists
+tvm_file_glob(GLOB_RECURSE COMPILER_SRCS_LIST       
+    auto_scheduler/*.cc
+    meta_schedule/*.cc
+    node/*.cc
+    ir/*.cc
+    arith/*.cc
+    te/*.cc
+    autotvm/*.cc
+    tir/*.cc
+    topi/*.cc
+    driver/*.cc
+    parser/*.cc
+    printer/*.cc
+    support/*.cc
+    )
+list(APPEND COMPILER_SRCS ${COMPILER_SRCS_LIST})
+
+tvm_file_glob(GLOB CODEGEN_SRCS
+  target/*.cc
+  target/source/*.cc
+    )
+
+list(APPEND COMPILER_SRCS ${CODEGEN_SRCS})
+
+tvm_file_glob(GLOB_RECURSE RELAY_OP_SRCS
+    relay/op/*.cc
+    )
+tvm_file_glob(GLOB_RECURSE RELAY_PASS_SRCS
+    relay/analysis/*.cc
+    relay/transforms/*.cc
+    relay/quantize/*.cc
+    )
+tvm_file_glob(GLOB RELAY_BACKEND_SRCS
+    relay/backend/*.cc
+    relay/backend/vm/*.cc
+    )
+tvm_file_glob(GLOB_RECURSE RELAY_IR_SRCS
+    relay/ir/*.cc
+    )
+tvm_file_glob(GLOB_RECURSE RELAY_QNN_SRCS
+    relay/qnn/*.cc
+)
+list(APPEND COMPILER_SRCS ${RELAY_OP_SRCS})
+list(APPEND COMPILER_SRCS ${RELAY_PASS_SRCS})
+list(APPEND COMPILER_SRCS ${RELAY_BACKEND_SRCS})
+list(APPEND COMPILER_SRCS ${RELAY_IR_SRCS})
+list(APPEND COMPILER_SRCS ${RELAY_QNN_SRCS})
+
+tvm_file_glob(GLOB DATATYPE_SRCS ${CMAKE_CURRENT_LIST_DIR}/target/datatype/*.cc)
+list(APPEND COMPILER_SRCS ${DATATYPE_SRCS})
+list(APPEND COMPILER_SRCS "${CMAKE_CURRENT_LIST_DIR}/target/datatype/myfloat/myfloat.cc")
+
+tvm_file_glob(GLOB RUNTIME_SRCS_LIST
+  runtime/*.cc
+  runtime/vm/*.cc
+)
+
+list(APPEND RUNTIME_SRCS ${RUNTIME_SRCS_LIST})
+
+if(BUILD_FOR_HEXAGON)
+  # Add file implementing posix_memalign when building the runtime as
+  # a shared library.
+  # This function is actually defined in the static libc, but when linking
+  # a shared library, libc is not linked into it. Some runtime systems
+  # don't implement posix_runtime, which causes runtime failires.
+  # To avoid this issue, Hexagon runtime contains an implementation of
+  # posix_memalign, but it should only be used with the dynamic TVM
+  # runtime, since it would cause multiple definition errors with the
+  # static one.
+  if(NOT BUILD_STATIC_RUNTIME)
+    list(APPEND RUNTIME_SRCS runtime/hexagon/android/hexagon_posix.cc)
+    # Allow undefined symbols (there will be some from libc).
+    set(TVM_NO_UNDEFINED_SYMBOLS "")
+  endif()
+
+  add_definitions(-D_MACH_I32=int)
+  add_definitions(-DDMLC_CXX11_THREAD_LOCAL=0)
+endif()
+
+if (PROJECT_IS_TOP_LEVEL)
+    # Package runtime rules
+    if(NOT USE_RTTI)
+        add_definitions(-DDMLC_ENABLE_RTTI=0)
+    endif()
+
+    if (INDEX_DEFAULT_I64)
+        add_definitions(-DTVM_INDEX_DEFAULT_I64=1)
+    endif()
+endif ()
+
+if(USE_RPC)
+  message(STATUS "Build with RPC support...")
+  tvm_file_glob(GLOB RUNTIME_RPC_SRCS runtime/rpc/*.cc)
+  list(APPEND RUNTIME_SRCS ${RUNTIME_RPC_SRCS})
+endif(USE_RPC)
+
+tvm_file_glob(GLOB STACKVM_RUNTIME_SRCS runtime/stackvm/*.cc)
+tvm_file_glob(GLOB STACKVM_CODEGEN_SRCS target/stackvm/*.cc)
+list(APPEND COMPILER_SRCS ${STACKVM_CODEGEN_SRCS})
+if(USE_STACKVM_RUNTIME)
+  message(STATUS "Build with stackvm support in runtime...")
+  list(APPEND RUNTIME_SRCS ${STACKVM_RUNTIME_SRCS})
+else()
+  list(APPEND COMPILER_SRCS ${STACKVM_RUNTIME_SRCS})
+endif(USE_STACKVM_RUNTIME)
+
+if (PROJECT_IS_TOP_LEVEL)
+    # NOTE(areusch): USE_GRAPH_RUNTIME will be deleted in a future release
+    if(USE_GRAPH_RUNTIME AND NOT DEFINED USE_GRAPH_EXECUTOR)
+        message(WARNING "USE_GRAPH_RUNTIME renamed to USE_GRAPH_EXECUTOR. Please update your config.cmake")
+        set(USE_GRAPH_EXECUTOR ${USE_GRAPH_RUNTIME})
+        unset(USE_GRAPH_RUNTIME CACHE)
+    endif(USE_GRAPH_RUNTIME AND NOT DEFINED USE_GRAPH_EXECUTOR)
+
+    # NOTE(areusch): USE_GRAPH_RUNTIME_DEBUG will be deleted in a future release
+    if(USE_GRAPH_RUNTIME_DEBUG AND NOT DEFINED USE_PROFILER)
+        message(WARNING "USE_GRAPH_RUNTIME_DEBUG renamed to USE_PROFILER. Please update your config.cmake")
+        set(USE_PROFILER ${USE_GRAPH_RUNTIME_DEBUG})
+        unset(USE_GRAPH_RUNTIME_DEBUG CACHE)
+    endif(USE_GRAPH_RUNTIME_DEBUG AND NOT DEFINED USE_PROFILER)
+endif ()
+
+if(USE_GRAPH_EXECUTOR)
+  message(STATUS "Build with Graph Executor support...")
+  tvm_file_glob(GLOB RUNTIME_GRAPH_EXECUTOR_SRCS runtime/graph_executor/*.cc)
+  list(APPEND RUNTIME_SRCS ${RUNTIME_GRAPH_EXECUTOR_SRCS})
+
+endif(USE_GRAPH_EXECUTOR)
+
+if (PROJECT_IS_TOP_LEVEL)
+    # convert old options for profiler
+    if(USE_GRAPH_EXECUTOR_DEBUG)
+        message(WARNING "USE_GRAPH_EXECUTOR_DEBUG renamed to USE_PROFILER. Please update your config.cmake")
+        unset(USE_GRAPH_EXECUTOR_DEBUG CACHE)
+        set(USE_PROFILER ON)
+    endif()
+    if(USE_VM_PROFILER)
+        message(WARNING "USE_VM_PROFILER renamed to USE_PROFILER. Please update your config.cmake")
+        unset(USE_VM_PROFILER CACHE)
+        set(USE_PROFILER ON)
+    endif()
+endif ()
+
+if(USE_PROFILER)
+  message(STATUS "Build with profiler...")
+
+  add_definitions(-DUSE_PROFILER=1)
+  tvm_file_glob(GLOB RUNTIME_GRAPH_EXECUTOR_DEBUG_SRCS runtime/graph_executor/debug/*.cc)
+  list(APPEND RUNTIME_SRCS ${RUNTIME_GRAPH_EXECUTOR_DEBUG_SRCS})
+  set_source_files_properties(${RUNTIME_GRAPH_EXECUTOR_SRCS}
+    PROPERTIES COMPILE_DEFINITIONS "TVM_GRAPH_EXECUTOR_DEBUG")
+
+  tvm_file_glob(GLOB RUNTIME_VM_PROFILER_SRCS runtime/vm/profiler/*.cc)
+  list(APPEND RUNTIME_SRCS ${RUNTIME_VM_PROFILER_SRCS})
+endif(USE_PROFILER)
+
+if(USE_AOT_EXECUTOR)
+  message(STATUS "Build with AOT Executor support...")
+  file(GLOB RUNTIME_AOT_EXECUTOR_SRCS runtime/aot_executor/*.cc)
+  list(APPEND RUNTIME_SRCS ${RUNTIME_AOT_EXECUTOR_SRCS})
+
+endif(USE_AOT_EXECUTOR)
+
+if(USE_PIPELINE_EXECUTOR)
+  message(STATUS "Build with Pipeline Executor support...")
+  tvm_file_glob(GLOB RUNTIME_PIPELINE_SRCS runtime/pipeline/*.cc)
+  list(APPEND RUNTIME_SRCS ${RUNTIME_PIPELINE_SRCS})
+endif(USE_PIPELINE_EXECUTOR)
+
+# Module rules
+include(../cmake/modules/VTA.cmake)
+include(../cmake/modules/StandaloneCrt.cmake)
+include(../cmake/modules/Zephyr.cmake)
+include(../cmake/modules/Arduino.cmake)
+include(../cmake/modules/CUDA.cmake)
+include(../cmake/modules/Hexagon.cmake)
+include(../cmake/modules/OpenCL.cmake)
+include(../cmake/modules/OpenMP.cmake)
+include(../cmake/modules/Vulkan.cmake)
+include(../cmake/modules/Metal.cmake)
+include(../cmake/modules/ROCM.cmake)
+include(../cmake/modules/LLVM.cmake)
+include(../cmake/modules/Micro.cmake)
+include(../cmake/modules/contrib/EthosN.cmake)
+include(../cmake/modules/contrib/CMSISNN.cmake)
+include(../cmake/modules/contrib/EthosU.cmake)
+include(../cmake/modules/contrib/BLAS.cmake)
+include(../cmake/modules/contrib/CODEGENC.cmake)
+include(../cmake/modules/contrib/DNNL.cmake)
+include(../cmake/modules/contrib/CUTLASS.cmake)
+include(../cmake/modules/contrib/ExampleTargetHooks.cmake)
+include(../cmake/modules/contrib/Random.cmake)
+include(../cmake/modules/contrib/Posit.cmake)
+include(../cmake/modules/contrib/MicroStandaloneRuntime.cmake)
+include(../cmake/modules/contrib/Sort.cmake)
+include(../cmake/modules/contrib/NNPack.cmake)
+include(../cmake/modules/contrib/HybridDump.cmake)
+include(../cmake/modules/contrib/TFLite.cmake)
+include(../cmake/modules/contrib/TF_TVMDSOOP.cmake)
+include(../cmake/modules/contrib/PT_TVMDSOOP.cmake)
+include(../cmake/modules/contrib/CoreML.cmake)
+include(../cmake/modules/contrib/BNNS.cmake)
+include(../cmake/modules/contrib/ONNX.cmake)
+include(../cmake/modules/contrib/ArmComputeLib.cmake)
+include(../cmake/modules/contrib/TensorRT.cmake)
+include(../cmake/modules/contrib/VitisAI.cmake)
+include(../cmake/modules/contrib/Verilator.cmake)
+include(../cmake/modules/Git.cmake)
+include(../cmake/modules/LibInfo.cmake)
+include(../cmake/modules/RustExt.cmake)
+
+if (PROJECT_IS_TOP_LEVEL)
+    include(CheckCXXCompilerFlag)
+    if(NOT MSVC)
+        check_cxx_compiler_flag("-std=c++14" SUPPORT_CXX14)
+        set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
+        set(CMAKE_CUDA_STANDARD 14)
+    else()
+        check_cxx_compiler_flag("/std:c++14" SUPPORT_CXX14)
+        set(CMAKE_CXX_FLAGS "/std:c++14 ${CMAKE_CXX_FLAGS}")
+        set(CMAKE_CUDA_STANDARD 14)
+    endif()
+endif ()
+
+set(LIBINFO_FILE ${CMAKE_CURRENT_LIST_DIR}/support/libinfo.cc)
+add_lib_info(${LIBINFO_FILE})
+list(REMOVE_ITEM COMPILER_SRCS ${LIBINFO_FILE})
+
+add_library(${PRJ_NAME} SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS} ${LIBINFO_FILE})

Review Comment:
   The reason why `tvm_runtime_objs` and `tvm_objs` exist is so that we do not compile files in the runtime twice. You will need to add them back in.



##########
src/CMakeLists.txt:
##########
@@ -0,0 +1,659 @@
+cmake_minimum_required(VERSION 3.2)
+
+set(PRJ_NAME "tvm")
+project(${PRJ_NAME} C CXX)

Review Comment:
   Is there a reason for using nested projects? Seems like it adds unnecessary complication.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org