2 #! Extracts target names from a string containing CMake option values.
6 #! set(build_options Plugins/org.mydomain.core:ON Plugins/org.mydomain.logic:ON)
7 #! ctkFunctionExtractPluginTargets("${build_options}" ALL target_names)
8 #! message("targets: ${target_names}")
10 #! will print <code>targets: org_mydomain_core;org_mydomain_logic</code>.
12 #! \param my_opts A string containing a list of options.
13 #! \param my_filter One of ON, OFF or ALL. Checks the actual build option of the plugin.
14 #! \param var_targets A variable name containing the output.
16 function(ctkFunctionExtractPluginTargets my_opts my_filter var_targets)
18 if("${my_filter}" STREQUAL "ON" OR "${my_filter}" STREQUAL "OFF"
19 OR "${my_filter}" STREQUAL "ALL")
23 set(error_msg "${my_filter} is not one of ON, OFF or ALL")
27 message(FATAL_ERROR "${error_msg}")
31 foreach(opt ${my_opts})
32 ctkFunctionExtractOptionNameAndValue(${opt} plugin_name_with_dirs plugin_value)
33 string(REPLACE "/" ";" _tokens ${plugin_name_with_dirs})
34 list(GET _tokens -1 plugin_name)
35 string(REPLACE "." "_" plugin_target ${plugin_name})
36 if("${my_filter}" STREQUAL "ALL")
37 list(APPEND plugin_targets ${plugin_target})
38 elseif("${my_filter}" STREQUAL "ON")
39 if(${${plugin_name_with_dirs}_option_name})
40 list(APPEND plugin_targets ${plugin_target})
43 if(NOT ${${plugin_name_with_dirs}_option_name})
44 list(APPEND plugin_targets ${plugin_target})
49 set(${var_targets} ${plugin_targets} PARENT_SCOPE)