###################################################################################### # Macros definition ###################################################################################### macro(ADD_OPTION variable description value) set(__value ${value}) set(__condition "") set(__varname "__value") foreach(arg ${ARGN}) if(arg STREQUAL "IF" OR arg STREQUAL "if") set(__varname "__condition") else() list(APPEND ${__varname} ${arg}) endif() endforeach() unset(__varname) if("${__condition}" STREQUAL "") set(__condition 2 GREATER 1) endif() if(${__condition}) if("${__value}" MATCHES ";") if(${__value}) option(${variable} "${description}" ON) else() option(${variable} "${description}" OFF) endif() elseif(DEFINED ${__value}) if(${__value}) option(${variable} "${description}" ON) else() option(${variable} "${description}" OFF) endif() else() option(${variable} "${description}" ${__value}) endif() else() unset(${variable} CACHE) endif() unset(__condition) unset(__value) endmacro() # Status report function. # Automatically align right column and selects text based on condition. # Usage: # status() # status( [ ...]) # status( THEN ELSE ) function(status text) set(status_cond) set(status_then) set(status_else) set(status_current_name "cond") foreach(arg ${ARGN}) if(arg STREQUAL "THEN") set(status_current_name "then") elseif(arg STREQUAL "ELSE") set(status_current_name "else") else() list(APPEND status_${status_current_name} ${arg}) endif() endforeach() if(DEFINED status_cond) set(status_placeholder_length 32) string(RANDOM LENGTH ${status_placeholder_length} ALPHABET " " status_placeholder) string(LENGTH "${text}" status_text_length) if(status_text_length LESS status_placeholder_length) string(SUBSTRING "${text}${status_placeholder}" 0 ${status_placeholder_length} status_text) elseif(DEFINED status_then OR DEFINED status_else) message(STATUS ${text}) set(status_text "${status_placeholder}") else() set(status_text "${text}") endif() if(DEFINED status_then OR DEFINED status_else) if(${status_cond}) string(REPLACE ";" " " status_then "${status_then}") string(REGEX REPLACE "^[ \t]+" "" status_then "${status_then}") message(STATUS "${status_text} ${status_then}") else() string(REPLACE ";" " " status_else "${status_else}") string(REGEX REPLACE "^[ \t]+" "" status_else "${status_else}") message(STATUS "${status_text} ${status_else}") endif() else() string(REPLACE ";" " " status_cond "${status_cond}") string(REGEX REPLACE "^[ \t]+" "" status_cond "${status_cond}") message(STATUS "${status_text} ${status_cond}") endif() else() message(STATUS "${text}") endif() endfunction() macro(ADD_MODULE name file ) set(__modulename "Module${name}") ADD_OPTION(MODULE_${name} "Use module ${name}" ON ) if( MODULE_${name} ) add_library( ${__modulename} ${SRC_DIR}/modules/${file} ) set(MODULES_LIBS ${MODULES_LIBS} ${__modulename}) add_definitions( -DUSE_${name} ) LIST(APPEND MODULES_LIST ${name} ) endif() unset(__modulename) endmacro() macro(ADD_LIB name ) include_directories( ${SRC_DIR}/lib/${name} ) add_library( ${name} ${SRC_DIR}/lib/${files} ) set(PLAYUVER_LIBS ${PLAYUVER_LIBS} ${name}) endmacro()