-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
89 lines (70 loc) · 2.74 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# https://stackoverflow.com/questions/17511496/how-to-create-a-shared-library-with-cmake
cmake_minimum_required(VERSION 3.8)
project(unstickymem VERSION 0.1.0 LANGUAGES CXX C)
include(GNUInstallDirs)
include(CTest)
set(CMAKE_VERBOSE_MAKEFILE OFF)
# require pthreads
set(CMAKE_THREAD_PREFER_PTHREAD ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# require boost program options
find_package(Boost COMPONENTS program_options REQUIRED)
#######################
# unstickymem library #
################################################################################
# get list of source files
file(GLOB_RECURSE unstickymem_src relative ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp" "src/*c")
add_library(unstickymem SHARED ${unstickymem_src})
set_property(TARGET unstickymem PROPERTY POSITION_INDEPENDENT_CODE on)
target_compile_options(unstickymem PRIVATE -g -Wall -pedantic -Wshadow -Wfatal-errors)
target_compile_features(unstickymem
PRIVATE cxx_std_17
)
target_include_directories(unstickymem
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PUBLIC $<INSTALL_INTERFACE:include>
PRIVATE ${Boost_INCLUDE_DIRS}
PRIVATE src)
target_link_libraries(unstickymem
Threads::Threads
${CMAKE_DL_LIBS}
rt
-rdynamic
${Boost_LIBRARIES}
numa
likwid
)
# 'make install' to the correct locations (provided by GNUInstallDirs)
install(TARGETS unstickymem
EXPORT unstickymem_config
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# This makes the project importable from the install directory
# Put config file in per-project dir (name MUST match), can also
# just go into 'cmake'
install(EXPORT unstickymem_config DESTINATION share/unstickymem/cmake)
# uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
################################################################################
# gureya's benchmark
add_executable(bench-private test/bench-private.c)
target_link_libraries(bench-private unstickymem Threads::Threads numa)
add_executable(bench-shared test/bench-shared.c)
target_link_libraries(bench-shared unstickymem Threads::Threads numa)
# hello world example
add_executable(test_hello_world test/test_hello_world.c)
target_link_libraries(test_hello_world unstickymem)
add_test(test_hello_world test_hello_world)
# allocations test
add_executable(test_allocations test/test_allocations.c)
target_link_libraries(test_allocations unstickymem)
add_test(test_allocations test_allocations)