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) 6 7project (hsbp-manager CXX) 8 9set ( 10 CMAKE_CXX_FLAGS 11 "${CMAKE_CXX_FLAGS} -lstdc++fs \ 12 -Werror \ 13 -Wall \ 14 -Wextra \ 15 -Wshadow \ 16 -Wnon-virtual-dtor \ 17 -Wold-style-cast \ 18 -Wcast-align \ 19 -Wunused \ 20 -Woverloaded-virtual \ 21 -Wpedantic \ 22 -Wconversion \ 23 -Wmisleading-indentation \ 24 -Wduplicated-cond \ 25 -Wduplicated-branches \ 26 -Wlogical-op \ 27 -Wnull-dereference \ 28 -Wuseless-cast \ 29 -Wdouble-promotion \ 30 -Wformat=2 \ 31 -fno-rtti" 32) 33 34option (YOCTO "Enable Building in Yocto" OFF) 35 36if (NOT YOCTO) 37 externalproject_add ( 38 Boost URL 39 https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz 40 URL_MD5 e425bf1f1d8c36a3cd464884e74f007a SOURCE_DIR 41 "${CMAKE_BINARY_DIR}/boost-src" BINARY_DIR 42 "${CMAKE_BINARY_DIR}/boost-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" 43 INSTALL_COMMAND mkdir -p "${CMAKE_BINARY_DIR}/prefix/include/" && cp -R 44 ${CMAKE_BINARY_DIR}/boost-src/boost ${CMAKE_BINARY_DIR}/prefix/include 45 ) # requires apt install autoconf-archive and autoconf 46 externalproject_add (sdbusplus-project PREFIX 47 ${CMAKE_BINARY_DIR}/sdbusplus-project GIT_REPOSITORY 48 https://github.com/openbmc/sdbusplus.git GIT_TAG 49 8a97100b806225df40c490eb748c9a4e1b3c11b3 SOURCE_DIR 50 ${CMAKE_BINARY_DIR}/sdbusplus-src BINARY_DIR 51 ${CMAKE_BINARY_DIR}/sdbusplus-build CONFIGURE_COMMAND 52 "" BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/sdbusplus-src 53 && meson build -Ddefault_library=static && ninja -C 54 build libsdbusplus.a INSTALL_COMMAND "" 55 LOG_DOWNLOAD ON) 56 57 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src) 58 link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/build) 59 60 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/boost-src) 61 set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/boost-src ${CMAKE_PREFIX_PATH}) 62endif () 63 64add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) 65add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) 66add_definitions (-DBOOST_ALL_NO_LIB) 67add_definitions (-DBOOST_NO_RTTI) 68add_definitions (-DBOOST_NO_TYPEID) 69add_definitions (-DBOOST_ASIO_DISABLE_THREADS) 70 71include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) 72 73add_executable (hsbp-manager src/hsbp_manager.cpp) 74 75target_link_libraries (hsbp-manager -lsystemd) 76target_link_libraries (hsbp-manager i2c) 77target_link_libraries (hsbp-manager ${Boost_LIBRARIES}) 78target_link_libraries (hsbp-manager sdbusplus) 79target_link_libraries (hsbp-manager stdc++fs) 80target_link_libraries (hsbp-manager gpiodcxx) 81 82if (NOT YOCTO) 83 add_dependencies (hsbp-manager sdbusplus-project) 84endif () 85 86 87find_package (PkgConfig REQUIRED) 88pkg_get_variable(SYSTEMD_SYSTEM_UNIT_DIR systemd systemdsystemunitdir) 89 90set (SERVICE_FILES ${PROJECT_SOURCE_DIR}/service_files/hsbp-manager.service) 91 92install (TARGETS hsbp-manager DESTINATION bin) 93install (FILES ${SERVICE_FILES} DESTINATION "${SYSTEMD_SYSTEM_UNIT_DIR}") 94