Make libpeci dependency optional

This option is disabled by default as libpeci uses the old out-of-tree
PECI driver's API and is thus incompatible with current OpenBMC kernels.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I3516b6937a4da3d64e700eb727d67bdb4b8e8fee
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b8457ce..781209b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,8 +10,9 @@
         OFF)
 
 option (YOCTO "Enable Building in Yocto" OFF)
+option (LIBPECI "Enable use of old peci driver API via libpeci" OFF)
 
-if (NOT YOCTO)
+if (LIBPECI AND NOT YOCTO)
     add_dependencies (host-error-monitor libpeci)
     externalproject_add (libpeci PREFIX ${CMAKE_BINARY_DIR}/libpeci
                          GIT_REPOSITORY https://github.com/openbmc/libpeci.git
@@ -34,7 +35,7 @@
 
 target_include_directories (host-error-monitor PRIVATE ${CMAKE_SOURCE_DIR})
 
-target_link_libraries (host-error-monitor sdbusplus -lsystemd gpiodcxx peci)
+target_link_libraries (host-error-monitor sdbusplus -lsystemd gpiodcxx)
 
 include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
 
@@ -53,6 +54,11 @@
 add_definitions (-DBOOST_NO_TYPEID)
 add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
 
+if (LIBPECI)
+    add_definitions (-DLIBPECI)
+    target_link_libraries (host-error-monitor peci)
+endif ()
+
 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti")