1cmake_minimum_required (VERSION 3.1 FATAL_ERROR) 2set (BUILD_SHARED_LIBRARIES OFF) 3include (ExternalProject) 4set (CMAKE_CXX_STANDARD 20) 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 " 38) 39# Temporarily disable rtti 40# See https://github.com/chriskohlhoff/asio/issues/533 41# -fno-rtti 42 43option (YOCTO "Enable Building in Yocto" OFF) 44 45if (NOT YOCTO) 46 externalproject_add ( 47 Boost URL 48 https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz 49 URL_MD5 e425bf1f1d8c36a3cd464884e74f007a SOURCE_DIR 50 "${CMAKE_BINARY_DIR}/boost-src" BINARY_DIR 51 "${CMAKE_BINARY_DIR}/boost-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" 52 INSTALL_COMMAND mkdir -p "${CMAKE_BINARY_DIR}/prefix/include/" && cp -R 53 ${CMAKE_BINARY_DIR}/boost-src/boost ${CMAKE_BINARY_DIR}/prefix/include 54 ) # requires apt install autoconf-archive and autoconf 55 externalproject_add (sdbusplus-project PREFIX 56 ${CMAKE_BINARY_DIR}/sdbusplus-project GIT_REPOSITORY 57 https://github.com/openbmc/sdbusplus.git GIT_TAG 58 8a97100b806225df40c490eb748c9a4e1b3c11b3 SOURCE_DIR 59 ${CMAKE_BINARY_DIR}/sdbusplus-src BINARY_DIR 60 ${CMAKE_BINARY_DIR}/sdbusplus-build CONFIGURE_COMMAND 61 "" BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/sdbusplus-src 62 && meson build -Ddefault_library=static && ninja -C 63 build libsdbusplus.a INSTALL_COMMAND "" 64 LOG_DOWNLOAD ON) 65 66 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src) 67 link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/build) 68 69 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/boost-src) 70 set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/boost-src ${CMAKE_PREFIX_PATH}) 71 72 option (HUNTER_ENABLED "Enable hunter package pulling" ON) 73 hunter_add_package (GTest) 74 75 find_package (GTest CONFIG REQUIRED) 76endif () 77 78add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) 79add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) 80add_definitions (-DBOOST_ALL_NO_LIB) 81add_definitions (-DBOOST_NO_RTTI) 82add_definitions (-DBOOST_NO_TYPEID) 83add_definitions (-DBOOST_ASIO_DISABLE_THREADS) 84 85include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) 86 87add_executable (hsbp-manager src/hsbp_manager.cpp) 88 89target_link_libraries (hsbp-manager -lsystemd) 90target_link_libraries (hsbp-manager i2c) 91target_link_libraries (hsbp-manager ${Boost_LIBRARIES}) 92target_link_libraries (hsbp-manager sdbusplus) 93target_link_libraries (hsbp-manager stdc++fs) 94target_link_libraries (hsbp-manager gpiodcxx) 95 96if (NOT YOCTO) 97 add_dependencies (hsbp-manager sdbusplus-project) 98endif () 99 100set (SERVICE_FILES ${PROJECT_SOURCE_DIR}/service_files/hsbp-manager.service) 101 102install (TARGETS hsbp-manager DESTINATION bin) 103install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) 104