Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This introduces support for building optee_client (libteec, tee-supplicant and the public header files) using CMake. Signed-off-by: Joakim Bech <joakim.bech@linaro.org> Reviewed-by: Igor Opaniuk <igor.opaniuk@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
- Loading branch information
1 parent
33fa3c1
commit e0a12e2
Showing
7 changed files
with
250 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
cscope.* | ||
build | ||
out | ||
Debug | ||
*.swp | ||
CMakeCache.txt | ||
CMakeFiles | ||
cmake_install.cmake | ||
.cproject | ||
.project | ||
cscope.* | ||
Debug | ||
GPATH | ||
GRTAGS | ||
GTAGS | ||
/libs | ||
Makefile | ||
/obj | ||
out | ||
.project | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
cmake_minimum_required (VERSION 3.4) | ||
project (optee_client C) | ||
|
||
# https://cmake.org/Wiki/CMake_Useful_Variables | ||
set (CMAKE_TOOLCHAIN_FILE CMakeToolchain.txt) | ||
|
||
include(GNUInstallDirs) | ||
|
||
################################################################################ | ||
# Compiler flags: | ||
# We want to use the same flags in the entire optee_client git | ||
################################################################################ | ||
add_compile_options ( | ||
-Wall -Wbad-function-cast -Wcast-align | ||
-Werror-implicit-function-declaration -Wextra | ||
-Wfloat-equal -Wformat-nonliteral -Wformat-security | ||
-Wformat=2 -Winit-self -Wmissing-declarations | ||
-Wmissing-format-attribute -Wmissing-include-dirs | ||
-Wmissing-noreturn -Wmissing-prototypes -Wnested-externs | ||
-Wpointer-arith -Wshadow -Wstrict-prototypes | ||
-Wswitch-default -Wunsafe-loop-optimizations | ||
-Wwrite-strings -Werror -fPIC | ||
) | ||
|
||
find_program(CCACHE_FOUND ccache) | ||
if(CCACHE_FOUND) | ||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) | ||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) | ||
endif(CCACHE_FOUND) | ||
|
||
add_subdirectory (libteec) | ||
add_subdirectory (tee-supplicant) | ||
add_subdirectory (public) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
set (CMAKE_SYSTEM_NAME Linux) | ||
|
||
set (CMAKE_SYSTEM_PROCESSOR arm) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
project(libteec C) | ||
|
||
set(PROJECT_VERSION "1.0.0") | ||
|
||
################################################################################ | ||
# Packages | ||
################################################################################ | ||
find_package(Threads REQUIRED) | ||
if(NOT THREADS_FOUND) | ||
message(FATAL_ERROR "Threads not found") | ||
endif() | ||
|
||
################################################################################ | ||
# Configuration flags always included | ||
################################################################################ | ||
option (CFG_TEE_BENCHMARK "Build with benchmark support" OFF) | ||
|
||
set (CFG_TEE_CLIENT_LOG_LEVEL "1" CACHE STRING "libteec log level") | ||
set (CFG_TEE_CLIENT_LOG_FILE "/data/teec.log" CACHE STRING "Location of libteec log") | ||
|
||
################################################################################ | ||
# Source files | ||
################################################################################ | ||
set (SRC | ||
src/tee_client_api.c | ||
src/teec_trace.c | ||
) | ||
|
||
if (CFG_TEE_BENCHMARK) | ||
set (SRC ${SRC} src/teec_benchmark.c) | ||
endif() | ||
|
||
################################################################################ | ||
# Built library | ||
################################################################################ | ||
add_library (teec SHARED ${SRC}) | ||
|
||
set_target_properties (teec PROPERTIES | ||
VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_NAME} | ||
) | ||
|
||
################################################################################ | ||
# Flags always set | ||
################################################################################ | ||
target_compile_definitions (teec | ||
PRIVATE -D_GNU_SOURCE | ||
PRIVATE -DCFG_TEE_CLIENT_LOG_LEVEL=${CFG_TEE_CLIENT_LOG_LEVEL} | ||
PRIVATE -DCFG_TEE_CLIENT_LOG_FILE="${CFG_TEE_CLIENT_LOG_FILE}" | ||
PRIVATE -DBINARY_PREFIX="LT" | ||
) | ||
|
||
################################################################################ | ||
# Optional flags | ||
################################################################################ | ||
if (CFG_TEE_BENCHMARK) | ||
target_compile_definitions (teec PRIVATE -DCFG_TEE_BENCHMARK) | ||
endif() | ||
|
||
################################################################################ | ||
# Public and private header and library dependencies | ||
################################################################################ | ||
target_include_directories(teec PUBLIC include) | ||
|
||
target_link_libraries (teec | ||
PUBLIC ${CMAKE_THREAD_LIBS_INIT} # this is pthreads | ||
PRIVATE optee-client-headers) | ||
|
||
################################################################################ | ||
# Install targets | ||
################################################################################ | ||
# FIXME: This should in someway harmonize with CFG_TEE_CLIENT_LOAD_PATH | ||
# FIXME: Should we change this to /usr/local/lib? | ||
install (TARGETS teec DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
project (optee-client-headers C) | ||
|
||
################################################################################ | ||
# Built library | ||
################################################################################ | ||
add_library(${PROJECT_NAME} INTERFACE) | ||
|
||
################################################################################ | ||
# Public and private header and library dependencies | ||
################################################################################ | ||
target_include_directories(teec PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
################################################################################ | ||
# Install targets | ||
################################################################################ | ||
install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
project (tee-supplicant C) | ||
|
||
################################################################################ | ||
# Configuration flags always included | ||
################################################################################ | ||
option (CFG_TA_TEST_PATH "Enable tee-supplicant to load from test/debug path" ON) | ||
option (CFG_TA_GPROF_SUPPORT "Enabled tee-supplicant profiling support" OFF) | ||
|
||
set (CFG_TEE_SUPP_LOG_LEVEL "1" CACHE STRING "tee-supplicant log level") | ||
set (CFG_TEE_SUPP_LOG_FILE "/data/teesupp.log" CACHE STRING "Location of tee-supplicant log") | ||
# FIXME: Question is, is this really needed? Should just use defaults from # GNUInstallDirs? | ||
set (CFG_TEE_CLIENT_LOAD_PATH "/lib" CACHE STRING "Location of libteec.so") | ||
set (CFG_TEE_FS_PARENT_PATH "/data" CACHE STRING "Location of TEE filesystem (secure storage)") | ||
# FIXME: Why do we have if defined(CFG_GP_SOCKETS) && CFG_GP_SOCKETS == 1 in the c-file? | ||
set (CFG_GP_SOCKETS "1" CACHE STRING "Enable GlobalPlatform Socket API support") | ||
|
||
################################################################################ | ||
# Source files | ||
################################################################################ | ||
set (SRC | ||
src/handle.c | ||
src/hmac_sha2.c | ||
src/rpmb.c | ||
src/sha2.c | ||
src/tee_supp_fs.c | ||
src/tee_supplicant.c | ||
src/teec_ta_load.c | ||
) | ||
|
||
if (CFG_GP_SOCKETS) | ||
set (SRC ${SRC} src/tee_socket.c) | ||
endif() | ||
|
||
if (CFG_TA_GPROF_SUPPORT) | ||
set (SRC ${SRC} src/gprof.c) | ||
endif() | ||
|
||
################################################################################ | ||
# Built binary | ||
################################################################################ | ||
add_executable (${PROJECT_NAME} ${SRC}) | ||
|
||
################################################################################ | ||
# Flags always set | ||
################################################################################ | ||
target_compile_definitions (${PROJECT_NAME} | ||
PRIVATE -DCFG_TEE_SUPP_LOG_LEVEL=${CFG_TEE_SUPP_LOG_LEVEL} | ||
PRIVATE -DCFG_TEE_SUPP_LOG_FILE="${CFG_TEE_SUPP_LOG_FILE}" | ||
PRIVATE -DTEEC_LOAD_PATH="${CFG_TEE_CLIENT_LOAD_PATH}" | ||
PRIVATE -DTEE_FS_PARENT_PATH="${CFG_TEE_FS_PARENT_PATH}" | ||
PRIVATE -DBINARY_PREFIX="TSUP" | ||
) | ||
|
||
################################################################################ | ||
# Optional flags | ||
################################################################################ | ||
if (CFG_GP_SOCKETS) | ||
target_compile_definitions (${PROJECT_NAME} | ||
PRIVATE -DCFG_GP_SOCKETS=${CFG_GP_SOCKETS}) | ||
endif() | ||
|
||
if (CFG_TA_TEST_PATH) | ||
target_compile_definitions (${PROJECT_NAME} | ||
PRIVATE -DCFG_TA_TEST_PATH=${CFG_TA_TEST_PATH}) | ||
endif() | ||
|
||
if (CFG_TA_GPROF_SUPPORT) | ||
target_compile_definitions (${PROJECT_NAME} | ||
PRIVATE -DCFG_TA_GPROF_SUPPORT) | ||
endif() | ||
|
||
################################################################################ | ||
# Public and private header and library dependencies | ||
################################################################################ | ||
target_include_directories(${PROJECT_NAME} PRIVATE src) | ||
|
||
target_link_libraries (${PROJECT_NAME} | ||
PRIVATE teec | ||
PRIVATE optee-client-headers) | ||
|
||
################################################################################ | ||
# Install targets | ||
################################################################################ | ||
install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_SBINDIR}) |