Roni Riska | f165e57 | 2019-08-14 10:53:40 +0300 | [diff] [blame] | 1 | # |
| 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 | |
| 18 | cmake_minimum_required (VERSION 3.5) |
| 19 | |
| 20 | file( |
| 21 | DOWNLOAD https://raw.githubusercontent.com/hunter-packages/gate/master/cmake/HunterGate.cmake |
| 22 | ${CMAKE_BINARY_DIR}/HunterGate.cmake) |
| 23 | |
| 24 | include("${CMAKE_BINARY_DIR}/HunterGate.cmake") |
| 25 | |
| 26 | HunterGate( |
| 27 | URL "https://github.com/ruslo/hunter/archive/v0.23.5.tar.gz" |
| 28 | SHA1 "2c5c6fc1cf609d0856695d60f147594daf4e6b3e" |
| 29 | ) |
| 30 | |
| 31 | project(tracelibcpp LANGUAGES CXX C) |
| 32 | set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cxx1.cmake) |
| 33 | |
| 34 | set (tracelibcpp_VERSION_MAJOR "0") |
| 35 | set (tracelibcpp_VERSION_MINOR "0") |
Roni Riska | 9075724 | 2019-08-15 10:21:49 +0300 | [diff] [blame^] | 36 | set (tracelibcpp_VERSION_MICRO "2") |
Roni Riska | f165e57 | 2019-08-14 10:53:40 +0300 | [diff] [blame] | 37 | set (tracelibcpp_VERSION_STRING |
| 38 | "${tracelibcpp_VERSION_MAJOR}.${tracelibcpp_VERSION_MINOR}.${tracelibcpp_VERSION_MICRO}") |
| 39 | |
Roni Riska | 9075724 | 2019-08-15 10:21:49 +0300 | [diff] [blame^] | 40 | # Set up cpack |
| 41 | # Common |
| 42 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "C++ implementation RIC tracing initialization") |
| 43 | set(CPACK_PACKAGE_VENDOR "Nokia") |
| 44 | set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") |
| 45 | set(CPACK_PACKAGE_VERSION_MAJOR ${tracelibcpp_VERSION_MAJOR}) |
| 46 | set(CPACK_PACKAGE_VERSION_MINOR ${tracelibcpp_VERSION_MINOR}) |
| 47 | set(CPACK_PACKAGE_VERSION_PATCH ${tracelibcpp_VERSION_MICRO}) |
| 48 | set(CPACK_COMPONENTS_ALL DIST DEVEL) |
| 49 | set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP ) |
| 50 | set(CPACK_GENERATOR "RPM;DEB") |
| 51 | set(CPACK_COMPONENTS_IGNORE_GROUPS 1) |
| 52 | set(CPACK_PACKAGE_CONTACT None) |
| 53 | |
| 54 | # RPM |
| 55 | set(CPACK_RPM_COMPONENT_INSTALL ON) |
| 56 | set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries") |
| 57 | set(CPACK_RPM_FILE_NAME RPM-DEFAULT) |
| 58 | set(CPACK_RPM_PACKAGE_AUTOREQ 1) |
| 59 | |
| 60 | # Debian |
| 61 | set(CPACK_DEB_COMPONENT_INSTALL ON) |
| 62 | set(CPACK_DEB_PACKAGE_COMPONENT ON) |
| 63 | set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) |
| 64 | set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) |
| 65 | |
| 66 | include(CPack) |
| 67 | |
Roni Riska | f165e57 | 2019-08-14 10:53:40 +0300 | [diff] [blame] | 68 | # Add jaeger |
| 69 | hunter_add_package(jaegertracing) |
| 70 | find_package(jaegertracing CONFIG REQUIRED) |
| 71 | |
| 72 | # Unit testing support of off by default |
| 73 | # Enable it with cmake -DWITH_TESTING=ON <srcdir> |
| 74 | option(WITH_TESTING "Include using testing support" OFF) |
| 75 | |
| 76 | include_directories ("${PROJECT_SOURCE_DIR}/include/tracelibcpp") |
| 77 | |
| 78 | add_library(tracelibcpp SHARED |
| 79 | src/tracelib.cpp |
| 80 | ) |
| 81 | |
| 82 | option(WITH_VERSION "Support for library versioning" ON) |
| 83 | |
| 84 | if (WITH_VERSION) |
| 85 | set_target_properties(tracelibcpp PROPERTIES VERSION ${tracelibcpp_VERSION_STRING} |
| 86 | SOVERSION ${tracelibcpp_VERSION_MAJOR}) |
| 87 | endif (WITH_VERSION) |
| 88 | |
| 89 | # Library versions are on by default |
| 90 | # i.e. so versions |
| 91 | option(WITH_VERSION "Support for library versioning" ON) |
| 92 | |
| 93 | if (WITH_VERSION) |
| 94 | set_target_properties(tracelibcpp PROPERTIES VERSION ${tracelibcpp_VERSION_STRING} |
| 95 | SOVERSION ${tracelibcpp_VERSION_MAJOR}) |
| 96 | endif (WITH_VERSION) |
| 97 | |
| 98 | target_link_libraries(tracelibcpp PUBLIC jaegertracing::jaegertracing-static) |
| 99 | |
| 100 | include(GNUInstallDirs) |
| 101 | if (NOT DEFINED LIB_INSTALL_DIR) |
| 102 | set(LIB_INSTALL_DIR lib) |
| 103 | endif() |
| 104 | |
| 105 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/tracelibcpp |
| 106 | DESTINATION include |
| 107 | COMPONENT DEVEL) |
| 108 | |
| 109 | install(TARGETS tracelibcpp |
| 110 | COMPONENT DIST |
| 111 | LIBRARY DESTINATION ${LIB_INSTALL_DIR} |
| 112 | NAMELINK_SKIP |
| 113 | ) |
| 114 | |
| 115 | install(TARGETS tracelibcpp |
| 116 | COMPONENT DEVEL |
| 117 | LIBRARY DESTINATION ${LIB_INSTALL_DIR} |
| 118 | NAMELINK_ONLY |
| 119 | ) |
| 120 | |
| 121 | # Add google test |
| 122 | if (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() |
| 134 | endif (WITH_TESTING) |