blob: 218c5c684915edcdc988eea90c413924d950552f [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
James Feist13b00392019-08-19 16:16:08 -070011set (
12 CMAKE_CXX_FLAGS
13 "${CMAKE_CXX_FLAGS} \
14 -Werror \
15 -Wtype-limits \
16 -Wnull-dereference \
17"
18)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080019
20project (intel-ipmi-oem CXX)
21
22add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY)
23add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED)
24add_definitions (-DBOOST_ALL_NO_LIB)
25add_definitions (-DBOOST_NO_RTTI)
26add_definitions (-DBOOST_NO_TYPEID)
Vernon Mauery9e7e17a2019-03-20 13:42:06 -070027add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
Vernon Mauery8b69fae2019-03-20 13:43:11 -070028add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING)
Vernon Mauerya3702c12019-05-22 13:20:59 -070029add_definitions (-Wno-psabi)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080030
Jason M. Billsb08f84e2019-06-10 12:59:42 -070031if (NOT YOCTO) # headers that can't be built without yocto
James Feist13b00392019-08-19 16:16:08 -070032 include_directories (SYSTEM non-yocto)
Vernon Mauerya3702c12019-05-22 13:20:59 -070033
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080034 configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt)
Jason M. Billsb08f84e2019-06-10 12:59:42 -070035 execute_process (COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
36 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
37 execute_process (COMMAND ${CMAKE_COMMAND} --build .
38 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080039
40 set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH})
James Feist13b00392019-08-19 16:16:08 -070041 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/prefix/include)
Vernon Mauery8b69fae2019-03-20 13:43:11 -070042 link_directories (${CMAKE_BINARY_DIR}/prefix/lib)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080043
James Feist13b00392019-08-19 16:16:08 -070044 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080045 link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs)
James Feist13b00392019-08-19 16:16:08 -070046 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/phosphor-logging-src)
James Feistb9683922019-01-02 15:04:45 -080047 link_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src/.libs)
James Feist13b00392019-08-19 16:16:08 -070048 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/intel-dbus-interfaces-src)
Yong Li0669d192019-05-06 14:01:46 +080049 link_directories (${CMAKE_BINARY_DIR}/intel-dbus-interfaces-src/.libs)
James Feist13b00392019-08-19 16:16:08 -070050 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/phosphor-ipmi-host/include)
51 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/ipmid/user_channel)
52 include_directories (SYSTEM ${CMAKE_BINARY_DIR}) # link_directories (${CMAK
53 # E_BINARY_DIR}/sdbusplus-
54 # src/.libs)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070055endif ()
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080056
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070057if (YOCTO)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080058 find_package (PkgConfig REQUIRED)
59 pkg_check_modules (LOGGING phosphor-logging REQUIRED)
James Feist13b00392019-08-19 16:16:08 -070060 include_directories (SYSTEM ${LOGGING_INCLUDE_DIRS})
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080061 link_directories (${LOGGING_LIBRARY_DIRS})
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070062
Vernon Mauery8b69fae2019-03-20 13:43:11 -070063 pkg_check_modules (LIBIPMID libipmid REQUIRED)
James Feist13b00392019-08-19 16:16:08 -070064 include_directories (SYSTEM ${LIBIPMID_INCLUDE_DIRS})
Vernon Mauery8b69fae2019-03-20 13:43:11 -070065 link_directories (${LIBIPMID_LIBRARY_DIRS})
66
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080067endif ()
68
69include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
70
James Feistb9683922019-01-02 15:04:45 -080071if (NOT YOCTO)
Jason M. Bills72867de2018-11-28 12:46:59 -080072 set (SENSOR_TEST_SRC tests/test_sensorcommands.cpp)
James Feistb9683922019-01-02 15:04:45 -080073
74 find_package (GTest REQUIRED)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070075
76 enable_testing ()
77
78 add_executable (runSensorTests ${SENSOR_TEST_SRC})
79 add_test (NAME test_sensorcommands COMMAND runSensorTests)
Jason M. Billsb08f84e2019-06-10 12:59:42 -070080 target_link_libraries (runSensorTests ${GTEST_BOTH_LIBRARIES}
81 ${CMAKE_THREAD_LIBS_INIT} sdbusplus -lsystemd)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070082endif ()
Vernon Mauerya3702c12019-05-22 13:20:59 -070083#
84# import OpenSSL (crypto)
85find_package (OpenSSL REQUIRED)
James Feist13b00392019-08-19 16:16:08 -070086include_directories (SYSTEM ${OPENSSL_INCLUDE_DIR})
Vernon Mauerya3702c12019-05-22 13:20:59 -070087
Jason M. Billsb08f84e2019-06-10 12:59:42 -070088add_library (zinteloemcmds
89 SHARED src/oemcommands.cpp src/sensorcommands.cpp
90 src/storagecommands.cpp src/multinodecommands.cpp
91 src/firmware-update.cpp src/appcommands.cpp src/smbioshandler.cpp
92 src/smbiosmdrv2handler.cpp src/manufacturingcommands.cpp
93 src/bmccontrolservices.cpp src/bridgingcommands.cpp
94 src/ipmi_to_redfish_hooks.cpp src/chassiscommands.cpp)
Richard Marian Thomaiyar6e056412018-11-14 23:26:49 +053095set_target_properties (zinteloemcmds PROPERTIES VERSION "0.1.0")
96set_target_properties (zinteloemcmds PROPERTIES SOVERSION "0")
Vernon Mauery4ac799d2019-05-20 15:50:37 -070097target_link_libraries (zinteloemcmds stdc++fs)
Vernon Mauery8b69fae2019-03-20 13:43:11 -070098target_link_libraries (zinteloemcmds ipmid)
Richard Marian Thomaiyar6e056412018-11-14 23:26:49 +053099target_link_libraries (zinteloemcmds sdbusplus)
James Feista128f492018-12-20 12:31:56 -0800100target_link_libraries (zinteloemcmds phosphor_logging)
Yong Li0669d192019-05-06 14:01:46 +0800101target_link_libraries (zinteloemcmds intel_dbus)
Suryakanth Sekard509eb92018-11-15 17:44:11 +0530102target_link_libraries (zinteloemcmds -luserlayer)
103target_link_libraries (zinteloemcmds -lchannellayer)
Vernon Mauerya3702c12019-05-22 13:20:59 -0700104target_link_libraries (zinteloemcmds ${OPENSSL_CRYPTO_LIBRARY})
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700105
James Feistb9683922019-01-02 15:04:45 -0800106install (TARGETS zinteloemcmds DESTINATION lib/ipmid-providers)
Rajashekar Gade Reddydf5e3272019-09-05 18:10:53 +0530107option (INTEL_PFR_ENABLED "Intel PFR Enabled" OFF)
108target_compile_definitions (
109 zinteloemcmds PRIVATE
110 $<$<BOOL:${INTEL_PFR_ENABLED}>: -DINTEL_PFR_ENABLED>
111)