CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(capi-system-sensor)
+INCLUDE(GNUInstallDirs)
-# Setup for pkgconfig File
-SET(fw_name "capi-system-sensor")
+SET(DEPENDENTS "dlog sensor capi-base-common")
+SET(VERSION ${FULLVER})
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(VERSION 1.0)
+
+SET(PC_NAME ${PROJECT_NAME})
+SET(PC_DESCRIPTION "Sensor C-API library")
+SET(PC_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/sensor")
+SET(PC_DEPENDENTS "${DEPENDENTS}")
+SET(PC_LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
+SET(PC_LDFLAGS "-l${PROJECT_NAME}")
INCLUDE_DIRECTORIES(include)
# Build options
INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_name} REQUIRED dlog sensor capi-base-common)
+PKG_CHECK_MODULES(${PROJECT_NAME} REQUIRED ${DEPENDENTS})
-FOREACH(flag ${${fw_name}_CFLAGS})
+FOREACH(flag ${${PROJECT_NAME}_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
# Complile Source files
AUX_SOURCE_DIRECTORY(src SOURCES)
-ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SOURCES})
-TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
-SET_TARGET_PROPERTIES(${fw_name} PROPERTIES VERSION ${FULLVER} SOVERSION ${MAJORVER} CLEAN_DIRECT_OUTPUT 1)
-CONFIGURE_FILE(${fw_name}.pc.in ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc @ONLY)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
-INSTALL(FILES include/sensor.h DESTINATION ${INCLUDE_INSTALL_DIR}/sensor)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${${PROJECT_NAME}_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${FULLVER} SOVERSION ${MAJORVER} CLEAN_DIRECT_OUTPUT 1)
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries)
+INSTALL(FILES include/sensor.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor)
# ###
IF(UNIX)
prefix=@PREFIX@
exec_prefix=@PREFIX@/bin
-libdir=@LIB_INSTALL_DIR@
-includedir=@INCLUDE_INSTALL_DIR@/sensor
+libdir=@PC_LIBDIR@
+includedir=@PC_INCLUDEDIR@
-Name: capi-system-sensor
-Description: A sensor library
+Name: @PC_NAME@
+Description: @PC_DESCRIPTION@
Version: @VERSION@
-Requires: capi-base-common
-Libs: -L${libdir} -lcapi-system-sensor
+Requires: @PC_DEPENDENTS@
+Libs: -L${libdir} @PC_LDFLAGS@
Cflags: -I${includedir}