1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
3 IF("${VERSION}" STREQUAL "")
4 MESSAGE(FATAL_ERROR "VERSION is not defined")
6 STRING(REGEX MATCH "^[0-9]+" VERSION_MAJOR ${VERSION})
7 IF("${VERSION_MAJOR}" STREQUAL "")
8 MESSAGE(FATAL_ERROR "can't get VERSION_MAJOR")
11 INCLUDE(FindPkgConfig)
12 PKG_CHECK_MODULES(pkgs REQUIRED
13 glib-2.0 dlog capi-base-common json-glib-1.0
16 FOREACH(flag ${pkgs_CFLAGS})
17 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
19 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -flto -Wall -Werror -Winline")
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")
25 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
26 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
27 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/)
29 AUX_SOURCE_DIRECTORY(src SOURCES)
31 ADD_LIBRARY (${PROJECT_NAME} SHARED ${SOURCES})
33 SET_TARGET_PROPERTIES(bundle PROPERTIES SOVERSION ${VERSION_MAJOR})
34 SET_TARGET_PROPERTIES(bundle PROPERTIES VERSION "${VERSION}")
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})
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)
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/)
49 ADD_SUBDIRECTORY(parcel)
50 ADD_DEPENDENCIES(parcel bundle)
52 IF(NOT DEFINED MINIMUM_BUILD)
54 SET(BUNDLE_UNITTESTS bundle_unittests)
55 ADD_TEST(NAME ${BUNDLE_UNITTESTS} COMMAND ${BUNDLE_UNITTESTS}
56 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/bundle_unittests)
58 ADD_SUBDIRECTORY(tests)
59 ADD_DEPENDENCIES(bundle_unittests bundle)
61 SET(PARCEL_UNITTESTS parcel_unittests)
62 ADD_TEST(NAME ${PARCEL_UNITTESTS} COMMAND ${PARCEL_UNITTESTS}
63 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/parcel_unittests)
65 ADD_DEPENDENCIES(parcel_unittests parcel)
66 ENDIF(NOT DEFINED MINIMUM_BUILD)