🛠️🐜 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.

126 lines
3.3 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(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. function(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. set(res)
  69. foreach(_ITEM ${${_LIST}})
  70. set(res "${res} ${_LPREFIX}${_ITEM}")
  71. endforeach()
  72. set(${_OUTPUT} "${res}" PARENT_SCOPE)
  73. endfunction()
  74. macro(LISTTOSTRREV _LIST _OUTPUT)
  75. if(${ARGC} EQUAL 3)
  76. # prefix for each element
  77. set(_LPREFIX ${ARGV2})
  78. else()
  79. set(_LPREFIX "")
  80. endif()
  81. # Do not use string(REPLACE ";" " ") here to avoid messing up list
  82. # entries
  83. foreach(_ITEM ${${_LIST}})
  84. set(${_OUTPUT} "${_LPREFIX}${_ITEM} ${${_OUTPUT}}")
  85. endforeach()
  86. endmacro()
  87. if(CMAKE_VERSION VERSION_LESS 3.16.0 OR SDL2_SUBPROJECT)
  88. # - CMake versions <3.16 do not support the OBJC language
  89. # - When SDL is built as a subproject and when the main project does not enable OBJC,
  90. # CMake fails due to missing internal CMake variables (CMAKE_OBJC_COMPILE_OBJECT)
  91. # (reproduced with CMake 3.24.2)
  92. macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR)
  93. set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}")
  94. set(CMAKE_REQUIRED_DEFINITIONS "-x objective-c ${PREV_REQUIRED_DEFS}")
  95. CHECK_C_SOURCE_COMPILES("${SOURCE}" ${VAR})
  96. set(CMAKE_REQUIRED_DEFINITIONS "${PREV_REQUIRED_DEFS}")
  97. endmacro()
  98. else()
  99. include(CheckOBJCSourceCompiles)
  100. if (APPLE)
  101. enable_language(OBJC)
  102. endif()
  103. endif()
  104. if(APPLE)
  105. check_language(OBJC)
  106. if(NOT CMAKE_OBJC_COMPILER)
  107. message(WARNING "Cannot find working OBJC compiler.")
  108. endif()
  109. endif()
  110. if(CMAKE_VERSION VERSION_LESS 3.13.0)
  111. macro(target_link_directories _TARGET _SCOPE)
  112. link_directories(${ARGN})
  113. endmacro()
  114. endif()