blob: 78e70a41ec51da39a1195fc03b0005907cbd1377 [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)
20
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070021if (NOT YOCTO)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080022 configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt)
James Feistb9683922019-01-02 15:04:45 -080023 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, Chunhuia835eaa2018-09-05 09:00:41 +080027
28 set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH})
29 include_directories (${CMAKE_BINARY_DIR}/prefix/include)
30endif ()
31
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070032if (NOT YOCTO)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080033 include_directories (${CMAKE_BINARY_DIR}/sdbusplus-src)
34 link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs)
James Feistb9683922019-01-02 15:04:45 -080035 include_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src)
36 link_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src/.libs)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080037
James Feistb9683922019-01-02 15:04:45 -080038 include_directories (${CMAKE_BINARY_DIR}) # link_directories
39 # (${CMAKE_BINARY_DIR}/sdbusplus-
40 # src/.libs)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070041endif ()
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080042
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070043if (YOCTO)
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080044 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. Bills3f7c5e42018-10-03 14:00:41 -070048
Jia, Chunhuia835eaa2018-09-05 09:00:41 +080049endif ()
50
51include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
52
James Feistb9683922019-01-02 15:04:45 -080053if (NOT YOCTO)
Jason M. Bills72867de2018-11-28 12:46:59 -080054 set (SENSOR_TEST_SRC tests/test_sensorcommands.cpp)
James Feistb9683922019-01-02 15:04:45 -080055
56 find_package (GTest REQUIRED)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070057
58 enable_testing ()
59
60 add_executable (runSensorTests ${SENSOR_TEST_SRC})
61 add_test (NAME test_sensorcommands COMMAND runSensorTests)
James Feistb9683922019-01-02 15:04:45 -080062 target_link_libraries (runSensorTests ${GTEST_BOTH_LIBRARIES}
63 ${CMAKE_THREAD_LIBS_INIT}
64 phosphor_logging sdbusplus -lsystemd)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070065endif ()
66
67include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
68
James Feistb9683922019-01-02 15:04:45 -080069add_library (zinteloemcmds
70 SHARED src/oemcommands.cpp src/utils.cpp src/sensorcommands.cpp
71 src/storagecommands.cpp)
Richard Marian Thomaiyar6e056412018-11-14 23:26:49 +053072set_target_properties (zinteloemcmds PROPERTIES VERSION "0.1.0")
73set_target_properties (zinteloemcmds PROPERTIES SOVERSION "0")
74target_link_libraries (zinteloemcmds sdbusplus)
Richard Marian Thomaiyar6e056412018-11-14 23:26:49 +053075target_link_libraries (zinteloemcmds ${CMAKE_THREAD_LIBS_INIT})
James Feista128f492018-12-20 12:31:56 -080076target_link_libraries (zinteloemcmds phosphor_logging)
Jason M. Billse2d1aee2018-10-03 15:57:18 -070077
James Feistb9683922019-01-02 15:04:45 -080078install (TARGETS zinteloemcmds DESTINATION lib/ipmid-providers)