Skip to content
Permalink
Browse files

added FindLibint2.cmake

  • Loading branch information...
evaleev committed May 7, 2019
1 parent ed9e08d commit b2558eb2a19622da92e2cc7e8e4d0693f0e291cd
Showing with 138 additions and 4 deletions.
  1. +108 −0 FindLibint2.cmake
  2. +7 −1 Makefile
  3. +5 −1 export/MakeRules.export
  4. +1 −0 export/MakeVars.export
  5. +1 −0 export/Makefile
  6. +7 −0 export/configure.export
  7. +8 −2 src/lib/MakeRules.in
  8. +1 −0 src/lib/MakeVars.in
@@ -0,0 +1,108 @@
# FindLibint2.cmake
#
# Finds the Libint2 header and library using the pkg-config program.
#
# Use this module by invoking find_package() as follows:
# find_package(Libint2
# [version] [EXACT] # Minimum or EXACT version e.g. 2.5.0
# [REQUIRED] # Fail with error if Libint2 is not found
# )
#
# The behavior can be controlled by setting the following variables
#
# LIBINT2_SHARED_LIBRARY_ONLY if true, will look for shared lib only; may be needed for some platforms
# where linking errors or worse, e.g. duplicate static data, occur if
# linking shared libraries against static Libint2 library.
# PKG_CONFIG_PATH (environment variable) Add the libint2 install prefix directory (e.g. /usr/local)
# to specify where to look for libint2
# CMAKE_MODULE_PATH Add the libint2 install prefix directory (e.g. /usr/local)
# to specify where to look for libint2
#
# This will define the following CMake cache variables
#
# LIBINT2_FOUND - true if libint2.h header and libint2 library were found
# LIBINT2_VERSION - the libint2 version
# LIBINT2_INCLUDE_DIRS - (deprecated: use the CMake IMPORTED targets listed below) list of libint2 include directories
# LIBINT2_LIBRARIES - (deprecated: use the CMake IMPORTED targets listed below) list of libint2 libraries
#
# and the following imported targets
#
# Libint2::Libint - library only
# Libint2::LibintCXX - library + C++11 API; may need to add dependence on Eigen3 and/or Boost.Preprocessor if
# was not found by Libint at configure time
#
# Author: Eduard Valeyev - libint@valeyev.net

# need cmake 3.8 for cxx_std_11 compile feature
if(CMAKE_VERSION VERSION_LESS 3.8.0)
message(FATAL_ERROR "This file relies on consumers using CMake 3.8.0 or greater.")
endif()

find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBINT2 QUIET libint2)
set(LIBINT2_VERSION ${PC_LIBINT2_VERSION})

find_path(LIBINT2_INCLUDE_DIR
NAMES libint2.h
PATHS ${PC_LIBINT2_INCLUDE_DIRS}
PATH_SUFFIXES libint2
)

if (LIBINT2_SHARED_LIBRARY_ONLY)
set(_LIBINT2_LIB_NAMES "libint2.so" "libint2.dylib")
else (LIBINT2_SHARED_LIBRARY_ONLY)
set(_LIBINT2_LIB_NAMES "int2")
endif(LIBINT2_SHARED_LIBRARY_ONLY)

find_library(LIBINT2_LIBRARY NAMES ${_LIBINT2_LIB_NAMES} HINTS ${PC_LIBINT2_LIBRARY_DIRS})

mark_as_advanced(LIBINT2_FOUND LIBINT2_INCLUDE_DIR LIBINT2_LIBRARY LIBINT2_VERSION)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libint2
FOUND_VAR LIBINT2_FOUND
REQUIRED_VARS LIBINT2_INCLUDE_DIR
VERSION_VAR LIBINT2_VERSION
)

