blob: b578ed2534cc8a4fc4f46680171d17563585097a [file] [log] [blame]
James Feist3cb5fec2018-01-23 14:41:51 -08001cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
2SET(BUILD_SHARED_LIBRARIES OFF)
3include(ExternalProject)
4set(CMAKE_CXX_STANDARD 14)
5set(CMAKE_CXX_STANDARD_REQUIRED ON)
6set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lstdc++fs")
7set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
8
9option(HUNTER_ENABLED "Enable hunter package pulling" OFF)
10include("cmake/HunterGate.cmake")
11
12HunterGate(
13 URL "https://github.com/ruslo/hunter/archive/v0.18.64.tar.gz"
14 SHA1 "baf9c8cc4f65306f0e442b5419967b4c4c04589a"
15)
16
17project(enitity-manager)
18
19hunter_add_package(Boost)
20find_package(Boost REQUIRED)
21include_directories(${Boost_INCLUDE_DIRS})
22
23add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
24add_definitions(-DBOOST_SYSTEM_NO_DEPRECATED)
25add_definitions(-DBOOST_ALL_NO_LIB)
26add_definitions(-DBOOST_NO_RTTI)
27add_definitions(-DBOOST_NO_TYPEID)
28
29hunter_add_package(dbus)
30find_package(dbus REQUIRED) # Include functions provided by PkgConfig module.
31include_directories(${DBUS_INCLUDE_DIRS})
32
33find_package(Threads REQUIRED)
34
35option(YOCTO "Enable Building in Yocto" OFF)
36
37if(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 Feist4131aea2018-03-09 09:47:30 -080041 GIT_TAG 216455021500e013a8d95a2d412ade31177353b7
James Feist3cb5fec2018-01-23 14:41:51 -080042 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()
76endif()
77include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
78
79link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
80
81include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
82
83add_executable(fru-device src/FruDevice.cpp src/Utils.cpp)
James Feist3cb5fec2018-01-23 14:41:51 -080084
James Feist3cb5fec2018-01-23 14:41:51 -080085target_link_libraries(fru-device ${DBUS_LIBRARIES})
86target_link_libraries(fru-device pthread)
87target_link_libraries(fru-device stdc++fs)
88target_link_libraries(fru-device ${Boost_LIBRARIES})
89
James Feistc95cb142018-02-26 10:41:42 -080090add_executable(entity-manager src/EntityManager.cpp
91 src/Overlay.cpp
92 src/Utils.cpp)
James Feist3cb5fec2018-01-23 14:41:51 -080093
James Feist3cb5fec2018-01-23 14:41:51 -080094target_link_libraries(entity-manager ${DBUS_LIBRARIES})
95target_link_libraries(entity-manager pthread)
96target_link_libraries(entity-manager stdc++fs)
97target_link_libraries(entity-manager ${Boost_LIBRARIES})
98
James Feistb5320a72018-01-24 12:28:12 -080099if(NOT YOCTO)
100 add_dependencies(entity-manager nlohmann-json)
101 add_dependencies(entity-manager boost-dbus)
102 add_dependencies(fru-device boost-dbus)
103endif()
104
James Feist3cb5fec2018-01-23 14:41:51 -0800105install (TARGETS fru-device entity-manager DESTINATION bin)