2 #############################################
4 # Step 1. Set Variable and Build Dependency
7 # set a name for the entire project
10 SET(LIBNAME "lib${PROJECT_NAME}")
11 SET(LIBDIR "${PREFIX}/lib")
14 SET(FW_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../include")
15 SET(FW_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../src/framework")
16 SET(FW_COMPONETS "account;data-adapter;device;device-manager;engine-controller;event;fsapi;initialization;network-access;platform-monitor;plugin;protocol-binder;security-assistant;utility")
18 # checks for build dependency modules : a pkg-config module for CMake
19 INCLUDE(FindPkgConfig)
20 pkg_check_modules(LPKGS REQUIRED
32 #############################################
34 # Step 2. Set Compile Environment
37 # set extra cflags from build dependency
38 STRING(REPLACE ";" " " EXTRA_CFLAGS "${LPKGS_CFLAGS}")
39 #SET(EXTRA_CFLAGS "-fvisibility=hidden ${EXTRA_CFLAGS}")
41 # find all source files in a directory.
42 FOREACH(FW_COMPONENT ${FW_COMPONETS})
43 AUX_SOURCE_DIRECTORY(${FW_SRC_DIR}/${FW_COMPONENT} SRCS)
44 ENDFOREACH(FW_COMPONENT)
46 # add include directories to the build.
47 INCLUDE_DIRECTORIES(${FW_INCLUDE_DIR})
48 FOREACH(FW_COMPONENT ${FW_COMPONETS})
49 INCLUDE_DIRECTORIES(${FW_INCLUDE_DIR}/${FW_COMPONENT})
50 ENDFOREACH(FW_COMPONENT)
51 INCLUDE_DIRECTORIES(${FW_SRC_DIR})
52 FOREACH(FW_COMPONENT ${FW_COMPONETS})
53 INCLUDE_DIRECTORIES(${FW_SRC_DIR}/${FW_COMPONENT})
54 ENDFOREACH(FW_COMPONENT)
56 #############################################
58 # Step 3. Set Link Environment
61 # add a library to the project using the specified source files.
62 ADD_LIBRARY(${LIBNAME} SHARED ${SRCS})
64 # link a target to given libraries from pkg-config.
65 TARGET_LINK_LIBRARIES(${LIBNAME} ${LPKGS_LDFLAGS} "-lgcrypt")
67 # sets additional compiler flags used to build sources within the target.
68 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
70 # override the default target name prefix (such as "lib")
71 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
73 # specify the build version
74 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${VERSION})
76 # specify the api version
77 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
80 #############################################
82 # Step 4. Install packages
85 # install library files
86 INSTALL(TARGETS ${LIBNAME} DESTINATION ${LIBDIR})
89 CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
90 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
92 # install header files
93 INSTALL(FILES ${FW_INCLUDE_DIR}/sync_agent.h DESTINATION include/)
94 FOREACH(FW_COMPONENT ${FW_COMPONETS})
95 INSTALL(DIRECTORY ${FW_INCLUDE_DIR}/${FW_COMPONENT}/ DESTINATION include/sync-agent/${FW_COMPONENT} FILES_MATCHING PATTERN "*.h")
96 ENDFOREACH(FW_COMPONENT)
98 ADD_DEFINITIONS("-DGLIB_VERSION_MIN_REQUIRED=(2<<16|32<<8) ")