-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+PROJECT(esd)
-PROJECT(esd C)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-zdefs")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
-SET(VERSION 0.0.1)
-SET(VERSION_MAJOR 0)
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_C_FLAGS} -std=c++17")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "\${prefix}")
-SET(LIBDIR "\${prefix}/lib")
-SET(INCLUDEDIR "\${prefix}/include")
-
-set(CMAKE_SKIP_BUILD_RPATH true)
-
-### Local include directories
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src)
-
-### Required packages
-INCLUDE(FindPkgConfig)
-
-pkg_check_modules(pkgs REQUIRED dlog bundle pkgmgr-info glib-2.0 gio-2.0 appsvc aul ecore vconf libtzplatform-config libsystemd-daemon cynara-client cynara-creds-gdbus cynara-session security-manager)
-
-FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
-#FIND_LIBRARY(LIB_DL dl)
+## Target esd
+SET(TARGET_ESD "esd")
+SET(TARGET_LIB_ESD "libesd")
-## Additional flag
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -Wall -Werror")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+## Target modules
+SET(TARGET_ESD_MOD_CION "esd-mod-cion")
+SET(TARGET_ESD_MOD_DBUS_EVENT "esd-mod-dbus-event")
-## Linker flags
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+#ENABLE_TESTING()
+#SET(TARGET_ESD_UNIT_TESTS "esd-unit-tests")
-##build eventsystem daemon
-add_executable(esd
- src/esd_main.c
- src/esd_system_event.c
-)
-TARGET_LINK_LIBRARIES(esd eventsystem pkgmgr-client ${pkgs_LDFLAGS})
-SET_TARGET_PROPERTIES(esd PROPERTIES COMPILE_FLAGS ${CFLAGS} "-fPIE")
-SET_TARGET_PROPERTIES(esd PROPERTIES LINK_FLAGS "-pie")
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
-# pkgconfig file
-configure_file(esd.manifest.in esd.manifest @ONLY)
-
-INSTALL(TARGETS esd DESTINATION bin)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/eventsystem.conf DESTINATION /etc/dbus-1/system.d)
+INCLUDE(FindPkgConfig)
+INCLUDE(ApplyPkgConfig)
+
+PKG_CHECK_MODULES(AUL_DEPS REQUIRED aul)
+PKG_CHECK_MODULES(BUNDLE_DEPS REQUIRED bundle)
+PKG_CHECK_MODULES(CAPI_SYSTEM_INFO_DEPS REQUIRED capi-system-info)
+PKG_CHECK_MODULES(CERT_SVC_VCORE_DEPS REQUIRED cert-svc-vcore)
+PKG_CHECK_MODULES(CYNARA_CLIENT_DEPS REQUIRED cynara-client)
+PKG_CHECK_MODULES(CYNARA_CREDS_DBUS_DEPS REQUIRED cynara-creds-gdbus)
+PKG_CHECK_MODULES(CYNARA_SESSION_DEPS REQUIRED cynara-session)
+PKG_CHECK_MODULES(DLOG_DEPS REQUIRED dlog)
+PKG_CHECK_MODULES(GIO_DEPS REQUIRED gio-2.0)
+PKG_CHECK_MODULES(GLIB_DEPS REQUIRED glib-2.0)
+PKG_CHECK_MODULES(LIBTZPLATFORM_CONFIG_DEPS REQUIRED libtzplatform-config)
+PKG_CHECK_MODULES(PARCEL_DEPS REQUIRED parcel)
+PKG_CHECK_MODULES(PKGMGR_INFO_DEPS REQUIRED pkgmgr-info)
+PKG_CHECK_MODULES(SECURITY_MANAGER_DEPS REQUIRED security-manager)
+PKG_CHECK_MODULES(SQLITE3_DEPS REQUIRED sqlite3)
+PKG_CHECK_MODULES(CION_DEPS REQUIRED cion)
+PKG_CHECK_MODULES(UUID_DEPS REQUIRED uuid)
+PKG_CHECK_MODULES(VCONF_DEPS REQUIRED vconf)
+PKG_CHECK_MODULES(PKGMGR_DEPS REQUIRED pkgmgr)
+PKG_CHECK_MODULES(EVENTSYSTEM_DEPS REQUIRED eventsystem)
+
+ADD_SUBDIRECTORY(src)