Modules
MPQC is a collection of libraries linked into a small end-user program. Each library is a logical module; eventually they will become C++ modules, with proper separation between public interface and implementation details, when support for modules by the compilers and build tools becomes more mature. In the meantime, it is programmer's responsibility to organize the MPQC source code and build harness appropriately to emulate modular behavior.
Modular structure of MPQC is shown below.
Source code organization, as detailed in The Source Tree , directly mirrors the modular structure of MPQC. The following rules govern the source code structure, and the related structure of the build harness.
1 Library per Directory: Each library should be located in its own directory, with single CMakeLists.txt
. There may be additional subdirectories, if needed, but they should not contain their own CMakeLists.txt
. Library's CMakeLists.txt
defines the CMake library target by invoking either add_mpqc_hdr_library
(for a header-only library) or add_mpqc_library
(for non-header-only library). Dependence of the library on other MPQC libraries and external dependencies (which have corresponding CMake imported targets) must be explicitly expressed by establishing dependence of the CMake library target of the corresponding prerequisite targets. Library's dependence on its prerequisites can occur at compile-time (by #include
public header files of the prerequisite) and link-time (by containing references to symbols defined in the prerequisite's public binary artifacts, such as, object files, static libraries, shared libraries, and frameworks). Both types of dependencies must be specified explicitly. N.B. although omitting compile-time dependence on other MPQC libraries usually will not cause a mis-build, it can; specifying compile-time dependencies between CMake targets will also help to determine dependencies between MPQC C++ modules in the future.
This example shows how the CMake target is defined for the library located in src/mpqc/chemistry/qc/lcao/wfn
:
Single Forward Declaration Header: Each library's forward declarations are collected in the fwd.h
file. work in progress
Explicit Instantiation of Template Functions/Classes: Expensive-to-compile template classes and functions should be instantiated and included in library's binary artifact. Implementations of such templates should be separated from the header file in which they are declared and included in a separate "implementation header" file; following Boost such file should have .ipp
extension. work in progress
Single Linkage Artifacts Header: Each library's forward declarations are collected in the linkage.h
file. work in progress