X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2FCMakeLists.txt;h=b7c130a79d7592139946f2a321b0fd9080ad9d2c;hb=ea587a2162338cc221ecdc7bbe56341d51a777c8;hp=807d30d1a5901f11328900ee5ff28356d0cd2385;hpb=eab449dec6b13464db5277c54ac23fc30d896353;p=src%2Fapp-framework-main.git diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 807d30d..b7c130a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ ########################################################################### -# Copyright 2015 IoT.bzh +# Copyright 2015, 2016, 2017 IoT.bzh # # author: José Bollo # @@ -16,31 +16,21 @@ # limitations under the License. ########################################################################### -include(FindPkgConfig) - -pkg_check_modules(EXTRAS REQUIRED - libzip>=0.11 - libxml-2.0 - openssl - xmlsec1 xmlsec1-openssl - json-c - dbus-1 - ) - -add_compile_options(${EXTRAS_CFLAGS}) -include_directories(${EXTRAS_INCLUDE_DIRS}) -link_libraries(${EXTRAS_LIBRARIES}) +cmake_minimum_required(VERSION 3.4.3) ########################################################################### -include_directories(simulation) +link_libraries(-Wl,--as-needed -Wl,--gc-sections) -########################################################################### - -add_compile_options(-Wall -Wno-pointer-sign) +add_compile_options(-Wall -Wextra -Wconversion) +add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care? +add_compile_options(-Werror=maybe-uninitialized) +add_compile_options(-Werror=implicit-function-declaration) +add_compile_options(-Wno-pointer-sign) # for XmlChar handling add_compile_options(-ffunction-sections -fdata-sections) +add_compile_options(-Wl,--as-needed -Wl,--gc-sections) add_compile_options(-fPIC) -add_compile_options(-Wl,--gc-sections) +#add_definitions(-DNDEBUG) set(CMAKE_C_FLAGS_PROFILING "-g -O0 -pg -Wp,-U_FORTIFY_SOURCE") set(CMAKE_C_FLAGS_DEBUG "-g -O0 -ggdb -Wp,-U_FORTIFY_SOURCE") @@ -49,59 +39,159 @@ set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage") ########################################################################### -add_library(wgtpkg +include(FindPkgConfig) + +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 AND USE_LIBZIP) + add_compile_options(${libzip_CFLAGS}) + include_directories(${libzip_INCLUDE_DIRS}) + link_libraries(${libzip_LIBRARIES}) + add_definitions(-DUSE_LIBZIP=1) +else() + add_definitions(-DUSE_LIBZIP=0) +endif() + +########################################################################### + +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}) + 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) + +########################################################################### + +add_library(wgtpkg STATIC wgtpkg-base64.c wgtpkg-certs.c 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 +add_library(utils STATIC + mustach.c utils-dir.c - utils-jbus.c + utils-file.c + utils-json.c verbose.c ) -add_library(wgt +add_library(wgt STATIC wgt-config.c wgt-info.c + wgt-strings.c + wgt-json.c wgt.c ) -add_library(secwrp +add_library(secwrp STATIC secmgr-wrap.c ) -add_library(afm - af-db.c - af-launch.c - af-run.c - ) +########################################################################### +# packaging tools + +MESSAGE(STATUS "Creating packaging tools") add_executable(wgtpkg-sign wgtpkg-sign.c) target_link_libraries(wgtpkg-sign wgtpkg utils) - add_executable(wgtpkg-pack wgtpkg-pack.c) target_link_libraries(wgtpkg-pack wgtpkg utils) - add_executable(wgtpkg-info wgtpkg-info.c) target_link_libraries(wgtpkg-info wgtpkg wgt utils) - add_executable(wgtpkg-installer wgtpkg-installer.c) target_link_libraries(wgtpkg-installer wgtpkg wgt secwrp utils) +install(TARGETS wgtpkg-sign wgtpkg-pack wgtpkg-info wgtpkg-installer DESTINATION ${CMAKE_INSTALL_BINDIR}) -add_executable(af-usrd af-usrd.c) -target_link_libraries(af-usrd afm secwrp wgt utils) +########################################################################### +# the targeted + +pkg_check_modules(SYSTEMD libsystemd>=222) +if(SYSTEMD_FOUND) + add_compile_options(${SYSTEMD_CFLAGS}) + include_directories(${SYSTEMD_INCLUDE_DIRS}) + link_libraries(${SYSTEMD_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) + ############################################################### + 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(SYSTEMD_FOUND) + +########################################################################### +# the tests -install(TARGETS wgtpkg-sign wgtpkg-pack wgtpkg-info wgtpkg-installer DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) -install(TARGETS af-usrd DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) +add_subdirectory(tests)