blob: a3b0e0d213bc810017f932cf4bd3db7e2d202c7d [file] [log] [blame]
Roni Riskaf165e572019-08-14 10:53:40 +03001#
2# Copyright (c) 2019 AT&T Intellectual Property.
3# Copyright (c) 2018-2019 Nokia.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18cmake_minimum_required (VERSION 3.5)
19
20file(
21 DOWNLOAD https://raw.githubusercontent.com/hunter-packages/gate/master/cmake/HunterGate.cmake
22 ${CMAKE_BINARY_DIR}/HunterGate.cmake)
23
24include("${CMAKE_BINARY_DIR}/HunterGate.cmake")
25
26HunterGate(
27 URL "https://github.com/ruslo/hunter/archive/v0.23.5.tar.gz"
28 SHA1 "2c5c6fc1cf609d0856695d60f147594daf4e6b3e"
29)
30
31project(tracelibcpp LANGUAGES CXX C)
32set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cxx1.cmake)
33
34set (tracelibcpp_VERSION_MAJOR "0")
35set (tracelibcpp_VERSION_MINOR "0")
Roni Riska90757242019-08-15 10:21:49 +030036set (tracelibcpp_VERSION_MICRO "2")
Roni Riskaf165e572019-08-14 10:53:40 +030037set (tracelibcpp_VERSION_STRING
38 "${tracelibcpp_VERSION_MAJOR}.${tracelibcpp_VERSION_MINOR}.${tracelibcpp_VERSION_MICRO}")
39
Roni Riska90757242019-08-15 10:21:49 +030040# Set up cpack
41# Common
42set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "C++ implementation RIC tracing initialization")
43set(CPACK_PACKAGE_VENDOR "Nokia")
44set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
45set(CPACK_PACKAGE_VERSION_MAJOR ${tracelibcpp_VERSION_MAJOR})
46set(CPACK_PACKAGE_VERSION_MINOR ${tracelibcpp_VERSION_MINOR})
47set(CPACK_PACKAGE_VERSION_PATCH ${tracelibcpp_VERSION_MICRO})
48set(CPACK_COMPONENTS_ALL DIST DEVEL)
49set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP )
50set(CPACK_GENERATOR "RPM;DEB")
51set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
52set(CPACK_PACKAGE_CONTACT None)
53
54# RPM
55set(CPACK_RPM_COMPONENT_INSTALL ON)
56set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
57set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
58set(CPACK_RPM_PACKAGE_AUTOREQ 1)
59
60# Debian
61set(CPACK_DEB_COMPONENT_INSTALL ON)
62set(CPACK_DEB_PACKAGE_COMPONENT ON)
63set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
64set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
65
66include(CPack)
67
Roni Riskaf165e572019-08-14 10:53:40 +030068# Add jaeger
69hunter_add_package(jaegertracing)
70find_package(jaegertracing CONFIG REQUIRED)
71
72# Unit testing support of off by default
73# Enable it with cmake -DWITH_TESTING=ON <srcdir>
74option(WITH_TESTING "Include using testing support" OFF)
75
76include_directories ("${PROJECT_SOURCE_DIR}/include/tracelibcpp")
77
78add_library(tracelibcpp SHARED
79 src/tracelib.cpp
80)
81
82option(WITH_VERSION "Support for library versioning" ON)
83
84if (WITH_VERSION)
85 set_target_properties(tracelibcpp PROPERTIES VERSION ${tracelibcpp_VERSION_STRING}
86 SOVERSION ${tracelibcpp_VERSION_MAJOR})
87endif (WITH_VERSION)
88
89# Library versions are on by default
90# i.e. so versions
91option(WITH_VERSION "Support for library versioning" ON)
92
93if (WITH_VERSION)
94set_target_properties(tracelibcpp PROPERTIES VERSION ${tracelibcpp_VERSION_STRING}
95 SOVERSION ${tracelibcpp_VERSION_MAJOR})
96endif (WITH_VERSION)
97
98target_link_libraries(tracelibcpp PUBLIC jaegertracing::jaegertracing-static)
99
100include(GNUInstallDirs)
101if (NOT DEFINED LIB_INSTALL_DIR)
102 set(LIB_INSTALL_DIR lib)
103endif()
104
105install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/tracelibcpp
106 DESTINATION include
107 COMPONENT DEVEL)
108
109install(TARGETS tracelibcpp
110 COMPONENT DIST
111 LIBRARY DESTINATION ${LIB_INSTALL_DIR}
112 NAMELINK_SKIP
113 )
114
115install(TARGETS tracelibcpp
116 COMPONENT DEVEL
117 LIBRARY DESTINATION ${LIB_INSTALL_DIR}
118 NAMELINK_ONLY
119 )
120
121# Add google test
122if (WITH_TESTING)
123 hunter_add_package(GTest)
124 find_package(GTest CONFIG REQUIRED)
125 add_executable(testrunner
126 tst/testcreate.cpp
127 )
128 target_link_libraries(testrunner GTest::main) # GTest::gtest will be linked automatically
129 target_link_libraries(testrunner GTest::gtest)
130 target_link_libraries(testrunner tracelibcpp)
131 add_test(UnitTest testrunner)
132 add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS testrunner)
133 ENABLE_TESTING()
134endif (WITH_TESTING)