103a02ad0SJames Feistcmake_minimum_required (VERSION 3.1 FATAL_ERROR) 203a02ad0SJames Feistset (BUILD_SHARED_LIBRARIES OFF) 303a02ad0SJames Feistinclude (ExternalProject) 403a02ad0SJames Feistset (CMAKE_CXX_STANDARD 17) 503a02ad0SJames Feistset (CMAKE_CXX_STANDARD_REQUIRED ON) 603a02ad0SJames Feistset (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) 703a02ad0SJames Feistset (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") 803a02ad0SJames Feistset (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti") 903a02ad0SJames Feist 1003a02ad0SJames Feistoption (YOCTO "Enable Building in Yocto" OFF) 1103a02ad0SJames Feist 1203a02ad0SJames Feistif (NOT YOCTO) 1303a02ad0SJames Feist externalproject_add ( 1403a02ad0SJames Feist Boost URL 159dc4abd5SPatrick Williams https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.gz 169dc4abd5SPatrick Williams URL_MD5 5f521b41b79bf8616582c4a8a2c10177 SOURCE_DIR 1703a02ad0SJames Feist "${CMAKE_BINARY_DIR}/boost-src" BINARY_DIR 1803a02ad0SJames Feist "${CMAKE_BINARY_DIR}/boost-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" 1903a02ad0SJames Feist INSTALL_COMMAND mkdir -p "${CMAKE_BINARY_DIR}/prefix/include/" && cp -R 2003a02ad0SJames Feist ${CMAKE_BINARY_DIR}/boost-src/boost ${CMAKE_BINARY_DIR}/prefix/include 2103a02ad0SJames Feist ) # requires apt install autoconf-archive and autoconf 2203a02ad0SJames Feist externalproject_add (sdbusplus-project PREFIX 2303a02ad0SJames Feist ${CMAKE_BINARY_DIR}/sdbusplus-project GIT_REPOSITORY 2403a02ad0SJames Feist https://github.com/openbmc/sdbusplus.git GIT_TAG 25*0d26db38SPatrick Williams fa3137a78e952134559bf7c41c4f29fa4afabe02 SOURCE_DIR 2603a02ad0SJames Feist ${CMAKE_BINARY_DIR}/sdbusplus-src BINARY_DIR 2703a02ad0SJames Feist ${CMAKE_BINARY_DIR}/sdbusplus-build CONFIGURE_COMMAND 2803a02ad0SJames Feist "" BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/sdbusplus-src 29*0d26db38SPatrick Williams && meson build -Ddefault_library=static && ninja -C 30*0d26db38SPatrick Williams build libsdbusplus.a INSTALL_COMMAND "" 3103a02ad0SJames Feist LOG_DOWNLOAD ON) 3203a02ad0SJames Feist 3303a02ad0SJames Feist include_directories (${CMAKE_BINARY_DIR}/sdbusplus-src) 3403a02ad0SJames Feist include_directories (${CMAKE_BINARY_DIR}/nlohmann/include) 3503a02ad0SJames Feist include_directories (${CMAKE_BINARY_DIR}/nlohmann/include/nlohmann) 3603a02ad0SJames Feist include_directories (${CMAKE_BINARY_DIR}/phosphor-dbus-interfaces/include) 37*0d26db38SPatrick Williams link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/build) 3803a02ad0SJames Feist 3903a02ad0SJames Feist include_directories (${CMAKE_BINARY_DIR}/boost-src) 4003a02ad0SJames Feist set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/boost-src ${CMAKE_PREFIX_PATH}) 4103a02ad0SJames Feist option (ENABLE_TEST "Enable Google Test" OFF) 4203a02ad0SJames Feist if (ENABLE_TEST) 4303a02ad0SJames Feist hunter_add_package (GTest) 4403a02ad0SJames Feist find_package (GTest CONFIG REQUIRED) 4503a02ad0SJames Feist enable_testing () 4603a02ad0SJames Feist endif () 4703a02ad0SJames Feistendif () 4803a02ad0SJames Feist 4903a02ad0SJames Feistadd_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) 5003a02ad0SJames Feistadd_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) 5103a02ad0SJames Feistadd_definitions (-DBOOST_ALL_NO_LIB) 5203a02ad0SJames Feistadd_definitions (-DBOOST_NO_RTTI) 5303a02ad0SJames Feistadd_definitions (-DBOOST_NO_TYPEID) 5403a02ad0SJames Feistadd_definitions (-DBOOST_ASIO_DISABLE_THREADS) 5503a02ad0SJames Feist 5603a02ad0SJames Feistinclude_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) 5703a02ad0SJames Feistinclude_directories (${Boost_INCLUDE_DIRS}) 5803a02ad0SJames Feistinclude_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) 5903a02ad0SJames Feist 6003a02ad0SJames Feistadd_executable (callback-manager src/callback_manager.cpp) 6103a02ad0SJames Feist 6203a02ad0SJames Feisttarget_link_libraries (callback-manager -lsystemd) 6303a02ad0SJames Feisttarget_link_libraries (callback-manager stdc++fs) 6403a02ad0SJames Feisttarget_link_libraries (callback-manager ${Boost_LIBRARIES}) 6503a02ad0SJames Feisttarget_link_libraries (callback-manager sdbusplus) 6603a02ad0SJames Feist 6703a02ad0SJames Feistif (NOT YOCTO) 6803a02ad0SJames Feist add_dependencies (callback-manager sdbusplus-project) 6903a02ad0SJames Feistendif () 7003a02ad0SJames Feist 7103a02ad0SJames Feistset (SERVICE_FILES ${PROJECT_SOURCE_DIR}/service_files/callback-manager.service) 7203a02ad0SJames Feist 7303a02ad0SJames Feistinstall (TARGETS callback-manager DESTINATION sbin) 7403a02ad0SJames Feistinstall (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) 75