Prepare the Integration with systemd
[src/app-framework-main.git] / src / CMakeLists.txt
index 9f6a944..c38dd07 100644 (file)
@@ -1,5 +1,5 @@
 ###########################################################################
-# Copyright 2015 IoT.bzh
+# Copyright 2015, 2016, 2017 IoT.bzh
 #
 # author: José Bollo <jose.bollo@iot.bzh>
 #
@@ -41,13 +41,13 @@ set(CMAKE_C_FLAGS_CCOV         "-g -O2 --coverage")
 
 include(FindPkgConfig)
 
-pkg_check_modules(EXTRAS REQUIRED libxml-2.0 openssl xmlsec1 xmlsec1-openssl json-c libsystemd)
+pkg_check_modules(EXTRAS REQUIRED libxml-2.0 openssl xmlsec1 xmlsec1-openssl json-c)
 add_compile_options(${EXTRAS_CFLAGS})
 include_directories(${EXTRAS_INCLUDE_DIRS})
 link_libraries(${EXTRAS_LIBRARIES})
 
 pkg_check_modules(libzip libzip>=0.11)
-if(libzip_FOUND)
+if(libzip_FOUND AND USE_LIBZIP)
        add_compile_options(${libzip_CFLAGS})
        include_directories(${libzip_INCLUDE_DIRS})
        link_libraries(${libzip_LIBRARIES})
@@ -58,14 +58,25 @@ endif()
 
 ###########################################################################
 
-if(USE_SIMULATION)
-       include_directories(simulation)
-else(USE_SIMULATION)
+if(SIMULATE_SECMGR)
+       add_definitions(-DSIMULATE_SECURITY_MANAGER=1)
+else(SIMULATE_SECMGR)
        pkg_check_modules(SECMGR REQUIRED security-manager)
        add_compile_options(${SECMGR_CFLAGS})
        include_directories(${SECMGR_INCLUDE_DIRS})
        link_libraries(${SECMGR_LIBRARIES})
-endif(USE_SIMULATION)
+       add_definitions(-DSIMULATE_SECURITY_MANAGER=0)
+endif(SIMULATE_SECMGR)
+
+if(SIMULATE_SMACK)
+       add_definitions(-DSIMULATE_LIBSMACK=1)
+else(SIMULATE_SMACK)
+       pkg_check_modules(SMACK REQUIRED libsmack)
+       add_compile_options(${SMACK_CFLAGS})
+       include_directories(${SMACK_INCLUDE_DIRS})
+       link_libraries(${SMACK_LIBRARIES})
+       add_definitions(-DSIMULATE_LIBSMACK=0)
+endif(SIMULATE_SMACK)
 
 ###########################################################################
 
@@ -75,16 +86,19 @@ add_library(wgtpkg STATIC
        wgtpkg-digsig.c
        wgtpkg-files.c
        wgtpkg-install.c
+       wgtpkg-mustach.c
        wgtpkg-permissions.c
        wgtpkg-uninstall.c
+       wgtpkg-unit.c
        wgtpkg-workdir.c
        wgtpkg-xmlsec.c
        wgtpkg-zip.c
        )
 
 add_library(utils STATIC
+       mustach.c
        utils-dir.c
-       utils-jbus.c
+       utils-file.c
        utils-json.c
        verbose.c
        )
