-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+# Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# @file CMakeLists.txt
+#
+
+############################# Check minimum CMake version #####################
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
SET(CAPI_UWB "capi-network-uwb")
+PROJECT(${CAPI_UWB})
-PROJECT(${CAPI_UWB} C CXX)
+############################# cmake packages ##################################
-MESSAGE(" - Defining...configuration variables")
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-
-SET(LIB ${LIB_PATH})
-SET(LIBDIR ${PREFIX}/${LIB_PATH})
-
-SET(INC_DIR include)
-INCLUDE_DIRECTORIES(${INC_DIR})
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
-
-MESSAGE(" - Checking...packages dependency")
-SET(COMMON_DEPS dlog gio-2.0 glib-2.0 gio-unix-2.0 capi-system-info)
-SET(PC_DEPS "")
-
-MESSAGE(" - Making...build configuration")
INCLUDE(FindPkgConfig)
-pkg_check_modules(${CAPI_UWB} REQUIRED ${COMMON_DEPS})
-FOREACH(flag ${${CAPI_UWB}_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-SET(DEFAULT_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE -fPIC -Werror -g -fvisibility=hidden")
-IF(BUILD_GCOV)
- SET(GCOV_C_FLAGS "-fprofile-arcs -ftest-coverage")
-ENDIF(BUILD_GCOV)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DEFAULT_CFLAGS} ${GCOV_C_FLAGS}")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-
-IF("${ARCH}" STREQUAL "arm")
- ADD_DEFINITIONS("-DTARGET")
-ENDIF("${ARCH}" STREQUAL "arm")
-
-ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-ADD_DEFINITIONS("-DTIZEN_DEBUG")
-
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie -Wl,--rpath=${LIBDIR}")
-
-MESSAGE(" - Generating...d-bus code")
-FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
-EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
- " \\
- --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/src/uwb_gdbus \\
- --interface-prefix org.tizen.uwb. \\
- ${CMAKE_CURRENT_SOURCE_DIR}/src/uwb-gdbuslib.xml \\
- ")
-
-MESSAGE(" - Building...shared library")
-SET(SOURCES src/uwb.c
- src/uwb_gdbus.c
- src/uwb_util.c)
-
-ADD_LIBRARY(${CAPI_UWB} SHARED ${SOURCES})
-TARGET_LINK_LIBRARIES(${CAPI_UWB} ${${CAPI_UWB}_LDFLAGS} pthread)
-
-SET_TARGET_PROPERTIES(${CAPI_UWB}
- PROPERTIES
- VERSION ${FULLVER}
- SOVERSION ${MAJORVER}
- CLEAN_DIRECT_OUTPUT 1
-)
-MESSAGE(" - Installing...the library and header files")
-INSTALL(TARGETS ${CAPI_UWB} DESTINATION ${LIB})
-INSTALL(
- DIRECTORY include/ DESTINATION include
- FILES_MATCHING
- PATTERN "include/*.h"
- )
+SET(COMMON_DEPS "dlog glib-2.0 gio-2.0 gio-unix-2.0 capi-system-info")
+SET(PC_DEPS "capi-base-common")
+SET(TEST_DEPS "glib-2.0")
+SET(GTEST_DEPS "gmock")
-SET(PC_NAME ${CAPI_UWB})
-SET(PC_REQUIRED ${PC_DEPS})
-SET(PC_LDFLAGS -l${CAPI_UWB})
+SET(TARGET_UWB "capi-network-uwb")
+SET(TARGET_UWB_TEST "capi-network-uwb-test")
+SET(TARGET_UWB_GTEST "capi-network-uwb-gtest")
-CONFIGURE_FILE(
- ${CAPI_UWB}.pc.in
- ${CMAKE_CURRENT_SOURCE_DIR}/${CAPI_UWB}.pc
- @ONLY
-)
+ADD_DEFINITIONS("-DUSE_DLOG")
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${CAPI_UWB}.pc DESTINATION ${LIB}/pkgconfig)
+ADD_SUBDIRECTORY(include)
+ADD_SUBDIRECTORY(pkgconfig)
+ADD_SUBDIRECTORY(src)
+++ /dev/null
-
-# Package Information for pkg-config
-
-prefix=@PREFIX@
-exec_prefix=/usr
-libdir=@libdir@
-includedir=/usr/include/
-
-Name: @PC_NAME@
-Description: @PACKAGE_DESCRIPTION@
-Version: @VERSION@
-Requires: @PC_REQUIRED@
-Libs: -L${libdir} @PC_LDFLAGS@
-Cflags: -I${includedir}
-
--- /dev/null
+# Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# @file CMakeLists.txt
+#
+
+INSTALL(FILES
+ ${CMAKE_SOURCE_DIR}/include/uwb.h
+ DESTINATION ${INCLUDE_DIR}
+ )
Summary: UWB CAPI
Version: 0.1.1
Release: 0
-Group: Network & Connectivity/Other
+Group: Network & Connectivity/API
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
Source1: %{name}.manifest
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
+%if 0%{?gcov:1}
+BuildRequires: lcov
+BuildRequires: tar
+%endif
+BuildRequires: pkgconfig(gmock)
+
%description
UWB API library
-Group: Network & Connectivity/Other
-Requires: %{name} = %{version}-%{release}
%package devel
Summary: UWB API library (development library)
-Group: Network & Connectivity/Other
+Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
This package contains the development files for %{name} API library.
+%package tests
+Summary: Test Application UWB
+Group: Network & Connectivity/Testing
+Requires: %{name} = %{version}-%{release}
+
+%description tests
+Test Application for UWB Framework
+
%if 0%{?gcov:1}
%package gcov
Summary: A UWB gcov Tool
%endif
%prep
-%setup #-q
-chmod g-w %_sourcedir/*
+%setup -q
+chmod 644 %{SOURCE0}
cp %{SOURCE1} ./%{name}.manifest
%build
-CFLAGS=$(echo $CFLAGS | sed 's/-O2/-O0/' | sed 's/-O1/-O0/' | sed 's/-Wp,-D_FORTIFY_SOURCE=2//')
-CXXFLAGS=$(echo $CXXFLAGS | sed 's/-O2/-O0/' | sed 's/-O1/-O0/' | sed 's/-Wp,-D_FORTIFY_SOURCE=2//')
+
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export FFLAGS+=" -fprofile-arcs -ftest-coverage"
export LDFLAGS+=" -lgcov"
%endif
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%define NETWORK_FW_DATADIR %{TZ_SYS_GLOBALUSER_DATA}/network
-%define DBDIR %{TZ_SYS_GLOBALUSER_DATA}/
+cmake . \
+ -DCMAKE_VERBOSE_MAKEFILE=ON \
+ -DLIB_DIR:PATH=%{_libdir} \
+ -DBIN_DIR:PATH=%{_bindir} \
+ -DINCLUDE_DIR:PATH=%{_includedir} \
+ -DFULLVER=%{version} \
+ -DMAJORVER=${MAJORVER}
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
- -DLIB_INSTALL_DIR=%{_libdir} \
- -DBIN_INSTALL_DIR=%{_bindir} \
- -DINCLUDE_INSTALL_DIR=%{_includedir} \
- -DLIB_PATH=%{_lib} \
- -DFULLVER=%{version} \
- -DMAJORVER=${MAJORVER} \
- -DNETWORK_FW_DATADIR=%{NETWORK_FW_DATADIR} \
- -DDBDIR=%{DBDIR} \
- -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0}
+make %{?_smp_mflags}
-make %{?jobs:-j%jobs}
+%install
+
+%make_install
%if 0%{?gcov:1}
-mkdir -p gcov-obj
-find . -name '*.gcno' -exec cp '{}' gcov-obj ';'
+find .. -name '*.gcno' | tar cf %{name}-gcov.tar -T -
+install -d -m 755 %{buildroot}%{_datadir}/gcov/obj
+tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj
%endif
-%install
-rm -rf %{buildroot}/BUILD/%{name}
-%make_install
-
+%check
+#tests/%{name}-gtest
%if 0%{?gcov:1}
-mkdir -p %{buildroot}%{_datadir}/gcov/obj
-install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
+lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info
+genhtml %{name}.info -o out --legend --show-details
%endif
%post -p /sbin/ldconfig
%files
%manifest %{name}.manifest
-%defattr(-,root,root,-)
%license LICENSE.APLv2
+%defattr(-,root,root,-)
%attr(644,-,-) %{_libdir}/lib%{name}.so.*
%files devel
%{_libdir}/pkgconfig/%{name}.pc
%{_includedir}/*.h
+%files tests
+#%{_bindir}/%{name}-test
+#%{_bindir}/%{name}-gtest
+
%if 0%{?gcov:1}
%files gcov
%{_datadir}/gcov/obj/*
--- /dev/null
+# Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# @file CMakeLists.txt
+#
+
+SET(PC_NAME ${CAPI_UWB})
+SET(PC_DESCRIPTION ${PACKAGE_DESCRIPTION})
+SET(PC_VERSION ${FULLVER})
+SET(PC_REQUIRED ${PC_DEPS})
+SET(PC_LDFLAGS -l${CAPI_UWB})
+
+CONFIGURE_FILE(${PC_NAME}.pc.in ${PC_NAME}.pc @ONLY)
+
+INSTALL(FILES
+ ${CMAKE_BINARY_DIR}/pkgconfig/${PC_NAME}.pc
+ DESTINATION
+ ${LIB_DIR}/pkgconfig
+ )
--- /dev/null
+# Package Information for pkg-config
+
+libdir=@LIB_DIR@
+includedir=@INCLUDE_DIR@
+
+Name: @PC_NAME@
+Description: @PC_DESCRIPTION@
+Version: @PC_VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
\ No newline at end of file
--- /dev/null
+########################## search for packages ################################
+
+PKG_CHECK_MODULES(UWB_DEPS REQUIRED ${COMMON_DEPS})
+
+############################# compiler flags ##################################
+
+SET(EXTRA_FLAGS "-fPIC -Wall -Werror -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_FLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lpthread -pie")
+
+######################## directory configuration ############################
+
+INCLUDE_DIRECTORIES(${UWB_DEPS_INCLUDE_DIRS})
+LINK_DIRECTORIES(${UWB_DEPS_LIBRARY_DIRS})
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src)
+
+MESSAGE(" - Generating...d-bus code")
+FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
+EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
+ " \\
+ --generate-c-code ${CMAKE_SOURCE_DIR}/src/uwb-gdbus \\
+ --interface-prefix org.tizen.uwb. \\
+ ${CMAKE_SOURCE_DIR}/src/uwb-gdbuslib.xml \\
+ ")
+# Build
+SET(SRCS
+ uwb.c
+ uwb-util.c
+ uwb-gdbus.c
+)
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${UWB_DEPS_LIBRARIES})
+SET_TARGET_PROPERTIES(${PROJECT_NAME}
+ PROPERTIES
+ VERSION ${FULLVER}
+ SOVERSION ${MAJORVER}
+)
+
+# Install
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_DIR})
+++ /dev/null
-gdbus-codegen --interface-prefix org.tizen.uwb \
- --generate-c-code uwb_gdbus \
- --c-generate-object-manager \
- uwb-gdbuslib.xml \
#include <gio/gio.h>
#include <glib.h>
#include <uwb.h>
-#include <uwb_log.h>
-#include <uwb_gdbus.h>
+#include <uwb-log.h>
#include <system_info.h>
#define UWB_FEATURE "http://tizen.org/feature/network.uwb"
*/
#include <glib.h>
#include <uwb.h>
-#include <uwb_log.h>
-#include <uwb_private.h>
+#include <uwb-log.h>
+#include <uwb-private.h>
#include <stdlib.h>
void _node_free_func(gpointer data)
#ifndef __UWB_UTIL_H__
#define __UWB_UTIL_H__
-#include <uwb_private.h>
-
#ifdef __cplusplus
extern "C" {
#endif
#include <dlog.h>
#include <uwb.h>
-#include <uwb_log.h>
-#include <uwb_private.h>
-#include <uwb_gdbus.h>
-#include <uwb_util.h>
+#include <uwb-log.h>
+#include <uwb-private.h>
+#include <uwb-gdbus.h>
+#include <uwb-util.h>
#include <inttypes.h>
#define UWB_DBUS_SERVICE "org.tizen.uwb" /**< For uwb dbus */