Dawid Frycki | a642a94 | 2018-06-12 10:44:23 -0700 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 3.5 FATAL_ERROR) |
| 2 | project (ipmbbridged CXX) |
| 3 | set (CMAKE_CXX_STANDARD 17) |
| 4 | set (CMAKE_CXX_STANDARD_REQUIRED ON) |
| 5 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") |
| 6 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti") |
| 7 | |
| 8 | # check for necessary headers / download if missing |
| 9 | enable_language (C) |
| 10 | include (CheckIncludeFile) |
| 11 | check_include_file ("linux/i2c-dev-user.h" header_present) |
| 12 | if (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 () |
| 29 | endif () |
| 30 | |
| 31 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}) |
| 32 | find_package (Boost REQUIRED) |
| 33 | include_directories (${Boost_INCLUDE_DIRS}) |
| 34 | add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) |
| 35 | add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) |
| 36 | add_definitions (-DBOOST_ALL_NO_LIB) |
| 37 | add_definitions (-DBOOST_NO_RTTI) |
| 38 | add_definitions (-DBOOST_NO_TYPEID) |
| 39 | add_definitions (-DBOOST_ASIO_DISABLE_THREADS) |
| 40 | |
| 41 | set (SRC_FILES ipmbbridged.cpp ipmbutils.cpp) |
| 42 | |
| 43 | # import libsystemd |
| 44 | find_package (PkgConfig REQUIRED) |
| 45 | pkg_check_modules (SYSTEMD libsystemd REQUIRED) |
| 46 | |
| 47 | # import sdbusplus |
| 48 | find_package (PkgConfig REQUIRED) |
| 49 | pkg_check_modules (SDBUSPLUSPLUS sdbusplus REQUIRED) |
| 50 | |
| 51 | # import phosphor-logging |
| 52 | find_package (PkgConfig REQUIRED) |
| 53 | pkg_check_modules (LOGGING phosphor-logging REQUIRED) |
| 54 | |
| 55 | add_executable (${PROJECT_NAME} ${SRC_FILES}) |
| 56 | target_link_libraries (${PROJECT_NAME} systemd) |
| 57 | target_link_libraries (${PROJECT_NAME} boost_coroutine) |
| 58 | target_link_libraries (${PROJECT_NAME} sdbusplus -lstdc++fs) |
| 59 | target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES}) |
James Feist | 932870a | 2018-12-19 14:30:45 -0800 | [diff] [blame^] | 60 | target_link_libraries(${PROJECT_NAME} phosphor_logging) |
Dawid Frycki | a642a94 | 2018-06-12 10:44:23 -0700 | [diff] [blame] | 61 | |
| 62 | link_directories (${EXTERNAL_INSTALL_LOCATION}/lib) |
| 63 | |
| 64 | set (SERVICE_FILES ${PROJECT_SOURCE_DIR}/ipmb.service) |
| 65 | |
| 66 | install (TARGETS ${PROJECT_NAME} DESTINATION sbin) |
| 67 | install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) |