@@ -92,6 +106,8 @@ add_library(utils STATIC
 add_library(wgt STATIC
        wgt-config.c
        wgt-info.c
+       wgt-strings.c
+       wgt-json.c
        wgt.c
        )
 
@@ -99,13 +115,6 @@ add_library(secwrp STATIC
        secmgr-wrap.c
        )
 
-add_library(afm STATIC
-       afm-db.c
-       afm-launch.c
-       afm-launch-mode.c
-       afm-run.c
-       )
-
 ###########################################################################
 # packaging tools
 
@@ -126,41 +135,67 @@ target_link_libraries(wgtpkg-installer wgtpkg wgt secwrp utils)
 install(TARGETS wgtpkg-sign wgtpkg-pack wgtpkg-info wgtpkg-installer DESTINATION ${CMAKE_INSTALL_BINDIR})
 
 ###########################################################################
-# the daemons
-
-MESSAGE(STATUS "Creating daemons")
-
-add_executable(afm-user-daemon afm-user-daemon.c)
-target_link_libraries(afm-user-daemon afm secwrp wgt utils )
-install(TARGETS afm-user-daemon DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-add_executable(afm-system-daemon afm-system-daemon.c)
-target_link_libraries(afm-system-daemon wgtpkg afm secwrp wgt utils)
-install(TARGETS afm-system-daemon DESTINATION ${CMAKE_INSTALL_BINDIR})
+# the targeted
+
+pkg_check_modules(EXTRA2 libsystemd)
+if(EXTRA2_FOUND)
+       add_compile_options(${EXTRA2_CFLAGS})
+       include_directories(${EXTRA2_INCLUDE_DIRS})
+       link_libraries(${EXTRA2_LIBRARIES})
+
+       add_library(utils2 STATIC
+               utils-jbus.c
+               )
+
+       add_library(afm STATIC
+               afm-db.c
+               afm-launch.c
+               afm-launch-mode.c
+               afm-run.c
+               )
+
+       ###########################################################################
+       # the daemons
+       MESSAGE(STATUS "Creating daemons")
+
+       add_executable(afm-user-daemon afm-user-daemon.c)
+       target_link_libraries(afm-user-daemon afm secwrp wgt utils utils2)
+       install(TARGETS afm-user-daemon DESTINATION ${CMAKE_INSTALL_BINDIR})
+
+       add_executable(afm-system-daemon afm-system-daemon.c)
+       target_link_libraries(afm-system-daemon wgtpkg afm secwrp wgt utils utils2)
+       install(TARGETS afm-system-daemon DESTINATION ${CMAKE_INSTALL_BINDIR})
+
+       ###########################################################################
+       # the binding for afb
+
+       pkg_check_modules(afb afb-daemon)
+       if(afb_FOUND)
+               message(STATUS "Creation afm-main-binding for AFB-DAEMON")
+               ###############################################################
+               #pkg_get_variable(afb_binding_install_dir afb-daemon binding_install_dir)
+               execute_process(
+                       COMMAND pkg-config --variable binding_install_dir afb-daemon
+                       OUTPUT_VARIABLE afb_binding_install_dir OUTPUT_STRIP_TRAILING_WHITESPACE
+               )
+               ###############################################################
+               add_library(afm-main-binding MODULE afm-main-binding.c)
+               target_compile_options(afm-main-binding PRIVATE ${afb_CFLAGS})
+               target_include_directories(afm-main-binding PRIVATE ${afb_INCLUDE_DIRS})
+               target_link_libraries(afm-main-binding utils utils2 ${afb_LIBRARIES})
+               set_target_properties(afm-main-binding PROPERTIES
+                       PREFIX ""
+                       LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/afm-main-binding.export-map"
+               )
+               install(TARGETS afm-main-binding LIBRARY DESTINATION ${afb_binding_install_dir})
+       else()
+               message(STATUS "Not creating the binding for AFB-DAEMON")
+       endif()
+
+endif(EXTRA2_FOUND)
 
 ###########################################################################
-# the plugin for afb
-
-pkg_check_modules(afb afb-daemon)
-if(afb_FOUND)
-       message(STATUS "Creation afm-main-plugin for AFB-DAEMON")
-       ###############################################################
-       #pkg_get_variable(afb_plugin_install_dir afb-daemon plugin_install_dir)
-       execute_process(
-               COMMAND pkg-config --variable plugin_install_dir afb-daemon
-               OUTPUT_VARIABLE afb_plugin_install_dir OUTPUT_STRIP_TRAILING_WHITESPACE
-       )
-       ###############################################################
-       add_library(afm-main-plugin MODULE afm-main-plugin.c)
-       target_compile_options(afm-main-plugin PRIVATE ${afb_CFLAGS})
-       target_include_directories(afm-main-plugin PRIVATE ${afb_INCLUDE_DIRS})
-       target_link_libraries(afm-main-plugin utils ${afb_LIBRARIES})
-       set_target_properties(afm-main-plugin PROPERTIES
-               PREFIX ""
-               LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/afm-main-plugin.export-map"
-       )
-       install(TARGETS afm-main-plugin LIBRARY DESTINATION ${afb_plugin_install_dir})
-else()
-       message(STATUS "Not creating the plugin for AFB-DAEMON")
-endif()
+# the tests
+
+add_subdirectory(tests)