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 | |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 29 | option(YOCTO "Enable Building in Yocto" OFF) |
| 30 | |
| 31 | if(NOT YOCTO) |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 32 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/non-yocto) |
| 33 | |
| 34 | ExternalProject_Add(nlohmann-json |
| 35 | PREFIX ${CMAKE_CURRENT_BINARY_DIR}/nlohmann-json |
| 36 | GIT_REPOSITORY https://github.com/nlohmann/json.git |
| 37 | GIT_TAG afebb6a3bbc8751e834a5472e5c53cb2b5bbd750 |
| 38 | CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} |
| 39 | CONFIGURE_COMMAND "" |
| 40 | BUILD_COMMAND mkdir -p |
| 41 | ${CMAKE_CURRENT_BINARY_DIR}/nlohmann-json/src/nlohmann-json/src/nlohmann && |
| 42 | cp ${CMAKE_CURRENT_BINARY_DIR}/nlohmann-json/src/nlohmann-json/src/json.hpp |
| 43 | ${CMAKE_CURRENT_BINARY_DIR}/nlohmann-json/src/nlohmann-json/src/nlohmann/json.hpp |
| 44 | INSTALL_COMMAND "" |
| 45 | LOG_DOWNLOAD ON |
| 46 | ) |
| 47 | |
| 48 | ExternalProject_Get_Property(nlohmann-json install_dir) |
| 49 | include_directories(${install_dir}/src/nlohmann-json/src) |
| 50 | |
James Feist | 9eb0b58 | 2018-04-27 12:15:46 -0700 | [diff] [blame] | 51 | ExternalProject_Add(sdbusplus |
| 52 | PREFIX ${CMAKE_CURRENT_BINARY_DIR}/sdbusplus |
| 53 | GIT_REPOSITORY ssh://git-amr-2.devtools.intel.com:29418/sdbusplus |
| 54 | CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} -DBOOST_ROOT=${BOOST_ROOT} |
| 55 | CONFIGURE_COMMAND "" |
| 56 | BUILD_COMMAND "" |
| 57 | INSTALL_COMMAND "" |
| 58 | LOG_DOWNLOAD ON |
| 59 | ) |
| 60 | set(WANT_TRANSACTION 0) |
| 61 | configure_file(${CMAKE_BINARY_DIR}/sdbusplus-src/sdbusplus/server.hpp.in |
| 62 | ${CMAKE_BINARY_DIR}/prefix/include/sdbusplus/server.hpp @ONLY) |
| 63 | configure_file(${CMAKE_BINARY_DIR}/sdbusplus-src/sdbusplus/bus.hpp.in |
| 64 | ${CMAKE_BINARY_DIR}/prefix/include/sdbusplus/bus.hpp @ONLY) |
| 65 | |
| 66 | ExternalProject_Get_Property(sdbusplus install_dir) |
| 67 | include_directories(${install_dir}/src/sdbusplus/include) |
| 68 | |
| 69 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/non-yocto) |
| 70 | |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 71 | option(ENABLE_TEST "Enable Google Test" OFF) |
| 72 | if(ENABLE_TEST) |
| 73 | hunter_add_package(GTest) |
| 74 | find_package(GTest CONFIG REQUIRED) |
| 75 | enable_testing() |
| 76 | endif() |
| 77 | endif() |
| 78 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 79 | |
| 80 | link_directories(${EXTERNAL_INSTALL_LOCATION}/lib) |
| 81 | |
| 82 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 83 | |
| 84 | add_executable(fru-device src/FruDevice.cpp src/Utils.cpp) |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 85 | |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 86 | target_link_libraries(fru-device pthread) |
| 87 | target_link_libraries(fru-device stdc++fs) |
| 88 | target_link_libraries(fru-device ${Boost_LIBRARIES}) |
James Feist | 9eb0b58 | 2018-04-27 12:15:46 -0700 | [diff] [blame] | 89 | target_link_libraries(fru-device -lsystemd) |
James Feist | 2a9d6db | 2018-04-27 15:48:28 -0700 | [diff] [blame] | 90 | target_link_libraries(fru-device phosphor_dbus) |
James Feist | c24899c | 2018-06-04 11:26:12 -0700 | [diff] [blame] | 91 | target_link_libraries(fru-device sdbusplus) |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 92 | |
James Feist | c95cb14 | 2018-02-26 10:41:42 -0800 | [diff] [blame] | 93 | add_executable(entity-manager src/EntityManager.cpp |
| 94 | src/Overlay.cpp |
| 95 | src/Utils.cpp) |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 96 | |
James Feist | 8f2710a | 2018-05-09 17:18:55 -0700 | [diff] [blame] | 97 | target_link_libraries(entity-manager -lsystemd) |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 98 | target_link_libraries(entity-manager pthread) |
| 99 | target_link_libraries(entity-manager stdc++fs) |
| 100 | target_link_libraries(entity-manager ${Boost_LIBRARIES}) |
James Feist | c24899c | 2018-06-04 11:26:12 -0700 | [diff] [blame] | 101 | target_link_libraries(entity-manager sdbusplus) |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 102 | |
James Feist | b5320a7 | 2018-01-24 12:28:12 -0800 | [diff] [blame] | 103 | if(NOT YOCTO) |
| 104 | add_dependencies(entity-manager nlohmann-json) |
James Feist | 9eb0b58 | 2018-04-27 12:15:46 -0700 | [diff] [blame] | 105 | add_dependencies(fru-device sdbusplus) |
James Feist | b5320a7 | 2018-01-24 12:28:12 -0800 | [diff] [blame] | 106 | endif() |
| 107 | |
James Feist | 3cb5fec | 2018-01-23 14:41:51 -0800 | [diff] [blame] | 108 | install (TARGETS fru-device entity-manager DESTINATION bin) |
James Feist | a7d9625 | 2018-08-09 12:04:48 -0700 | [diff] [blame] | 109 | install (DIRECTORY configurations DESTINATION share) |
| 110 | install (DIRECTORY overlay_templates DESTINATION share) |
| 111 | # install (DIRECTORY schemas DESTINATION share/configurations) |