James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.1 FATAL_ERROR) |
| 2 | SET(BUILD_SHARED_LIBRARIES OFF) |
| 3 | include(ExternalProject) |
| 4 | set(CMAKE_CXX_STANDARD 14) |
| 5 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lstdc++fs") |
| 7 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
| 8 | |
| 9 | option(HUNTER_ENABLED "Enable hunter package pulling" OFF) |
| 10 | include("cmake/HunterGate.cmake") |
| 11 | |
| 12 | HunterGate( |
| 13 | URL "https://github.com/ruslo/hunter/archive/v0.18.64.tar.gz" |
| 14 | SHA1 "baf9c8cc4f65306f0e442b5419967b4c4c04589a" |
| 15 | ) |
| 16 | |
| 17 | project(enitity-manager) |
| 18 | |
| 19 | hunter_add_package(Boost) |
| 20 | find_package(Boost REQUIRED) |
| 21 | include_directories(${Boost_INCLUDE_DIRS}) |
| 22 | |
| 23 | add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY) |
| 24 | add_definitions(-DBOOST_SYSTEM_NO_DEPRECATED) |
| 25 | add_definitions(-DBOOST_ALL_NO_LIB) |
| 26 | add_definitions(-DBOOST_NO_RTTI) |
| 27 | add_definitions(-DBOOST_NO_TYPEID) |
| 28 | |
| 29 | hunter_add_package(dbus) |
| 30 | find_package(dbus REQUIRED) # Include functions provided by PkgConfig module. |
| 31 | include_directories(${DBUS_INCLUDE_DIRS}) |
| 32 | |
| 33 | find_package(Threads REQUIRED) |
| 34 | |
| 35 | option(YOCTO "Enable Building in Yocto" OFF) |
| 36 | |
| 37 | if(NOT YOCTO) |
| 38 | ExternalProject_Add(boost-dbus |
| 39 | PREFIX ${CMAKE_CURRENT_BINARY_DIR}/boost-dbus |
| 40 | GIT_REPOSITORY ssh://git-amr-2.devtools.intel.com:29418/openbmc-boost-dbus |
James Feist | 1b2e224 | 2018-01-30 13:45:19 -0800 | [diff] [blame] | 41 | GIT_TAG e7dae9ce93226e6a7bf3d9101f457d29afac40c2 |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 42 | CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} -DBOOST_ROOT=${BOOST_ROOT} |
| 43 | CONFIGURE_COMMAND "" |
| 44 | BUILD_COMMAND "" |
| 45 | INSTALL_COMMAND "" |
| 46 | LOG_DOWNLOAD ON |
| 47 | ) |
| 48 | ExternalProject_Get_Property(boost-dbus install_dir) |
| 49 | include_directories(${install_dir}/src/boost-dbus/include) |
| 50 | |
| 51 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/non-yocto) |
| 52 | |
| 53 | ExternalProject_Add(nlohmann-json |
| 54 | PREFIX ${CMAKE_CURRENT_BINARY_DIR}/nlohmann-json |
| 55 | GIT_REPOSITORY https://github.com/nlohmann/json.git |
| 56 | GIT_TAG afebb6a3bbc8751e834a5472e5c53cb2b5bbd750 |
| 57 | CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} |
| 58 | CONFIGURE_COMMAND "" |
| 59 | BUILD_COMMAND mkdir -p |
| 60 | ${CMAKE_CURRENT_BINARY_DIR}/nlohmann-json/src/nlohmann-json/src/nlohmann && |
| 61 | cp ${CMAKE_CURRENT_BINARY_DIR}/nlohmann-json/src/nlohmann-json/src/json.hpp |
| 62 | ${CMAKE_CURRENT_BINARY_DIR}/nlohmann-json/src/nlohmann-json/src/nlohmann/json.hpp |
| 63 | INSTALL_COMMAND "" |
| 64 | LOG_DOWNLOAD ON |
| 65 | ) |
| 66 | |
| 67 | ExternalProject_Get_Property(nlohmann-json install_dir) |
| 68 | include_directories(${install_dir}/src/nlohmann-json/src) |
| 69 | |
| 70 | option(ENABLE_TEST "Enable Google Test" OFF) |
| 71 | if(ENABLE_TEST) |
| 72 | hunter_add_package(GTest) |
| 73 | find_package(GTest CONFIG REQUIRED) |
| 74 | enable_testing() |
| 75 | endif() |
| 76 | endif() |
| 77 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 78 | |
| 79 | link_directories(${EXTERNAL_INSTALL_LOCATION}/lib) |
| 80 | |
| 81 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 82 | |
| 83 | add_executable(fru-device src/FruDevice.cpp src/Utils.cpp) |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 84 | |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 85 | target_link_libraries(fru-device ${DBUS_LIBRARIES}) |
| 86 | target_link_libraries(fru-device pthread) |
| 87 | target_link_libraries(fru-device stdc++fs) |
| 88 | target_link_libraries(fru-device ${Boost_LIBRARIES}) |
| 89 | |
James Feist | c95cb14 | 2018-02-26 10:41:42 -0800 | [diff] [blame^] | 90 | add_executable(entity-manager src/EntityManager.cpp |
| 91 | src/Overlay.cpp |
| 92 | src/Utils.cpp) |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 93 | |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 94 | target_link_libraries(entity-manager ${DBUS_LIBRARIES}) |
| 95 | target_link_libraries(entity-manager pthread) |
| 96 | target_link_libraries(entity-manager stdc++fs) |
| 97 | target_link_libraries(entity-manager ${Boost_LIBRARIES}) |
| 98 | |
James Feist | b5320a7 | 2018-01-24 12:28:12 -0800 | [diff] [blame] | 99 | if(NOT YOCTO) |
| 100 | add_dependencies(entity-manager nlohmann-json) |
| 101 | add_dependencies(entity-manager boost-dbus) |
| 102 | add_dependencies(fru-device boost-dbus) |
| 103 | endif() |
| 104 | |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 105 | install (TARGETS fru-device entity-manager DESTINATION bin) |