Skip to content
Merged
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
7 changes: 7 additions & 0 deletions docs/src/get-started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ The build and installation can be configures with a few cmake options, using
| FEATOMIC_FETCH_METATENSOR | Automatically fetch, build and install | OFF |
| | metatensor (a dependency of featomic) | |
+--------------------------------------+-----------------------------------------------+----------------+
| FEATOMIC_USE_STATIC_METATENSOR | Link against the static version of | OFF |
| | metatensor. You should only use this if you | |
| | know your code will never be loaded with | |
| | together with another library using | |
| | metatensor, for example if you are building | |
| | a fully static executable. | |
+--------------------------------------+-----------------------------------------------+----------------+

Using the Rust library
----------------------
Expand Down
11 changes: 9 additions & 2 deletions featomic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ set(PROJECT_VERSION ${FEATOMIC_FULL_VERSION})
# an installed library (see cmake/featomic-config.cmake)
option(BUILD_SHARED_LIBS "Use a shared library by default instead of a static one" ON)
option(FEATOMIC_INSTALL_BOTH_STATIC_SHARED "Install both shared and static libraries" ON)
option(FEATOMIC_USE_STATIC_METATENSOR "Link featomic with the static metatensor library instead of the shared one" OFF)

set(BIN_INSTALL_DIR "bin" CACHE PATH "Path relative to CMAKE_INSTALL_PREFIX where to install binaries/DLL")
set(LIB_INSTALL_DIR "lib" CACHE PATH "Path relative to CMAKE_INSTALL_PREFIX where to install libraries")
Expand Down Expand Up @@ -384,8 +385,14 @@ else()
endif()

add_dependencies(cargo-build-featomic metatensor)
target_link_libraries(featomic::shared INTERFACE metatensor::shared)
target_link_libraries(featomic::static INTERFACE metatensor::shared)

if (FEATOMIC_USE_STATIC_METATENSOR)
target_link_libraries(featomic::shared INTERFACE metatensor::static)
target_link_libraries(featomic::static INTERFACE metatensor::static)
else()
target_link_libraries(featomic::shared INTERFACE metatensor::shared)
target_link_libraries(featomic::static INTERFACE metatensor::shared)
endif()

#------------------------------------------------------------------------------#
# Installation configuration
Expand Down
8 changes: 7 additions & 1 deletion featomic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ rayon-core = "=1.12"

log = "0.4"
once_cell = "1"
indexmap = "2"
# the last version that supports Rust 1.74
indexmap = "=2.11.4"
thread_local = "1.1"
time-graph = "0.3.0"

Expand All @@ -47,6 +48,11 @@ chemfiles = { version = "0.10", optional = true, features = ["build-from-sources

approx = "0.5"

# the last versions that supports Rust 1.74
serde_spanned = "=1.0.1"
toml_datetime = "=0.7.1"
toml_parser = "=1.0.2"

[build-dependencies]
cbindgen = { version = "0.29", default-features = false }
fs_extra = "1"
Expand Down
18 changes: 16 additions & 2 deletions featomic/cmake/featomic-config.in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ endif()

enable_language(CXX)

if(NOT DEFINED FEATOMIC_USE_STATIC_METATENSOR)
set(FEATOMIC_USE_STATIC_METATENSOR OFF CACHE BOOL "Link featomic with static metatensor by default")
endif()

get_filename_component(FEATOMIC_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/@PACKAGE_RELATIVE_PATH@" ABSOLUTE)

if (WIN32)
Expand Down Expand Up @@ -38,7 +42,12 @@ if (@FEATOMIC_INSTALL_BOTH_STATIC_SHARED@ OR @BUILD_SHARED_LIBS@)
INTERFACE_INCLUDE_DIRECTORIES ${FEATOMIC_INCLUDE}
BUILD_VERSION "@FEATOMIC_FULL_VERSION@"
)
target_link_libraries(featomic::shared INTERFACE metatensor::shared)

if (FEATOMIC_USE_STATIC_METATENSOR)
target_link_libraries(featomic::shared INTERFACE metatensor::static)
else()
target_link_libraries(featomic::shared INTERFACE metatensor::shared)
endif()

target_compile_features(featomic::shared INTERFACE cxx_std_17)

Expand Down Expand Up @@ -67,7 +76,12 @@ if (@FEATOMIC_INSTALL_BOTH_STATIC_SHARED@ OR NOT @BUILD_SHARED_LIBS@)
INTERFACE_LINK_LIBRARIES "@CARGO_DEFAULT_LIBRARIES@"
BUILD_VERSION "@FEATOMIC_FULL_VERSION@"
)
target_link_libraries(featomic::static INTERFACE metatensor::shared)

if (FEATOMIC_USE_STATIC_METATENSOR)
target_link_libraries(featomic::static INTERFACE metatensor::static)
else()
target_link_libraries(featomic::static INTERFACE metatensor::shared)
endif()

target_compile_features(featomic::static INTERFACE cxx_std_17)
endif()
Expand Down
10 changes: 8 additions & 2 deletions featomic/tests/cmake-project/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ string(REGEX REPLACE "([0-9]*)\\.([0-9]*).*" "\\1.\\2" REQUIRED_FEATOMIC_VERSION
find_package(featomic ${REQUIRED_FEATOMIC_VERSION} REQUIRED)

add_executable(c-main main.c)
target_link_libraries(c-main featomic)
target_link_libraries(c-main featomic::shared)

add_executable(c-main-static main.c)
target_link_libraries(c-main-static featomic::static)

add_executable(cxx-main main.cpp)
target_link_libraries(cxx-main featomic)
target_link_libraries(cxx-main featomic::shared)

add_executable(cxx-main-static main.cpp)
target_link_libraries(cxx-main-static featomic::static)
Loading