csullivan commented on code in PR #13138:
URL: https://github.com/apache/tvm/pull/13138#discussion_r999931498


##########
cmake/modules/Hexagon.cmake:
##########
@@ -182,6 +182,36 @@ if(BUILD_FOR_HEXAGON)
     "${TVMRT_SOURCE_DIR}/hexagon/ops/conv2d_fp16_hvx.cc"
     PROPERTIES COMPILE_FLAGS "-mhvx"
   )
+
+  # Include hexagon external library runtime sources
+  if(DEFINED USE_HEXAGON_EXTERNAL_LIBS)
+    if (EXISTS ${USE_HEXAGON_EXTERNAL_LIBS})
+    elseif(USE_HEXAGON_EXTERNAL_LIBS MATCHES "\.git$")
+      if (NOT DEFINED HEXAGON_EXTERNAL_LIBS_SHA)
+        message(FATAL_ERROR "HEXAGON_EXTERNA_LIBS_SHA must be set when "
+          "USE_HEXAGON_EXTERNAL_LIBS is set to a git repository")
+      endif()
+      include(FetchContent)
+      FetchContent_Declare(hexagon_external
+        GIT_REPOSITORY "${USE_HEXAGON_EXTERNAL_LIBS}"
+        GIT_TAG "${HEXAGON_EXTERNAL_LIBS_SHA}")
+      FetchContent_MakeAvailable(hexagon_external)
+      set(USE_HEXAGON_EXTERNAL_LIBS "${hexagon_external_SOURCE_DIR}")
+    else()
+      message(FATAL_ERROR "Invalid use of USE_HEXAGON_EXTERNAL_LIBS="
+        "${USE_HEXAGON_EXTERNAL_LIBS}; USE_HEXAGON_EXTERNAL_LIBS only "
+        "supports absolute paths and paths and git repository urls")
+    endif()
+
+    file_glob_append(HEXAGON_EXTERNAL_RUNTIME_SRCS
+      "${USE_HEXAGON_EXTERNAL_LIBS}/src/runtime/hexagon/*.cc"
+    )
+    list(APPEND RUNTIME_HEXAGON_SRCS "${HEXAGON_EXTERNAL_RUNTIME_SRCS}")
+    set_source_files_properties(
+      "${HEXAGON_EXTERNAL_RUNTIME_SRCS}"
+      PROPERTIES COMPILE_FLAGS "-mhvx -mhmx"

Review Comment:
   I was wondering the same also yesterday. 
   
   One option, that I personally prefer not to rely on, is to not allow 
external sources and require the external libs to fully manage their own build 
to object files which are linked in. 
   
   Another option that comes to mind would be to do a cmake include on a 
required hexagon_external.cmake in the external lib. I haven't explored the 
feasibility of this option but it could work.



-- 
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-unsubscr...@tvm.apache.org

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

Reply via email to