Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions cmake/libint2-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,26 @@ list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
# check library language component
include(CMakeFindDependencyMacro)

if(NOT TARGET Eigen3::Eigen)
set(Eigen3_CONFIG @Eigen3_CONFIG@)
if (NOT Eigen3_CONFIG OR NOT EXISTS ${Eigen3_CONFIG})
message(WARNING "Libint2 library was built with Eigen3Config.cmake detected at ${Eigen3_CONFIG}, but this path is no longer valid; directory moved since Libint2 library build?")
find_dependency(Eigen3 REQUIRED)
else()
get_filename_component(Eigen3_DIR "${Eigen3_CONFIG}" DIRECTORY)
find_dependency(Eigen3 REQUIRED HINTS "${Eigen3_DIR}")
endif()
get_filename_component(_LIBINT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
if(EXISTS "${_LIBINT_PREFIX}/include/libint2/eigen3/Eigen/Core")
if(NOT TARGET Eigen3::Eigen)
add_library(Eigen3::Eigen INTERFACE IMPORTED)
set_target_properties(Eigen3::Eigen PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_LIBINT_PREFIX}/include/libint2/eigen3"
)
endif()
else()
if(NOT TARGET Eigen3::Eigen)
set(Eigen3_CONFIG @Eigen3_CONFIG@)
if (NOT Eigen3_CONFIG OR NOT EXISTS ${Eigen3_CONFIG})
include(CMakeFindDependencyMacro)
find_dependency(Eigen3 REQUIRED)
else()
include(CMakeFindDependencyMacro)
get_filename_component(Eigen3_DIR "${Eigen3_CONFIG}" DIRECTORY)
find_dependency(Eigen3 REQUIRED HINTS "${Eigen3_DIR}")
endif()
endif()
endif()

if (@LIBINT_HAS_SYSTEM_BOOST_PREPROCESSOR_VARIADICS@) # LIBINT_HAS_SYSTEM_BOOST_PREPROCESSOR_VARIADICS
Expand Down
37 changes: 35 additions & 2 deletions export/CMakeLists.txt.export
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ option_with_print(LIBINT2_LOCAL_Eigen3_INSTALL
"Install an exported target with hard-coded Eigen3 dependency paths. This is potentially useful and important when consuming the compiled C++11 interface library so that the Libint library build and Libint consumer build use the same Eigen3 installation & ABI. This is at most a convenience when consuming the header-only C++11 interface library. In consumer build, set `LIBINT2_LOCAL_Eigen3_FIND=ON` before `find_package(Libint2) to load the exported Eigen3." OFF)
option_with_print(CMAKE_DISABLE_FIND_PACKAGE_Boost
"When Boost required for C++11 API, disable its detection, thereby forcing use of bundled Boost (Standard CMake variable: https://cmake.org/cmake/help/latest/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.html)" OFF)
option_with_print(CMAKE_DISABLE_FIND_PACKAGE_Eigen3
"Disable Eigen3 detection, thereby forcing use of bundled Eigen3" OFF)

check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
if (HAVE_POSIX_MEMALIGN)
Expand Down Expand Up @@ -167,7 +169,9 @@ if (LIBINT2_REQUIRE_CXX_API)
endif()
endif()

find_package(Eigen3 MODULE)
if (NOT TARGET Eigen3::Eigen AND NOT CMAKE_DISABLE_FIND_PACKAGE_Eigen3)
find_package(Eigen3 MODULE)
endif()

set(LIBINT2_CXX_STANDARD 11)
if (TARGET Eigen3::Eigen)
Expand All @@ -177,6 +181,27 @@ if (TARGET Eigen3::Eigen)
set(LIBINT2_CXX_STANDARD 14)
message(STATUS "Eigen ${EIGEN3_VERSION} requires C++14; setting LIBINT2_CXX_STANDARD=14")
endif()
else()
if (LIBINT2_REQUIRE_CXX_API)
message(STATUS "Unpacking bundled Eigen3...")
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/libint2)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf ${PROJECT_SOURCE_DIR}/external/eigen3.tar.gz
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/include/libint2
RESULT_VARIABLE UNPACK_EIGEN_RESULT
OUTPUT_VARIABLE UNPACK_EIGEN_OUTPUT
ERROR_VARIABLE UNPACK_EIGEN_OUTPUT
)
if (NOT UNPACK_EIGEN_RESULT EQUAL 0)
message(FATAL_ERROR "Failed to unpack the bundled Eigen3!\nThe tar command output:\n${UNPACK_EIGEN_OUTPUT}")
endif()
add_library(Eigen3::Eigen INTERFACE IMPORTED)
set_target_properties(Eigen3::Eigen PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${PROJECT_BINARY_DIR}/include/libint2/eigen3"
)
set(LIBINT_HAS_EIGEN 1)
set(LIBINT_HAS_BUNDLED_EIGEN 1)
endif()
endif()
if (LIBINT2_REQUIRE_CXX_API AND NOT LIBINT_HAS_EIGEN)
message(FATAL_ERROR "C++ API cannot be built without Eigen3; configure (via CMake) and install Eigen3 and add the install prefix to CMAKE_PREFIX_PATH, or add -D LIBINT2_REQUIRE_CXX_API=OFF to the CMake command line if the C++ API is not required")
Expand Down Expand Up @@ -792,13 +817,21 @@ install(CODE "
")

# install bundled Boost headers if needed
if (NOT LIBINT_HAS_SYSTEM_BOOST_PREPROCESSOR_VARIADICS)
if (LIBINT2_REQUIRE_CXX_API AND NOT LIBINT_HAS_SYSTEM_BOOST_PREPROCESSOR_VARIADICS)
install(
DIRECTORY ${PROJECT_BINARY_DIR}/include/libint2/boost
DESTINATION "${LIBINT2_INSTALL_INCLUDEDIR}/libint2"
)
endif()

# install bundled Eigen3 headers if needed
if (LIBINT_HAS_BUNDLED_EIGEN)
install(
DIRECTORY ${PROJECT_BINARY_DIR}/include/libint2/eigen3
DESTINATION "${LIBINT2_INSTALL_INCLUDEDIR}/libint2"
)
endif()

# install basis set library
install(
DIRECTORY ${PROJECT_SOURCE_DIR}/lib/basis
Expand Down
Binary file added external/eigen3.tar.gz
Binary file not shown.
1 change: 1 addition & 0 deletions src/lib/libint/populate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ file(
file(
INSTALL
"${PROJECT_SOURCE_DIR}/external/boost.tar.gz"
"${PROJECT_SOURCE_DIR}/external/eigen3.tar.gz"
DESTINATION "${EXPORT_STAGE_DIR}/external"
)

Expand Down
Loading