-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathCMakeLists.txt
executable file
·99 lines (84 loc) · 2.54 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
90
91
92
93
94
95
96
97
98
99
cmake_minimum_required(VERSION 3.5)
project(Task-Spooler C)
set(CMAKE_C_STANDARD 11)
option(TASK_SPOOLER_COMPILE_CUDA "Compile CUDA support (NVML)" ON)
# VERSIONING
execute_process(
COMMAND git rev-parse --is-inside-work-tree
OUTPUT_VARIABLE GIT_REPO OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (GIT_REPO)
execute_process (
COMMAND bash -c "echo $(git describe --dirty --always --tags) | tr - +"
OUTPUT_VARIABLE git_version
)
add_definitions(-DTS_VERSION=${git_version})
endif()
set(target ts)
set(TASK_SPOOLER_SOURCES
client.c
env.c
error.c
execute.c
info.c
jobs.c
list.c
mail.c
msg.c
msgdump.c
print.c
server.c
server_start.c
signals.c
tail.c
cjson/cJSON.c)
if(TASK_SPOOLER_COMPILE_CUDA)
set(TASK_SPOOLER_SOURCES ${TASK_SPOOLER_SOURCES} gpu.c)
endif(TASK_SPOOLER_COMPILE_CUDA)
add_executable(
${target}
main.c
${TASK_SPOOLER_SOURCES}
)
add_executable(makeman man.c)
if(TASK_SPOOLER_COMPILE_CUDA)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
find_package(CUDA REQUIRED)
# Do what the new package does
find_library(CUDA_DRIVER_LIBRARY
NAMES cuda_driver cuda
HINTS ${CUDA_TOOLKIT_ROOT_DIR}
ENV CUDA_PATH
PATH_SUFFIXES nvidia/current lib64 lib/x64 lib)
if (NOT CUDA_DRIVER_LIBRARY)
# Don't try any stub directories until we have exhausted all other search locations.
find_library(CUDA_DRIVER_LIBRARY
NAMES cuda_driver cuda
HINTS ${CUDA_TOOLKIT_ROOT_DIR}
ENV CUDA_PATH
PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs)
endif ()
mark_as_advanced(CUDA_DRIVER_LIBRARY)
##
target_link_libraries(${target} nvidia-ml)
else()
find_package(CUDAToolkit REQUIRED)
target_link_libraries(${target} CUDA::nvml)
endif()
else(TASK_SPOOLER_COMPILE_CUDA)
message("Installing a CPU version...")
add_definitions(-DCPU)
endif(TASK_SPOOLER_COMPILE_CUDA)
# Man pages
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man1)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/man1/ts.1
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/makeman
DEPENDS makeman
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man1)
add_custom_target(man ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/man1/ts.1)
# install
install(TARGETS ${target}
RUNTIME)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man1
TYPE MAN)