if(LIBINT2_FOUND)
set(LIBINT2_LIBRARIES ${LIBINT2_LIBRARY})
set(LIBINT2_INCLUDE_DIRS ${LIBINT2_INCLUDE_DIR} ${LIBINT2_INCLUDE_DIR}/libint2 ${PC_LIBINT2_INCLUDE_DIRS})
# sanitize LIBINT2_INCLUDE_DIRS: remove duplicates and non-existent entries
list(REMOVE_DUPLICATES LIBINT2_INCLUDE_DIRS)
set(LIBINT2_INCLUDE_DIRS_SANITIZED )
foreach(DIR IN LISTS LIBINT2_INCLUDE_DIRS)
if (EXISTS ${DIR})
list(APPEND LIBINT2_INCLUDE_DIRS_SANITIZED ${DIR})
endif()
endforeach()
set(LIBINT2_INCLUDE_DIRS ${LIBINT2_INCLUDE_DIRS_SANITIZED})
endif()

if(LIBINT2_FOUND AND NOT TARGET Libint2::Libint)
add_library(Libint2::Libint INTERFACE IMPORTED)
set_target_properties(Libint2::Libint PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LIBINT2_INCLUDE_DIR};${LIBINT2_INCLUDE_DIR}/libint2"
)
set_target_properties(Libint2::Libint PROPERTIES
INTERFACE_LINK_LIBRARIES ${LIBINT2_LIBRARY}
)
endif()

if(LIBINT2_FOUND AND NOT TARGET Libint2::LibintCXX)
add_library(Libint2::LibintCXX INTERFACE IMPORTED)
set_target_properties(Libint2::LibintCXX PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LIBINT2_INCLUDE_DIRS}"
)
set_target_properties(Libint2::LibintCXX PROPERTIES
INTERFACE_COMPILE_FEATURES "cxx_std_11"
)
target_link_libraries(Libint2::LibintCXX INTERFACE Libint2::Libint)
endif()

else(PKG_CONFIG_FOUND)

message(FATAL_ERROR "Could not find the required pkg-config executable")

endif(PKG_CONFIG_FOUND)
@@ -30,7 +30,7 @@ export::
done
(cd export && $(MAKE) $(DODEPENDOPT) export) || exit 1;

install:: all install_pkgconfig install_inc install_data
install:: all install_pkgconfig install_cmake install_inc install_data
for dir in $(SUBDIRS); \
do \
(cd $${dir} && $(MAKE) $(DODEPENDOPT) install) || exit 1; \
@@ -42,6 +42,12 @@ install_pkgconfig::
$(INSTALL) $(INSTALLLIBOPT) $(TOPDIR)/libint2.pc $(DESTDIR)$(pkgconfigdir)
endif

ifdef cmakedir
install_cmake::
$(INSTALL) $(INSTALLDIROPT) $(DESTDIR)$(cmakedir)
$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/FindLibint2.cmake $(DESTDIR)$(cmakedir)
endif

