blob: cdf462295c7386321e0f6df66325a7fd8a30dae2 [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
James Feist9eb0b582018-04-27 12:15:46 -070070 ExternalProject_Add(sdbusplus
71 PREFIX ${CMAKE_CURRENT_BINARY_DIR}/sdbusplus
72 GIT_REPOSITORY ssh://git-amr-2.devtools.intel.com:29418/sdbusplus
73 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} -DBOOST_ROOT=${BOOST_ROOT}
74 CONFIGURE_COMMAND ""
75 BUILD_COMMAND ""
76 INSTALL_COMMAND ""
77 LOG_DOWNLOAD ON
78 )
79 set(WANT_TRANSACTION 0)
80 configure_file(${CMAKE_BINARY_DIR}/sdbusplus-src/sdbusplus/server.hpp.in
81 ${CMAKE_BINARY_DIR}/prefix/include/sdbusplus/server.hpp @ONLY)
82 configure_file(${CMAKE_BINARY_DIR}/sdbusplus-src/sdbusplus/bus.hpp.in
83 ${CMAKE_BINARY_DIR}/prefix/include/sdbusplus/bus.hpp @ONLY)
84
85 ExternalProject_Get_Property(sdbusplus install_dir)
86 include_directories(${install_dir}/src/sdbusplus/include)
87
88 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/non-yocto)
89
James Feist3cb5fec2018-01-23 14:41:51 -080090 option(ENABLE_TEST "Enable Google Test" OFF)
91 if(ENABLE_TEST)
92 hunter_add_package(GTest)
93 find_package(GTest CONFIG REQUIRED)
94 enable_testing()
95 endif()
96endif()
97include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
98
99link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
100
101include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
102
103add_executable(fru-device src/FruDevice.cpp src/Utils.cpp)
James Feist3cb5fec2018-01-23 14:41:51 -0800104
James Feist3cb5fec2018-01-23 14:41:51 -0800105target_link_libraries(fru-device pthread)
106target_link_libraries(fru-device stdc++fs)
107target_link_libraries(fru-device ${Boost_LIBRARIES})
James Feist9eb0b582018-04-27 12:15:46 -0700108target_link_libraries(fru-device -lsystemd)
James Feist3cb5fec2018-01-23 14:41:51 -0800109
James Feistc95cb142018-02-26 10:41:42 -0800110add_executable(entity-manager src/EntityManager.cpp
111 src/Overlay.cpp
112 src/Utils.cpp)
James Feist3cb5fec2018-01-23 14:41:51 -0800113
James Feist3cb5fec2018-01-23 14:41:51 -0800114target_link_libraries(entity-manager ${DBUS_LIBRARIES})
115target_link_libraries(entity-manager pthread)
116target_link_libraries(entity-manager stdc++fs)
117target_link_libraries(entity-manager ${Boost_LIBRARIES})
118
James Feistb5320a72018-01-24 12:28:12 -0800119if(NOT YOCTO)
120 add_dependencies(entity-manager nlohmann-json)
121 add_dependencies(entity-manager boost-dbus)
James Feist9eb0b582018-04-27 12:15:46 -0700122 add_dependencies(fru-device sdbusplus)
James Feistb5320a72018-01-24 12:28:12 -0800123endif()
124
James Feist3cb5fec2018-01-23 14:41:51 -0800125install (TARGETS fru-device entity-manager DESTINATION bin)