Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 3.5 FATAL_ERROR) |
| 2 | |
| 3 | cmake_policy (SET CMP0054 NEW) |
| 4 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 5 | option (YOCTO "Use YOCTO depedencies system" OFF) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 6 | include (ExternalProject) |
| 7 | set (CMAKE_CXX_STANDARD 17) |
| 8 | set (CMAKE_CXX_STANDARD_REQUIRED ON) |
| 9 | set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
| 10 | |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 11 | set ( |
| 12 | CMAKE_CXX_FLAGS |
| 13 | "${CMAKE_CXX_FLAGS} \ |
| 14 | -Werror \ |
| 15 | -Wtype-limits \ |
| 16 | -Wnull-dereference \ |
| 17 | " |
| 18 | ) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 19 | |
| 20 | project (intel-ipmi-oem CXX) |
| 21 | |
| 22 | add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) |
| 23 | add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) |
| 24 | add_definitions (-DBOOST_ALL_NO_LIB) |
| 25 | add_definitions (-DBOOST_NO_RTTI) |
| 26 | add_definitions (-DBOOST_NO_TYPEID) |
Vernon Mauery | 9e7e17a | 2019-03-20 13:42:06 -0700 | [diff] [blame] | 27 | add_definitions (-DBOOST_ASIO_DISABLE_THREADS) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 28 | add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 29 | add_definitions (-Wno-psabi) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 30 | |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 31 | if (NOT YOCTO) # headers that can't be built without yocto |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 32 | include_directories (SYSTEM non-yocto) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 33 | |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 34 | configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt) |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 35 | 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, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 39 | |
| 40 | set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH}) |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 41 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}/prefix/include) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 42 | link_directories (${CMAKE_BINARY_DIR}/prefix/lib) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 43 | |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 44 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 45 | link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs) |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 46 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}/phosphor-logging-src) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 47 | link_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src/.libs) |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 48 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}/intel-dbus-interfaces-src) |
Yong Li | 0669d19 | 2019-05-06 14:01:46 +0800 | [diff] [blame] | 49 | link_directories (${CMAKE_BINARY_DIR}/intel-dbus-interfaces-src/.libs) |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 50 | 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. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 55 | endif () |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 56 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 57 | if (YOCTO) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 58 | find_package (PkgConfig REQUIRED) |
| 59 | pkg_check_modules (LOGGING phosphor-logging REQUIRED) |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 60 | include_directories (SYSTEM ${LOGGING_INCLUDE_DIRS}) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 61 | link_directories (${LOGGING_LIBRARY_DIRS}) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 62 | |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 63 | pkg_check_modules (LIBIPMID libipmid REQUIRED) |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 64 | include_directories (SYSTEM ${LIBIPMID_INCLUDE_DIRS}) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 65 | link_directories (${LIBIPMID_LIBRARY_DIRS}) |
| 66 | |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 67 | endif () |
| 68 | |
| 69 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 70 | |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 71 | if (NOT YOCTO) |
Jason M. Bills | 72867de | 2018-11-28 12:46:59 -0800 | [diff] [blame] | 72 | set (SENSOR_TEST_SRC tests/test_sensorcommands.cpp) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 73 | |
| 74 | find_package (GTest REQUIRED) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 75 | |
| 76 | enable_testing () |
| 77 | |
| 78 | add_executable (runSensorTests ${SENSOR_TEST_SRC}) |
| 79 | add_test (NAME test_sensorcommands COMMAND runSensorTests) |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 80 | target_link_libraries (runSensorTests ${GTEST_BOTH_LIBRARIES} |
| 81 | ${CMAKE_THREAD_LIBS_INIT} sdbusplus -lsystemd) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 82 | endif () |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 83 | # |
| 84 | # import OpenSSL (crypto) |
| 85 | find_package (OpenSSL REQUIRED) |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 86 | include_directories (SYSTEM ${OPENSSL_INCLUDE_DIR}) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 87 | |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 88 | add_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 Thomaiyar | 6e05641 | 2018-11-14 23:26:49 +0530 | [diff] [blame] | 95 | set_target_properties (zinteloemcmds PROPERTIES VERSION "0.1.0") |
| 96 | set_target_properties (zinteloemcmds PROPERTIES SOVERSION "0") |
Vernon Mauery | 4ac799d | 2019-05-20 15:50:37 -0700 | [diff] [blame] | 97 | target_link_libraries (zinteloemcmds stdc++fs) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 98 | target_link_libraries (zinteloemcmds ipmid) |
Richard Marian Thomaiyar | 6e05641 | 2018-11-14 23:26:49 +0530 | [diff] [blame] | 99 | target_link_libraries (zinteloemcmds sdbusplus) |
James Feist | a128f49 | 2018-12-20 12:31:56 -0800 | [diff] [blame] | 100 | target_link_libraries (zinteloemcmds phosphor_logging) |
Yong Li | 0669d19 | 2019-05-06 14:01:46 +0800 | [diff] [blame] | 101 | target_link_libraries (zinteloemcmds intel_dbus) |
Suryakanth Sekar | d509eb9 | 2018-11-15 17:44:11 +0530 | [diff] [blame] | 102 | target_link_libraries (zinteloemcmds -luserlayer) |
| 103 | target_link_libraries (zinteloemcmds -lchannellayer) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 104 | target_link_libraries (zinteloemcmds ${OPENSSL_CRYPTO_LIBRARY}) |
Jason M. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame] | 105 | |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 106 | install (TARGETS zinteloemcmds DESTINATION lib/ipmid-providers) |
Rajashekar Gade Reddy | df5e327 | 2019-09-05 18:10:53 +0530 | [diff] [blame] | 107 | option (INTEL_PFR_ENABLED "Intel PFR Enabled" OFF) |
| 108 | target_compile_definitions ( |
| 109 | zinteloemcmds PRIVATE |
| 110 | $<$<BOOL:${INTEL_PFR_ENABLED}>: -DINTEL_PFR_ENABLED> |
| 111 | ) |