1cmake_policy(SET CMP0012 NEW) 2 3set(summary_willbuild "") 4set(summary_willnotbuild "") 5 6macro(summary_add name test) 7 if (${test}) 8 list(APPEND summary_willbuild ${name}) 9 else (${test}) 10 list(APPEND summary_willnotbuild "${name}") 11 endif (${test}) 12endmacro(summary_add) 13 14macro(summary_show_part variable title) 15 list(LENGTH ${variable} _len) 16 if (_len) 17 message("") 18 message(${title}) 19 foreach (_item ${${variable}}) 20 message(" ${_item}") 21 endforeach (_item) 22 endif (_len) 23endmacro(summary_show_part) 24 25macro(summary_show) 26 list(SORT summary_willbuild) 27 list(SORT summary_willnotbuild) 28 message("") 29 message("Building Clementine version: ${CLEMENTINE_VERSION_DISPLAY}") 30 summary_show_part(summary_willbuild "The following components will be built:") 31 summary_show_part(summary_willnotbuild "The following components WILL NOT be built:") 32 message("") 33endmacro(summary_show) 34 35function(optional_component name default description) 36 set(option_variable "ENABLE_${name}") 37 set(have_variable "HAVE_${name}") 38 set(${have_variable} OFF) 39 40 # Create the option 41 option(${option_variable} "${description}" ${default}) 42 43 # Was the option set? 44 if(NOT ${option_variable}) 45 set(summary_willnotbuild "${summary_willnotbuild};${description} (disabled in CMake config)" PARENT_SCOPE) 46 return() 47 endif() 48 49 # Check each of the dependencies 50 set(next_arg_is_dep_name FALSE) 51 set(testing_deps TRUE) 52 set(current_dep_name) 53 set(missing_deps) 54 55 foreach(arg ${ARGN}) 56 if(${next_arg_is_dep_name}) 57 set(current_dep_name "${arg}") 58 set(next_arg_is_dep_name FALSE) 59 elseif(arg STREQUAL "DEPENDS") 60 set(next_arg_is_dep_name TRUE) 61 set(testing_deps TRUE) 62 elseif(${testing_deps}) 63 string(REPLACE " " ";" arglist "${arg}") 64 if(${arglist}) 65 # We have to do this instead of if(NOT ${arg}) so that tests may contain 66 # "NOT" themselves. 67 else() 68 list(APPEND missing_deps "${current_dep_name}") 69 set(testing_deps FALSE) 70 endif() 71 endif() 72 endforeach() 73 74 if(missing_deps) 75 foreach(dep ${missing_deps}) 76 if(deplist_text) 77 set(deplist_text "${deplist_text}, ${dep}") 78 else() 79 set(deplist_text "${dep}") 80 endif() 81 endforeach() 82 set(text "${description} (missing ${deplist_text})") 83 84 set(summary_willnotbuild "${summary_willnotbuild};${text}" PARENT_SCOPE) 85 else() 86 set(${have_variable} ON PARENT_SCOPE) 87 set(summary_willbuild "${summary_willbuild};${description}" PARENT_SCOPE) 88 endif() 89endfunction() 90