Skip to content

Commit 61df487

Browse files
committed
Add initial version of CMake build.
1 parent d23e312 commit 61df487

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/build_linux_x86_uio/
33
/doxygen/
44
/patches/linux_uio/uio_pci_dma.ko
5-
5+
/build*/

CMakeLists.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2017 Jan de Cuveland <[email protected]>
2+
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
3+
4+
# retrieve project version information
5+
file(READ VERSION PDA_VERSION)
6+
string(STRIP "${PDA_VERSION}" PDA_VERSION)
7+
project(pda LANGUAGES C VERSION "${PDA_VERSION}")
8+
9+
# generate config.h
10+
include(CheckIncludeFiles)
11+
check_include_files(numa.h NUMA_AVAIL)
12+
check_include_files(kmod.h KMOD_AVAIL)
13+
set(MODPROBE_MODE TRUE CACHE BOOL "Enable modprobe mode")
14+
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/src)
15+
configure_file(config.h.in ${PROJECT_BINARY_DIR}/src/config.h)
16+
17+
# generate symlinks to arch sources
18+
foreach (source bar device_operator dma_buffer pci)
19+
execute_process(
20+
COMMAND ${CMAKE_COMMAND} -E create_symlink
21+
${PROJECT_SOURCE_DIR}/arch/linux_x86_uio/${source}_inc.c
22+
${PROJECT_BINARY_DIR}/src/${source}.inc)
23+
endforeach()
24+
25+
# build userspace library
26+
file(GLOB LIB_SOURCES src/*.c)
27+
add_library(pda-static STATIC ${LIB_SOURCES})
28+
add_library(pda-shared SHARED ${LIB_SOURCES})
29+
set_target_properties(pda-shared
30+
PROPERTIES POSITION_INDEPENDENT_CODE 1)
31+
set_target_properties(pda-static pda-shared
32+
PROPERTIES OUTPUT_NAME pda CLEAN_DIRECT_OUTPUT 1)
33+
foreach (lib pda-static pda-shared)
34+
target_include_directories(${lib}
35+
PUBLIC include
36+
PRIVATE src
37+
PRIVATE patches/linux_uio
38+
PRIVATE ${PROJECT_BINARY_DIR}/src
39+
)
40+
endforeach()
41+
42+
# specify files to install
43+
install(TARGETS pda-static ARCHIVE DESTINATION lib)
44+
install(TARGETS pda-shared LIBRARY DESTINATION lib)
45+
install(DIRECTORY include/ DESTINATION include)

config.h.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
3+
#define PDA_VERSION "${pda_VERSION}"
4+
#define PDA_CURRENT ${pda_VERSION_MAJOR}
5+
#define PDA_REVISION ${pda_VERSION_MINOR}
6+
#define PDA_AGE ${pda_VERSION_PATCH}
7+
8+
#cmakedefine KMOD_AVAIL
9+
#cmakedefine NUMA_AVAIL
10+
#cmakedefine MODPROBE_MODE

0 commit comments

Comments
 (0)