blob: cc4955956185dff6b16efe5533384b0a3cddd452 [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)
James Feista2a98112018-08-07 11:15:37 -070030option(USE_OVERLAYS "Enable Overlay Usage" ON)
James Feist3cb5fec2018-01-23 14:41:51 -080031
32if(NOT YOCTO)
James Feist3cb5fec2018-01-23 14:41:51 -080033 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/non-yocto)
34
35 ExternalProject_Add(nlohmann-json
36 PREFIX ${CMAKE_CURRENT_BINARY_DIR}/nlohmann-json
37 GIT_REPOSITORY https://github.com/nlohmann/json.git
38 GIT_TAG afebb6a3bbc8751e834a5472e5c53cb2b5bbd750
39 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
40 CONFIGURE_COMMAND ""
41 BUILD_COMMAND mkdir -p
42 ${CMAKE_CURRENT_BINARY_DIR}/nlohmann-json/src/nlohmann-json/src/nlohmann &&
43 cp ${CMAKE_CURRENT_BINARY_DIR}/nlohmann-json/src/nlohmann-json/src/json.hpp
44 ${CMAKE_CURRENT_BINARY_DIR}/nlohmann-json/src/nlohmann-json/src/nlohmann/json.hpp
45 INSTALL_COMMAND ""
46 LOG_DOWNLOAD ON
47 )
48
49 ExternalProject_Get_Property(nlohmann-json install_dir)
50 include_directories(${install_dir}/src/nlohmann-json/src)
51
James Feist9eb0b582018-04-27 12:15:46 -070052 ExternalProject_Add(sdbusplus
53 PREFIX ${CMAKE_CURRENT_BINARY_DIR}/sdbusplus
54 GIT_REPOSITORY ssh://git-amr-2.devtools.intel.com:29418/sdbusplus
55 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} -DBOOST_ROOT=${BOOST_ROOT}
56 CONFIGURE_COMMAND ""
57 BUILD_COMMAND ""
58 INSTALL_COMMAND ""
59 LOG_DOWNLOAD ON
60 )
61 set(WANT_TRANSACTION 0)
62 configure_file(${CMAKE_BINARY_DIR}/sdbusplus-src/sdbusplus/server.hpp.in
63 ${CMAKE_BINARY_DIR}/prefix/include/sdbusplus/server.hpp @ONLY)
64 configure_file(${CMAKE_BINARY_DIR}/sdbusplus-src/sdbusplus/bus.hpp.in
65 ${CMAKE_BINARY_DIR}/prefix/include/sdbusplus/bus.hpp @ONLY)
66
67 ExternalProject_Get_Property(sdbusplus install_dir)
68 include_directories(${install_dir}/src/sdbusplus/include)
69
70 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/non-yocto)
71
James Feist3cb5fec2018-01-23 14:41:51 -080072 option(ENABLE_TEST "Enable Google Test" OFF)
73 if(ENABLE_TEST)
74 hunter_add_package(GTest)
75 find_package(GTest CONFIG REQUIRED)
76 enable_testing()
77 endif()
78endif()
79include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
80
81link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
82
83include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
84
85add_executable(fru-device src/FruDevice.cpp src/Utils.cpp)
James Feist3cb5fec2018-01-23 14:41:51 -080086
James Feist3cb5fec2018-01-23 14:41:51 -080087target_link_libraries(fru-device pthread)
88target_link_libraries(fru-device stdc++fs)
89target_link_libraries(fru-device ${Boost_LIBRARIES})
James Feist9eb0b582018-04-27 12:15:46 -070090target_link_libraries(fru-device -lsystemd)
James Feist2a9d6db2018-04-27 15:48:28 -070091target_link_libraries(fru-device phosphor_dbus)
James Feistc24899c2018-06-04 11:26:12 -070092target_link_libraries(fru-device sdbusplus)
James Feist3cb5fec2018-01-23 14:41:51 -080093
James Feistc95cb142018-02-26 10:41:42 -080094add_executable(entity-manager src/EntityManager.cpp
95 src/Overlay.cpp
96 src/Utils.cpp)
James Feist3cb5fec2018-01-23 14:41:51 -080097
James Feist8f2710a2018-05-09 17:18:55 -070098target_link_libraries(entity-manager -lsystemd)
James Feist3cb5fec2018-01-23 14:41:51 -080099target_link_libraries(entity-manager pthread)
100target_link_libraries(entity-manager stdc++fs)
101target_link_libraries(entity-manager ${Boost_LIBRARIES})
James Feistc24899c2018-06-04 11:26:12 -0700102target_link_libraries(entity-manager sdbusplus)
James Feist3cb5fec2018-01-23 14:41:51 -0800103
James Feista2a98112018-08-07 11:15:37 -0700104if(USE_OVERLAYS)
105 # overlays can be disabled because they require a kernel patch as of today
106 target_compile_definitions(entity-manager PRIVATE OVERLAYS=1)
107endif()
108
James Feistb5320a72018-01-24 12:28:12 -0800109if(NOT YOCTO)
110 add_dependencies(entity-manager nlohmann-json)
James Feist9eb0b582018-04-27 12:15:46 -0700111 add_dependencies(fru-device sdbusplus)
James Feistb5320a72018-01-24 12:28:12 -0800112endif()
113
James Feist3cb5fec2018-01-23 14:41:51 -0800114install (TARGETS fru-device entity-manager DESTINATION bin)
James Feista7d96252018-08-09 12:04:48 -0700115install (DIRECTORY configurations DESTINATION share)
116install (DIRECTORY overlay_templates DESTINATION share)
James Feistb4383f42018-08-06 16:54:10 -0700117install (DIRECTORY schemas DESTINATION share/configurations)