Skip to content

Commit

Permalink
Merge pull request #568 from thelfer/555-cmake-better-handling-of-dep…
Browse files Browse the repository at this point in the history
…endencies-in-exported-cmake-files

555 cmake better handling of dependencies in exported cmake files
  • Loading branch information
thelfer authored May 21, 2024
2 parents 99fa428 + 021f7ca commit cabd3b4
Show file tree
Hide file tree
Showing 23 changed files with 348 additions and 4 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,18 @@ if(install-system-libraries)

endif(install-system-libraries)

# install tfel-modules-common.cmake

if(TFEL_APPEND_SUFFIX)
install(FILES cmake/modules/tfel-modules-common.cmake
DESTINATION "share/tfel-${TFEL_SUFFIX}/cmake"
COMPONENT core)
else(TFEL_APPEND_SUFFIX)
install(FILES cmake/modules/tfel-modules-common.cmake
DESTINATION "share/tfel/cmake"
COMPONENT core)
endif(TFEL_APPEND_SUFFIX)

# install licences
if(TFEL_APPEND_SUFFIX)
install (FILES LICENCE-GNU-GPL
Expand Down
11 changes: 11 additions & 0 deletions cmake/modules/tfel-modules-common.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if(TFEL_DIR)
set(TFEL_MODULE_PATH ${TFEL_DIR})
else(TFEL_DIR)
if(TFELHOME)
set(TFEL_MODULE_PATH ${TFELHOME})
else(TFELHOME)
if(DEFINED ENV{TFELHOME})
set(TFEL_MODULE_PATH "$ENV{TFELHOME}")
endif(DEFINED ENV{TFELHOME})
endif(TFELHOME)
endif(TFEL_DIR)
1 change: 1 addition & 0 deletions docs/web/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pandoc_html(packages)
pandoc_html(about)
pandoc_html(svn)
pandoc_html(devel)
pandoc_html(libraries_usage "--toc" "--toc-depth=3")
pandoc_html(mtest)
pandoc_html(mtest-python "--toc" "--toc-depth=3")
pandoc_html(tutorial "--toc" "--toc-depth=3")
Expand Down
2 changes: 1 addition & 1 deletion docs/web/devel.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ can be invoked as follows:

~~~~ {#check_all .bash}
$ $SRCDIR/check_all [-j $NBPROCS]
~~~~~~~~~~~~~~~~~~~~~~
~~~~

where `SRCDIR` is the path to the source directory. The `-j` option
allows the user to specify the number of jobs that the `make` command
Expand Down
145 changes: 145 additions & 0 deletions docs/web/libraries_usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
---
title: Using the `TFEL` libraries in `C++`
author: Thomas Helfer, Maxence Wangermez
date: 2024
lang: en-EN
numbersections: true
documentclass: article
from: markdown+tex_math_single_backslash
geometry:
- margin=2cm
papersize: a4
link-citations: true
colorlinks: true
figPrefixTemplate: "$$i$$"
tblPrefixTemplate: "$$i$$"
secPrefixTemplate: "$$i$$"
eqnPrefixTemplate: "($$i$$)"
---

The `TFEL` project generates several `C++` libraries that can be used
directly: `TFELMFront`, `TFELMTest`, `TFELSystem`,
[`TFELMaterial`](tfel-material.html), `TFELMathCubicSpline`,
`TFELMathKriging`, `TFELMathParser`, [`TFELMath`](tfel-math.html),
`TFELTests`, `TFELCheck`, `TFELException`, `TFELGlossary`,
`TFELUtilities`, `TFELNUMODIS`, `TFELConfig`, and `TFELUnicodeSupport`.

Using those libraries requires in practice to add several pre-processor,
compiler or linker flags, including paths to headers and libraries, and
handling dependencies between those libraries.

The `TFEL` project provides two tools to ease developers' life:

- the `tfel-config` utility,
- a set of [`cmake`](https://cmake.org/) packages.

# Using `tfel-config`

The `tfel-config` utility provides many informations useful for
compiling projects based on the `TFEL` libraries. This utility is used
internally by `MFront` (see [this
page](compiling-mfront-shared-libraries.html) for details).

## Paths

Most paths are influenced by the `TFELHOME` environment variable. If this
variable is not defined, then the installation path, defined by the
`CMAKE_INSTALL_PREFIX` variable, is used.

### Headers

The following flags allow to get the paths toward the `TFEL` headers.

- `--include-path`: returns the path to the `TFEL` headers.
- `--includes`: returns pre-processor directives to include the `TFEL`
headers.

### Libraries

The following flags allow to request information for the linker:

- `--library-path`: returns the path to the `TFEL` libraries.
- `--libs`: returns linker directives to link with the selected libraries
(see below). This option also returns the linker directives for the
dependencies of the selected libraries.

## Compilation flags

The following flags allow to request various pre-processor, compiler or
linker flags:

- `--compiler-flags` : returns TFEL's recommended compiler flags.
- `--cppflags` : returns flags related to the `C++` standard used.
- `--cxx-standard` : prints the version of the `C++` standard used to
compile TFEL.
- `--debug-flags` : returns flags adding debugging symbols.
- `--ldflags` : returns linking flags.
- `--oflags` : returns tfel recommended optimisation flags with
architecture specific flags.
- `--oflags0` : returns tfel recommended optimisation flags without
architecture specific flags.
- `--oflags2` : returns some aggressive optimisation flags, possibly at
the expense of numerical precision. This shall be added to `--oflags`
results.

Note that those flags are consistent with the compiler used to compile
the `TFEL` project.

## Selection of the libraries

The following flags allow to select specific libraries:

- `--material` : requests flags for the `TFELMaterial` library.
- `--math` : requests flags for the `TFELMath` library.
- `--math-cubic-spline`: requests flags for the `TFELMathCubicSpline` library.
- `--math-kriging` : requests flags for the `TFELMathKriging` library.
- `--math-parser` : requests flags for the `TFELMathParser` library.
- `--numodis` : requests flags for the `TFELNUMODIS` library.
- `--exceptions` : requests flags for the `TFELException` library.
- `--glossary` : requests flags for the `TFELGlossary` library.
- `--mfront-profiling` : requests flags for the `libMFrontProfiling` library.

## Examples of usage

The following examples showcase typical usages of `tfel-config`:

~~~~{.bash}
$ tfel-config --includes
-I<TFEL_INSTALL_PATH>/include
$ tfel-config --include-path
<TFEL_INSTALL_PATH>/include
$ tfel-config --libs --math-parser
-L<TFEL_INSTALL_PATH>/lib -lTFELMathParser -lTFELMathKriging -lTFELMath -lTFELUnicodeSupport -lTFELException
~~~~

In those example, `<TFEL_INSTALL_PATH>` is to be replaced by the actual
installation path of the `TFEL` project.

# Using `cmake`

The following `cmake` packages are available: `TFELMFront`, `TFELMTest`,
`TFELMaterial`, `TFELMath`, `TFELMathCubicSpline`, `TFELMathKriging`,
`TFELMathParser`, `TFELSystem`, `TFELNUMODIS`, `TFELCheck`,
`TFELUtilities`, `TFELGlossary`, `TFELTests`, `TFELUnicodeSupport`,
`TFELException`, `TFELConfig`

Those packages can be loaded using the `find_package` command. It is
highly recommended to pass the `TFEL_DIR` to `cmake` to indicate where
the `TFEL` library has been installed.

Note that those packages import targets in the `tfel::` namespace.

## Example of usage

The following `CMakeLists.txt` file declares a simple executable relying
the `TFELMathCubicSpline` library:

~~~~{.cmake}
project(Test)
cmake_minimum_required(VERSION 3.13)
set(CMAKE_CXX_STANDARD 20)
set(CXX_STANDARD_REQUIRED ON)
find_package(TFELMathCubicSpline REQUIRED HINTS "${TFEL_DIR}/share/tfel/cmake")
add_executable(test main.cxx)
target_link_libraries(test tfel::TFELMathCubicSpline)
~~~~
1 change: 1 addition & 0 deletions docs/web/mfront-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
</li>
<li><a>TFEL libraries</a>
<ul>
<li><a href="libraries_usage.html">Usage of the TFEL libraries in C++</a></li>
<li><a href="tfel-math.html">TFEL/Math</a></li>
<li><a href="tfel-material.html">TFEL/Material</a></li>
</ul>
Expand Down
16 changes: 13 additions & 3 deletions docs/web/release-notes-5.0.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Release notes of the 5.0 version of `TFEL`, `MFront` and `MTest`
author: Thomas Helfer, Maxence Wangermez
date: 2020
date: 2024
lang: en-EN
numbersections: true
documentclass: article
Expand Down Expand Up @@ -121,16 +121,26 @@ where \(\varepsilon\) is the accuracy of the floatting point considered.

The results of those tests are reported on Tables
@tbl:comp_eigensolvers_float, @tbl:comp_eigensolvers_double and
@tbl:comp_eigensolvers_long_double:
@tbl:comp_eigensolvers_long_double. The Harari eigen solver offers a
better compromise between accuracy and numerical efficiency than the
default `TFEL` solver.

- The Harari eigen solver offers a better compromise between accuracy and numerical efficiency than the default `TFEL` solver.
# Documentation

The page [Libaries usage in C++](libraries_usage.html) describe how to
use the `TFEL` libraries in `C++` projects, using either the
`tfel-config` utility or `cmake` packages.

# Issues fixed

## Issue 557: `[mfront]` allow to specify dsl options in `MFrontBase::getDSL`

For more details, see <https://github.com/thelfer/tfel/issues/557>

## Issue 555: [cmake] better handling of dependencies in exported `cmake` files

For more details, see <https://github.com/thelfer/tfel/issues/556>

## Issue 526: The `@UseQt` keyword is not mentioned in the `MaterialLaw`'s keywords help page

For more details, see <https://github.com/thelfer/tfel/issues/526>
Expand Down
17 changes: 17 additions & 0 deletions mfront/src/TFELMFrontConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@PACKAGE_INIT@

find_package(TFELConfig REQUIRED)
find_package(TFELException REQUIRED)
find_package(TFELUnicodeSupport REQUIRED)
find_package(TFELGlossary REQUIRED)
find_package(TFELUtilities REQUIRED)
find_package(TFELSystem REQUIRED)
find_package(TFELMath REQUIRED)
find_package(TFELMathKriging REQUIRED)
find_package(TFELMathParser REQUIRED)
find_package(TFELMathCubicSpline REQUIRED)
find_package(TFELNumodis REQUIRED)
find_package(TFELMaterial REQUIRED)
find_package(MFrontLogStream REQUIRED)

include("${CMAKE_CURRENT_LIST_DIR}/TFELMFrontTargets.cmake")
17 changes: 17 additions & 0 deletions mfront/src/TFELMFrontStaticConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@PACKAGE_INIT@

find_package(TFELConfigStaticStatic REQUIRED)
find_package(TFELExceptionStatic REQUIRED)
find_package(TFELUnicodeSupportStatic REQUIRED)
find_package(TFELGlossaryStatic REQUIRED)
find_package(TFELUtilitiesStatic REQUIRED)
find_package(TFELSystemStatic REQUIRED)
find_package(TFELMathStatic REQUIRED)
find_package(TFELMathKrigingStatic REQUIRED)
find_package(TFELMathParserStatic REQUIRED)
find_package(TFELMathCubicSplineStatic REQUIRED)
find_package(TFELNumodisStatic REQUIRED)
find_package(TFELMaterialStatic REQUIRED)
find_package(MFrontLogStreamStatic REQUIRED)

include("${CMAKE_CURRENT_LIST_DIR}/TFELMFrontStaticTargets.cmake")
7 changes: 7 additions & 0 deletions src/Glossary/TFELGlossaryConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/tfel-modules-common.cmake")
find_package(TFELGlossary REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")

include("${CMAKE_CURRENT_LIST_DIR}/TFELGlossaryTargets.cmake")
7 changes: 7 additions & 0 deletions src/Glossary/TFELGlossaryStaticConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/tfel-modules-common.cmake")
find_package(TFELUtilitiesStatic REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")

include("${CMAKE_CURRENT_LIST_DIR}/TFELGlossaryStaticTargets.cmake")
13 changes: 13 additions & 0 deletions src/Material/TFELMaterialConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/tfel-modules-common.cmake")
find_package(TFELException REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")
find_package(TFELUtilities REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")
find_package(TFELNumodis REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")
find_package(TFELMath REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")

include("${CMAKE_CURRENT_LIST_DIR}/TFELMaterialTargets.cmake")
13 changes: 13 additions & 0 deletions src/Material/TFELMaterialStaticConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/tfel-modules-common.cmake")
find_package(TFELExceptionStatic REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")
find_package(TFELUtilitiesStatic REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")
find_package(TFELNumodisStatic REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")
find_package(TFELMathStatic REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")

include("${CMAKE_CURRENT_LIST_DIR}/TFELMaterialStaticTargets.cmake")
7 changes: 7 additions & 0 deletions src/Math/TFELMathConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/tfel-modules-common.cmake")
find_package(TFELException REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")

include("${CMAKE_CURRENT_LIST_DIR}/TFELMathTargets.cmake")
9 changes: 9 additions & 0 deletions src/Math/TFELMathCubicSplineConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/tfel-modules-common.cmake")
find_package(TFELException REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")
find_package(TFELMath REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")

include("${CMAKE_CURRENT_LIST_DIR}/TFELMathCubicSplineTargets.cmake")
9 changes: 9 additions & 0 deletions src/Math/TFELMathCubicSplineStaticConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/tfel-modules-common.cmake")
find_package(TFELExceptionStatic REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")
find_package(TFELMathStatic REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")

include("${CMAKE_CURRENT_LIST_DIR}/TFELMathCubicSplineStaticTargets.cmake")
9 changes: 9 additions & 0 deletions src/Math/TFELMathKrigingConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/tfel-modules-common.cmake")
find_package(TFELException REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")
find_package(TFELMath REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")

include("${CMAKE_CURRENT_LIST_DIR}/TFELMathKrigingTargets.cmake")
9 changes: 9 additions & 0 deletions src/Math/TFELMathKrigingStaticConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/tfel-modules-common.cmake")
find_package(TFELExceptionStatic REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")
find_package(TFELMathStatic REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")

include("${CMAKE_CURRENT_LIST_DIR}/TFELMathKrigingStaticTargets.cmake")
13 changes: 13 additions & 0 deletions src/Math/TFELMathParserConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/tfel-modules-common.cmake")
find_package(TFELException REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")
find_package(TFELUnicodeSupport REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")
find_package(TFELMath REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")
find_package(TFELMathKriging REQUIRED
HINTS "${CMAKE_CURRENT_LIST_DIR}" "${TFEL_MODULE_PATH}")

include("${CMAKE_CURRENT_LIST_DIR}/TFELMathParserTargets.cmake")
Loading

0 comments on commit cabd3b4

Please sign in to comment.