install_data::
$(INSTALL) $(INSTALLDIROPT) $(DESTDIR)$(datadir)/basis
$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/lib/basis/* $(DESTDIR)$(datadir)/basis
@@ -5,7 +5,7 @@ all:: default

default:: $(TOPDIR)/lib/$(TARGET)

INSTALL_TARGETS = install_inc install_target install_pkgconfig install_data
INSTALL_TARGETS = install_inc install_target install_pkgconfig install_cmake install_cmake install_data

ifeq ($(ENABLE_FORTRAN),yes)
INSTALL_TARGETS += install_fortran
@@ -34,6 +34,10 @@ install_pkgconfig::
$(INSTALL) $(INSTALLDIROPT) $(DESTDIR)$(pkgconfigdir)
$(INSTALL) $(INSTALLLIBOPT) $(TOPDIR)/libint2.pc $(DESTDIR)$(pkgconfigdir)

install_cmake::
$(INSTALL) $(INSTALLDIROPT) $(DESTDIR)$(cmakedir)
$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/FindLibint2.cmake $(DESTDIR)$(cmakedir)

install_data::
$(INSTALL) $(INSTALLDIROPT) $(DESTDIR)$(datadir)/basis
$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/lib/basis/* $(DESTDIR)$(datadir)/basis
@@ -83,6 +83,7 @@ bindir=@bindir@
libdir=@libdir@
includedir=@libintincludedir@
pkgconfigdir=@PKGCONFIGDIR@
cmakedir=@CMAKEDIR@
datadir=@datarootdir@/libint/$(LIBINT_VERSION)

RANLIB = @RANLIB@
@@ -36,6 +36,7 @@ strip_some_preproc_symb:: exportdir

exportdir::
-$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/libint2.pc.in $(TOPDIR)/$(EXPORTDIR)
-$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/FindLibint2.cmake $(TOPDIR)/$(EXPORTDIR)
-$(INSTALL) $(INSTALLLIBOPT) $(SRCDIR)/INSTALL.export $(TOPDIR)/$(EXPORTDIR)/INSTALL
-$(INSTALL) $(INSTALLLIBOPT) $(SRCDIR)/LICENSE.export $(TOPDIR)/$(EXPORTDIR)/LICENSE
-$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/README.md $(TOPDIR)/$(EXPORTDIR)/README.md
@@ -168,6 +168,13 @@ PKGCONFIGDIR=$withval
)
AC_SUBST(PKGCONFIGDIR)

CMAKEDIR='$(libdir)/cmake/libint2'
AC_ARG_WITH(cmakedir,
AS_HELP_STRING([--with-cmakedir],[Specifies the location to put FindLibint2.cmake file. Default is $(libdir)/cmake/libint2.]),
CMAKEDIR=$withval
)
AC_SUBST(CMAKEDIR)

# these definitions must match configure.ac
LIBINT_SHGSHELL_ORDERING_STANDARD=1
LIBINT_SHGSHELL_ORDERING_GAUSSIAN=2
@@ -1,5 +1,5 @@

.PHONY: default export install install_inc install_target clean oclean distclean targetclean realclean
.PHONY: default export install install_inc install_pkgconfig install_cmake install_target clean oclean distclean targetclean realclean

default:: $(TOPDIR)/lib/$(TARGET)

@@ -18,7 +18,7 @@ export:: source
$(TOPDIR)/lib/$(TARGET): source
cd $(LIBSRCLINK); $(MAKE) TO_TOPDIR=$(TO_TOPDIR) TOPDIR=$(TOPOBJDIR) SRCDIR=$(SRCDIR)

install:: install_inc install_target install_pkgconfig install_data
install:: install_inc install_target install_pkgconfig install_cmake install_data

HAVE_SYSTEM_BOOST_PREPROCESSOR_VARIADICS = @HAVE_SYSTEM_BOOST_PREPROCESSOR_VARIADICS@

@@ -50,6 +50,12 @@ install_pkgconfig::
$(INSTALL) $(INSTALLLIBOPT) $(TOPDIR)/libint2.pc $(DESTDIR)$(pkgconfigdir)
endif

ifdef cmakedir
install_cmake::
$(INSTALL) $(INSTALLDIROPT) $(DESTDIR)$(cmakedir)
$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/FindLibint2.cmake $(DESTDIR)$(cmakedir)
endif

install_data::
$(INSTALL) $(INSTALLDIROPT) $(DESTDIR)$(datadir)/basis
$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/lib/basis/* $(DESTDIR)$(datadir)/basis
@@ -89,6 +89,7 @@ bindir=@bindir@
libdir=@libdir@
includedir=@libintincludedir@
pkgconfigdir=@PKGCONFIGDIR@
cmakedir=@CMAKEDIR@
datadir=@datarootdir@/libint/$(LIBINT_VERSION)

RANLIB = @RANLIB@

0 comments on commit b2558eb

Please sign in to comment.
You can’t perform that action at this time.