lucasmyers97 / maier-saupe-lc-hydrodynamics

Work at University of Minnesota using finite element methods to simulate hydrodynamics of liquid crystals with a Maier-Saupe field theory free energy
4 stars 0 forks source link

CMake and Library Restructuring #1

Closed tomeichlersmith closed 3 years ago

tomeichlersmith commented 3 years ago

(will edit/comment further later tonight after we meet)

Goals

tomeichlersmith commented 3 years ago

Random Notes

Diatribe About Dynamic Linking

Long ago (in a galaxy far far away), we needed to save space on our computers because our hard-drives were very small. In those days, reducing code copying was a necessity and so "linking" was invented. This allows a program or a library to refer to a "library" of code and use its code by "linking" to it after compiling. Refering to a library can be done in two ways.

  1. "Static" - the full path to the library is given.
  2. "Dynamic" - just the name of the library is given and the system has to sort out where it is.

Dynamic is more common so that two people can have a different directory structure but still use the same programs. This whole explanation only exists to point out that you have to tell the computer where to find the libraries you want your program to link to. In the terminal I'm used to using bash, this is done via a set of environment variables that are lists of directories separated by colons :. The useful environment variables I've found are in the table below.

Variable Purpose
PATH Directories to search when trying to find a command to run on the command line
LD_LIBRARY_PATH Directories to search when trying to find a library to link
CMAKE_PREFIX_PATH Directories to search when trying to find a package in CMake

The environment script I've written assumes that your directory structure looks like this:

- base
  - dealii-9.3.1
    - install
  - eigen-3.4.0
    - install
  - hdf5-1.12.0
    - install
  - HighFive
    - install
  - maier-saupe-lc-hydrodynamics
    - install

where the install directory is alongside the source code just for ease. Then you can define the necessary environment variables using

source env.sh <full-path-to-base>

This may not be the way you want to work, but I'm hoping the environment script will give you the necessary tools to modify it to your own workflow.

tomeichlersmith commented 3 years ago

I noticed that you are using Boost's unit test framework to write some tests. It's good that you are thinking about writing tests.

Boost's unit test framework is mainly geared towards testing various aspects of a library. Another testing framework comes with CMake which may work better for you because it is focused on testing the behavior of executables. You can go with either or both, just wanted to offer another option.