82 lines
2.1 KiB
CMake
82 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(temp-monitor)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
|
|
|
# Find CUDA/NVML
|
|
find_path(NVML_INCLUDE_DIR nvml.h
|
|
PATHS /usr/include /usr/local/include /usr/local/cuda/include /opt/cuda/include
|
|
NO_DEFAULT_PATH
|
|
)
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
pkg_check_modules(GTK REQUIRED gtk4)
|
|
pkg_check_modules(CAIRO REQUIRED cairo)
|
|
find_package(X11)
|
|
|
|
# Find glib-compile-resources tool
|
|
find_program(GLIB_COMPILE_RESOURCES glib-compile-resources REQUIRED)
|
|
|
|
include_directories(${CMAKE_SOURCE_DIR}/include)
|
|
include_directories(${CMAKE_BINARY_DIR})
|
|
include_directories(${NVML_INCLUDE_DIR})
|
|
include_directories(${GTK_INCLUDE_DIRS})
|
|
include_directories(${CAIRO_INCLUDE_DIRS})
|
|
|
|
# Compile resources
|
|
add_custom_command(
|
|
OUTPUT ${CMAKE_BINARY_DIR}/resources.c
|
|
COMMAND ${GLIB_COMPILE_RESOURCES}
|
|
--generate-source
|
|
--sourcedir=${CMAKE_SOURCE_DIR}/resources
|
|
--target=${CMAKE_BINARY_DIR}/resources.c
|
|
${CMAKE_SOURCE_DIR}/resources/resources.xml
|
|
DEPENDS ${CMAKE_SOURCE_DIR}/resources/nvme-monitor.svg
|
|
${CMAKE_SOURCE_DIR}/resources/resources.xml
|
|
)
|
|
|
|
set(SOURCES
|
|
src/main.cpp
|
|
src/mainwindow.cpp
|
|
src/temp_monitor.cpp
|
|
src/cpu_monitor.cpp
|
|
src/temperature_chart.cpp
|
|
src/config_manager.cpp
|
|
src/gpu_monitor.cpp
|
|
${CMAKE_BINARY_DIR}/resources.c
|
|
)
|
|
|
|
set(HEADERS
|
|
include/mainwindow.h
|
|
include/temp_monitor.h
|
|
include/cpu_monitor.h
|
|
include/temperature_chart.h
|
|
include/config_manager.h
|
|
include/gpu_monitor.h
|
|
)
|
|
|
|
add_executable(temp-monitor ${SOURCES} ${HEADERS})
|
|
|
|
target_link_libraries(temp-monitor
|
|
${GTK_LIBRARIES}
|
|
${CAIRO_LIBRARIES}
|
|
m
|
|
nvidia-ml
|
|
)
|
|
|
|
if(X11_FOUND)
|
|
target_link_libraries(temp-monitor ${X11_LIBRARIES})
|
|
endif()
|
|
|
|
target_compile_options(temp-monitor PRIVATE ${GTK_CFLAGS_OTHER})
|
|
target_compile_options(temp-monitor PRIVATE ${CAIRO_CFLAGS_OTHER})
|
|
|
|
# Install executable
|
|
install(TARGETS temp-monitor
|
|
DESTINATION bin)
|
|
|
|
# Install desktop file for system integration
|
|
install(FILES resources/nvme-monitor.desktop
|
|
DESTINATION share/applications)
|