From 7e7cd21d89326cbcaa86ca26bfa5c65cbc261c4a Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Thu, 12 Oct 2023 17:20:34 -0400 Subject: [PATCH] initial cmake --- CMakeLists.txt | 28 ++++++++++++++++++++++++++++ Makefile | 27 --------------------------- 2 files changed, 28 insertions(+), 27 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..30c28f4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.0) +project(libdto) + +# Build the shared library +add_library(dto SHARED dto.c) + +# 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) + +# Install targets +install( + TARGETS dto + LIBRARY DESTINATION lib +) + +# Build dto-test and dto-test-wodto +add_executable(dto-test dto-test.c) +target_link_libraries(dto-test PRIVATE dto pthread) + +add_executable(dto-test-wodto dto-test.c) +target_link_libraries(dto-test-wodto PRIVATE pthread) + diff --git a/Makefile b/Makefile deleted file mode 100644 index b58c56a..0000000 --- a/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2023 Intel Corporation -# -# SPDX-License-Identifier: MIT - -all: libdto dto-test-wodto - -DML_LIB_CXX=-D_GNU_SOURCE - -libdto: dto.c - gcc -shared -fPIC -Wl,-soname,libdto.so dto.c $(DML_LIB_CXX) -DDTO_STATS_SUPPORT -o libdto.so.1.0 -laccel-config -ldl - -libdto_nostats: dto.c - gcc -shared -fPIC -Wl,-soname,libdto.so dto.c $(DML_LIB_CXX) -o libdto.so.1.0 -laccel-config -ldl - -install: - cp libdto.so.1.0 /usr/lib64/ - ln -sf /usr/lib64/libdto.so.1.0 /usr/lib64/libdto.so.1 - ln -sf /usr/lib64/libdto.so.1.0 /usr/lib64/libdto.so - -dto-test: dto-test.c - gcc -g dto-test.c $(DML_LIB_CXX) -o dto-test -ldto -lpthread - -dto-test-wodto: dto-test.c - gcc -g dto-test.c $(DML_LIB_CXX) -o dto-test-wodto -lpthread - -clean: - rm -rf *.o *.so dto-test