+# If we install a dynamically linked binary that also uses dynamically used
+# libraries from deps/install/lib, we need to be cautious. Changing these
+# shared libraries from deps/install/lib most probably breaks the binary.
+# We only allow such an installation for custom installation prefixes
+# (in the assumption that only reasonably experienced users use this and
+# also that custom installation prefixes are not used for longer periods of
+# time anyway). Also, we print a big warning with further instructions.
+if(BUILD_SHARED_LIBS)
+ # Get the libraries that cvc5 links against
+ get_target_property(libs cvc5 INTERFACE_LINK_LIBRARIES)
+ set(LIBS_SHARED_FROM_DEPS "")
+ foreach(lib ${libs})
+ # Filter out those that are linked dynamically and come from deps/install
+ if(lib MATCHES ".*/deps/install/lib/.*\.so")
+ list(APPEND LIBS_SHARED_FROM_DEPS ${lib})
+ endif()
+ endforeach()
+ list(LENGTH LIBS_SHARED_FROM_DEPS list_len)
+ # Check if we actually use such "dangerous" libraries
+ if(list_len GREATER 0)
+ # Print a generic warning
+ install(CODE "message(WARNING \"You are installing a dynamically linked \
+ binary of cvc5 which may be a problem if you are using any dynamically \
+ linked third-party library that you obtained through one of the \
+ contrib/get-xxx scripts. The binary uses the rpath mechanism to find these \
+ locally, hence executing such a contrib script removing the \
+ \\\"deps/install\\\" folder most probably breaks the installed binary! \
+ Consider installing the dynamically linked dependencies on your system \
+ manually or link cvc5 statically.\")")
+ # Print the libraries in question
+ foreach(lib ${LIBS_SHARED_FROM_DEPS})
+ install(CODE "message(WARNING \"The following library is used by the cvc5 binary: ${lib}\")")
+ endforeach()
+ # Check if we use a custom installation prefix
+ if(CMAKE_INSTALL_PREFIX STREQUAL "/usr/local")
+ install(CODE "message(FATAL_ERROR \"To avoid installing a \
+ soon-to-be-broken binary, system-wide installation is disabled if the \
+ binary depends on locally-built shared libraries.\")")
+ else()
+ install(CODE "message(WARNING \"You have selected a custom install \
+ directory ${CMAKE_INSTALL_PREFIX}, so we expect you understood the \
+ previous warning and know what you are doing.\")")
+ endif()
+ endif()
+endif()
+
+install(EXPORT cvc5-targets
+ FILE cvc5Targets.cmake
+ NAMESPACE cvc5::
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cvc5)