From 72cd13aac7d531eddd7d89762ca1bc698cbd4488 Mon Sep 17 00:00:00 2001
From: Christoph Junghans <junghans@lanl.gov>
Date: Fri, 6 Apr 2018 17:22:54 -0600
Subject: [PATCH] cmake: add openkim build as external project

---
 cmake/CMakeLists.txt | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 3a7e5dace6..4b615df28f 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -290,7 +290,21 @@ if(ENABLE_USER-VTK)
 endif()
 
 if(ENABLE_KIM)
-  find_package(KIM REQUIRED)
+  find_package(KIM QUIET)
+  if(NOT KIM_FOUND)
+    message(STATUS "KIM not found - we will build our own")
+    include(ExternalProject)
+    ExternalProject_Add(kim_build
+      URL https://github.com/openkim/kim-api/archive/v1.9.3.tar.gz
+      URL_MD5 86bb67622a09bcd45332c6506dc0ddd9
+      BUILD_IN_SOURCE 1
+      CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
+      )
+    ExternalProject_get_property(kim_build INSTALL_DIR)
+    set(KIM_INCLUDE_DIRS ${INSTALL_DIR}/include/kim-api-v1)
+    set(KIM_LIBRARIES ${INSTALL_DIR}/lib/libkim-api-v1.so)
+    list(APPEND LAMMPS_DEPS kim_build)
+  endif()
   list(APPEND LAMMPS_LINK_LIBS ${KIM_LIBRARIES})
   include_directories(${KIM_INCLUDE_DIRS})
 endif()
-- 
GitLab