Feist, James | c95cf67 | 2019-08-29 16:10:35 -0700 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 3.1 FATAL_ERROR) |
| 2 | set (BUILD_SHARED_LIBRARIES OFF) |
| 3 | include (ExternalProject) |
| 4 | set (CMAKE_CXX_STANDARD 17) |
| 5 | set (CMAKE_CXX_STANDARD_REQUIRED ON) |
| 6 | set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
| 7 | if (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") |
| 11 | endif () |
| 12 | |
| 13 | project (hsbp-manager CXX) |
| 14 | |
| 15 | set ( |
| 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 \ |
Jason M. Bills | a83c827 | 2020-12-09 12:16:34 -0800 | [diff] [blame] | 37 | " |
Feist, James | c95cf67 | 2019-08-29 16:10:35 -0700 | [diff] [blame] | 38 | ) |
Jason M. Bills | a83c827 | 2020-12-09 12:16:34 -0800 | [diff] [blame] | 39 | # Temporarily disable rtti |
| 40 | # See https://github.com/chriskohlhoff/asio/issues/533 |
| 41 | # -fno-rtti |
Feist, James | c95cf67 | 2019-08-29 16:10:35 -0700 | [diff] [blame] | 42 | |
| 43 | option (YOCTO "Enable Building in Yocto" OFF) |
| 44 | |
| 45 | if (NOT YOCTO) |
| 46 | externalproject_add ( |
| 47 | Boost URL |
Rohit Chandel | dad853a | 2021-05-14 02:10:46 +0530 | [diff] [blame] | 48 | https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz |
| 49 | URL_MD5 e425bf1f1d8c36a3cd464884e74f007a SOURCE_DIR |
Feist, James | c95cf67 | 2019-08-29 16:10:35 -0700 | [diff] [blame] | 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 |
Patrick Williams | 0d26db3 | 2020-06-01 07:45:28 -0500 | [diff] [blame] | 58 | fa3137a78e952134559bf7c41c4f29fa4afabe02 SOURCE_DIR |
Feist, James | c95cf67 | 2019-08-29 16:10:35 -0700 | [diff] [blame] | 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 |
Patrick Williams | 0d26db3 | 2020-06-01 07:45:28 -0500 | [diff] [blame] | 62 | && meson build -Ddefault_library=static && ninja -C |
| 63 | build libsdbusplus.a INSTALL_COMMAND "" |
Feist, James | c95cf67 | 2019-08-29 16:10:35 -0700 | [diff] [blame] | 64 | LOG_DOWNLOAD ON) |
| 65 | |
| 66 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src) |
Patrick Williams | 0d26db3 | 2020-06-01 07:45:28 -0500 | [diff] [blame] | 67 | link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/build) |
Feist, James | c95cf67 | 2019-08-29 16:10:35 -0700 | [diff] [blame] | 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) |
| 76 | endif () |
| 77 | |
| 78 | add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) |
| 79 | add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) |
| 80 | add_definitions (-DBOOST_ALL_NO_LIB) |
| 81 | add_definitions (-DBOOST_NO_RTTI) |
| 82 | add_definitions (-DBOOST_NO_TYPEID) |
| 83 | add_definitions (-DBOOST_ASIO_DISABLE_THREADS) |
| 84 | |
| 85 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 86 | |
| 87 | add_executable (hsbp-manager src/hsbp_manager.cpp) |
| 88 | |
| 89 | target_link_libraries (hsbp-manager -lsystemd) |
| 90 | target_link_libraries (hsbp-manager i2c) |
| 91 | target_link_libraries (hsbp-manager ${Boost_LIBRARIES}) |
| 92 | target_link_libraries (hsbp-manager sdbusplus) |
James Feist | 0b236ab | 2019-10-02 09:09:16 -0700 | [diff] [blame] | 93 | target_link_libraries (hsbp-manager stdc++fs) |
Rohit Chandel | 52639be | 2021-04-14 15:10:41 +0530 | [diff] [blame] | 94 | target_link_libraries (hsbp-manager gpiodcxx) |
Feist, James | c95cf67 | 2019-08-29 16:10:35 -0700 | [diff] [blame] | 95 | |
| 96 | if (NOT YOCTO) |
| 97 | add_dependencies (hsbp-manager sdbusplus-project) |
| 98 | endif () |
| 99 | |
| 100 | set (SERVICE_FILES ${PROJECT_SOURCE_DIR}/service_files/hsbp-manager.service) |
| 101 | |
| 102 | install (TARGETS hsbp-manager DESTINATION bin) |
| 103 | install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) |