-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
41 lines (33 loc) · 1.2 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
cmake_minimum_required(VERSION 3.10)
project(JobReport)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Include directories
include_directories("./include")
# Ensure GCC version is at least 9 for std::filesystem support
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if(GCC_VERSION VERSION_LESS 9)
message(FATAL_ERROR "GCC version must be at least 9 to support std::filesystem")
endif()
endif()
# add_definitions(-DJOBREPORT_DEBUG)
# Add the executable
add_executable(jobreport ./src/main.cpp)
# Find and link libraries
find_library(DCGM_LIB NAMES dcgm HINTS /usr/lib64)
if(NOT DCGM_LIB)
message(FATAL_ERROR "libdcgm not found in /usr/lib64")
endif()
# Set RPATH
set_target_properties(jobreport PROPERTIES
INSTALL_RPATH "/usr/lib64"
BUILD_WITH_INSTALL_RPATH TRUE
)
# Link standard library statically
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
endif()
target_link_libraries(jobreport ${DCGM_LIB})