From f898608e65bc20c7c49ac0f87802226cdc021b6d Mon Sep 17 00:00:00 2001 From: cannedbeef Date: Mon, 23 Mar 2026 15:08:56 +1100 Subject: [PATCH 01/31] CMakeLists: - use dependent options to de-nest some configuration (requires bumping version to 3.22) - further de-nest by inverting MINIFB_USE_WAYLAND_API to make an internal MINIFB_USE_X11_API - change old "UNIX"/"APPLE"/"IOS"/"WIN32" etc to more modern CMAKE_SYSTEM_NAME STREQUAL should hopefully function no different to previous version, which i've verified for x11, but only x11 STILL A WIP, will do more later --- CMakeLists.txt | 280 +++++++++++++++++++++++++------------------------ 1 file changed, 144 insertions(+), 136 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ea0c98..477d527 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,10 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.22) project(MiniFB VERSION 0.10.0 LANGUAGES C CXX) -if (APPLE) +# remove before this is merged +message(STATUS "CMAKE_SYSTEM_NAME: " ${CMAKE_SYSTEM_NAME}) + +if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS") include(CheckLanguage) check_language(OBJC) if (CMAKE_OBJC_COMPILER) @@ -132,7 +135,7 @@ set(MINIFB_COMPILE_DEFINITIONS) set(MINIFB_LINK_OPTIONS_LIB) set(MINIFB_LINK_OPTIONS_EXE) -if (DJGPP) +if (CMAKE_SYSTEM_NAME STREQUAL "DOS") # DJGPP headers expose key DOS APIs only in GNU (non-strict ANSI) mode. set(MINIFB_C_EXTENSIONS ON) set(MINIFB_CXX_EXTENSIONS ON) @@ -146,24 +149,41 @@ endif() option(MINIFB_BUILD_EXAMPLES "Build minifb example programs" TRUE) option(MINIFB_AVOID_CPP_HEADERS "Avoid including C++ Headers" FALSE) -if (NOT IOS AND NOT ANDROID AND NOT EMSCRIPTEN) - option(MINIFB_BUILD_VERSION_INFO "Build version info utility" ON) +include(CMakeDependentOption) # Requires 3.22 to use full condition syntax + +# cmake_dependent_option is used to create a default value for options in case their specific condition isn't met. +# the first 3 args are the same as a normal option(), but the 4th is a condition, where if it's true, expose the option, and if it isn't, the 5th argument is a default value to use. +# setting the default value lets us de-nest `if() if(