Merge "Revert "Fixed Prevent issue."" into tizen_2.2
[platform/core/security/cert-svc.git] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2 PROJECT(certsvc)
3
4 INCLUDE(FindPkgConfig)
5
6 SET(SO_VERSION 1)
7 SET(VERSION "${SO_VERSION}.0.0")
8
9 # define debug output
10 SET(DEBUG_OUTPUT "-DCERT_SVC_LOG")             # for debug
11 #SET(DEBUG_OUTPUT "-DCERT_SVC_LOG_CONSOLE")     # for debug
12
13 SET(TARGET_CERT_SVC_LIB "cert-svc")
14 SET(TARGET_VCORE_LIB "cert-svc-vcore")
15 SET(TARGET_SIGN_TOOL "dpkg-pki-sig")
16
17 # compiler options
18 SET(GC_SECTIONS_FLAGS "-fdata-sections -ffunction-sections -Wl,--gc-sections")
19 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GC_SECTIONS_FLAGS}")
20 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GC_SECTIONS_FLAGS}")
21
22 SET(CMAKE_C_FLAGS_RELEASE "-fvisibility=hidden -Wall -O2")
23 SET(CMAKE_CXX_FLAGS_RELEASE "-std=c++0x -Wall -O2")
24
25 SET(CMAKE_C_FLAGS_DEBUG "-fvisibility=hidden -Wall -O0 -g")
26 SET(CMAKE_CXX_FLAGS_DEBUG "-std=c++0x -Wall -O0 -g")
27
28 SET(CMAKE_C_FLAGS_CCOV "-fvisibility=hidden -Wall -O2 --coverage")
29 SET(CMAKE_CXX_FLAGS_CCOV "-std=c++0x -Wall -O2 --coverage")
30
31 SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
32 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
33 SET(CMAKE_SKIP_RPATH "TRUE")
34
35 ################################################################################
36 # for libcert-svc.so
37 ################################################################################
38
39 PKG_CHECK_MODULES(CERT_SVC_DEPS
40     openssl
41     dlog
42     glib-2.0
43     REQUIRED
44 )
45
46 SET(CERT_SVC_SOURCES
47     ${PROJECT_SOURCE_DIR}/srcs/cert-service.c
48     ${PROJECT_SOURCE_DIR}/srcs/cert-service-util.c
49     ${PROJECT_SOURCE_DIR}/srcs/cert-service-store.c
50     ${PROJECT_SOURCE_DIR}/srcs/cert-service-process.c
51 )
52
53 IF(DEFINED DEBUG_OUTPUT)
54     SET_SOURCE_FILES_PROPERTIES(${CERT_SVC_SOURCES}
55         PROPERTIES COMPILE_FLAGS ${DEBUG_OUTPUT})
56 ENDIF(DEFINED DEBUG_OUTPUT)
57
58 INCLUDE_DIRECTORIES(
59     ${PROJECT_SOURCE_DIR}/include
60     ${CERT_SVC_DEPS_INCLUDE_DIRS}
61 )
62
63 ADD_LIBRARY(${TARGET_CERT_SVC_LIB} SHARED ${CERT_SVC_SOURCES})
64
65 SET_TARGET_PROPERTIES(${TARGET_CERT_SVC_LIB} PROPERTIES
66     SOVERSION ${SO_VERSION}
67     VERSION ${VERSION}
68 )
69
70 TARGET_LINK_LIBRARIES(${TARGET_CERT_SVC_LIB}
71     pthread
72     ${CERT_SVC_DEPS_LIBRARIES}
73 )
74
75 ################################################################################
76 # for dpkg-pki-sig
77 ################################################################################
78
79 SET(SIGN_TOOL_SOURCES
80     ${PROJECT_SOURCE_DIR}/srcs/dpkg-pki-sig.c
81     ${PROJECT_SOURCE_DIR}/srcs/cert-service-process.c
82     ${PROJECT_SOURCE_DIR}/srcs/cert-service-util.c
83 )
84
85 ADD_EXECUTABLE(${TARGET_SIGN_TOOL} ${SIGN_TOOL_SOURCES})
86
87 TARGET_LINK_LIBRARIES(${TARGET_SIGN_TOOL}
88     ${TARGET_CERT_SVC_LIB}
89     ${CERT_SVC_DEPS_LIBRARIES}
90 )
91
92 ################################################################################
93
94 CONFIGURE_FILE(cert-svc.pc.in cert-svc.pc @ONLY)
95 CONFIGURE_FILE(cert-svc-vcore.pc.in cert-svc-vcore.pc @ONLY)
96
97 INSTALL(TARGETS ${TARGET_CERT_SVC_LIB} DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
98 INSTALL(PROGRAMS ${TARGET_SIGN_TOOL} DESTINATION ${BINDIR})
99 INSTALL(FILES
100     ${CMAKE_CURRENT_BINARY_DIR}/cert-svc.pc
101     ${CMAKE_CURRENT_BINARY_DIR}/cert-svc-vcore.pc
102     DESTINATION ${LIBDIR}/pkgconfig
103 )
104 INSTALL(FILES ${PROJECT_SOURCE_DIR}/targetinfo DESTINATION /opt/share/cert-svc/)
105 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/cert-service.h DESTINATION ${INCLUDEDIR})
106
107 # Now we must create empty directory for certificates.
108 # Without this directories rpm package will fail during build.
109 INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/etc/empty
110     DESTINATION /usr/share/cert-svc/ca-certs/code-signing/native
111     FILES_MATCHING PATTERN THISPATTERNMUSTNOTMATCH
112 )
113 INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/etc/empty
114     DESTINATION /usr/share/cert-svc/ca-certs/code-signing/wac
115     FILES_MATCHING PATTERN THISPATTERNMUSTNOTMATCH
116 )
117 INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/etc/empty
118     DESTINATION /opt/share/cert-svc/certs/code-signing/wac
119     FILES_MATCHING PATTERN THISPATTERNMUSTNOTMATCH
120 )
121 INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/etc/empty
122     DESTINATION /opt/share/cert-svc/certs/code-signing/tizen
123     FILES_MATCHING PATTERN THISPATTERNMUSTNOTMATCH
124 )
125 INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/etc/empty
126     DESTINATION /opt/share/cert-svc/certs/sim/operator
127     FILES_MATCHING PATTERN THISPATTERNMUSTNOTMATCH
128 )
129 INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/etc/empty
130     DESTINATION /opt/share/cert-svc/certs/sim/thirdparty
131     FILES_MATCHING PATTERN THISPATTERNMUSTNOTMATCH
132 )
133 INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/etc/empty
134     DESTINATION /opt/share/cert-svc/certs/user
135     FILES_MATCHING PATTERN THISPATTERNMUSTNOTMATCH
136 )
137 INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/etc/empty
138     DESTINATION /opt/share/cert-svc/certs/trusteduser
139     FILES_MATCHING PATTERN THISPATTERNMUSTNOTMATCH
140 )
141 INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/etc/empty
142     DESTINATION /opt/share/cert-svc/certs/mdm/security
143     FILES_MATCHING PATTERN THISPATTERNMUSTNOTMATCH
144 )
145 INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/etc/empty
146     DESTINATION /opt/share/cert-svc/certs/mdm/security/cert
147     FILES_MATCHING PATTERN THISPATTERNMUSTNOTMATCH
148 )
149 INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/etc/empty
150     DESTINATION /opt/share/cert-svc/pkcs12
151     FILES_MATCHING PATTERN THISPATTERNMUSTNOTMATCH
152 )
153
154 ADD_SUBDIRECTORY(vcore)
155 ADD_SUBDIRECTORY(etc)