blob: 95c4a7baea0766cd7bbae250af4058f11b9b75be [file] [log] [blame]
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
2
3cmake_policy (SET CMP0054 NEW)
4
5option (YOCTO "Use YOCTO depedencies system" OFF)
6include (ExternalProject)
7set (CMAKE_CXX_STANDARD 17)
8set (CMAKE_CXX_STANDARD_REQUIRED ON)
9set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
10
11set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
12
13project (fb-ipmi-oem CXX)
14
15add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY)
16add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED)
17add_definitions (-DBOOST_ALL_NO_LIB)
18add_definitions (-DBOOST_NO_RTTI)
19add_definitions (-DBOOST_NO_TYPEID)
20
21if (NOT YOCTO)
22 configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt)
23 execute_process (COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
24 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
25 execute_process (COMMAND ${CMAKE_COMMAND} --build .
26 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
27
28 set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH})
29 include_directories (${CMAKE_BINARY_DIR}/prefix/include)
30endif ()
31
32if (NOT YOCTO)
33 include_directories (${CMAKE_BINARY_DIR}/sdbusplus-src)
34 link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs)
35 include_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src)
36 link_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src/.libs)
37
38 include_directories (${CMAKE_BINARY_DIR}) # link_directories
39 # (${CMAKE_BINARY_DIR}/sdbusplus-
40 # src/.libs)
41endif ()
42
43if (YOCTO)
44 find_package (PkgConfig REQUIRED)
45 pkg_check_modules (LOGGING phosphor-logging REQUIRED)
46 include_directories (${LOGGING_INCLUDE_DIRS})
47 link_directories (${LOGGING_LIBRARY_DIRS})
48
49endif ()
50
51include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
52
53if (NOT YOCTO)
54 set (SENSOR_TEST_SRC tests/test_sensorcommands.cpp)
55
56 find_package (GTest REQUIRED)
57
58 enable_testing ()
59
60 add_executable (runSensorTests ${SENSOR_TEST_SRC})
61 add_test (NAME test_sensorcommands COMMAND runSensorTests)
62 target_link_libraries (runSensorTests ${GTEST_BOTH_LIBRARIES}
63 ${CMAKE_THREAD_LIBS_INIT}
64 phosphor_logging sdbusplus -lsystemd)
65endif ()
66
67include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
68
69add_library (zfboemcmds
70 SHARED src/oemcommands.cpp src/utils.cpp
71 src/storagecommands.cpp src/usb-dbg.cpp)
72set_target_properties (zfboemcmds PROPERTIES VERSION "0.1.0")
73set_target_properties (zfboemcmds PROPERTIES SOVERSION "0")
74target_link_libraries (zfboemcmds sdbusplus)
75target_link_libraries (zfboemcmds ${CMAKE_THREAD_LIBS_INIT})
76target_link_libraries (zfboemcmds phosphor_logging)
77
78install (TARGETS zfboemcmds DESTINATION lib/ipmid-providers)