191cdbe46SBenjamin Kietzman# Copyright (c) Benjamin Kietzman (github.com/bkietz) 291cdbe46SBenjamin Kietzman# 391cdbe46SBenjamin Kietzman# Distributed under the Boost Software License, Version 1.0. (See accompanying 491cdbe46SBenjamin Kietzman# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 591cdbe46SBenjamin Kietzman 6377e76abSEd Tanousset(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) 7da3eeb6aSEd Tanous 8fc79e461SBenjamin Kietzman############### 9fc79e461SBenjamin Kietzman# CMake options 10fc79e461SBenjamin Kietzmancmake_minimum_required(VERSION 2.8) 11fc79e461SBenjamin Kietzman 12377e76abSEd Tanousset(CMAKE_CXX_STANDARD 14) 13377e76abSEd Tanousset(CMAKE_CXX_STANDARD_REQUIRED ON) 14377e76abSEd Tanous 15377e76abSEd Tanousoption(HUNTER_ENABLED "Enable hunter package pulling" OFF) 16377e76abSEd Tanous 17377e76abSEd Tanousinclude("cmake/HunterGate.cmake") 18377e76abSEd TanousHunterGate( 19377e76abSEd Tanous URL "https://github.com/ruslo/hunter/archive/v0.18.64.tar.gz" 20377e76abSEd Tanous SHA1 "baf9c8cc4f65306f0e442b5419967b4c4c04589a" 21377e76abSEd Tanous) 22377e76abSEd Tanous 23377e76abSEd Tanousproject(boost-dbus CXX) 24377e76abSEd Tanous 25fc79e461SBenjamin Kietzman############### 26fc79e461SBenjamin Kietzman# C++ options 27421f9900SEd Tanousset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") 28b6e8327aSEd Tanousinclude_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) 29b6e8327aSEd Tanousinclude_directories(${CMAKE_CURRENT_SOURCE_DIR}/test) 30fc79e461SBenjamin Kietzman 31fc79e461SBenjamin Kietzman############### 32fc79e461SBenjamin Kietzman# import Boost 335d4bd2bdSEd Tanousadd_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY) 345d4bd2bdSEd Tanousadd_definitions(-DBOOST_SYSTEM_NO_DEPRECATED) 355d4bd2bdSEd Tanousadd_definitions(-DBOOST_ALL_NO_LIB) 36377e76abSEd Tanousadd_definitions(-DBOOST_NO_RTTI) 37377e76abSEd Tanousadd_definitions(-DBOOST_NO_TYPEID) 38377e76abSEd Tanoushunter_add_package(Boost) 39b6e8327aSEd Tanousfind_package(Boost REQUIRED) 405d4bd2bdSEd Tanous 41fc79e461SBenjamin Kietzmaninclude_directories(${Boost_INCLUDE_DIRS}) 42fc79e461SBenjamin Kietzmanlink_directories(${Boost_LIBRARY_DIRS}) 43fc79e461SBenjamin Kietzman 44fc79e461SBenjamin Kietzman############### 45fc79e461SBenjamin Kietzman# import D-Bus 46377e76abSEd Tanoushunter_add_package(dbus) 47377e76abSEd Tanousfind_package(dbus REQUIRED) # Include functions provided by PkgConfig module. 48377e76abSEd Tanousinclude_directories(${DBUS_INCLUDE_DIRS}) 49377e76abSEd Tanous 50377e76abSEd Tanoushunter_add_package(pthread-stubs) 51377e76abSEd Tanousfind_package (Threads) 52fc79e461SBenjamin Kietzman 53fc79e461SBenjamin Kietzman############## 54421f9900SEd Tanous# Install 55421f9900SEd Tanousadd_library(boost-dbus INTERFACE) 56*3e36ae67SEd Tanoustarget_include_directories(boost-dbus INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${DBUS_INCLUDE_DIRS}) 57421f9900SEd Tanoustarget_link_libraries(boost-dbus INTERFACE ${DBUS_LIBRARIES}) 58*3e36ae67SEd Tanousinstall(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include) 59421f9900SEd Tanous 60421f9900SEd Tanous############## 61421f9900SEd Tanous# Tests 62421f9900SEd Tanousenable_testing() 63421f9900SEd Tanous 64421f9900SEd Tanousadd_executable(dbustests "test/avahi.cpp" "test/message.cpp" "test/error.cpp" "test/dbusPropertiesServer.cpp") 65421f9900SEd Tanous 66421f9900SEd Tanous############## 67a83e5951SBenjamin Kietzman# import GTest 68377e76abSEd Tanoushunter_add_package(GTest) 69a83e5951SBenjamin Kietzmanfind_package(GTest REQUIRED) 70a83e5951SBenjamin Kietzmaninclude_directories(${GTEST_INCLUDE_DIRS}) 71a83e5951SBenjamin Kietzman 72377e76abSEd Tanousif (${HUNTER_ENABLED}) 73377e76abSEd Tanous find_package(GMock CONFIG REQUIRED) 74377e76abSEd Tanous target_link_libraries(dbustests GMock::main) 75377e76abSEd Tanouselse() 76377e76abSEd Tanous find_package(GMock REQUIRED) 77b6e8327aSEd Tanous target_link_libraries(dbustests ${GTEST_BOTH_LIBRARIES} gmock) 78377e76abSEd Tanousendif() 79377e76abSEd Tanoustarget_link_libraries(dbustests ${CMAKE_THREAD_LIBS_INIT}) 80da3eeb6aSEd Tanousadd_test(dbustests dbustests "--gtest_output=xml:${test_name}.xml") 81da3eeb6aSEd Tanous 82421f9900SEd Tanoustarget_link_libraries(dbustests boost-dbus) 83