@@ -10,7 +10,7 @@ option(ZK_BUILD_SHARED "ZenKit: Build a shared library." OFF)
1010option (ZK_ENABLE_ASAN "ZenKit: Enable sanitizers in debug builds." ON )
1111option (ZK_ENABLE_DEPRECATION "ZenKit: Enable deprecation warnings." ON )
1212option (ZK_ENABLE_INSTALL "ZenKit: Enable CMake install target creation." ON )
13- option (ZK_ENABLE_MMAP "ZenKit: Build ZenKit with memory-mapping support ." ON )
13+ option (ZK_ENABLE_MMAP "ZenKit: Build ZenKit with memory-mapping if supported by platform ." ON )
1414option (ZK_ENABLE_FUTURE "ZenKit: Enable breaking changes to be release in a future version" OFF )
1515
1616add_subdirectory (vendor)
@@ -118,18 +118,28 @@ bs_select_cflags(${ZK_ENABLE_ASAN} _ZK_COMPILE_FLAGS _ZK_LINK_FLAGS)
118118bs_check_posix_mmap(_ZK_HAS_MMAP_POSIX)
119119bs_check_win32_mmap(_ZK_HAS_MMAP_WIN32)
120120
121- if (ZK_ENABLE_MMAP AND (_ZK_HAS_MMAP_POSIX OR _ZK_HAS_MMAP_WIN32))
122- if (_ZK_HAS_MMAP_POSIX)
123- message (STATUS "ZenKit: Building with POSIX memory mapping support" )
124- list (APPEND _ZK_SOURCES src/MmapPosix.cc)
125- target_compile_definitions (zenkit PUBLIC _ZK_WITH_MMAP=1)
126- elseif (_ZK_HAS_MMAP_WIN32)
127- message (STATUS "ZenKit: Building with Windows memory mapping support" )
128- list (APPEND _ZK_SOURCES src/MmapWin32.cc)
121+ if (_ZK_HAS_MMAP_POSIX OR _ZK_HAS_MMAP_WIN32)
122+ target_compile_definitions (zenkit PUBLIC _ZK_MMAP_AVAILABLE=1)
123+ if (ZK_ENABLE_MMAP)
124+ message (STATUS "ZenKit: Memory mapping enabled" )
129125 target_compile_definitions (zenkit PUBLIC _ZK_WITH_MMAP=1)
126+ else ()
127+ message (STATUS "ZenKit: Memory mapping disabled" )
130128 endif ()
131129else ()
132- message (WARNING "ZenKit: Building WITHOUT memory mapping support" )
130+ if (ZK_ENABLE_MMAP)
131+ message (WARNING "ZenKit: Memory mapping enabled but not supported!" )
132+ else ()
133+ message (STATUS "ZenKit: Memory mapping not supported" )
134+ endif ()
135+ endif ()
136+
137+ if (_ZK_HAS_MMAP_POSIX)
138+ message (STATUS "ZenKit: Building with POSIX memory mapping support" )
139+ list (APPEND _ZK_SOURCES src/MmapPosix.cc)
140+ elseif (_ZK_HAS_MMAP_WIN32)
141+ message (STATUS "ZenKit: Building with Windows memory mapping support" )
142+ list (APPEND _ZK_SOURCES src/MmapWin32.cc)
133143endif ()
134144
135145target_sources (zenkit PRIVATE ${_ZK_SOURCES} ${_ZK_HEADERS} )
0 commit comments