cmake/macros.cmake
changeset 6674 45a21e50ba5e
child 7182 1089a8a701c3
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/cmake/macros.cmake	Fri Nov 16 09:23:18 2012 -0300
     1.3 @@ -0,0 +1,65 @@
     1.4 +macro(SET_OPTION _NAME _DESC)
     1.5 +  list(APPEND ALLOPTIONS ${_NAME})
     1.6 +  if(${ARGC} EQUAL 3)
     1.7 +    set(_DEFLT ${ARGV2})
     1.8 +  else()
     1.9 +    set(_DEFLT OFF)
    1.10 +  endif()
    1.11 +  option(${_NAME} ${_DESC} ${_DEFLT})
    1.12 +endmacro()
    1.13 +
    1.14 +macro(DEP_OPTION _NAME _DESC _DEFLT _DEPTEST _FAILDFLT)
    1.15 +  list(APPEND ALLOPTIONS ${_NAME})
    1.16 +  cmake_dependent_option(${_NAME} ${_DESC} ${_DEFLT} ${_DEPTEST} ${_FAILDFLT})
    1.17 +endmacro()
    1.18 +
    1.19 +macro(OPTION_STRING _NAME _DESC _VALUE)
    1.20 +  list(APPEND ALLOPTIONS ${_NAME})
    1.21 +  set(${_NAME} ${_VALUE} CACHE STRING "${_DESC}")
    1.22 +  set(HAVE_${_NAME} ${_VALUE})
    1.23 +ENDMACRO()
    1.24 +
    1.25 +# Message Output
    1.26 +macro(MESSAGE_WARN _TEXT)
    1.27 +  message(STATUS "*** WARNING: ${_TEXT}")
    1.28 +endmacro()
    1.29 +
    1.30 +macro(MESSAGE_ERROR _TEXT)
    1.31 +  message(FATAL_ERROR "*** ERROR: ${_TEXT}")
    1.32 +endmacro()
    1.33 +
    1.34 +macro(MESSAGE_BOOL_OPTION _NAME _VALUE)
    1.35 +  if(${_VALUE})
    1.36 +    message(STATUS "  ${_NAME}:\tON")
    1.37 +  else()
    1.38 +    message(STATUS "  ${_NAME}:\tOFF")
    1.39 +  endif()
    1.40 +endmacro()
    1.41 +
    1.42 +macro(MESSAGE_TESTED_OPTION _NAME)
    1.43 +  set(_REQVALUE ${${_NAME}})
    1.44 +  set(_PAD " ")
    1.45 +  if(${ARGC} EQUAL 2)
    1.46 +    set(_PAD ${ARGV1})
    1.47 +  endif()
    1.48 +  if(NOT HAVE_${_NAME})
    1.49 +    set(HAVE_${_NAME} OFF)
    1.50 +  elseif("${HAVE_${_NAME}}" MATCHES "1|TRUE|YES|Y")
    1.51 +    set(HAVE_${_NAME} ON)
    1.52 +  endif()
    1.53 +  message(STATUS "  ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_NAME}}")
    1.54 +endmacro()
    1.55 +
    1.56 +macro(LISTTOSTR _LIST _OUTPUT)
    1.57 +  if(${ARGC} EQUAL 3)
    1.58 +    # prefix for each element
    1.59 +    set(_LPREFIX ${ARGV2})
    1.60 +  else()
    1.61 +    set(_LPREFIX "")
    1.62 +  endif()
    1.63 +  # Do not use string(REPLACE ";" " ") here to avoid messing up list
    1.64 +  # entries
    1.65 +  foreach(_ITEM ${${_LIST}})
    1.66 +    set(${_OUTPUT} "${_LPREFIX}${_ITEM} ${${_OUTPUT}}")
    1.67 +  endforeach()
    1.68 +endmacro()