1cmake_minimum_required (VERSION 3.1 FATAL_ERROR) 2set (BUILD_SHARED_LIBRARIES OFF) 3include (ExternalProject) 4set (CMAKE_CXX_STANDARD 17) 5set (CMAKE_CXX_STANDARD_REQUIRED ON) 6set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) 7if (NOT YOCTO) # to download gtest 8 include ("cmake/HunterGate.cmake") 9 huntergate (URL "https://github.com/ruslo/hunter/archive/v0.18.64.tar.gz" 10 SHA1 "baf9c8cc4f65306f0e442b5419967b4c4c04589a") 11endif () 12 13project (hsbp-manager CXX) 14 15set ( 16 CMAKE_CXX_FLAGS 17 "${CMAKE_CXX_FLAGS} -lstdc++fs \ 18 -Werror \ 19 -Wall \ 20 -Wextra \ 21 -Wshadow \ 22 -Wnon-virtual-dtor \ 23 -Wold-style-cast \ 24 -Wcast-align \ 25 -Wunused \ 26 -Woverloaded-virtual \ 27 -Wpedantic \ 28 -Wconversion \ 29 -Wmisleading-indentation \ 30 -Wduplicated-cond \ 31 -Wduplicated-branches \ 32 -Wlogical-op \ 33 -Wnull-dereference \ 34 -Wuseless-cast \ 35 -Wdouble-promotion \ 36 -Wformat=2 \ 37 -fno-rtti" 38) 39 40option (YOCTO "Enable Building in Yocto" OFF) 41 42if (NOT YOCTO) 43 externalproject_add ( 44 Boost URL 45 https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.tar.gz 46 URL_MD5 b50944c0c13f81ce2c006802a1186f5a SOURCE_DIR 47 "${CMAKE_BINARY_DIR}/boost-src" BINARY_DIR 48 "${CMAKE_BINARY_DIR}/boost-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" 49 INSTALL_COMMAND mkdir -p "${CMAKE_BINARY_DIR}/prefix/include/" && cp -R 50 ${CMAKE_BINARY_DIR}/boost-src/boost ${CMAKE_BINARY_DIR}/prefix/include 51 ) # requires apt install autoconf-archive and autoconf 52 externalproject_add (sdbusplus-project PREFIX 53 ${CMAKE_BINARY_DIR}/sdbusplus-project GIT_REPOSITORY 54 https://github.com/openbmc/sdbusplus.git GIT_TAG 55 bed15f0cee4784acdf151cca14efdfb98cb9d397 SOURCE_DIR 56 ${CMAKE_BINARY_DIR}/sdbusplus-src BINARY_DIR 57 ${CMAKE_BINARY_DIR}/sdbusplus-build CONFIGURE_COMMAND 58 "" BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/sdbusplus-src 59 && ./bootstrap.sh && ./configure --enable-transaction 60 && make -j libsdbusplus.la INSTALL_COMMAND "" 61 LOG_DOWNLOAD ON) 62 63 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src) 64 link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs) 65 66 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/boost-src) 67 set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/boost-src ${CMAKE_PREFIX_PATH}) 68 69 option (HUNTER_ENABLED "Enable hunter package pulling" ON) 70 hunter_add_package (GTest) 71 72 find_package (GTest CONFIG REQUIRED) 73endif () 74 75add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) 76add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) 77add_definitions (-DBOOST_ALL_NO_LIB) 78add_definitions (-DBOOST_NO_RTTI) 79add_definitions (-DBOOST_NO_TYPEID) 80add_definitions (-DBOOST_ASIO_DISABLE_THREADS) 81 82include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) 83 84add_executable (hsbp-manager src/hsbp_manager.cpp) 85 86target_link_libraries (hsbp-manager -lsystemd) 87target_link_libraries (hsbp-manager i2c) 88target_link_libraries (hsbp-manager ${Boost_LIBRARIES}) 89target_link_libraries (hsbp-manager sdbusplus) 90target_link_libraries (hsbp-manager stdc++fs) 91 92if (NOT YOCTO) 93 add_dependencies (hsbp-manager sdbusplus-project) 94endif () 95 96set (SERVICE_FILES ${PROJECT_SOURCE_DIR}/service_files/hsbp-manager.service) 97 98install (TARGETS hsbp-manager DESTINATION bin) 99install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) 100