Fichiers
rocm-systems/tests/rdc_tests/CMakeLists.txt
T
Chris Freehill 5cc498c6aa Make rdcd run as user "rdc"
The rdc account will be created on installation if it does
not already exist. It will be a system account with no
home directory.

rdcd will be started as a systemd service, but change to
user "rdc". The rdc user will drop all priviliges except
CAP_DAC_OVERRIDE, permitted. This means the default mode
will have no special privileges, but have the ability to
gain write access (e.g., to sysfs) when needed.

rdc tests were being inadvertantly added to the
installation. This was adversely impacting the new
functionality, so it was corrected in this commit.

Also included are a few small formatting changes.

Change-Id: I9c6bb132fee28119fd3960594dfb97bd2e7b282a
2020-08-17 14:07:25 -05:00

162 lignes
4.3 KiB
CMake
Fichiers exécutables

#
# Minimum version of cmake required
#
cmake_minimum_required(VERSION 3.5.0)
# TODO We will probably also have to add a RDC_DIR to pick up the
# header and library
# Required Defines on cmake command line
#
# 1) Set location of ROCm root to pick up RDC and RDC headers and RDC lib
#
# ROCM_DIR="Root for ROCM install"
#
# 2) Set RDCTST_BLD_TYPE to either "Debug" or "Release".
# If not set, the default value is "Debug" is bound.
#
# RDCTST_BLD_TYPE=Debug or RDCTST_BLD_TYPE=Release
#
# Building rocrtst Suite
#
#
# 1) Create build folder e.g. "rdctst/build" - any name will do
# 2) Cd into build folder
# 3) Run "cmake .."
# 4) Run "make"
#
# Currently support for Windows platform is not present
#############################
# COMMON AREA
#############################
if(WIN32)
message("rdc library test suite is not supported on Windows platform")
return()
endif()
#
# Process input variables
#
# Required Defines first:
set(RDC_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../client/include)
set(RDC_LIB_DIR ${RDC_BUILD_DIR}/client)
set(RSMI_INC_DIR ${ROCM_DIR}/rocm_smi/include)
#
# Determine RDC Header files are present
# (no external source dependencies)
string(TOLOWER "${RDCTST_BLD_TYPE}" tmp)
if("${tmp}" STREQUAL release)
set(BUILD_TYPE "Release")
set(ISDEBUG 0)
else()
set(BUILD_TYPE "Debug")
set(ISDEBUG 1)
endif()
#
# Print out the build configuration being used:
#
# Build Src directory
# Build Binary directory
# Build Type: Debug Vs Release, 32 Vs 64
# Compiler Version, etc
#
message("")
message("Build Configuration:")
message("-----------BuildType: " ${BUILD_TYPE})
message("------------Compiler: " ${CMAKE_CXX_COMPILER})
message("-------------Version: " ${CMAKE_CXX_COMPILER_VERSION})
message("--------Proj Src Dir: " ${PROJECT_SOURCE_DIR})
message("--------Proj Bld Dir: " ${PROJECT_BINARY_DIR})
message("--------Proj Lib Dir: " ${PROJECT_BINARY_DIR}/lib)
message("--------Proj Exe Dir: " ${PROJECT_BINARY_DIR}/bin)
message("--------RDC Lib Dir: " ${RDC_LIB_DIR})
message("")
#
# Set the build type based on user input
#
set(CMAKE_BUILD_TYPE ${BUILD_TYPE})
#
# Flag to enable / disable verbose output.
#
set(CMAKE_VERBOSE_MAKEFILE on)
#
# Compiler pre-processor definitions.
#
# Define MACRO "DEBUG" if build type is "Debug"
if(${BUILD_TYPE} STREQUAL "Debug")
add_definitions(-DDEBUG)
endif()
add_definitions(-D__linux__)
add_definitions(-DLITTLEENDIAN_CPU=1)
#
# Linux Compiler options
#
set(CMAKE_CXX_FLAGS "-std=c++11 ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-math-errno")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmerge-all-constants")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fms-extensions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
#
# Add compiler flags to include symbol information for debug builds
#
if(ISDEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -O0")
endif()
set(RDCTST_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
set(RDCTST "rdctst")
set(RDCTST_LIBS "rdc_client")
# Set Name for Google Test Framework and build it as a
# static library to be linked with user test programs
#
set(GOOGLE_TEST_FRWK_NAME "gtest")
add_subdirectory(${RDCTST_ROOT}/gtest "${PROJECT_BINARY_DIR}/gtest")
set (RDCTST_LIBS ${RDCTST_LIBS} ${GOOGLE_TEST_FRWK_NAME})
set(RDCTST_LIBS ${RDCTST_LIBS} ${GOOGLE_TEST_FRWK_NAME})
# Other source directories
aux_source_directory(${RDCTST_ROOT}/functional functionalSources)
#
# Specify the directory containing various libraries of ROCR
# to be linked against for building ROC Perf applications
#
link_directories(${RDC_LIB_DIR})
#
# Source files for building rocrtst
#
aux_source_directory(${RDCTST_ROOT} rdctstSources)
# Build rules
add_executable(${RDCTST} ${rdctstSources} ${functionalSources})
# Header file include path
target_include_directories(${RDCTST} PRIVATE ${RDC_INC_DIR}
PRIVATE ${RSMI_INC_DIR}
PRIVATE ${RDCTST_ROOT}/..
PRIVATE ${RDCTST_ROOT}/gtest/include)
target_link_libraries(${RDCTST} ${RDCTST_LIBS} c stdc++ pthread)