kou commented on code in PR #14224:
URL: https://github.com/apache/arrow/pull/14224#discussion_r980507729


##########
cpp/cmake_modules/DefineOptions.cmake:
##########
@@ -81,6 +94,48 @@ macro(define_option_string name description default)
   endif()
 endmacro()
 
+# Topological sort by Tarjan's algorithm.
+set(ARROW_BOOL_OPTION_DEPENDENCIES_TSORTED)
+macro(tsort_bool_option_dependencies_visit option_name)
+  if("${${option_name}_TSORT_STATUS}" STREQUAL "VISITING")
+    message(FATAL_ERROR "Cycled option dependency is detected: ${option_name}")
+  elseif("${${option_name}_TSORT_STATUS}" STREQUAL "")
+    set(${option_name}_TSORT_STATUS "VISITING")
+    foreach(needed_option_name ${${option_name}_OPTION_DEPENDS})
+      tsort_bool_option_dependencies_visit(${needed_option_name})
+    endforeach()
+    set(${option_name}_TSORT_STATUS "VISITED")
+    list(INSERT ARROW_BOOL_OPTION_DEPENDENCIES_TSORTED 0 ${option_name})
+  endif()
+endmacro()
+macro(tsort_bool_option_dependencies)
+  foreach(category ${ARROW_OPTION_CATEGORIES})
+    foreach(option_name ${ARROW_${category}_OPTION_NAMES})
+      if("${${option_name}_OPTION_TYPE}" STREQUAL "bool")
+        if("${${option_name}_TSORT_STATUS}" STREQUAL "")

Review Comment:
   Ah, it may work. But I want to keep this topological sort implementation as 
simple as possible for maintainability. (I want to keep this as a 
straightforward Tarjan's algorithm implementation without any optimization.)
   
   This is not a performance critical process. We have only 90 bool options and 
this is executed only once.
   
   Can we avoid the such optimization here?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to