blob: ae4d5e4af719c1520432069141d3a87dbbcfd1c8 [file] [log] [blame]
James Feist03a02ad2019-02-06 12:38:50 -08001cmake_minimum_required (VERSION 3.1 FATAL_ERROR)
2set (BUILD_SHARED_LIBRARIES OFF)
3include (ExternalProject)
Patrick Williamsffcaad82022-09-01 15:09:18 -05004set (CMAKE_CXX_STANDARD 20)
James Feist03a02ad2019-02-06 12:38:50 -08005set (CMAKE_CXX_STANDARD_REQUIRED ON)
6set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
7set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
8set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti")
9
10option (YOCTO "Enable Building in Yocto" OFF)
11
12if (NOT YOCTO)
13 externalproject_add (
14 Boost URL
Patrick Williams9dc4abd2020-06-01 10:20:22 -050015 https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.gz
16 URL_MD5 5f521b41b79bf8616582c4a8a2c10177 SOURCE_DIR
James Feist03a02ad2019-02-06 12:38:50 -080017 "${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 Williams6fc0ed72022-07-25 06:58:53 -050025 8a97100b806225df40c490eb748c9a4e1b3c11b3 SOURCE_DIR
James Feist03a02ad2019-02-06 12:38:50 -080026 ${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 Williams0d26db32020-06-01 07:45:28 -050029 && meson build -Ddefault_library=static && ninja -C
30 build libsdbusplus.a INSTALL_COMMAND ""
James Feist03a02ad2019-02-06 12:38:50 -080031 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 Williams0d26db32020-06-01 07:45:28 -050037 link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/build)
James Feist03a02ad2019-02-06 12:38:50 -080038
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 ()
47endif ()
48
49add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY)
50add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED)
51add_definitions (-DBOOST_ALL_NO_LIB)
52add_definitions (-DBOOST_NO_RTTI)
53add_definitions (-DBOOST_NO_TYPEID)
54add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
55
56include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
57include_directories (${Boost_INCLUDE_DIRS})
58include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
59
60add_executable (callback-manager src/callback_manager.cpp)
61
62target_link_libraries (callback-manager -lsystemd)
63target_link_libraries (callback-manager stdc++fs)
64target_link_libraries (callback-manager ${Boost_LIBRARIES})
65target_link_libraries (callback-manager sdbusplus)
66
67if (NOT YOCTO)
68 add_dependencies (callback-manager sdbusplus-project)
69endif ()
70
71set (SERVICE_FILES ${PROJECT_SOURCE_DIR}/service_files/callback-manager.service)
72
73install (TARGETS callback-manager DESTINATION sbin)
74install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)