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) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 22 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 23 | if (NOT YOCTO) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 24 | configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 25 | 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, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 33 | |
| 34 | set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH}) |
| 35 | include_directories (${CMAKE_BINARY_DIR}/prefix/include) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 36 | link_directories (${CMAKE_BINARY_DIR}/prefix/lib) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 37 | |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 38 | include_directories (${CMAKE_BINARY_DIR}/sdbusplus-src) |
| 39 | link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 40 | include_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src) |
| 41 | link_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src/.libs) |
Vernon Mauery | 5480ef6 | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 42 | include_directories (${CMAKE_BINARY_DIR}/phosphor-ipmi-host/include) |
Suryakanth Sekar | d509eb9 | 2018-11-15 17:44:11 +0530 | [diff] [blame] | 43 | include_directories (${CMAKE_BINARY_DIR}/ipmid/user_channel) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 44 | include_directories (${CMAKE_BINARY_DIR}) # link_directories |
| 45 | # (${CMAKE_BINARY_DIR}/sdbusplus- |
| 46 | # src/.libs) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 47 | endif () |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 48 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 49 | if (YOCTO) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 50 | 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. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 54 | |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 55 | pkg_check_modules (LIBIPMID libipmid REQUIRED) |
| 56 | include_directories (${LIBIPMID_INCLUDE_DIRS}) |
| 57 | link_directories (${LIBIPMID_LIBRARY_DIRS}) |
| 58 | |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 59 | endif () |
| 60 | |
| 61 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 62 | |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 63 | if (NOT YOCTO) |
Jason M. Bills | 72867de | 2018-11-28 12:46:59 -0800 | [diff] [blame] | 64 | set (SENSOR_TEST_SRC tests/test_sensorcommands.cpp) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 65 | |
| 66 | find_package (GTest REQUIRED) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 67 | |
| 68 | enable_testing () |
| 69 | |
| 70 | add_executable (runSensorTests ${SENSOR_TEST_SRC}) |
| 71 | add_test (NAME test_sensorcommands COMMAND runSensorTests) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 72 | target_link_libraries ( |
| 73 | runSensorTests ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} |
| 74 | phosphor_logging sdbusplus -lsystemd |
| 75 | ) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 76 | endif () |
| 77 | |
| 78 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 79 | |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 80 | add_library ( |
| 81 | zinteloemcmds SHARED src/oemcommands.cpp src/sensorcommands.cpp |
| 82 | src/storagecommands.cpp |
| 83 | ) |
Richard Marian Thomaiyar | 6e05641 | 2018-11-14 23:26:49 +0530 | [diff] [blame] | 84 | set_target_properties (zinteloemcmds PROPERTIES VERSION "0.1.0") |
| 85 | set_target_properties (zinteloemcmds PROPERTIES SOVERSION "0") |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 86 | target_link_libraries (zinteloemcmds ipmid) |
Richard Marian Thomaiyar | 6e05641 | 2018-11-14 23:26:49 +0530 | [diff] [blame] | 87 | target_link_libraries (zinteloemcmds sdbusplus) |
James Feist | a128f49 | 2018-12-20 12:31:56 -0800 | [diff] [blame] | 88 | target_link_libraries (zinteloemcmds phosphor_logging) |
Suryakanth Sekar | d509eb9 | 2018-11-15 17:44:11 +0530 | [diff] [blame] | 89 | target_link_libraries (zinteloemcmds -luserlayer) |
| 90 | target_link_libraries (zinteloemcmds -lchannellayer) |
Jason M. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame] | 91 | |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 92 | install (TARGETS zinteloemcmds DESTINATION lib/ipmid-providers) |