CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(sensors CXX)
+PROJECT(sensor-fusion CXX)
INCLUDE(GNUInstallDirs)
-SET(HRM "ON")
-SET(HRM_VIRT "OFF")
SET(AUTO_ROTATION "ON")
SET(GRAVITY "ON")
SET(LINEAR_ACCEL "ON")
-SET(ORIENTATION "OFF")
-SET(FUSION "OFF")
-SET(MOTION "OFF")
-SET(RV "OFF")
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/shared
- ${CMAKE_SOURCE_DIR}/src/server
${CMAKE_CURRENT_SOURCE_DIR}
)
-FILE(GLOB SENSOR_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
-SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR})
+# Common Options
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2 -omit-frame-pointer -std=gnu++0x")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -ffunction-sections")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -Wl,--print-gc-sections")
+MESSAGE("FLAGS: ${CMAKE_CXX_FLAGS}")
+MESSAGE("FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
-FILE(GLOB_RECURSE SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/accel/*.cpp)
-SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/accel)
-SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_ACCEL")
+# Internal Debugging Options
+#ADD_DEFINITIONS(-Wall -g -D_DEBUG)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PLUGINS_PKGS REQUIRED dlog)
+
+FOREACH(flag ${PLUGINS_PKGS_CFLAGS})
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
+
+FILE(GLOB SRCS *.cpp)
-IF("${HRM}" STREQUAL "ON")
- FILE(GLOB_RECURSE SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/hrm/*.cpp)
- SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/hrm)
- SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_HRM")
-ENDIF()
-IF("${HRM_VIRT}" STREQUAL "ON")
-add_subdirectory(hrm_virt)
-ENDIF()
IF("${AUTO_ROTATION}" STREQUAL "ON")
- FILE(GLOB_RECURSE SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/auto_rotation/*.cpp)
- SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/auto_rotation)
- SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_AUTO_ROTATION")
+FILE(GLOB_RECURSE SRCS ${SRCS} auto_rotation/*.cpp)
+ADD_DEFINITIONS(-DENABLE_AUTO_ROTATION)
ENDIF()
+
IF("${GRAVITY}" STREQUAL "ON")
- FILE(GLOB_RECURSE SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/gravity/*.cpp)
- SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/gravity)
- SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_GRAVITY")
+FILE(GLOB_RECURSE SRCS ${SRCS} gravity/*.cpp)
+ADD_DEFINITIONS(-DENABLE_GRAVITY)
ENDIF()
+
IF("${LINEAR_ACCEL}" STREQUAL "ON")
- FILE(GLOB_RECURSE SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/linear_accel/*.cpp)
- SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/linear_accel)
- SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_LINEAR_ACCEL")
-ENDIF()
-IF("${ORIENTATION}" STREQUAL "ON")
-add_subdirectory(orientation)
-ENDIF()
-IF("${RV}" STREQUAL "ON")
-add_subdirectory(rotation_vector)
-ENDIF()
-IF("${FUSION}" STREQUAL "ON")
-add_subdirectory(fusion)
-ENDIF()
-IF("${MOTION}" STREQUAL "ON")
-add_subdirectory(motion)
+FILE(GLOB_RECURSE SRCS ${SRCS} linear_accel/*.cpp)
+ADD_DEFINITIONS(-DENABLE_LINEAR_ACCEL)
ENDIF()
-MESSAGE("${SENSOR_SRCS}")
-SET(SENSOR_SRCS ${SENSOR_SRCS} PARENT_SCOPE)
-SET(SENSOR_HEADERS ${SENSOR_HEADERS} PARENT_SCOPE)
-SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} PARENT_SCOPE)
+MESSAGE("Sources: ${SRCS}")
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PLUGINS_PKGS_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/sensor/fusion)