Skip to content

Commit fec9ff3

Browse files
committed
Build Mmap.hh even if memory mapping is disabled
Build flag `ZK_ENABLE_MMAP` no longer excludes relevant header and implementation files from build -> Users of ZenKit can now use Mmap.hh by themselves even if `ZK_ENABLE_MMAP` is `OFF`
1 parent c8e562c commit fec9ff3

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

CMakeLists.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,18 @@ bs_check_posix_mmap(_ZK_HAS_MMAP_POSIX)
112112
bs_check_win32_mmap(_ZK_HAS_MMAP_WIN32)
113113

114114
if (ZK_ENABLE_MMAP AND (_ZK_HAS_MMAP_POSIX OR _ZK_HAS_MMAP_WIN32))
115-
if (_ZK_HAS_MMAP_POSIX)
116-
message(STATUS "ZenKit: Building with POSIX memory mapping support")
117-
list(APPEND _ZK_SOURCES src/MmapPosix.cc)
118-
target_compile_definitions(zenkit PUBLIC _ZK_WITH_MMAP=1)
119-
elseif (_ZK_HAS_MMAP_WIN32)
120-
message(STATUS "ZenKit: Building with Windows memory mapping support")
121-
list(APPEND _ZK_SOURCES src/MmapWin32.cc)
122-
target_compile_definitions(zenkit PUBLIC _ZK_WITH_MMAP=1)
123-
endif ()
115+
message(WARNING "ZenKit: Memory mapping enabled")
116+
target_compile_definitions(zenkit PUBLIC _ZK_WITH_MMAP=1)
124117
else ()
125-
message(WARNING "ZenKit: Building WITHOUT memory mapping support")
118+
message(WARNING "ZenKit: Memory mapping DISABLED")
119+
endif ()
120+
121+
if (_ZK_HAS_MMAP_POSIX)
122+
message(STATUS "ZenKit: Building with POSIX memory mapping support")
123+
list(APPEND _ZK_SOURCES src/MmapPosix.cc)
124+
elseif (_ZK_HAS_MMAP_WIN32)
125+
message(STATUS "ZenKit: Building with Windows memory mapping support")
126+
list(APPEND _ZK_SOURCES src/MmapWin32.cc)
126127
endif ()
127128

128129
target_sources(zenkit PRIVATE ${_ZK_SOURCES} ${_ZK_HEADERS})

include/zenkit/Mmap.hh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <filesystem>
55

66
namespace zenkit {
7-
#ifdef _ZK_WITH_MMAP
87
class Mmap {
98
public:
109
explicit Mmap(std::filesystem::path const& path);
@@ -28,5 +27,4 @@ namespace zenkit {
2827

2928
void* _m_platform_handle {nullptr};
3029
};
31-
#endif
3230
} // namespace zenkit

0 commit comments

Comments
 (0)