#2271·flecs

Add support for MS-DOS build

Author: dertsehaCreated Aug 29, 2026Updated Sep 9, 2026
Labelsenhancement

Describe the problem you are trying to solve. I would like to have an officially supported build for MS-DOS targets (using DJGPP). Currently, I need to perform a little handstand with the custom build flags to get it working.

This is the current CMake file as per this commit:

FetchContent_Declare(
        flecs
        GIT_REPOSITORY https://github.com/SanderMertens/flecs.git
        # Matching v4.1.6
        GIT_TAG fb55f3c25660425cfe1bc4cf5e6bff8b3f18a9b8
        EXCLUDE_FROM_ALL
)
SET(FLECS_SHARED OFF CACHE BOOL "Disabled shared libraries" FORCE)
FetchContent_MakeAvailable(flecs)

target_compile_definitions(flecs_static
        PUBLIC
        FLECS_CUSTOM_BUILD
        FLECS_APP
        # FLECS_LOG disabled until bug about mismatching log types is fixed about mismatching function signatures
        FLECS_MODULE
        FLECS_NO_OS_API_IMPL # to force os_api_impl to not include anything, due to it getting re-enabled
        __COSMOCC__ # to force os_api.c to assume execinfo is not available
        FLECS_SYSTEM
        FLECS_STATS
        FLECS_TIMER
)
if (DOS)
    target_compile_definitions(flecs_static PUBLIC ECS_TARGET_FREEBSD) # to force os_api.h to include stdlib.h
endif ()
  1. FLECS_LOG is currently disabled due to bug #2270
  2. Despite the documentation about FLECS_CUSTOM_BUILD to disable everything by default, I had to explicitly define FLECS_NO_OS_API_IMPL as FLECS_OS_API_IMP got auto-enabled somewhere
  3. __COSMOCC__ is a hack to force HAVE_EXECINFO to be 0 - #include <execinfo.h> fails otherwise.
  4. ECS_TARGET_FREEBSD is another hack, because the default #include <alloca.h> fails in os_api.h, and trying to define ECS_TARGET_WINDOWS (which may be considered similar to MS-DOS) fails with other includes.

I did not try all the addons, I already curated the list a bit for the needs of my project. Things like threading and socket things had to be disabled outright, due to not being available on that platform.

Describe the solution you'd like

  1. Clarification on the FLECS_(NO)_OS_API_IMPL behaviour when FLECS_CUSTOM_BUILD is defined
  2. No hacks needed to get an MS-DOS build working

(Point 0 in this list is probably: Decide whether MS-DOS builds are going to be officially supported. Given the "recently" added support by SDL3 it is a fun property - also the main reason why I started doing that in my hobby project.)