Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.6) |
| 2 | project(libpeci) |
| 3 | |
| 4 | add_library(peci SHARED peci.c) |
Brad Bishop | 05edc22 | 2022-12-07 10:56:58 -0500 | [diff] [blame] | 5 | configure_file(peci.pc.in peci.pc @ONLY) |
| 6 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/peci.pc DESTINATION lib/pkgconfig) |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 7 | |
Vernon Mauery | 380998b | 2022-09-29 14:02:25 -0700 | [diff] [blame] | 8 | set(CMAKE_CXX_STANDARD 20) |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 9 | set_property(TARGET peci PROPERTY C_STANDARD 99) |
| 10 | target_include_directories(peci PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) |
| 11 | set_target_properties(peci PROPERTIES VERSION "1.0" SOVERSION "1") |
| 12 | |
Jason M. Bills | bdefaa3 | 2021-11-12 14:09:20 -0800 | [diff] [blame] | 13 | option(DBUS_RAW_PECI "Add the raw PECI D-Bus daemon to the build." OFF) |
| 14 | |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 15 | set( |
| 16 | CMAKE_C_FLAGS |
| 17 | "${CMAKE_C_FLAGS} \ |
Ed Tanous | b78d4c8 | 2022-09-19 15:21:56 -0700 | [diff] [blame] | 18 | -Wall \ |
| 19 | -Wextra \ |
| 20 | -Wcast-align \ |
| 21 | -Wunused \ |
| 22 | -Wconversion \ |
| 23 | -Wsign-conversion \ |
| 24 | -Wnull-dereference \ |
| 25 | -Wdouble-promotion \ |
| 26 | -Wformat=2 \ |
| 27 | -Wno-unused-parameter \ |
| 28 | -Werror \ |
| 29 | -Wduplicated-cond \ |
| 30 | -Wduplicated-branches \ |
| 31 | -Wlogical-op \ |
| 32 | ") |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 33 | |
| 34 | install(TARGETS peci DESTINATION lib) |
| 35 | install(FILES peci.h DESTINATION include) |
| 36 | |
| 37 | add_executable(peci_cmds peci_cmds.c) |
| 38 | add_dependencies(peci_cmds peci) |
| 39 | target_link_libraries(peci_cmds peci) |
| 40 | |
| 41 | install(TARGETS peci_cmds |
| 42 | RUNTIME DESTINATION bin |
| 43 | LIBRARY DESTINATION lib |
| 44 | ARCHIVE DESTINATION lib/static) |
Jason M. Bills | bdefaa3 | 2021-11-12 14:09:20 -0800 | [diff] [blame] | 45 | |
| 46 | if(${DBUS_RAW_PECI}) |
Ed Tanous | b78d4c8 | 2022-09-19 15:21:56 -0700 | [diff] [blame] | 47 | set( |
| 48 | CMAKE_CXX_FLAGS |
| 49 | "${CMAKE_CXX_FLAGS} \ |
| 50 | -Wall \ |
| 51 | -Wextra \ |
| 52 | -Wcast-align \ |
| 53 | -Wunused \ |
| 54 | -Wconversion \ |
| 55 | -Wsign-conversion \ |
| 56 | -Wdouble-promotion \ |
| 57 | -Wformat=2 \ |
| 58 | -Wno-unused-parameter \ |
| 59 | -Werror \ |
| 60 | -Wduplicated-cond \ |
| 61 | -Wduplicated-branches \ |
| 62 | -Wlogical-op \ |
| 63 | -Wno-psabi \ |
| 64 | -fno-rtti \ |
| 65 | ") |
| 66 | # This flag doesn't compile, but should be debuged in a future patchset |
| 67 | #-Wnull-dereference \ |
| 68 | |
Jason M. Bills | bdefaa3 | 2021-11-12 14:09:20 -0800 | [diff] [blame] | 69 | add_executable(raw-peci dbus_raw_peci.cpp) |
| 70 | add_dependencies(raw-peci peci) |
| 71 | |
| 72 | find_package(Boost 1.73 REQUIRED) |
| 73 | include_directories(${BOOST_SRC_DIR}) |
| 74 | |
| 75 | add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY) |
| 76 | add_definitions(-DBOOST_SYSTEM_NO_DEPRECATED) |
| 77 | add_definitions(-DBOOST_ALL_NO_LIB) |
| 78 | add_definitions(-DBOOST_NO_RTTI) |
| 79 | add_definitions(-DBOOST_NO_TYPEID) |
Ed Tanous | b78d4c8 | 2022-09-19 15:21:56 -0700 | [diff] [blame] | 80 | add_definitions(-DBOOST_EXCEPTION_DISABLE) |
| 81 | add_definitions(-DBOOST_ASIO_DISABLE_THREADS) |
| 82 | add_definitions(-DBOOST_ASIO_NO_DEPRECATED) |
Jason M. Bills | bdefaa3 | 2021-11-12 14:09:20 -0800 | [diff] [blame] | 83 | |
| 84 | target_link_libraries(raw-peci peci -lsystemd sdbusplus) |
| 85 | |
| 86 | install(TARGETS raw-peci |
| 87 | RUNTIME DESTINATION bin |
| 88 | LIBRARY DESTINATION lib |
| 89 | ARCHIVE DESTINATION lib/static) |
| 90 | |
| 91 | set(SERVICE_FILES ${PROJECT_SOURCE_DIR}/service_files/com.intel.peci.service) |
| 92 | |
| 93 | install(FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) |
Ed Tanous | b78d4c8 | 2022-09-19 15:21:56 -0700 | [diff] [blame] | 94 | endif() |
Brad Bishop | 05edc22 | 2022-12-07 10:56:58 -0500 | [diff] [blame] | 95 | |