| James Feist | 03a02ad | 2019-02-06 12:38:50 -0800 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 3.1 FATAL_ERROR) | 
 | 2 | set (BUILD_SHARED_LIBRARIES OFF) | 
 | 3 | include (ExternalProject) | 
| Patrick Williams | ffcaad8 | 2022-09-01 15:09:18 -0500 | [diff] [blame] | 4 | set (CMAKE_CXX_STANDARD 20) | 
| James Feist | 03a02ad | 2019-02-06 12:38:50 -0800 | [diff] [blame] | 5 | set (CMAKE_CXX_STANDARD_REQUIRED ON) | 
 | 6 | set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) | 
 | 7 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") | 
 | 8 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti") | 
 | 9 |  | 
 | 10 | option (YOCTO "Enable Building in Yocto" OFF) | 
 | 11 |  | 
 | 12 | if (NOT YOCTO) | 
 | 13 |     externalproject_add ( | 
 | 14 |         Boost URL | 
| Patrick Williams | 9dc4abd | 2020-06-01 10:20:22 -0500 | [diff] [blame] | 15 |         https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.gz | 
 | 16 |         URL_MD5 5f521b41b79bf8616582c4a8a2c10177 SOURCE_DIR | 
| James Feist | 03a02ad | 2019-02-06 12:38:50 -0800 | [diff] [blame] | 17 |         "${CMAKE_BINARY_DIR}/boost-src" BINARY_DIR | 
 | 18 |         "${CMAKE_BINARY_DIR}/boost-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" | 
 | 19 |         INSTALL_COMMAND mkdir -p "${CMAKE_BINARY_DIR}/prefix/include/" && cp -R | 
 | 20 |         ${CMAKE_BINARY_DIR}/boost-src/boost ${CMAKE_BINARY_DIR}/prefix/include | 
 | 21 |     ) # requires apt install autoconf-archive and autoconf | 
 | 22 |     externalproject_add (sdbusplus-project PREFIX | 
 | 23 |                          ${CMAKE_BINARY_DIR}/sdbusplus-project GIT_REPOSITORY | 
 | 24 |                          https://github.com/openbmc/sdbusplus.git GIT_TAG | 
| Patrick Williams | 6fc0ed7 | 2022-07-25 06:58:53 -0500 | [diff] [blame] | 25 |                          8a97100b806225df40c490eb748c9a4e1b3c11b3 SOURCE_DIR | 
| James Feist | 03a02ad | 2019-02-06 12:38:50 -0800 | [diff] [blame] | 26 |                          ${CMAKE_BINARY_DIR}/sdbusplus-src BINARY_DIR | 
 | 27 |                          ${CMAKE_BINARY_DIR}/sdbusplus-build CONFIGURE_COMMAND | 
 | 28 |                          "" BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/sdbusplus-src | 
| Patrick Williams | 0d26db3 | 2020-06-01 07:45:28 -0500 | [diff] [blame] | 29 |                          && meson build -Ddefault_library=static && ninja -C | 
 | 30 |                          build libsdbusplus.a INSTALL_COMMAND "" | 
| James Feist | 03a02ad | 2019-02-06 12:38:50 -0800 | [diff] [blame] | 31 |                          LOG_DOWNLOAD ON) | 
 | 32 |  | 
 | 33 |     include_directories (${CMAKE_BINARY_DIR}/sdbusplus-src) | 
 | 34 |     include_directories (${CMAKE_BINARY_DIR}/nlohmann/include) | 
 | 35 |     include_directories (${CMAKE_BINARY_DIR}/nlohmann/include/nlohmann) | 
 | 36 |     include_directories (${CMAKE_BINARY_DIR}/phosphor-dbus-interfaces/include) | 
| Patrick Williams | 0d26db3 | 2020-06-01 07:45:28 -0500 | [diff] [blame] | 37 |     link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/build) | 
| James Feist | 03a02ad | 2019-02-06 12:38:50 -0800 | [diff] [blame] | 38 |  | 
 | 39 |     include_directories (${CMAKE_BINARY_DIR}/boost-src) | 
 | 40 |     set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/boost-src ${CMAKE_PREFIX_PATH}) | 
 | 41 |     option (ENABLE_TEST "Enable Google Test" OFF) | 
 | 42 |     if (ENABLE_TEST) | 
 | 43 |         hunter_add_package (GTest) | 
 | 44 |         find_package (GTest CONFIG REQUIRED) | 
 | 45 |         enable_testing () | 
 | 46 |     endif () | 
 | 47 | endif () | 
 | 48 |  | 
 | 49 | add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) | 
 | 50 | add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) | 
 | 51 | add_definitions (-DBOOST_ALL_NO_LIB) | 
 | 52 | add_definitions (-DBOOST_NO_RTTI) | 
 | 53 | add_definitions (-DBOOST_NO_TYPEID) | 
 | 54 | add_definitions (-DBOOST_ASIO_DISABLE_THREADS) | 
 | 55 |  | 
 | 56 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) | 
 | 57 | include_directories (${Boost_INCLUDE_DIRS}) | 
 | 58 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) | 
 | 59 |  | 
 | 60 | add_executable (callback-manager src/callback_manager.cpp) | 
 | 61 |  | 
 | 62 | target_link_libraries (callback-manager -lsystemd) | 
 | 63 | target_link_libraries (callback-manager stdc++fs) | 
 | 64 | target_link_libraries (callback-manager ${Boost_LIBRARIES}) | 
 | 65 | target_link_libraries (callback-manager sdbusplus) | 
 | 66 |  | 
 | 67 | if (NOT YOCTO) | 
 | 68 |     add_dependencies (callback-manager sdbusplus-project) | 
 | 69 | endif () | 
 | 70 |  | 
 | 71 | set (SERVICE_FILES ${PROJECT_SOURCE_DIR}/service_files/callback-manager.service) | 
 | 72 |  | 
 | 73 | install (TARGETS callback-manager DESTINATION sbin) | 
 | 74 | install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) |