2cb8477e6df4a1bb0cd8959811c4bb04bf4dd1fc
[platform/core/security/libcryptsvc.git] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2 PROJECT(cryptsvc C)
3
4 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
5 SET(EXEC_PREFIX "\${prefix}")
6 SET(INCLUDEDIR "\${prefix}/include")
7
8 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
9
10 SET(pc_requires " openssl dlog libcrypto capi-system-info")
11
12 INCLUDE(FindPkgConfig)
13 pkg_check_modules(pkgs REQUIRED ${pc_requires})
14
15 FOREACH(flag ${pkgs_CFLAGS})
16         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
17 ENDFOREACH(flag)
18
19 SET(source_dir "./srcs")
20 SET(include_dir "./include")
21 SET(test_dir "./test")
22
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}")
26
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
30
31 ##################################################################################################################
32 # for libcryptsvc.so
33 SET(SRCS
34         ${source_dir}/SecCryptoSvc.c
35 )
36
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 ")
40
41 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
42
43 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libcryptsvc_LDFLAGS})
44
45 IF("${ARCH}" MATCHES "arm")
46 TARGET_LINK_LIBRARIES(${PROJECT_NAME})
47 ENDIF("${ARCH}" MATCHES "arm")
48
49 SET_TARGET_PROPERTIES(
50         ${PROJECT_NAME}
51         PROPERTIES
52         VERSION ${FULLVER}
53         SOVERSION ${MAJORVER}
54 )
55 ##################################################################################################################
56
57 ##################################################################################################################
58 # for libdevice_info.so
59 SET(SRCS_DEVICE_INFO
60     ${source_dir}/device_info.c
61 )
62
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 ")
66
67 SET(LIBDEVICE_INFO_SO "device_info")
68 ADD_LIBRARY(${LIBDEVICE_INFO_SO} SHARED ${SRCS_DEVICE_INFO})
69
70 TARGET_LINK_LIBRARIES(${LIBDEVICE_INFO_SO} ${libdevice_info_LDFLAGS} cryptsvc)
71
72 IF("${ARCH}" MATCHES "arm")
73 TARGET_LINK_LIBRARIES(${LIBDEVICE_INFO_SO})
74 ENDIF("${ARCH}" MATCHES "arm")
75
76
77 SET_TARGET_PROPERTIES(
78     ${LIBDEVICE_INFO_SO}
79     PROPERTIES
80     VERSION ${FULLVER}
81     SOVERSION ${MAJORVER}
82 )
83 ##################################################################################################################
84
85
86 ##################################################################################################################
87 # for module_test
88 #SET(module_test_SOURCES
89         #${test_dir}/module_test.c
90         #${source_dir}/CryptoSvc-debug.c
91 #)
92
93 #SET(module_test_CFLAGS " -fvisibility=hidden -I. -I${CMAKE_CURRENT_SOURCE_DIR}/include ")
94 #SET(module_test_LDFALGS " -module -avoid-version ${pkgs_LDFLAGS} ")
95
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 ##################################################################################################################
100
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")
109
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)
115
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})
120
121 ADD_DEFINITIONS(-D_bool_cryptsvc)
122
123 ADD_SUBDIRECTORY(gadget)