Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ option(ZK_BUILD_SHARED "ZenKit: Build a shared library." OFF)
option(ZK_ENABLE_ASAN "ZenKit: Enable sanitizers in debug builds." ON)
option(ZK_ENABLE_DEPRECATION "ZenKit: Enable deprecation warnings." ON)
option(ZK_ENABLE_INSTALL "ZenKit: Enable CMake install target creation." ON)
option(ZK_ENABLE_MMAP "ZenKit: Build ZenKit with memory-mapping support." ON)
option(ZK_ENABLE_MMAP "ZenKit: Build ZenKit with memory-mapping if supported by platform." ON)
option(ZK_ENABLE_FUTURE "ZenKit: Enable breaking changes to be release in a future version" OFF)

add_subdirectory(vendor)
Expand Down Expand Up @@ -118,18 +118,25 @@ bs_select_cflags(${ZK_ENABLE_ASAN} _ZK_COMPILE_FLAGS _ZK_LINK_FLAGS)
bs_check_posix_mmap(_ZK_HAS_MMAP_POSIX)
bs_check_win32_mmap(_ZK_HAS_MMAP_WIN32)

if (ZK_ENABLE_MMAP AND (_ZK_HAS_MMAP_POSIX OR _ZK_HAS_MMAP_WIN32))
if (_ZK_HAS_MMAP_POSIX)
message(STATUS "ZenKit: Building with POSIX memory mapping support")
list(APPEND _ZK_SOURCES src/MmapPosix.cc)
target_compile_definitions(zenkit PUBLIC _ZK_WITH_MMAP=1)
elseif (_ZK_HAS_MMAP_WIN32)
message(STATUS "ZenKit: Building with Windows memory mapping support")
list(APPEND _ZK_SOURCES src/MmapWin32.cc)
if (_ZK_HAS_MMAP_POSIX)
message(STATUS "ZenKit: POSIX memory mapping available")
list(APPEND _ZK_SOURCES src/MmapPosix.cc)
target_compile_definitions(zenkit PUBLIC _ZK_MMAP_AVAILABLE=1)
elseif (_ZK_HAS_MMAP_WIN32)
message(STATUS "ZenKit: Windows memory mapping available")
list(APPEND _ZK_SOURCES src/MmapWin32.cc)
target_compile_definitions(zenkit PUBLIC _ZK_MMAP_AVAILABLE=1)
endif ()

if (ZK_ENABLE_MMAP)
if (_ZK_HAS_MMAP_POSIX OR _ZK_HAS_MMAP_WIN32)
message(STATUS "ZenKit: Memory mapping enabled")
target_compile_definitions(zenkit PUBLIC _ZK_WITH_MMAP=1)
elseif (ZK_ENABLE_MMAP)
message(WARNING "ZenKit: Memory mapping enabled but not supported!")
endif ()
else ()
message(WARNING "ZenKit: Building WITHOUT memory mapping support")
message(STATUS "ZenKit: Memory mapping disabled")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could also change this back to being warning if you want

endif ()

target_sources(zenkit PRIVATE ${_ZK_SOURCES} ${_ZK_HEADERS})
Expand Down
2 changes: 1 addition & 1 deletion include/zenkit/Mmap.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <filesystem>

namespace zenkit {
#ifdef _ZK_WITH_MMAP
#ifdef _ZK_MMAP_AVAILABLE
class Mmap {
public:
explicit Mmap(std::filesystem::path const& path);
Expand Down