🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.9 KiB

  1. macro(ADD_TO_ALLOPTIONS _NEWNAME)
  2. list(APPEND ALLOPTIONS ${_NEWNAME})
  3. string(LENGTH ${_NEWNAME} _SLEN)
  4. if(${LONGESTOPTIONNAME} LESS ${_SLEN})
  5. set(LONGESTOPTIONNAME ${_SLEN})
  6. endif()
  7. endmacro()
  8. macro(SET_OPTION _NAME _DESC)
  9. add_to_alloptions(${_NAME})
  10. if(${ARGC} EQUAL 3)
  11. set(_DEFLT ${ARGV2})
  12. else()
  13. set(_DEFLT OFF)
  14. endif()
  15. option(${_NAME} ${_DESC} ${_DEFLT})
  16. endmacro()
  17. macro(DEP_OPTION _NAME _DESC _DEFLT _DEPTEST _FAILDFLT)
  18. add_to_alloptions(${_NAME})
  19. cmake_dependent_option(${_NAME} ${_DESC} ${_DEFLT} ${_DEPTEST} ${_FAILDFLT})
  20. endmacro()
  21. macro(OPTION_STRING _NAME _DESC _VALUE)
  22. add_to_alloptions(${_NAME})
  23. set(${_NAME} ${_VALUE} CACHE STRING "${_DESC}")
  24. set(HAVE_${_NAME} ${_VALUE})
  25. ENDMACRO()
  26. # Message Output
  27. macro(MESSAGE_WARN _TEXT)
  28. message(STATUS "*** WARNING: ${_TEXT}")
  29. endmacro()
  30. macro(MESSAGE_ERROR _TEXT)
  31. message(FATAL_ERROR "*** ERROR: ${_TEXT}")
  32. endmacro()
  33. macro(MESSAGE_BOOL_OPTION _NAME _VALUE)
  34. if(${_VALUE})
  35. message(STATUS " ${_NAME}:\tON")
  36. else()
  37. message(STATUS " ${_NAME}:\tOFF")
  38. endif()
  39. endmacro()
  40. macro(MESSAGE_TESTED_OPTION _NAME)
  41. set(_REQVALUE ${${_NAME}})
  42. set(_PAD " ")
  43. if(${ARGC} EQUAL 2)
  44. set(_PAD ${ARGV1})
  45. endif()
  46. string(SUBSTRING "${_NAME}" 0 4 _NAMESTART)
  47. if(_NAMESTART STREQUAL "SDL_")
  48. string(SUBSTRING "${_NAME}" 4 -1 _STRIPPEDNAME)
  49. else()
  50. set(_STRIPPEDNAME "${_NAME}")
  51. endif()
  52. if(NOT HAVE_${_STRIPPEDNAME})
  53. set(HAVE_${_STRIPPEDNAME} OFF)
  54. elseif("${HAVE_${_STRIPPEDNAME}}" MATCHES "1|TRUE|YES|Y")
  55. set(HAVE_${_STRIPPEDNAME} ON)
  56. endif()
  57. message(STATUS " ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_STRIPPEDNAME}}")
  58. endmacro()
  59. macro(LISTTOSTR _LIST _OUTPUT)
  60. if(${ARGC} EQUAL 3)
  61. # prefix for each element
  62. set(_LPREFIX ${ARGV2})
  63. else()
  64. set(_LPREFIX "")
  65. endif()
  66. # Do not use string(REPLACE ";" " ") here to avoid messing up list
  67. # entries
  68. foreach(_ITEM ${${_LIST}})
  69. set(${_OUTPUT} "${_LPREFIX}${_ITEM} ${${_OUTPUT}}")
  70. endforeach()
  71. endmacro()
  72. macro(LISTTOSTRREV _LIST _OUTPUT)
  73. if(${ARGC} EQUAL 3)
  74. # prefix for each element
  75. set(_LPREFIX ${ARGV2})
  76. else()
  77. set(_LPREFIX "")
  78. endif()
  79. # Do not use string(REPLACE ";" " ") here to avoid messing up list
  80. # entries
  81. foreach(_ITEM ${${_LIST}})
  82. set(${_OUTPUT} "${${_OUTPUT}} ${_LPREFIX}${_ITEM}")
  83. endforeach()
  84. endmacro()
  85. if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
  86. macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR)
  87. set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}")
  88. set(CMAKE_REQUIRED_DEFINITIONS "-x objective-c ${PREV_REQUIRED_DEFS}")
  89. CHECK_C_SOURCE_COMPILES(${SOURCE} ${VAR})
  90. set(CMAKE_REQUIRED_DEFINITIONS "${PREV_REQUIRED_DEFS}")
  91. endmacro()
  92. else()
  93. include(CheckOBJCSourceCompiles)
  94. if (APPLE)
  95. enable_language(OBJC)
  96. endif()
  97. endif()
  98. if(CMAKE_VERSION VERSION_LESS 3.13.0)
  99. macro(target_link_directories _TARGET _SCOPE)
  100. link_directories(${ARGN})
  101. endmacro()
  102. endif()