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 | |
| 11 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") |
| 12 | |
| 13 | project (intel-ipmi-oem CXX) |
| 14 | |
| 15 | add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) |
| 16 | add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) |
| 17 | add_definitions (-DBOOST_ALL_NO_LIB) |
| 18 | add_definitions (-DBOOST_NO_RTTI) |
| 19 | add_definitions (-DBOOST_NO_TYPEID) |
Vernon Mauery | 9e7e17a | 2019-03-20 13:42:06 -0700 | [diff] [blame] | 20 | add_definitions (-DBOOST_ASIO_DISABLE_THREADS) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 21 | add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 22 | add_definitions (-Wno-psabi) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 23 | |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 24 | if (NOT YOCTO) # headers that can't be built without yocto |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 25 | include_directories (non-yocto) |
| 26 | |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 27 | configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt) |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 28 | 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, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 32 | |
| 33 | set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH}) |
| 34 | include_directories (${CMAKE_BINARY_DIR}/prefix/include) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 35 | link_directories (${CMAKE_BINARY_DIR}/prefix/lib) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 36 | |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 37 | include_directories (${CMAKE_BINARY_DIR}/sdbusplus-src) |
| 38 | link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 39 | include_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src) |
| 40 | link_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src/.libs) |
Yong Li | 0669d19 | 2019-05-06 14:01:46 +0800 | [diff] [blame] | 41 | include_directories (${CMAKE_BINARY_DIR}/intel-dbus-interfaces-src) |
| 42 | link_directories (${CMAKE_BINARY_DIR}/intel-dbus-interfaces-src/.libs) |
Vernon Mauery | 5480ef6 | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 43 | include_directories (${CMAKE_BINARY_DIR}/phosphor-ipmi-host/include) |
Suryakanth Sekar | d509eb9 | 2018-11-15 17:44:11 +0530 | [diff] [blame] | 44 | include_directories (${CMAKE_BINARY_DIR}/ipmid/user_channel) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 45 | include_directories (${CMAKE_BINARY_DIR}) # link_directories |
| 46 | # (${CMAKE_BINARY_DIR}/sdbusplus- |
| 47 | # src/.libs) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 48 | endif () |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 49 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 50 | if (YOCTO) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 51 | 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. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 55 | |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 56 | pkg_check_modules (LIBIPMID libipmid REQUIRED) |
| 57 | include_directories (${LIBIPMID_INCLUDE_DIRS}) |
| 58 | link_directories (${LIBIPMID_LIBRARY_DIRS}) |
| 59 | |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 60 | endif () |
| 61 | |
| 62 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 63 | |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 64 | if (NOT YOCTO) |
Jason M. Bills | 72867de | 2018-11-28 12:46:59 -0800 | [diff] [blame] | 65 | set (SENSOR_TEST_SRC tests/test_sensorcommands.cpp) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 66 | |
| 67 | find_package (GTest REQUIRED) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 68 | |
| 69 | enable_testing () |
| 70 | |
| 71 | add_executable (runSensorTests ${SENSOR_TEST_SRC}) |
| 72 | add_test (NAME test_sensorcommands COMMAND runSensorTests) |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 73 | target_link_libraries (runSensorTests ${GTEST_BOTH_LIBRARIES} |
| 74 | ${CMAKE_THREAD_LIBS_INIT} sdbusplus -lsystemd) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 75 | endif () |
| 76 | |
| 77 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 78 | |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 79 | # |
| 80 | # import OpenSSL (crypto) |
| 81 | find_package (OpenSSL REQUIRED) |
| 82 | include_directories (${OPENSSL_INCLUDE_DIR}) |
| 83 | |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 84 | add_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 Thomaiyar | 6e05641 | 2018-11-14 23:26:49 +0530 | [diff] [blame] | 91 | set_target_properties (zinteloemcmds PROPERTIES VERSION "0.1.0") |
| 92 | set_target_properties (zinteloemcmds PROPERTIES SOVERSION "0") |
Vernon Mauery | 4ac799d | 2019-05-20 15:50:37 -0700 | [diff] [blame] | 93 | target_link_libraries (zinteloemcmds stdc++fs) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 94 | target_link_libraries (zinteloemcmds ipmid) |
Richard Marian Thomaiyar | 6e05641 | 2018-11-14 23:26:49 +0530 | [diff] [blame] | 95 | target_link_libraries (zinteloemcmds sdbusplus) |
James Feist | a128f49 | 2018-12-20 12:31:56 -0800 | [diff] [blame] | 96 | target_link_libraries (zinteloemcmds phosphor_logging) |
Yong Li | 0669d19 | 2019-05-06 14:01:46 +0800 | [diff] [blame] | 97 | target_link_libraries (zinteloemcmds intel_dbus) |
Suryakanth Sekar | d509eb9 | 2018-11-15 17:44:11 +0530 | [diff] [blame] | 98 | target_link_libraries (zinteloemcmds -luserlayer) |
| 99 | target_link_libraries (zinteloemcmds -lchannellayer) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 100 | target_link_libraries (zinteloemcmds ${OPENSSL_CRYPTO_LIBRARY}) |
Jason M. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame] | 101 | |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 102 | install (TARGETS zinteloemcmds DESTINATION lib/ipmid-providers) |