Skip to content
Stephen Orso edited this page Apr 30, 2018 · 9 revisions

WikiCMake ScriptsCMake HOWTO

Add a Source File

Edit Herc61_SlibSource.cmake. Add the new file name to the <target>_sources CMake variable, where <target> is the name of the executable, shared library, or loadable module that should include the new file.

Header files should be added to the same target as the c progarm that uses them. Global header files should be added to headers_sources.

At the end of Herc61_SlibSource.cmake, the source file variables are altered as required for a Windows build. If the file being added is for Windows only, it should be added here. If the file being added is not used for Windows, it should be removed here.

Herc61_SlibSource.cmake includes comments and current coding that illustrates all of the above.

Add an Executable Or Library

CMake refers to executables, shared libraries, and loadable modules as targets, and adding any of these means creating a new target. Functions exist in Herc00_Includes.cmake to standardize target creation within the Hercules build.

First, edit Herc61_SlibSource.cmake as described above to add the source files and headers required to compile the target. It does not matter if the new target is an executable, shared library, or loadable module.

Second, edit Herc60_CreateTargets.cmake to add the new target. Add the new executable, shared library, or loadable module near where other targets of the same type are added. Use the existing herc\_Define\_Shared\_Lib or Herc\_Define\_Executable statements as examples.

Third, if adding a loadable module, add a target\_link\_libraries() statement for the added module on the shared library herc to allow for a successful build on Windows or macOS; look for hdt1025c for an example.

Add a Header Test

Add a Runtest Case


This Wiki page Copyright © 2018 by Stephen R. Orso. This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

Clone this wiki locally