92b009ebf9c35acc9f26a3044bc05d81b1b02937
[platform/core/base/bundle.git] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
2 PROJECT(bundle C CXX)
3 IF("${VERSION}" STREQUAL "")
4        MESSAGE(FATAL_ERROR "VERSION is not defined")
5 ENDIF()
6 STRING(REGEX MATCH "^[0-9]+" VERSION_MAJOR ${VERSION})
7 IF("${VERSION_MAJOR}" STREQUAL "")
8        MESSAGE(FATAL_ERROR "can't get VERSION_MAJOR")
9 ENDIF()
10
11 INCLUDE(FindPkgConfig)
12 PKG_CHECK_MODULES(pkgs REQUIRED
13         glib-2.0 dlog capi-base-common json-glib-1.0
14 )
15
16 FOREACH(flag ${pkgs_CFLAGS})
17         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
18 ENDFOREACH(flag)
19 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -flto -Wall -Werror -Winline")
20
21 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++11")
22 SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
23 SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
24
25 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
26 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
27 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/)
28
29 AUX_SOURCE_DIRECTORY(src SOURCES)
30
31 ADD_LIBRARY (${PROJECT_NAME} SHARED ${SOURCES})
32
33 SET_TARGET_PROPERTIES(bundle PROPERTIES SOVERSION ${VERSION_MAJOR})
34 SET_TARGET_PROPERTIES(bundle PROPERTIES VERSION "${VERSION}")
35
36 SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS} -fPIE")
37 SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-pie")
38 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
39
40 ### Make pkgconfig file
41 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
42 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/bundle.pc.in ${CMAKE_BINARY_DIR}/bundle.pc @ONLY)
43
44 ### Install
45 INSTALL(TARGETS bundle DESTINATION ${LIB_INSTALL_DIR})
46 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/)
47 INSTALL(FILES ${CMAKE_BINARY_DIR}/bundle.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig/)
48
49 ADD_SUBDIRECTORY(parcel)
50 ADD_DEPENDENCIES(parcel bundle)
51
52 IF(NOT DEFINED MINIMUM_BUILD)
53 ENABLE_TESTING()
54 SET(BUNDLE_UNITTESTS bundle_unittests)
55 ADD_TEST(NAME ${BUNDLE_UNITTESTS} COMMAND ${BUNDLE_UNITTESTS}
56         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/bundle_unittests)
57
58 ADD_SUBDIRECTORY(tests)
59 ADD_DEPENDENCIES(bundle_unittests bundle)
60
61 SET(PARCEL_UNITTESTS parcel_unittests)
62 ADD_TEST(NAME ${PARCEL_UNITTESTS} COMMAND ${PARCEL_UNITTESTS}
63         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/parcel_unittests)
64
65 ADD_DEPENDENCIES(parcel_unittests parcel)
66 ENDIF(NOT DEFINED MINIMUM_BUILD)