1cmake_minimum_required (VERSION 2.8) 2project (rkcrypto C) 3 4################################################################################ 5# toolchain config 6################################################################################ 7set (CMAKE_SYSTEM_NAME Linux) 8 9if (NOT DEFINED CMAKE_C_COMPILER) 10 message(FATAL_ERROR "librkcrypto: CMAKE_C_COMPILER not define") 11endif() 12 13if (NOT DEFINED CMAKE_CXX_COMPILER) 14 message(FATAL_ERROR "librkcrypto: CMAKE_CXX_COMPILER not define") 15endif() 16 17################################################################################ 18# compile flags 19################################################################################ 20add_compile_options(-Wall -Werror) 21add_compile_options(-Wno-unused-function) 22add_compile_options(-Wno-unused-parameter) 23add_compile_options(-Wno-format-truncation) 24add_compile_options(-Wno-maybe-uninitialized) 25 26if(NOT CMAKE_BUILD_TYPE) 27 set(CMAKE_BUILD_TYPE "Release" CACHE STRING 28 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." 29 FORCE) 30endif(NOT CMAKE_BUILD_TYPE) 31 32################################################################################ 33# librkcrypto files 34################################################################################ 35set(RKCRYPTO_PUBLIC_HEADER 36 include/rkcrypto_otp_key.h 37 include/rkcrypto_common.h 38 include/rkcrypto_core.h 39 include/rkcrypto_mem.h 40) 41 42include_directories(include) 43file(GLOB SOURCES "src/*.c") 44 45################################################################################ 46# libdrm dependencies 47################################################################################ 48include_directories(third_party/libdrm/include) 49include_directories(third_party/libdrm/include/drm) 50file(GLOB SOURCES_DRM "third_party/libdrm/src/*.c") 51add_definitions(-DMAJOR_IN_SYSMACROS=1 -D_GNU_SOURCE) 52 53################################################################################ 54# libteec dependencies 55################################################################################ 56add_definitions(-DBINARY_PREFIX=\"TEEC\") 57set(TEEC_PATH third_party/optee_client/libteec) 58include_directories(${TEEC_PATH}/../public ${TEEC_PATH}/include) 59file(GLOB SOURCES_TEEC 60 ${TEEC_PATH}/src/tee_client_api.c 61 ${TEEC_PATH}/src/teec_trace.c) 62 63################################################################################ 64# build librkcrypto shared library 65################################################################################ 66set(SHARED_LIB_NAME rkcrypto) 67 68add_library(${SHARED_LIB_NAME} SHARED ${SOURCES} ${SOURCES_DRM} ${SOURCES_TEEC}) 69set_target_properties(${SHARED_LIB_NAME} PROPERTIES PUBLIC_HEADER "${RKCRYPTO_PUBLIC_HEADER}") 70 71################################################################################ 72# build librkcrypto static library 73################################################################################ 74set(STATIC_LIB_NAME ${SHARED_LIB_NAME}_static) 75add_library(${STATIC_LIB_NAME} STATIC ${SOURCES} ${SOURCES_DRM} ${SOURCES_TEEC}) 76set_target_properties(${STATIC_LIB_NAME} PROPERTIES OUTPUT_NAME ${SHARED_LIB_NAME}) 77 78################################################################################ 79# build other components 80################################################################################ 81add_subdirectory(test) 82 83################################################################################ 84# install public files 85################################################################################ 86install(TARGETS ${SHARED_LIB_NAME} 87 LIBRARY DESTINATION "lib" 88 PUBLIC_HEADER DESTINATION "include") 89install(TARGETS ${STATIC_LIB_NAME} 90 ARCHIVE DESTINATION "lib") 91