Skip to content

Commit c41a394

Browse files
committed
redorder module vs standalone discussion
1 parent a2356c5 commit c41a394

File tree

1 file changed

+35
-27
lines changed

1 file changed

+35
-27
lines changed

source/arche/cmake.rst

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,44 @@ listing:
9595

9696
Examples
9797
--------
98-
98+
99+
Module Installation
100+
+++++++++++++++++++
101+
102+
The "Hello World" example only allows you to add multiple archetypes to the same
103+
module/library, using the `USE_CYCLUS` and `INSTALL_CYCLUS_MODULE` macros. If
104+
you call `cycstub` multiple times in the same folder, it requires you to specify
105+
the same path and library name for each new archetype. This approach reduces
106+
the number of libraries and executables that are added to a system, perhaps
107+
unnecessarily.
108+
109+
The resulting `src/CMakeLists.txt` file will includes lines like this:
110+
111+
.. literalinclude:: module-cmake
112+
113+
This will generate:
114+
115+
* a single shared object library in ``$CYCLUS_INSTALL_PREFIX/lib/cyclus/tutorial``
116+
named ``libTutorialLibrary.so`` (\*nix) or ``libTutorialLibrary.dylib`` (mac)
117+
118+
* a single unit test executable in ``$CYCLUS_INSTALL_PREFIX/bin`` named
119+
``TutorialLibrary_unit_tests``
120+
121+
where both incorporate the ``TutorialFacility``, ``TutorialInstitution``, and
122+
``TutorialRegion`` :term:`archetypes <archetype>`.
123+
124+
99125
Standalone Installation
100126
+++++++++++++++++++++++
101127

102-
Through the :ref:`hello_world` example, three standalone modules are installed
103-
using a ``src/CMakeLists.txt`` file that looks something like
128+
There may be cases where one prefers to have separate libraries and executables
129+
for each archetype. This is not currently supported by `cycstub` in a direct
130+
way. However, you can modify the above module approach by editing
131+
``src/CMakeLists.txt`` and replacing:
132+
133+
.. literalinclude:: module-cmake
134+
135+
with
104136

105137
.. literalinclude:: standalone-cmake
106138

@@ -121,29 +153,5 @@ and three unit test executables in ``$CYCLUS_INSTALL_PREFIX/bin``:
121153

122154
* ``TutorialRegion_unit_tests``
123155

124-
Module Installation
125-
+++++++++++++++++++
126-
127-
A valid criticism of the hello world standalone approach is that a lot of
128-
libraries and executables are generated for three modules that are grouped
129-
together. We can do better!
130-
131-
What if we wanted to install one module named ``helloworld``? Specifically, we
132-
would want:
133-
134-
* a single shared object library in ``$CYCLUS_INSTALL_PREFIX/lib/cyclus/tutorial``
135-
named ``libhelloworld.so`` (\*nix) or ``libhelloworld.dylib`` (mac)
136-
137-
* a single unit test executable in ``$CYCLUS_INSTALL_PREFIX/bin`` named
138-
``helloworld_unit_tests``
139-
140-
where both incorporate the ``TutorialFacility``, ``TutorialInstitution``, and
141-
``TutorialRegion`` :term:`archetypes <archetype>`.
142-
143-
Such behavior is pretty simple to achieve. We first must call ``UseCyclus`` on
144-
each of our source file roots to inform the build system of their presence and
145-
follow up with a call to ``INSTALL_CYCLUS_MODULE``:
146-
147-
.. literalinclude:: module-cmake
148156

149157

0 commit comments

Comments
 (0)