blob: f14f97f5df7a8542923204484691dd5e7ea05d5a [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
James Feist3cb5fec2018-01-23 14:41:51 -080029option(YOCTO "Enable Building in Yocto" OFF)
30
31if(NOT YOCTO)
James Feist3cb5fec2018-01-23 14:41:51 -080032 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 Feist9eb0b582018-04-27 12:15:46 -070051 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 Feist3cb5fec2018-01-23 14:41:51 -080071 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()
77endif()
78include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
79
80link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
81
82include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
83
84add_executable(fru-device src/FruDevice.cpp src/Utils.cpp)
James Feist3cb5fec2018-01-23 14:41:51 -080085
James Feist3cb5fec2018-01-23 14:41:51 -080086target_link_libraries(fru-device pthread)
87target_link_libraries(fru-device stdc++fs)
88target_link_libraries(fru-device ${Boost_LIBRARIES})
James Feist9eb0b582018-04-27 12:15:46 -070089target_link_libraries(fru-device -lsystemd)
James Feist2a9d6db2018-04-27 15:48:28 -070090target_link_libraries(fru-device phosphor_dbus)
James Feistc24899c2018-06-04 11:26:12 -070091target_link_libraries(fru-device sdbusplus)
James Feist3cb5fec2018-01-23 14:41:51 -080092
James Feistc95cb142018-02-26 10:41:42 -080093add_executable(entity-manager src/EntityManager.cpp
94 src/Overlay.cpp
95 src/Utils.cpp)
James Feist3cb5fec2018-01-23 14:41:51 -080096
James Feist8f2710a2018-05-09 17:18:55 -070097target_link_libraries(entity-manager -lsystemd)
James Feist3cb5fec2018-01-23 14:41:51 -080098target_link_libraries(entity-manager pthread)
99target_link_libraries(entity-manager stdc++fs)
100target_link_libraries(entity-manager ${Boost_LIBRARIES})
James Feistc24899c2018-06-04 11:26:12 -0700101target_link_libraries(entity-manager sdbusplus)
James Feist3cb5fec2018-01-23 14:41:51 -0800102
James Feistb5320a72018-01-24 12:28:12 -0800103if(NOT YOCTO)
104 add_dependencies(entity-manager nlohmann-json)
James Feist9eb0b582018-04-27 12:15:46 -0700105 add_dependencies(fru-device sdbusplus)
James Feistb5320a72018-01-24 12:28:12 -0800106endif()
107
James Feist3cb5fec2018-01-23 14:41:51 -0800108install (TARGETS fru-device entity-manager DESTINATION bin)
James Feista7d96252018-08-09 12:04:48 -0700109install (DIRECTORY configurations DESTINATION share)
110install (DIRECTORY overlay_templates DESTINATION share)
James Feistb4383f42018-08-06 16:54:10 -0700111install (DIRECTORY schemas DESTINATION share/configurations)