tizen beta release
[platform/core/security/cert-svc.git] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2 PROJECT(certsvc C)
3
4 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
5 SET(EXEC_PREFIX "\${prefix}")
6 SET(LIBDIR "\${prefix}/lib")
7 SET(INCLUDEDIR "\${prefix}/include")
8 SET(VERSION_MAJOR 1)
9 SET(VERSION "${VERSION_MAJOR}.0.0")
10
11 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
12
13 INCLUDE(FindPkgConfig)
14 pkg_check_modules(pkgs REQUIRED openssl dlog)
15
16 FOREACH(flag ${pkgs_CFLAGS})
17 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
18 ENDFOREACH(flag)
19
20 SET(source_dir "./srcs")
21 SET(include_dir "./include")
22
23 # About debug
24 SET(debug "-DCERT_SVC_LOG")                     # for debug
25 #SET(debug "-DCERT_SVC_LOG_CONSOLE")    # for debug
26
27 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
28 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
29
30 ###################################################################################################
31 # for libcert-svc.so
32 SET(libcert-svc_SOURCES 
33                 ${source_dir}/cert-service.c 
34                 ${source_dir}/cert-service-util.c 
35                 ${source_dir}/cert-service-store.c 
36                 ${source_dir}/cert-service-process.c )
37 SET(libcert-svc_LDFLAGS " -module -avoid-version ${pkgs_LDFALGS} ")
38 SET(libcert-svc_CFLAGS " ${CFLAGS} -fvisibility=hidden -g -fPIC -I${CMAKE_CURRENT_SOURCE_DIR}/include ${debug} ")
39 SET(libcert-svc_CPPFLAGS " -DPIC ")
40
41 ADD_LIBRARY(cert-svc SHARED ${libcert-svc_SOURCES})
42 TARGET_LINK_LIBRARIES(cert-svc ${pkgs_LDFLAGS} -L${prefix}/lib -lpthread)
43 SET_TARGET_PROPERTIES(cert-svc PROPERTIES COMPILE_FLAGS "${libcert-svc_CFLAGS} ${libcert-svc_CPPFLAGS}")
44 SET_TARGET_PROPERTIES(cert-svc PROPERTIES SOVERSION ${VERSION_MAJOR})
45 SET_TARGET_PROPERTIES(cert-svc PROPERTIES VERSION ${VERSION})
46 ###################################################################################################
47
48 ###################################################################################################
49 # for dpkg-pki-sig
50 SET(PackageSignVerify_SOURCES
51                 ${source_dir}/dpkg-pki-sig.c
52                 ${source_dir}/cert-service-util.c )
53 SET(PackageSignVerify_CFLAGS " -fvisibility=hidden -I. -I${CMAKE_CURRENT_SOURCE_DIR}/include ${debug} ")
54 SET(PackageSignVerify_LDFALGS " -module -avoid-version ${pkgs_LDFLAGS} ")
55
56 ADD_EXECUTABLE(dpkg-pki-sig ${PackageSignVerify_SOURCES})
57 TARGET_LINK_LIBRARIES(dpkg-pki-sig ${pkgs_LDFLAGS} cert-svc)
58 SET_TARGET_PROPERTIES(dpkg-pki-sig PROPERTIES COMPILE_FLAGS "${PackageSignVerify_CFLAGS} ")
59 ###################################################################################################
60
61 CONFIGURE_FILE(cert-svc.pc.in cert-svc.pc @ONLY)
62
63 INSTALL(TARGETS cert-svc DESTINATION lib COMPONENT RuntimeLibraries)
64 INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/dpkg-pki-sig DESTINATION bin)
65 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/cert-svc.pc DESTINATION lib/pkgconfig)
66 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/targetinfo DESTINATION /opt/share/cert-svc/)
67 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/cert-service.h DESTINATION include)