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*016605c5SEd Tanoustarget_include_directories(boost-dbus INTERFACE 57*016605c5SEd Tanous $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> 58*016605c5SEd Tanous $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include> 59*016605c5SEd Tanous ${DBUS_INCLUDE_DIRS}) 60*016605c5SEd Tanous 61421f9900SEd Tanoustarget_link_libraries(boost-dbus INTERFACE ${DBUS_LIBRARIES}) 623e36ae67SEd Tanousinstall(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include) 63421f9900SEd Tanous 64421f9900SEd Tanous############## 65421f9900SEd Tanous# Tests 66421f9900SEd Tanousenable_testing() 67421f9900SEd Tanous 68421f9900SEd Tanousadd_executable(dbustests "test/avahi.cpp" "test/message.cpp" "test/error.cpp" "test/dbusPropertiesServer.cpp") 69421f9900SEd Tanous 70421f9900SEd Tanous############## 71a83e5951SBenjamin Kietzman# import GTest 72377e76abSEd Tanoushunter_add_package(GTest) 73a83e5951SBenjamin Kietzmanfind_package(GTest REQUIRED) 74a83e5951SBenjamin Kietzmaninclude_directories(${GTEST_INCLUDE_DIRS}) 75a83e5951SBenjamin Kietzman 76377e76abSEd Tanousif (${HUNTER_ENABLED}) 77377e76abSEd Tanous find_package(GMock CONFIG REQUIRED) 78377e76abSEd Tanous target_link_libraries(dbustests GMock::main) 79377e76abSEd Tanouselse() 80377e76abSEd Tanous find_package(GMock REQUIRED) 81b6e8327aSEd Tanous target_link_libraries(dbustests ${GTEST_BOTH_LIBRARIES} gmock) 82377e76abSEd Tanousendif() 83377e76abSEd Tanoustarget_link_libraries(dbustests ${CMAKE_THREAD_LIBS_INIT}) 84da3eeb6aSEd Tanousadd_test(dbustests dbustests "--gtest_output=xml:${test_name}.xml") 85da3eeb6aSEd Tanous 86421f9900SEd Tanoustarget_link_libraries(dbustests boost-dbus) 87*016605c5SEd Tanous 88*016605c5SEd Tanous 89*016605c5SEd Tanous# export targets for find_package config mode 90*016605c5SEd Tanousexport(TARGETS boost-dbus 91*016605c5SEd Tanous FILE ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Targets.cmake) 92*016605c5SEd Tanous 93*016605c5SEd Tanousfile(WRITE 94*016605c5SEd Tanous ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake 95*016605c5SEd Tanous "include(\${CMAKE_CURRENT_LIST_DIR}/${CMAKE_PROJECT_NAME}Targets.cmake)\n") 96*016605c5SEd Tanous 97*016605c5SEd Tanousinstall(FILES 98*016605c5SEd Tanous ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake 99*016605c5SEd Tanous DESTINATION lib/cmake/${CMAKE_PROJECT_NAME}) 100*016605c5SEd Tanous 101*016605c5SEd Tanousinstall(TARGETS boost-dbus 102*016605c5SEd Tanous EXPORT ${CMAKE_PROJECT_NAME}Targets 103*016605c5SEd Tanous RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 104*016605c5SEd Tanous LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 105*016605c5SEd Tanous ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) 106*016605c5SEd Tanous 107*016605c5SEd Tanousinstall(EXPORT ${CMAKE_PROJECT_NAME}Targets 108*016605c5SEd Tanous DESTINATION lib/cmake/${CMAKE_PROJECT_NAME}) 109