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


##########
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 "")
+          tsort_bool_option_dependencies_visit(${option_name})
+        endif()
+      endif()
+    endforeach()
+  endforeach()
+endmacro()
+
+macro(resolve_option_dependencies)
+  if(MSVC_TOOLCHAIN)
+    # Plasma using glog is not fully tested on windows.
+    set(ARROW_USE_GLOG OFF)
+  endif()
+
+  tsort_bool_option_dependencies()
+  foreach(option_name ${ARROW_BOOL_OPTION_DEPENDENCIES_TSORTED})
+    foreach(needed_option_name ${${option_name}_OPTION_DEPENDS})
+      if(${${option_name}})

Review Comment:
   Good catch!
   I'll do it.



-- 
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