blob: ee485779d63d10ba0dc914dccf42dd9f87be91bf [file] [log] [blame]
Jason M. Bills7ef5a552020-04-06 14:58:44 -07001cmake_minimum_required(VERSION 3.6)
2project(libpeci)
3
4add_library(peci SHARED peci.c)
Brad Bishop05edc222022-12-07 10:56:58 -05005configure_file(peci.pc.in peci.pc @ONLY)
6install(FILES ${CMAKE_CURRENT_BINARY_DIR}/peci.pc DESTINATION lib/pkgconfig)
Jason M. Bills7ef5a552020-04-06 14:58:44 -07007
Vernon Mauery380998b2022-09-29 14:02:25 -07008set(CMAKE_CXX_STANDARD 20)
Jason M. Bills7ef5a552020-04-06 14:58:44 -07009set_property(TARGET peci PROPERTY C_STANDARD 99)
10target_include_directories(peci PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
11set_target_properties(peci PROPERTIES VERSION "1.0" SOVERSION "1")
12
Jason M. Billsbdefaa32021-11-12 14:09:20 -080013option(DBUS_RAW_PECI "Add the raw PECI D-Bus daemon to the build." OFF)
14
Jason M. Bills7ef5a552020-04-06 14:58:44 -070015set(
16 CMAKE_C_FLAGS
17 "${CMAKE_C_FLAGS} \
Ed Tanousb78d4c82022-09-19 15:21:56 -070018 -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. Bills7ef5a552020-04-06 14:58:44 -070033
34install(TARGETS peci DESTINATION lib)
35install(FILES peci.h DESTINATION include)
36
37add_executable(peci_cmds peci_cmds.c)
38add_dependencies(peci_cmds peci)
39target_link_libraries(peci_cmds peci)
40
41install(TARGETS peci_cmds
42 RUNTIME DESTINATION bin
43 LIBRARY DESTINATION lib
44 ARCHIVE DESTINATION lib/static)
Jason M. Billsbdefaa32021-11-12 14:09:20 -080045
46if(${DBUS_RAW_PECI})
Ed Tanousb78d4c82022-09-19 15:21:56 -070047 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. Billsbdefaa32021-11-12 14:09:20 -080069 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 Tanousb78d4c82022-09-19 15:21:56 -070080 add_definitions(-DBOOST_EXCEPTION_DISABLE)
81 add_definitions(-DBOOST_ASIO_DISABLE_THREADS)
82 add_definitions(-DBOOST_ASIO_NO_DEPRECATED)
Jason M. Billsbdefaa32021-11-12 14:09:20 -080083
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 Tanousb78d4c82022-09-19 15:21:56 -070094endif()
Brad Bishop05edc222022-12-07 10:56:58 -050095