forked from FindHao/nvsmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
38 lines (28 loc) · 1004 Bytes
/
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
cmake_minimum_required(VERSION 3.10)
# Set project name and language
project(nvsmi)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Default build type: RelWithDebInfo" FORCE)
endif()
# Find NVML library
find_library(NVML_LIBRARY NAMES nvidia-ml)
# Find cuda toolkit
find_package(CUDA REQUIRED)
# add cuda toolkit include directories
include_directories(${CUDA_INCLUDE_DIRS})
include_directories(
${CMAKE_CURRENT_LIST_DIR}/include/
${CMAKE_CURRENT_LIST_DIR}/src/
)
add_compile_options(-fstack-usage)
# include all source files
file(GLOB_RECURSE SOURCES "src/*.cpp")
# set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++ -Wl,-Bstatic -lc -Wl,-Bdynamic -lnvidia-ml")
# Add executable target
add_executable(nvsmi ${SOURCES})
# Link with NVML library
target_link_libraries(nvsmi PRIVATE ${NVML_LIBRARY} ${CUDA_LIBRARIES} -fstack-usage)
# Set include directories
target_include_directories(nvsmi PRIVATE
${CUDA_INCLUDE_DIRS})