1project (tee-supplicant C) 2 3################################################################################ 4# Configuration flags always included 5################################################################################ 6option (CFG_TA_TEST_PATH "Enable tee-supplicant to load from test/debug path" OFF) 7option (RPMB_EMU "Enable tee-supplicant to emulate RPMB" ON) 8option (CFG_TA_GPROF_SUPPORT "Enable tee-supplicant support for TAs instrumented with gprof" ON) 9option (CFG_FTRACE_SUPPORT "Enable tee-supplicant support for TAs instrumented with ftrace" ON) 10option (CFG_TEE_SUPP_PLUGINS "Enable tee-supplicant plugin support" ON) 11 12set (CFG_TEE_SUPP_LOG_LEVEL "1" CACHE STRING "tee-supplicant log level") 13# FIXME: Question is, is this really needed? Should just use defaults from # GNUInstallDirs? 14set (CFG_TEE_CLIENT_LOAD_PATH "/lib" CACHE STRING "Colon-separated list of paths where to look for TAs (see also --ta-dir)") 15set (CFG_TEE_FS_PARENT_PATH "/data/tee" CACHE STRING "Location of TEE filesystem (secure storage)") 16# FIXME: Why do we have if defined(CFG_GP_SOCKETS) && CFG_GP_SOCKETS == 1 in the c-file? 17set (CFG_GP_SOCKETS "1" CACHE STRING "Enable GlobalPlatform Socket API support") 18set (CFG_TEE_PLUGIN_LOAD_PATH "/usr/lib/tee-supplicant/plugins/" CACHE STRING "tee-supplicant's plugins path") 19 20if (CFG_TEE_SUPP_PLUGINS) 21 set (CMAKE_INSTALL_RPATH "${CFG_TEE_PLUGIN_LOAD_PATH}") 22endif() 23 24################################################################################ 25# Source files 26################################################################################ 27set (SRC 28 src/handle.c 29 src/hmac_sha2.c 30 src/rpmb.c 31 src/sha2.c 32 src/tee_supp_fs.c 33 src/tee_supplicant.c 34 src/teec_ta_load.c 35) 36 37if (CFG_GP_SOCKETS) 38 set (SRC ${SRC} src/tee_socket.c) 39endif() 40 41if (CFG_TA_GPROF_SUPPORT OR CFG_FTRACE_SUPPORT) 42 set (SRC ${SRC} src/prof.c) 43endif() 44 45if (CFG_TEE_SUPP_PLUGINS) 46 set (SRC ${SRC} src/plugin.c) 47endif() 48 49################################################################################ 50# Built binary 51################################################################################ 52add_executable (${PROJECT_NAME} ${SRC}) 53 54################################################################################ 55# Flags always set 56################################################################################ 57target_compile_definitions (${PROJECT_NAME} 58 PRIVATE -DDEBUGLEVEL_${CFG_TEE_SUPP_LOG_LEVEL} 59 PRIVATE -DTEEC_LOAD_PATH="${CFG_TEE_CLIENT_LOAD_PATH}" 60 PRIVATE -DTEE_FS_PARENT_PATH="${CFG_TEE_FS_PARENT_PATH}" 61 PRIVATE -DBINARY_PREFIX="TSUP" 62) 63 64################################################################################ 65# Optional flags 66################################################################################ 67if (CFG_GP_SOCKETS) 68 target_compile_definitions (${PROJECT_NAME} 69 PRIVATE -DCFG_GP_SOCKETS=${CFG_GP_SOCKETS}) 70endif() 71 72if (CFG_TA_TEST_PATH) 73 target_compile_definitions (${PROJECT_NAME} 74 PRIVATE -DCFG_TA_TEST_PATH=${CFG_TA_TEST_PATH}) 75endif() 76 77if (RPMB_EMU) 78 target_compile_definitions (${PROJECT_NAME} 79 PRIVATE -DRPMB_EMU=1) 80endif() 81 82if (CFG_TA_GPROF_SUPPORT) 83 target_compile_definitions (${PROJECT_NAME} 84 PRIVATE -DCFG_TA_GPROF_SUPPORT) 85endif() 86 87if (CFG_FTRACE_SUPPORT) 88 target_compile_definitions (${PROJECT_NAME} 89 PRIVATE -DCFG_FTRACE_SUPPORT) 90endif() 91 92if (CFG_TEE_SUPP_PLUGINS) 93 target_compile_definitions (${PROJECT_NAME} 94 PRIVATE -DTEE_SUPP_PLUGINS 95 PRIVATE -DTEE_PLUGIN_LOAD_PATH="${CFG_TEE_PLUGIN_LOAD_PATH}" 96 ) 97endif() 98 99################################################################################ 100# Public and private header and library dependencies 101################################################################################ 102target_include_directories(${PROJECT_NAME} PRIVATE src) 103 104target_link_libraries (${PROJECT_NAME} 105 PRIVATE teec 106 PRIVATE optee-client-headers 107) 108 109if (CFG_TEE_SUPP_PLUGINS) 110 target_link_libraries (${PROJECT_NAME} 111 PRIVATE dl 112 ) 113endif() 114 115################################################################################ 116# Install targets 117################################################################################ 118install (TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}) 119