-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c740f37
commit 0d0986f
Showing
17 changed files
with
182 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,67 @@ | ||
# Minimum CMake version required | ||
cmake_minimum_required(VERSION 3.15) | ||
# Minimum CMake version | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
# Project name and description | ||
# Project definition | ||
project(AllocX | ||
VERSION 1.0 | ||
DESCRIPTION "A high-performance, cross-platform memory management library designed for low-latency, high-frequency systems." | ||
LANGUAGES C CXX | ||
VERSION 1.0.0 | ||
DESCRIPTION "High-performance, cross-platform memory management library for low-latency systems" | ||
LANGUAGES C | ||
) | ||
|
||
# Set the C++ standard | ||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
# Set C standard | ||
set(CMAKE_C_STANDARD 11) | ||
set(CMAKE_C_STANDARD_REQUIRED ON) | ||
set(CMAKE_C_EXTENSIONS OFF) | ||
|
||
# Enable testing | ||
enable_testing() | ||
include(CTest) | ||
|
||
# Options | ||
option(ALLOCX_BUILD_TESTS "Build unit tests" ON) | ||
option(ALLOCX_BUILD_EXAMPLES "Build examples" ON) | ||
|
||
# Define output directories | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | ||
# Enable compile warnings | ||
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic -Werror) | ||
endif() | ||
|
||
# Include source directories | ||
add_subdirectory(src) | ||
add_subdirectory(include) | ||
# Options | ||
option(ALLOCX_BUILD_TESTS "Build tests for AllocX" ON) | ||
option(ALLOCX_ENABLE_SANITIZERS "Enable sanitizers for debugging" OFF) | ||
|
||
# Add tests if enabled | ||
if(ALLOCX_BUILD_TESTS) | ||
add_subdirectory(tests) | ||
# Sanitizers (if enabled) | ||
if(ALLOCX_ENABLE_SANITIZERS AND (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")) | ||
add_compile_options(-fsanitize=address -fsanitize=undefined) | ||
add_link_options(-fsanitize=address -fsanitize=undefined) | ||
endif() | ||
|
||
# Add examples if enabled | ||
if(ALLOCX_BUILD_EXAMPLES) | ||
add_subdirectory(examples) | ||
endif() | ||
# Define project directories | ||
set(ALLOCX_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include) | ||
set(ALLOCX_SOURCE_DIR ${PROJECT_SOURCE_DIR}/src) | ||
|
||
# Documentation target | ||
find_package(Doxygen) | ||
if(Doxygen_FOUND) | ||
add_subdirectory(docs) | ||
else() | ||
message(STATUS "Doxygen not found. Documentation will not be generated.") | ||
endif() | ||
# Create the AllocX library target | ||
add_library(allocx STATIC | ||
${ALLOCX_SOURCE_DIR}/memory_pool.c | ||
${ALLOCX_SOURCE_DIR}/memory_buffer.c | ||
) | ||
|
||
# Include directories | ||
target_include_directories(allocx | ||
PUBLIC ${ALLOCX_INCLUDE_DIR} | ||
) | ||
|
||
# Installation rules | ||
include(GNUInstallDirs) | ||
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
install(TARGETS AllocX | ||
EXPORT AllocXTargets | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
# Library properties | ||
set_target_properties(allocx PROPERTIES | ||
OUTPUT_NAME allocx | ||
POSITION_INDEPENDENT_CODE ON | ||
) | ||
|
||
# Export targets for downstream projects | ||
install(EXPORT AllocXTargets | ||
FILE AllocXConfig.cmake | ||
NAMESPACE AllocX:: | ||
DESTINATION ${CMAKE_INSTALL_DATADIR}/AllocX | ||
# Install AllocX | ||
install(TARGETS allocx | ||
ARCHIVE DESTINATION lib | ||
LIBRARY DESTINATION lib | ||
RUNTIME DESTINATION bin | ||
) | ||
install(DIRECTORY ${ALLOCX_INCLUDE_DIR}/allocx DESTINATION include) | ||
|
||
# Display configuration summary | ||
message(STATUS "Project: ${PROJECT_NAME}") | ||
message(STATUS "Version: ${PROJECT_VERSION}") | ||
message(STATUS "Description: ${PROJECT_DESCRIPTION}") | ||
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}") | ||
# Tests (if enabled) | ||
#if(ALLOCX_BUILD_TESTS) | ||
# enable_testing() | ||
# add_subdirectory(tests) | ||
#endif() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# CMakeLists.txt for the include directory of AllocX | ||
|
||
# Specify the minimum required version of CMake | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
# Define the project name and language | ||
project(AllocXHeaders LANGUAGES C) | ||
|
||
# Set the base directory for headers | ||
set(ALLOCX_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
# List all public header files | ||
set(ALLOCX_PUBLIC_HEADERS | ||
${ALLOCX_INCLUDE_DIR}/allocx.h | ||
${ALLOCX_INCLUDE_DIR}/allocx_atomic.h | ||
${ALLOCX_INCLUDE_DIR}/allocx_core_types.h | ||
${ALLOCX_INCLUDE_DIR}/allocx_errors.h | ||
${ALLOCX_INCLUDE_DIR}/memory_pool.h | ||
) | ||
|
||
# Create an interface library to hold the headers | ||
add_library(allocx_headers INTERFACE) | ||
|
||
# Specify the include directories for the interface library | ||
target_include_directories(allocx_headers INTERFACE ${ALLOCX_INCLUDE_DIR}) | ||
|
||
# Install the headers to the appropriate destination | ||
install(FILES ${ALLOCX_PUBLIC_HEADERS} DESTINATION include/allocx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
#ifndef ALLOCX_H | ||
#define ALLOCX_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "allocx_core_types.h" | ||
#include "allocx_alignment.h" | ||
#include "allocx_assertions.h" | ||
#include "allocx_atomic.h" | ||
#include "allocx_bitwise.h" | ||
#include "allocx_debug.h" | ||
#include "allocx_utilities.h" | ||
#include "memory_pool.h" | ||
#include "memory_buffer.h" | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // ALLOCX_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "allocx/memory_buffer.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "allocx/memory_pool.h" |