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