blob: c5537b86650dda0faf977b972e842157723d6774 [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)
Vernon Mauerya3702c12019-05-22 13:20:59 -070022add_definitions (-Wno-psabi)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080023
Jason M. Billsb08f84e2019-06-10 12:59:42 -070024if (NOT YOCTO) # headers that can't be built without yocto
Vernon Mauerya3702c12019-05-22 13:20:59 -070025 include_directories (non-yocto)
26
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080027 configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt)
Jason M. Billsb08f84e2019-06-10 12:59:42 -070028 execute_process (COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
29 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
30 execute_process (COMMAND ${CMAKE_COMMAND} --build .
31 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080032
33 set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH})
34 include_directories (${CMAKE_BINARY_DIR}/prefix/include)
Vernon Mauery8b69fae2019-03-20 13:43:11 -070035 link_directories (${CMAKE_BINARY_DIR}/prefix/lib)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080036
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080037 include_directories (${CMAKE_BINARY_DIR}/sdbusplus-src)
38 link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs)
James Feistb9683922019-01-02 15:04:45 -080039 include_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src)
40 link_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src/.libs)
Yong Li0669d192019-05-06 14:01:46 +080041 include_directories (${CMAKE_BINARY_DIR}/intel-dbus-interfaces-src)
42 link_directories (${CMAKE_BINARY_DIR}/intel-dbus-interfaces-src/.libs)
Vernon Mauery5480ef62019-03-20 13:43:11 -070043 include_directories (${CMAKE_BINARY_DIR}/phosphor-ipmi-host/include)
Suryakanth Sekard509eb92018-11-15 17:44:11 +053044 include_directories (${CMAKE_BINARY_DIR}/ipmid/user_channel)
James Feistb9683922019-01-02 15:04:45 -080045 include_directories (${CMAKE_BINARY_DIR}) # link_directories
46 # (${CMAKE_BINARY_DIR}/sdbusplus-
47 # src/.libs)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070048endif ()
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080049
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070050if (YOCTO)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080051 find_package (PkgConfig REQUIRED)
52 pkg_check_modules (LOGGING phosphor-logging REQUIRED)
53 include_directories (${LOGGING_INCLUDE_DIRS})
54 link_directories (${LOGGING_LIBRARY_DIRS})
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070055
Vernon Mauery8b69fae2019-03-20 13:43:11 -070056 pkg_check_modules (LIBIPMID libipmid REQUIRED)
57 include_directories (${LIBIPMID_INCLUDE_DIRS})
58 link_directories (${LIBIPMID_LIBRARY_DIRS})
59
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080060endif ()
61
62include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
63
James Feistb9683922019-01-02 15:04:45 -080064if (NOT YOCTO)
Jason M. Bills72867de2018-11-28 12:46:59 -080065 set (SENSOR_TEST_SRC tests/test_sensorcommands.cpp)
James Feistb9683922019-01-02 15:04:45 -080066
67 find_package (GTest REQUIRED)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070068
69 enable_testing ()
70
71 add_executable (runSensorTests ${SENSOR_TEST_SRC})
72 add_test (NAME test_sensorcommands COMMAND runSensorTests)
Jason M. Billsb08f84e2019-06-10 12:59:42 -070073 target_link_libraries (runSensorTests ${GTEST_BOTH_LIBRARIES}
74 ${CMAKE_THREAD_LIBS_INIT} sdbusplus -lsystemd)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070075endif ()
76
77include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
78
Vernon Mauerya3702c12019-05-22 13:20:59 -070079#
80# import OpenSSL (crypto)
81find_package (OpenSSL REQUIRED)
82include_directories (${OPENSSL_INCLUDE_DIR})
83
Jason M. Billsb08f84e2019-06-10 12:59:42 -070084add_library (zinteloemcmds
85 SHARED src/oemcommands.cpp src/sensorcommands.cpp
86 src/storagecommands.cpp src/multinodecommands.cpp
87 src/firmware-update.cpp src/appcommands.cpp src/smbioshandler.cpp
88 src/smbiosmdrv2handler.cpp src/manufacturingcommands.cpp
89 src/bmccontrolservices.cpp src/bridgingcommands.cpp
90 src/ipmi_to_redfish_hooks.cpp src/chassiscommands.cpp)
Richard Marian Thomaiyar6e056412018-11-14 23:26:49 +053091set_target_properties (zinteloemcmds PROPERTIES VERSION "0.1.0")
92set_target_properties (zinteloemcmds PROPERTIES SOVERSION "0")
Vernon Mauery4ac799d2019-05-20 15:50:37 -070093target_link_libraries (zinteloemcmds stdc++fs)
Vernon Mauery8b69fae2019-03-20 13:43:11 -070094target_link_libraries (zinteloemcmds ipmid)
Richard Marian Thomaiyar6e056412018-11-14 23:26:49 +053095target_link_libraries (zinteloemcmds sdbusplus)
James Feista128f492018-12-20 12:31:56 -080096target_link_libraries (zinteloemcmds phosphor_logging)
Yong Li0669d192019-05-06 14:01:46 +080097target_link_libraries (zinteloemcmds intel_dbus)
Suryakanth Sekard509eb92018-11-15 17:44:11 +053098target_link_libraries (zinteloemcmds -luserlayer)
99target_link_libraries (zinteloemcmds -lchannellayer)
Vernon Mauerya3702c12019-05-22 13:20:59 -0700100target_link_libraries (zinteloemcmds ${OPENSSL_CRYPTO_LIBRARY})
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700101
James Feistb9683922019-01-02 15:04:45 -0800102install (TARGETS zinteloemcmds DESTINATION lib/ipmid-providers)