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
67 changes: 67 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
cmake_minimum_required(VERSION 3.0)
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

[nitpick] CMake 3.0 is quite old (from 2014). Consider requiring a more recent version like 3.16 or 3.20 for better modern CMake features and practices.

Suggested change
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.16)

Copilot uses AI. Check for mistakes.
project(DTO VERSION 1.0 LANGUAGES C)

include(GNUInstallDirs)
set(CMAKE_INSTALL_LIBDIR lib)


# Build the shared library
add_library(dto SHARED dto.c)
add_library(DTO::dto ALIAS dto)
target_include_directories(dto
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

# set gnu source everywhere
add_compile_definitions(_GNU_SOURCE)

# Add the -DDTO_STATS_SUPPORT preprocessor definition
target_compile_definitions(dto PRIVATE DTO_STATS_SUPPORT)

# Link libraries
target_link_libraries(dto accel-config dl numa)

include(CheckCCompilerFlag)
check_c_compiler_flag("-mwaitpkg" HAS_WAITPKG)
if (HAS_WAITPKG)
target_compile_options(dto PRIVATE -mwaitpkg -march=native)
Comment on lines +26 to +28
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

The -march=native flag makes the binary non-portable as it optimizes for the build machine's CPU. Consider making this optional or using a more portable approach for distribution builds.

Suggested change
check_c_compiler_flag("-mwaitpkg" HAS_WAITPKG)
if (HAS_WAITPKG)
target_compile_options(dto PRIVATE -mwaitpkg -march=native)
# Option to enable -march=native (default OFF for portability)
option(DTO_USE_MARCH_NATIVE "Enable -march=native for best performance on local machine (non-portable)" OFF)
check_c_compiler_flag("-mwaitpkg" HAS_WAITPKG)
if (HAS_WAITPKG)
if (DTO_USE_MARCH_NATIVE)
target_compile_options(dto PRIVATE -mwaitpkg -march=native)
else()
target_compile_options(dto PRIVATE -mwaitpkg)
endif()

Copilot uses AI. Check for mistakes.
endif()

# Build dto-test and dto-test-wodto
add_executable(dto-test dto-test.c)
target_link_libraries(dto-test PRIVATE DTO::dto pthread)

add_executable(dto-test-wodto dto-test.c)
target_link_libraries(dto-test-wodto PRIVATE pthread)

# Install and export the library
install(TARGETS dto
EXPORT DTOTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

install(FILES dto.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

install(EXPORT DTOTargets
FILE DTOTargets.cmake
NAMESPACE DTO::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/DTO)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/DTOConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)

configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/DTOConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/DTOConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/DTO)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/DTOConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/DTOConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/DTO)

5 changes: 5 additions & 0 deletions DTOConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/DTOTargets.cmake")

check_required_components(DTO)
31 changes: 0 additions & 31 deletions Makefile

This file was deleted.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ On Fedora/CentOS/Rhel: kernel-headers, accel-config-devel, libuuid-devel, libnum
On Ubuntu/Debian: linux-libc-dev, libaccel-config-dev, uuid-dev, libnuma-dev

```bash
make libdto
mkdir build
cd build
cmake ..
make
make install
```

Expand Down
16 changes: 16 additions & 0 deletions dto.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

#ifndef DTO_H
#define DTO_H

#ifdef __cplusplus
extern "C" {
#endif

//empty until we add the API

#ifdef __cplusplus
}
#endif

#endif

Loading