@@ -59,3 +59,74 @@ PR and proposal was approved by "vast majority".
5959
6060You are welcome to propose changes to this workflow by opening an
6161[ issue] ( https://github.com/fortran-lang/stdlib/issues ) .
62+
63+
64+ ## Build system
65+
66+ This project supports two build systems right now, CMake and make.
67+ Eventually, stdlib will be using the Fortran package manager
68+ ([ fpm] ( https://github.com/fortran-lang/fpm ) ) as build system as well.
69+ The effort of supporting fpm is tracked in issue
70+ [ #279 ] ( https://github.com/fortran-lang/stdlib/issues/279 ) .
71+
72+
73+ ### CMake build files
74+
75+ The build files for CMake allow both in-tree, * i.e.* build artifacts share
76+ the same tree as the source files, and out-of-tree builds, * i.e.* build artifacts
77+ exist in a separate directory tree.
78+ Both build types are explicitly supported and tested, the latter strategy
79+ is recommended for local development.
80+
81+ Sources for the main library target are added in `` src/CMakeLists.txt ``
82+ relative to the library target, * i.e.* no absolute paths are required.
83+
84+ To add tests, the macro `` ADDTEST `` should be used instead of the CMake function
85+ `` add_test `` , the macro hides creation of the executable target, linking against the
86+ main library target and registering the test.
87+ The tests themselves are defined as standalone executables in the subdirectories
88+ in `` src/tests `` , a new subdirectory with tests has to be registred in
89+ `` src/tests/CMakeLists.txt `` .
90+
91+ The source tree should be considered read-only. References to `` PROJECT_SOURCE_DIR ``
92+ and `` CMAKE_CURRENT_SOURCE_DIR `` should only be used for accessing source files,
93+ never to write build outputs, use `` PROJECT_BINARY_DIR `` and `` CMAKE_CURRENT_BINARY_DIR ``
94+ to write build artifacts instead.
95+ To fully support in-tree builds, build artifacts must never have the same name as
96+ source files to avoid accidentally overwriting them, * e.g.* when preprocessing or
97+ configuring a file.
98+
99+ The `` CMAKE_INSTALL_PREFIX `` should only be written to on install, never in the build
100+ process. To install generated files, create a build output in the build tree and
101+ install it with the `` install `` function.
102+ This project follows the GNU install conventions, this means that the variables
103+ `` CMAKE_INSTALL_BINDIR `` , `` CMAKE_INSTALL_LIBDIR `` , and `` CMAKE_INSTALL_INCLUDEDIR ``
104+ must be used instead of `` bin `` , `` lib `` , and `` include `` , respectively.
105+ Library targets should be exported on install to allow correct inclusion of the
106+ project in other CMake projects.
107+ Prefer dashes as in `` project-config `` or `` project-targets `` over camel-case as in
108+ `` projectConfig `` or `` projectTarget `` for file names as the former allows easier
109+ construction from the `` PROJECT_NAME `` variable by concatenation.
110+
111+ The project is usable as CMake subproject. Explicit references to
112+ `` CMAKE_SOURCE_DIR `` and `` CMAKE_BINARY_DIR `` must be avoided to not
113+ break subproject builds.
114+ An example project is available [ here] ( https://github.com/fortran-lang/stdlib-cmake-example )
115+ to test the CMake subproject integration.
116+
117+
118+ ### Make build files
119+
120+ The build files for `` make `` are using the name `` Makefile.manual `` to
121+ not conflict with the in-tree build of CMake.
122+ This project uses recursive make to transverse the subdirectory structure
123+ from the top-level makefile, called `` Makefile.manual `` , and the build
124+ happens in-tree, * i.e.* build artifacts are present along with the source code.
125+
126+ New source files are added in `` src/Makefile.manual `` and include manual
127+ dependency definitions through the object files to allow parallel
128+ compilation.
129+ Tests are generated by the make include file `` src/tests/Makefile.manual.test.mk ``
130+ and defined in the subdirectories of the `` src/tests `` as entries in `` PROGS_SRC `` .
131+ New subdirectories have to be explicitly added to `` src/tests/Makefile.manual ``
132+ or are ignored.
0 commit comments