Add CMake build files (required by Yocto build process)
authorManuel Bachmann <manuel.bachmann@iot.bzh>
Thu, 10 Dec 2015 08:36:34 +0000 (09:36 +0100)
committerManuel Bachmann <manuel.bachmann@iot.bzh>
Thu, 10 Dec 2015 09:06:04 +0000 (10:06 +0100)
We now can use CMake by doing :
$ mkdir build
$ cd build
$ cmake ..
$ make
$ make install

Signed-off-by: Manuel Bachmann <manuel.bachmann@iot.bzh>
CMakeLists.txt [new file with mode: 0644]
include/local-def.h
src/CMakeLists.txt [new file with mode: 0644]
src/rest-api.c

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d780588
--- /dev/null
@@ -0,0 +1,42 @@
+PROJECT(afb-daemon C)
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+SET(CMAKE_BUILD_TYPE, Debug)
+SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+SET(PROJECT_NAME "AFB Daemon")
+SET(PROJECT_PRETTY_NAME "Application Framework Binder Daemon")
+SET(PROJECT_VERSION "0.1")
+
+INCLUDE(FindPkgConfig)
+INCLUDE(CheckIncludeFiles)
+INCLUDE(CheckLibraryExists)
+
+CHECK_INCLUDE_FILES(magic.h HAVE_MAGIC_H)
+CHECK_LIBRARY_EXISTS(magic magic_load "" HAVE_LIBMAGIC_SO)
+IF(HAVE_MAGIC_H)
+  IF(HAVE_LIBMAGIC_SO)
+    SET(HAVE_LIBMAGIC "1")
+  ENDIF(HAVE_LIBMAGIC_SO)
+ENDIF(HAVE_MAGIC_H)
+IF(NOT HAVE_LIBMAGIC)
+  MESSAGE(FATAL_ERROR "\"magic.h\" or \"libmagic.so\" missing.
+    Please install the \"file-devel\" or \"libmagic-dev\" package !")
+ENDIF(NOT HAVE_LIBMAGIC)
+
+IF(CMAKE_BUILD_TYPE MATCHES Debug)
+  CHECK_LIBRARY_EXISTS(efence malloc "" HAVE_LIBEFENCE)
+  IF(HAVE_LIBEFENCE)
+    MESSAGE(STATUS "Linking with ElectricFence for debugging purposes...")
+    SET(libefence_LIBRARIES "-lefence")
+  ENDIF(HAVE_LIBEFENCE)
+ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(json-c REQUIRED json-c)
+PKG_CHECK_MODULES(libmicrohttpd REQUIRED libmicrohttpd)
+
+SET(include_dirs ${INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include ${json-c_INCLUDE_DIRS} ${libmicrohttpd_INCLUDE_DIRS})
+SET(link_libraries ${json-c_LIBRARIES} ${libmicrohttpd_LIBRARIES} ${libefence_LIBRARIES} -lmagic)
+
+ADD_SUBDIRECTORY(src)
index 5deca98..8fe87d0 100644 (file)
@@ -19,7 +19,9 @@
 
 */
 
-#define _GNU_SOURCE
+#ifndef _GNU_SOURCE
+  #define _GNU_SOURCE
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..434332b
--- /dev/null
@@ -0,0 +1,9 @@
+SET(AFB-DAEMON_HEADERS local-def.h proto-def.h)
+SET(AFB-DAEMON_SOURCES main.c config.c session.c http-svc.c afbs-api.c dbus-api.c rest-api.c alsa-api.c)
+ADD_EXECUTABLE(afb-daemon ${AFB-DAEMON_SOURCES})
+
+include_directories(${include_dirs})
+target_link_libraries(afb-daemon ${link_libraries})
+
+INSTALL(TARGETS afb-daemon
+        RUNTIME DESTINATION bin)
index be16b81..5e32d31 100644 (file)
@@ -330,4 +330,4 @@ void initPlugins(AFB_session *session) {
 
     // complete plugins and save them within current sessions    
     session->plugins = RegisterPlugins(plugins);
-}
\ No newline at end of file
+}