blob: 891e1d32855ceb254b9e813f6ac1a2d0df4e5bf5 [file] [log] [blame]
Jia, Chunhuia835eaa2018-09-05 09:00:41 +08001cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
2
3cmake_policy (SET CMP0054 NEW)
4
Jason M. Bills3f7c5e42018-10-03 14:00:41 -07005option (YOCTO "Use YOCTO depedencies system" OFF)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +08006include (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 (intel-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)
Vernon Mauery9e7e17a2019-03-20 13:42:06 -070020add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
Vernon Mauery8b69fae2019-03-20 13:43:11 -070021add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080022
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070023if (NOT YOCTO)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080024 configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt)
Vernon Mauery8b69fae2019-03-20 13:43:11 -070025 execute_process (
26 COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
27 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty
28 )
29 execute_process (
30 COMMAND ${CMAKE_COMMAND} --build .
31 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty
32 )
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080033
34 set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH})
35 include_directories (${CMAKE_BINARY_DIR}/prefix/include)
Vernon Mauery8b69fae2019-03-20 13:43:11 -070036 link_directories (${CMAKE_BINARY_DIR}/prefix/lib)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080037
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080038 include_directories (${CMAKE_BINARY_DIR}/sdbusplus-src)
39 link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs)
James Feistb9683922019-01-02 15:04:45 -080040 include_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src)
41 link_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src/.libs)
Vernon Mauery5480ef62019-03-20 13:43:11 -070042 include_directories (${CMAKE_BINARY_DIR}/phosphor-ipmi-host/include)
Suryakanth Sekard509eb92018-11-15 17:44:11 +053043 include_directories (${CMAKE_BINARY_DIR}/ipmid/user_channel)
James Feistb9683922019-01-02 15:04:45 -080044 include_directories (${CMAKE_BINARY_DIR}) # link_directories
45 # (${CMAKE_BINARY_DIR}/sdbusplus-
46 # src/.libs)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070047endif ()
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080048
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070049if (YOCTO)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080050 find_package (PkgConfig REQUIRED)
51 pkg_check_modules (LOGGING phosphor-logging REQUIRED)
52 include_directories (${LOGGING_INCLUDE_DIRS})
53 link_directories (${LOGGING_LIBRARY_DIRS})
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070054
Vernon Mauery8b69fae2019-03-20 13:43:11 -070055 pkg_check_modules (LIBIPMID libipmid REQUIRED)
56 include_directories (${LIBIPMID_INCLUDE_DIRS})
57 link_directories (${LIBIPMID_LIBRARY_DIRS})
58
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080059endif ()
60
61include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
62
James Feistb9683922019-01-02 15:04:45 -080063if (NOT YOCTO)
Jason M. Bills72867de2018-11-28 12:46:59 -080064 set (SENSOR_TEST_SRC tests/test_sensorcommands.cpp)
James Feistb9683922019-01-02 15:04:45 -080065
66 find_package (GTest REQUIRED)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070067
68 enable_testing ()
69
70 add_executable (runSensorTests ${SENSOR_TEST_SRC})
71 add_test (NAME test_sensorcommands COMMAND runSensorTests)
Vernon Mauery8b69fae2019-03-20 13:43:11 -070072 target_link_libraries (
73 runSensorTests ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
74 phosphor_logging sdbusplus -lsystemd
75 )
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070076endif ()
77
78include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
79
Vernon Mauery8b69fae2019-03-20 13:43:11 -070080add_library (
81 zinteloemcmds SHARED src/oemcommands.cpp src/sensorcommands.cpp
82 src/storagecommands.cpp
83)
Richard Marian Thomaiyar6e056412018-11-14 23:26:49 +053084set_target_properties (zinteloemcmds PROPERTIES VERSION "0.1.0")
85set_target_properties (zinteloemcmds PROPERTIES SOVERSION "0")
Vernon Mauery8b69fae2019-03-20 13:43:11 -070086target_link_libraries (zinteloemcmds ipmid)
Richard Marian Thomaiyar6e056412018-11-14 23:26:49 +053087target_link_libraries (zinteloemcmds sdbusplus)
James Feista128f492018-12-20 12:31:56 -080088target_link_libraries (zinteloemcmds phosphor_logging)
Suryakanth Sekard509eb92018-11-15 17:44:11 +053089target_link_libraries (zinteloemcmds -luserlayer)
90target_link_libraries (zinteloemcmds -lchannellayer)
Jason M. Billse2d1aee2018-10-03 15:57:18 -070091
James Feistb9683922019-01-02 15:04:45 -080092install (TARGETS zinteloemcmds DESTINATION lib/ipmid-providers)