Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmake/yup_audio_plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ function (yup_audio_plugin)
return()
endif()

set (target_modules "${YUP_ARG_MODULES}")
list (APPEND target_modules yup_audio_plugin_client)
if (YUP_ARG_PLUGIN_CREATE_STANDALONE)
list (APPEND target_modules yup_audio_devices)
endif()
_yup_module_check_circular_dependencies ("${target_name} audio plugin" "${target_modules}")

# ==== Create static library for user's plugin code
_yup_message (STATUS "Creating static library for user's plugin code")
add_library (${target_name}_shared INTERFACE)
Expand Down
58 changes: 58 additions & 0 deletions cmake/yup_modules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,64 @@ endfunction()

#==============================================================================

function (_yup_module_normalize_dependency_target dependency output_variable)
set (normalized_dependency "${dependency}")

if (TARGET "${normalized_dependency}")
get_target_property (aliased_target "${normalized_dependency}" ALIASED_TARGET)
if (aliased_target)
set (normalized_dependency "${aliased_target}")
endif()
elseif ("${normalized_dependency}" MATCHES "^yup::(.+)$")
string (REGEX REPLACE "^yup::" "" normalized_dependency "${normalized_dependency}")
endif()

set (${output_variable} "${normalized_dependency}" PARENT_SCOPE)
endfunction()

#==============================================================================

function (_yup_module_check_dependency_cycle module_name context_name active_stack)
_yup_module_normalize_dependency_target ("${module_name}" module_target)

if (NOT TARGET "${module_target}")
return()
endif()

get_target_property (module_path "${module_target}" YUP_MODULE_PATH)
if (NOT module_path)
return()
endif()

list (FIND active_stack "${module_target}" cycle_start)
if (NOT cycle_start EQUAL -1)
list (LENGTH active_stack active_stack_length)
math (EXPR cycle_length "${active_stack_length} - ${cycle_start}")
list (SUBLIST active_stack ${cycle_start} ${cycle_length} cycle_path)
list (APPEND cycle_path "${module_target}")
list (JOIN cycle_path " -> " cycle_message)

_yup_message (FATAL_ERROR "${context_name} introduces a circular YUP module dependency: ${cycle_message}")
endif()

list (APPEND active_stack "${module_target}")

get_target_property (module_dependencies "${module_target}" YUP_MODULE_DEPENDENCIES)
foreach (module_dependency IN LISTS module_dependencies)
_yup_module_check_dependency_cycle ("${module_dependency}" "${context_name}" "${active_stack}")
endforeach()
endfunction()

#==============================================================================

function (_yup_module_check_circular_dependencies context_name module_targets)
foreach (module_target IN LISTS module_targets)
_yup_module_check_dependency_cycle ("${module_target}" "${context_name}" "")
endforeach()
endfunction()

#==============================================================================

function (_yup_module_setup_target module_name
module_path
module_cpp_standard
Expand Down
3 changes: 3 additions & 0 deletions cmake/yup_standalone.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ function (yup_standalone_app)
return()
endif()

# ==== Check for modules circular dependencies
_yup_module_check_circular_dependencies ("${target_name} standalone application" "${YUP_ARG_MODULES}")

# ==== Find modules includes
set (module_include_dirs "")
foreach (module IN ITEMS ${YUP_ARG_MODULES})
Expand Down
Loading