1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
4 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
5 SET(EXEC_PREFIX "\${prefix}")
6 SET(INCLUDEDIR "\${prefix}/include")
8 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
10 SET(pc_requires " openssl dlog libcrypto capi-system-info")
12 INCLUDE(FindPkgConfig)
13 pkg_check_modules(pkgs REQUIRED ${pc_requires})
15 FOREACH(flag ${pkgs_CFLAGS})
16 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
19 SET(source_dir "./srcs")
20 SET(include_dir "./include")
21 SET(test_dir "./test")
23 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
24 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
25 SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${EXTRA_CFLAGS}")
27 #ADD_DEFINITIONS("-DCTR_SUPPORT") # for using CTR mode
28 #ADD_DEFINITIONS("-DCRYPT_SVC_LOG") # for debug
29 #ADD_DEFINITIONS("-DCRYPTOSVC_TARGET") # to get DUK from Target
31 ##################################################################################################################
34 ${source_dir}/SecCryptoSvc.c
37 SET(libcryptsvc_LDFLAGS "${pkgs_LDFLAGS}")
38 SET(libcryptsvc_CFLAGS " ${CFLAGS} -fvisibility=hidden -g -fPIC -I${CMAKE_CURRENT_SOURCE_DIR}/include ")
39 SET(libcryptsvc_CPPFLAGS " -DPIC ")
41 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
43 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libcryptsvc_LDFLAGS})
45 IF("${ARCH}" MATCHES "arm")
46 TARGET_LINK_LIBRARIES(${PROJECT_NAME})
47 ENDIF("${ARCH}" MATCHES "arm")
49 SET_TARGET_PROPERTIES(
55 ##################################################################################################################
57 ##################################################################################################################
58 # for libdevice_info.so
60 ${source_dir}/device_info.c
63 SET(libdevice_info_LDFLAGS "${pkgs_LDFLAGS}")
64 SET(libdevice_info_CFLAGS " ${CFLAGS} ${CMAKE_C_FLAGS} -fvisibility=hidden -g -fPIC -I${CMAKE_CURRENT_SOURCE_DIR}/include ")
65 SET(libdevice_info_CPPFLAGS " -DPIC ")
67 SET(LIBDEVICE_INFO_SO "device_info")
68 ADD_LIBRARY(${LIBDEVICE_INFO_SO} SHARED ${SRCS_DEVICE_INFO})
70 TARGET_LINK_LIBRARIES(${LIBDEVICE_INFO_SO} ${libdevice_info_LDFLAGS} cryptsvc)
72 IF("${ARCH}" MATCHES "arm")
73 TARGET_LINK_LIBRARIES(${LIBDEVICE_INFO_SO})
74 ENDIF("${ARCH}" MATCHES "arm")
77 SET_TARGET_PROPERTIES(
83 ##################################################################################################################
86 ##################################################################################################################
88 #SET(module_test_SOURCES
89 #${test_dir}/module_test.c
90 #${source_dir}/CryptoSvc-debug.c
93 #SET(module_test_CFLAGS " -fvisibility=hidden -I. -I${CMAKE_CURRENT_SOURCE_DIR}/include ")
94 #SET(module_test_LDFALGS " -module -avoid-version ${pkgs_LDFLAGS} ")
96 #ADD_EXECUTABLE(${test_dir}/module_test ${module_test_SOURCES})
97 #TARGET_LINK_LIBRARIES(${test_dir}/module_test ${pkgs_LDFLAGS} cryptsvc)
98 #SET_TARGET_PROPERTIES(${test_dir}/module_test PROPERTIES COMPILE_FLAGS "${module_test_CFLAGS} ")
99 ##################################################################################################################
101 #FIND_PROGRAM(UNAME NAMES uname)
102 #EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
103 IF("${ARCH}" MATCHES "arm")
104 #ADD_DEFINITIONS("-DTARGET")
105 ADD_DEFINITIONS("-DCRYPTOSVC_TARGET")
106 ADD_DEFINITIONS("-DCRYPTOSVC_TZ")
107 #MESSAGE("add -DTARGET")
108 ENDIF("${ARCH}" MATCHES "arm")
110 SET(PC_NAME ${PROJECT_NAME})
111 SET(PC_DESCRIPTION ${DESCRIPTION})
112 SET(PC_LDFLAGS " -l${PROJECT_NAME} ")
113 SET(PC_REQUIRED ${pc_requires})
114 CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
116 INSTALL(FILES ${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
117 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
118 INSTALL(TARGETS ${LIBDEVICE_INFO_SO} DESTINATION ${LIB_INSTALL_DIR})
119 INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${INCLUDEDIR})
121 ADD_DEFINITIONS(-D_bool_cryptsvc)
123 ADD_SUBDIRECTORY(gadget)