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
79 changes: 79 additions & 0 deletions cmake/QUIPConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)
find_dependency(BLAS)
find_dependency(LAPACK)

# Find QUIP libraries
find_library(QUIP_POTENTIALS_LIBRARY NAMES Potentials HINTS "${PACKAGE_PREFIX_DIR}/lib")
find_library(QUIP_LIBATOMS_LIBRARY NAMES libAtoms HINTS "${PACKAGE_PREFIX_DIR}/lib")
find_library(QUIP_FOX_LIBRARY NAMES fox HINTS "${PACKAGE_PREFIX_DIR}/lib")
find_library(QUIP_UTILS_LIBRARY NAMES Utils HINTS "${PACKAGE_PREFIX_DIR}/lib")
# f90wrap stub provides f90wrap_abort for non-Python usage
find_library(QUIP_F90WRAP_STUB_LIBRARY NAMES f90wrap_stub HINTS "${PACKAGE_PREFIX_DIR}/lib")

# GAP is optional
set(QUIP_HAS_GAP @QUIP_HAS_GAP@)
if(QUIP_HAS_GAP)
find_library(QUIP_GAP_LIBRARY NAMES GAP HINTS "${PACKAGE_PREFIX_DIR}/lib")
endif()

# Create imported targets
if(QUIP_FOX_LIBRARY)
add_library(QUIP::fox SHARED IMPORTED)
set_target_properties(QUIP::fox PROPERTIES IMPORTED_LOCATION "${QUIP_FOX_LIBRARY}")
endif()

# f90wrap stub target (static library providing f90wrap_abort for non-Python usage)
if(QUIP_F90WRAP_STUB_LIBRARY)
add_library(QUIP::f90wrap_stub STATIC IMPORTED)
set_target_properties(QUIP::f90wrap_stub PROPERTIES IMPORTED_LOCATION "${QUIP_F90WRAP_STUB_LIBRARY}")
endif()

if(QUIP_LIBATOMS_LIBRARY)
add_library(QUIP::libAtoms SHARED IMPORTED)
set_target_properties(QUIP::libAtoms PROPERTIES
IMPORTED_LOCATION "${QUIP_LIBATOMS_LIBRARY}"
INTERFACE_LINK_LIBRARIES "QUIP::f90wrap_stub;QUIP::fox;${BLAS_LIBRARIES};${LAPACK_LIBRARIES}")
endif()

if(QUIP_HAS_GAP AND QUIP_GAP_LIBRARY)
add_library(QUIP::GAP SHARED IMPORTED)
set_target_properties(QUIP::GAP PROPERTIES
IMPORTED_LOCATION "${QUIP_GAP_LIBRARY}"
INTERFACE_LINK_LIBRARIES "QUIP::libAtoms")
endif()

if(QUIP_POTENTIALS_LIBRARY)
add_library(QUIP::Potentials SHARED IMPORTED)
set_target_properties(QUIP::Potentials PROPERTIES
IMPORTED_LOCATION "${QUIP_POTENTIALS_LIBRARY}")
if(QUIP_HAS_GAP)
set_target_properties(QUIP::Potentials PROPERTIES
INTERFACE_LINK_LIBRARIES "QUIP::GAP;QUIP::libAtoms")
else()
set_target_properties(QUIP::Potentials PROPERTIES
INTERFACE_LINK_LIBRARIES "QUIP::libAtoms")
endif()
endif()

if(QUIP_UTILS_LIBRARY)
add_library(QUIP::Utils SHARED IMPORTED)
set_target_properties(QUIP::Utils PROPERTIES
IMPORTED_LOCATION "${QUIP_UTILS_LIBRARY}"
INTERFACE_LINK_LIBRARIES "QUIP::Potentials")
endif()

# Unified target for convenience
add_library(QUIP::QUIP INTERFACE IMPORTED)
if(QUIP_HAS_GAP)
set_target_properties(QUIP::QUIP PROPERTIES
INTERFACE_LINK_LIBRARIES "QUIP::Utils;QUIP::Potentials;QUIP::GAP;QUIP::libAtoms;QUIP::fox")
else()
set_target_properties(QUIP::QUIP PROPERTIES
INTERFACE_LINK_LIBRARIES "QUIP::Utils;QUIP::Potentials;QUIP::libAtoms;QUIP::fox")
endif()

set(QUIP_FOUND TRUE)
set(QUIP_LIBRARIES QUIP::QUIP)
set(QUIP_VERSION @QUIP_VERSION@)
20 changes: 20 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,23 @@ endif

subdir('src')

# CMake package config generation for find_package(QUIP) support
cmake = import('cmake')

cmake_conf = configuration_data()
cmake_conf.set('QUIP_VERSION', meson.project_version())
cmake_conf.set('QUIP_HAS_GAP', get_option('gap') ? 'TRUE' : 'FALSE')

cmake.write_basic_package_version_file(
name: 'QUIP',
version: meson.project_version(),
compatibility: 'SameMajorVersion',
install_dir: get_option('libdir') / 'cmake' / 'QUIP'
)

cmake.configure_package_config_file(
name: 'QUIP',
input: 'cmake/QUIPConfig.cmake.in',
configuration: cmake_conf,
install_dir: get_option('libdir') / 'cmake' / 'QUIP'
)
2 changes: 1 addition & 1 deletion src/GAP
Submodule GAP updated 1 files
+1 −0 meson.build
1 change: 1 addition & 0 deletions src/Potentials/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ Potentials = library('Potentials',
],
link_with : [libAtoms,fox,GAP],
link_args: openmp_link_args,
install: true,
)
1 change: 1 addition & 0 deletions src/Utils/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ Utils = library('Utils',
],
link_with : [libAtoms,fox,GAP,Potentials],
link_args: openmp_link_args,
install: true,
)
2 changes: 1 addition & 1 deletion src/fox
Submodule fox updated 1 files
+1 −0 meson.build
5 changes: 4 additions & 1 deletion src/libAtoms/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ libAtoms_c_sources = [
'xyz.c',
'sockets.c',
]
# Create static library for f90wrap stub (linked only with standalone programs)
# Create static library for f90wrap stub (linked with standalone programs and external users)
# This provides the f90wrap_abort implementation for non-Python usage
f90wrap_stub_lib = static_library('f90wrap_stub',
'f90wrap_stub.F90',
install: true,
)

# Platform-specific link args
Expand All @@ -84,4 +86,5 @@ libAtoms = library('libAtoms',
c_args: ['-DPROTOTYPES=1'],
link_args: libatoms_link_args,
override_options: ['b_lundef=false'], # Allow undefined symbols
install: true,
)
Loading