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) |
| 20 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 21 | if (NOT YOCTO) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 22 | configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 23 | execute_process (COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . |
| 24 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty) |
| 25 | execute_process (COMMAND ${CMAKE_COMMAND} --build . |
| 26 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 27 | |
| 28 | set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH}) |
| 29 | include_directories (${CMAKE_BINARY_DIR}/prefix/include) |
| 30 | endif () |
| 31 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 32 | if (NOT YOCTO) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 33 | include_directories (${CMAKE_BINARY_DIR}/sdbusplus-src) |
| 34 | link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 35 | include_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src) |
| 36 | link_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src/.libs) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 37 | |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 38 | include_directories (${CMAKE_BINARY_DIR}) # link_directories |
| 39 | # (${CMAKE_BINARY_DIR}/sdbusplus- |
| 40 | # src/.libs) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 41 | endif () |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 42 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 43 | if (YOCTO) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 44 | find_package (PkgConfig REQUIRED) |
| 45 | pkg_check_modules (LOGGING phosphor-logging REQUIRED) |
| 46 | include_directories (${LOGGING_INCLUDE_DIRS}) |
| 47 | link_directories (${LOGGING_LIBRARY_DIRS}) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 48 | |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 49 | endif () |
| 50 | |
| 51 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 52 | |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 53 | if (NOT YOCTO) |
Jason M. Bills | 72867de | 2018-11-28 12:46:59 -0800 | [diff] [blame] | 54 | set (SENSOR_TEST_SRC tests/test_sensorcommands.cpp) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 55 | |
| 56 | find_package (GTest REQUIRED) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 57 | |
| 58 | enable_testing () |
| 59 | |
| 60 | add_executable (runSensorTests ${SENSOR_TEST_SRC}) |
| 61 | add_test (NAME test_sensorcommands COMMAND runSensorTests) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 62 | target_link_libraries (runSensorTests ${GTEST_BOTH_LIBRARIES} |
| 63 | ${CMAKE_THREAD_LIBS_INIT} |
| 64 | phosphor_logging sdbusplus -lsystemd) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 65 | endif () |
| 66 | |
| 67 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 68 | |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 69 | add_library (zinteloemcmds |
| 70 | SHARED src/oemcommands.cpp src/utils.cpp src/sensorcommands.cpp |
| 71 | src/storagecommands.cpp) |
Richard Marian Thomaiyar | 6e05641 | 2018-11-14 23:26:49 +0530 | [diff] [blame] | 72 | set_target_properties (zinteloemcmds PROPERTIES VERSION "0.1.0") |
| 73 | set_target_properties (zinteloemcmds PROPERTIES SOVERSION "0") |
| 74 | target_link_libraries (zinteloemcmds sdbusplus) |
Richard Marian Thomaiyar | 6e05641 | 2018-11-14 23:26:49 +0530 | [diff] [blame] | 75 | target_link_libraries (zinteloemcmds ${CMAKE_THREAD_LIBS_INIT}) |
James Feist | a128f49 | 2018-12-20 12:31:56 -0800 | [diff] [blame] | 76 | target_link_libraries (zinteloemcmds phosphor_logging) |
Jason M. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame] | 77 | |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 78 | install (TARGETS zinteloemcmds DESTINATION lib/ipmid-providers) |