From cf184c6f124f105fb18aea6fbd6570ca9902c88a Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Wed, 12 Feb 2020 15:12:57 +0100
Subject: [PATCH] Fix CMake to find spot library

---
 .gitignore                  |   5 +++++
 CMakeLists.txt              |  35 +++++++++++++++++++++++------------
 src/.MCHybridSOG.h.kate-swp | Bin 67 -> 0 bytes
 src/CMakeLists.txt          |  29 +++++++++++------------------
 4 files changed, 39 insertions(+), 30 deletions(-)
 delete mode 100644 src/.MCHybridSOG.h.kate-swp

diff --git a/.gitignore b/.gitignore
index db7a40b..2b8662f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -139,5 +139,10 @@ local.properties
 
 .sts4-cache/
 
+### Kate ###
+# Swap Files #
+.*.kate-swp
+.swp.*
+
 # End of https://www.gitignore.io/api/c++,cmake
 
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ce56425..8d84c87 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,18 +21,29 @@ set(SYLVAN_DIR "${CMAKE_SOURCE_DIR}/third-party/sylvan")
 include_directories(${SYLVAN_DIR})
 add_subdirectory(${SYLVAN_DIR})
 
-# add spot
-include(ExternalProject)
-message(STATUS "Building Spot ...")
-set(SPOT_SOURCE_DIR "${CMAKE_SOURCE_DIR}/third-party/spot")
-set(SPOT_DIR "${CMAKE_BINARY_DIR}/third-party/spot")
-ExternalProject_Add(SpotLibrary
-  PREFIX            ${SPOT_DIR}
-  SOURCE_DIR        ${SPOT_SOURCE_DIR}
-  CONFIGURE_COMMAND autoreconf -if ${SPOT_SOURCE_DIR} && ${SPOT_SOURCE_DIR}/configure --disable-python --prefix=<INSTALL_DIR> --enable-static
-  BUILD_COMMAND     make -j
-)
-include_directories("${SPOT_DIR}/include")
+# build spot if it is not installed on the system
+find_library(SPOT_LIBRARY "spot")
+find_library(BDDX_LIBRARY "bddx")
+
+if(NOT SPOT_LIBRARY)
+  include(ExternalProject)
+
+  message(STATUS "Building Spot ...")
+  set(SPOT_SOURCE_DIR "${CMAKE_SOURCE_DIR}/third-party/spot")
+  set(SPOT_DIR "${CMAKE_BINARY_DIR}/third-party/spot")
+
+  ExternalProject_Add(SpotLibrary
+    PREFIX            ${SPOT_DIR}
+    SOURCE_DIR        ${SPOT_SOURCE_DIR}
+    CONFIGURE_COMMAND autoreconf -if ${SPOT_SOURCE_DIR} && ${SPOT_SOURCE_DIR}/configure --disable-python --prefix=<INSTALL_DIR>
+    BUILD_COMMAND     make -j
+  )
+
+  include_directories("${SPOT_DIR}/include")
+else ()
+  message(STATUS "Found spot: ${SPOT_LIBRARY}")
+  message(STATUS "Found bddx: ${BDDX_LIBRARY}")
+endif()
 
 # add source folder
 include_directories(src)
diff --git a/src/.MCHybridSOG.h.kate-swp b/src/.MCHybridSOG.h.kate-swp
deleted file mode 100644
index a65057426854c2e2438dac15c8c74a0492744abb..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 67
zcmZQzU=Z?7EJ;-eE>A2_aLdd|RWQ;sU|?VnSy!;$PTlh1i8FSq6_Z>lm<}%ZEf5^a
Pz`zjT3Z_CKRIn=mk#7?0

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4231a5f..f15c8d0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,27 +6,20 @@ find_package(MPI REQUIRED)
 include_directories(${MPI_INCLUDE_PATH})
 
 # include openssl
-find_package(OpenSSL)
+find_package(OpenSSL REQUIRED)
 include_directories(${OPENSSL_INCLUDE_DIR})
 
-include_directories("${CMAKE_SOURCE_DIR}/third-party/sylvan/src")
-
-
-add_library(spot SHARED IMPORTED) # or STATIC instead of SHARED
-set_target_properties(spot PROPERTIES
-  IMPORTED_LOCATION "/usr/lib/x86_64-linux-gnu/libspot.so"
-  INTERFACE_INCLUDE_DIRECTORIES "/usr/include/spot/"
-)
-
-add_library(bddx SHARED IMPORTED) # or STATIC instead of SHARED
-set_target_properties(bddx PROPERTIES
-  IMPORTED_LOCATION "/usr/lib/x86_64-linux-gnu/libbddx.so"
-  INTERFACE_INCLUDE_DIRECTORIES "/usr/include/spot/"
-)
-
-
-
+# include spot and bddx library
+add_library(spot SHARED IMPORTED)
+add_library(bddx SHARED IMPORTED)
 
+if(NOT SPOT_LIBRARY)
+  set_target_properties(spot PROPERTIES IMPORTED_LOCATION "${SPOT_DIR}/lib/libspot.so")
+  set_target_properties(bddx PROPERTIES IMPORTED_LOCATION "${SPOT_DIR}/lib/libbddx.so")
+else()
+  set_target_properties(spot PROPERTIES IMPORTED_LOCATION ${BDDX_LIBRARY})
+  set_target_properties(bddx PROPERTIES IMPORTED_LOCATION ${SPOT_LIBRARY})
+endif()
 
 # Hybrid SOG executable
 add_executable(hybrid-sog main.cpp
-- 
GitLab