cmake: bump minimum required CMake version to 3.16

main features:

- No more sdl-build-options/sdl-shared-build-options/sdl-global-options
- Dependency information is stored on SDL3-collector for sdl3.pc
- Use helper functions to modify the SDL targets;
    - sdl_sources to add sources
    - sdl_glob_sources to add glob soruces
    - sdl_link_dependency to add a link dependency that might also
      appear in sdl3.pc/SDL3Config.cmake
    - sdl_compile_definitions to add macro's
    - sdl_compile_options for compile options
    - sdl_include_directories for include directories
  They avoid repeated checks for existence of the SDL targets
- A nice feature of the previous is the ability to generate
  a sdl3.pc or SDL3Config.cmake that describes its dependencies
  accurately.

various:

- remove duplicate libc symbol list
- add CheckVulkan
- remove unused HAVE_MPROTECT
- add checks for getpagesize
This commit is contained in:
Anonymous Maarten
2023-02-28 04:20:30 +01:00
committed by Anonymous Maarten
parent a3a9019265
commit 3ab4665956
17 changed files with 1836 additions and 1533 deletions

View File

@@ -1,9 +1,5 @@
macro(add_to_alloptions _NEWNAME)
list(APPEND ALLOPTIONS ${_NEWNAME})
string(LENGTH ${_NEWNAME} _SLEN)
if(${LONGESTOPTIONNAME} LESS ${_SLEN})
set(LONGESTOPTIONNAME ${_SLEN})
endif()
endmacro()
macro(set_option _NAME _DESC)
@@ -27,15 +23,6 @@ macro(option_string _NAME _DESC _VALUE)
set(HAVE_${_NAME} ${_VALUE})
ENDMACRO()
# Message Output
macro(message_warn _TEXT)
message(WARNING "${_TEXT}")
endmacro()
macro(message_error _TEXT)
message(FATAL_ERROR "*** ERROR: ${_TEXT}")
endmacro()
macro(message_bool_option _NAME _VALUE)
set(_PAD "\t")
if(${ARGC} EQUAL 3)
@@ -68,27 +55,6 @@ macro(message_tested_option _NAME)
message(STATUS " ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_STRIPPEDNAME}}")
endmacro()
function(listtostr LIST OUTPUT)
if(${ARGC} EQUAL 3)
# prefix for each element
set(LPREFIX ${ARGV2})
else()
set(LPREFIX "")
endif()
# Do not use string(REPLACE ";" " ") here to avoid messing up list entries
set(res)
foreach(ITEM ${${LIST}})
if(ITEM MATCHES "^SHELL:")
string(SUBSTRING "${ITEM}" 6 -1 ITEM)
endif()
if(ITEM)
set(res "${res} ${LPREFIX}${ITEM}")
endif()
endforeach()
string(STRIP "${res}" res)
set(${OUTPUT} "${res}" PARENT_SCOPE)
endfunction()
function(find_stringlength_longest_item inList outLength)
set(maxLength 0)
foreach(item IN LISTS ${inList})
@@ -111,22 +77,9 @@ function(message_dictlist inList)
endforeach()
endfunction()
if(CMAKE_VERSION VERSION_LESS 3.16.0 OR SDL3_SUBPROJECT)
# - CMake versions <3.16 do not support the OBJC language
# - When SDL is built as a subproject and when the main project does not enable OBJC,
# CMake fails due to missing internal CMake variables (CMAKE_OBJC_COMPILE_OBJECT)
# (reproduced with CMake 3.24.2)
macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR)
set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}")
set(CMAKE_REQUIRED_DEFINITIONS "-x objective-c ${PREV_REQUIRED_DEFS}")
CHECK_C_SOURCE_COMPILES("${SOURCE}" ${VAR})
set(CMAKE_REQUIRED_DEFINITIONS "${PREV_REQUIRED_DEFS}")
endmacro()
else()
if(APPLE)
include(CheckOBJCSourceCompiles)
if (APPLE)
enable_language(OBJC)
endif()
enable_language(OBJC)
endif()
if(CMAKE_VERSION VERSION_LESS 3.18)
@@ -156,8 +109,63 @@ if(APPLE)
endif()
endif()
if(CMAKE_VERSION VERSION_LESS 3.13.0)
macro(target_link_directories _TARGET _SCOPE)
link_directories(${ARGN})
endmacro()
endif()
function(SDL_PrintSummary)
##### Info output #####
message(STATUS "")
message(STATUS "SDL3 was configured with the following options:")
message(STATUS "")
message(STATUS "Platform: ${CMAKE_SYSTEM}")
message(STATUS "64-bit: ${ARCH_64}")
message(STATUS "Compiler: ${CMAKE_C_COMPILER}")
message(STATUS "Revision: ${SDL_REVISION}")
message(STATUS "Vendor: ${SDL_VENDOR_INFO}")
message(STATUS "")
message(STATUS "Subsystems:")
find_stringlength_longest_item(SDL_SUBSYSTEMS maxLength)
foreach(_SUB IN LISTS SDL_SUBSYSTEMS)
string(LENGTH ${_SUB} _SUBLEN)
math(EXPR _PADLEN "(${maxLength} + 1) - ${_SUBLEN}")
string(RANDOM LENGTH ${_PADLEN} ALPHABET " " _PADDING)
string(TOUPPER ${_SUB} _OPT)
message_bool_option(${_SUB} SDL_${_OPT} ${_PADDING})
endforeach()
message(STATUS "")
message(STATUS "Options:")
list(SORT ALLOPTIONS)
message_dictlist(ALLOPTIONS)
message(STATUS "")
message(STATUS " Build Shared Library: ${SDL_SHARED}")
message(STATUS " Build Static Library: ${SDL_STATIC}")
if(SDL_STATIC)
message(STATUS " Build Static Library with Position Independent Code: ${SDL_STATIC_PIC}")
endif()
if(APPLE)
message(STATUS " Build libraries as Apple Framework: ${SDL_FRAMEWORK}")
endif()
message(STATUS "")
if(UNIX)
message(STATUS "If something was not detected, although the libraries")
message(STATUS "were installed, then make sure you have set the")
message(STATUS "CMAKE_C_FLAGS and CMAKE_PREFIX_PATH CMake variables correctly.")
message(STATUS "")
endif()
if(WARN_ABOUT_ARM_SIMD_ASM_MIT)
message(STATUS "SDL is being built with ARM SIMD optimizations, which")
message(STATUS "uses code licensed under the MIT license. If this is a")
message(STATUS "problem, please disable that code by rerunning CMake with:")
message(STATUS "")
message(STATUS " -DSDL_ARMSIMD=OFF")
message(STATUS "")
endif()
if(WARN_ABOUT_ARM_NEON_ASM_MIT)
message(STATUS "SDL is being built with ARM NEON optimizations, which")
message(STATUS "uses code licensed under the MIT license. If this is a")
message(STATUS "problem, please disable that code by rerunning CMake with:")
message(STATUS "")
message(STATUS " -DSDL_ARMNEON=OFF")
message(STATUS "")
endif()
endfunction()