blob: 9752096daccd7ce29a179fb18d2bec58b9a10c36 [file] [log] [blame]
Dawid Fryckia642a942018-06-12 10:44:23 -07001cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
2project (ipmbbridged CXX)
3set (CMAKE_CXX_STANDARD 17)
4set (CMAKE_CXX_STANDARD_REQUIRED ON)
5set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
6set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti")
7
8# check for necessary headers / download if missing
9enable_language (C)
10include (CheckIncludeFile)
11check_include_file ("linux/i2c-dev-user.h" header_present)
12if (NOT header_present)
13 message (
14 "Could not find linux/i2c-dev-user.h: Attempting to download locally "
15 "for building from https://raw.githubusercontent.com/openbmc/linux/"
16 "dev-4.13/include/uapi/linux/i2c-dev.h"
17 )
18
19 string (CONCAT url "https://raw.githubusercontent.com/openbmc/linux/"
20 "dev-4.13/include/uapi/linux/i2c-dev.h")
21
22 file (DOWNLOAD ${url} "linux/i2c-dev-user.h" SHOW_PROGRESS STATUS status)
23
24 list (GET status 0 status_code)
25
26 if (NOT status_code EQUAL 0)
27 message (FATAL_ERROR "i2c-dev-user.h missing")
28 endif ()
29endif ()
30
31include_directories (${CMAKE_CURRENT_SOURCE_DIR})
32find_package (Boost REQUIRED)
33include_directories (${Boost_INCLUDE_DIRS})
34add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY)
35add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED)
36add_definitions (-DBOOST_ALL_NO_LIB)
37add_definitions (-DBOOST_NO_RTTI)
38add_definitions (-DBOOST_NO_TYPEID)
39add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
40
41set (SRC_FILES ipmbbridged.cpp ipmbutils.cpp)
42
43# import libsystemd
44find_package (PkgConfig REQUIRED)
45pkg_check_modules (SYSTEMD libsystemd REQUIRED)
46
47# import sdbusplus
48find_package (PkgConfig REQUIRED)
49pkg_check_modules (SDBUSPLUSPLUS sdbusplus REQUIRED)
50
51# import phosphor-logging
52find_package (PkgConfig REQUIRED)
53pkg_check_modules (LOGGING phosphor-logging REQUIRED)
54
55add_executable (${PROJECT_NAME} ${SRC_FILES})
56target_link_libraries (${PROJECT_NAME} systemd)
57target_link_libraries (${PROJECT_NAME} boost_coroutine)
58target_link_libraries (${PROJECT_NAME} sdbusplus -lstdc++fs)
59target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES})
James Feist932870a2018-12-19 14:30:45 -080060target_link_libraries(${PROJECT_NAME} phosphor_logging)
Dawid Fryckia642a942018-06-12 10:44:23 -070061
62link_directories (${EXTERNAL_INSTALL_LOCATION}/lib)
63
64set (SERVICE_FILES ${PROJECT_SOURCE_DIR}/ipmb.service)
65
66install (TARGETS ${PROJECT_NAME} DESTINATION sbin)
67install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)