
I'm taking a page from Dolphin's book, and including copies of each dependency's source code. This combines the ease of use of including pre-built libraries instead of needing to navigate a package manager - as is (or was) the case for MSVC - with the portability of using packages. Granted, this method's more of a jack of all trades, master of none, since it's *less* user-friendly than prebuilt packages (compilation times), and you don't get the per-distro compatibility fixes you'd get from a package manager. You can still use system libs if you want. In fact, it's still the default behaviour: compiling the libs manually is just a fallback. I'll add an option to force-enable this soon, however, since it's a nicer way to produce static MSYS2 builds than the hackish nightmare that I was using before. Not to mention, having my own copy of the sources means I can provide my own fixes and tweaks your package manager may not. For example, I can combine MSYS2's FreeType subpixel rendering with vcpkg's fix for SDL2 exporting its symbols in static builds.
73 lines
1.8 KiB
CMake
73 lines
1.8 KiB
CMake
macro(SET_OPTION _NAME _DESC)
|
|
list(APPEND ALLOPTIONS ${_NAME})
|
|
if(${ARGC} EQUAL 3)
|
|
set(_DEFLT ${ARGV2})
|
|
else()
|
|
set(_DEFLT OFF)
|
|
endif()
|
|
option(${_NAME} ${_DESC} ${_DEFLT})
|
|
endmacro()
|
|
|
|
macro(DEP_OPTION _NAME _DESC _DEFLT _DEPTEST _FAILDFLT)
|
|
list(APPEND ALLOPTIONS ${_NAME})
|
|
cmake_dependent_option(${_NAME} ${_DESC} ${_DEFLT} ${_DEPTEST} ${_FAILDFLT})
|
|
endmacro()
|
|
|
|
macro(OPTION_STRING _NAME _DESC _VALUE)
|
|
list(APPEND ALLOPTIONS ${_NAME})
|
|
set(${_NAME} ${_VALUE} CACHE STRING "${_DESC}")
|
|
set(HAVE_${_NAME} ${_VALUE})
|
|
ENDMACRO()
|
|
|
|
# Message Output
|
|
macro(MESSAGE_WARN _TEXT)
|
|
message(STATUS "*** WARNING: ${_TEXT}")
|
|
endmacro()
|
|
|
|
macro(MESSAGE_ERROR _TEXT)
|
|
message(FATAL_ERROR "*** ERROR: ${_TEXT}")
|
|
endmacro()
|
|
|
|
macro(MESSAGE_BOOL_OPTION _NAME _VALUE)
|
|
if(${_VALUE})
|
|
message(STATUS " ${_NAME}:\tON")
|
|
else()
|
|
message(STATUS " ${_NAME}:\tOFF")
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(MESSAGE_TESTED_OPTION _NAME)
|
|
set(_REQVALUE ${${_NAME}})
|
|
set(_PAD " ")
|
|
if(${ARGC} EQUAL 2)
|
|
set(_PAD ${ARGV1})
|
|
endif()
|
|
if(NOT HAVE_${_NAME})
|
|
set(HAVE_${_NAME} OFF)
|
|
elseif("${HAVE_${_NAME}}" MATCHES "1|TRUE|YES|Y")
|
|
set(HAVE_${_NAME} ON)
|
|
endif()
|
|
message(STATUS " ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_NAME}}")
|
|
endmacro()
|
|
|
|
macro(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
|
|
foreach(_ITEM ${${_LIST}})
|
|
set(${_OUTPUT} "${_LPREFIX}${_ITEM} ${${_OUTPUT}}")
|
|
endforeach()
|
|
endmacro()
|
|
|
|
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()
|
|
|