Difference between revisions of "CMake Addressing"
(In Progress Cmak target file addressing from build directory examples) |
(dd illustrations of possible locations of a build directory relative to the target source directory and relative and absolute addressing of the source directory from the build) |
||
Line 15: | Line 15: | ||
The <path-to-source>, i.e. to the "gnucash-3.x" or "gnucash" top level directory in the cmake command can be either: | The <path-to-source>, i.e. to the "gnucash-3.x" or "gnucash" top level directory in the cmake command can be either: | ||
*an absolute path to this directory; or it may be | *an absolute path to this directory; or it may be | ||
− | *a relative path from the build directory to the "gnucash-3.0" or "gnucash" directory. | + | *a relative path from the build directory to the "gnucash-3.0" or "gnucash" directory which contains the top levelCMakeLists.txt file. |
+ | Three possible scenarios are illustrated below: | ||
− | $HOME | + | |
− | | | + | $HOME |
− | -------------------------------------------------... | + | | |
− | | | + | -------------------------------------------------... |
− | Downloads | + | Downloads ApplicationBuilds |
− | + | | | | |
− | gnucash-3.x | + | gnucash-3.x build-gnucash-3.x |
+ | | | ||
+ | --------------------- | ||
+ | | | | ||
+ | CMakeLists.txt rest of sources | ||
+ | |||
+ | |||
+ | |||
+ | '''Relative''' ../../Downloads/gnucash-3.x | ||
+ | |||
+ | '''Absolute''' $HOME/Downloads/gnucash-3.x | ||
+ | |||
+ | --------------------------------------------------------------- | ||
+ | |||
+ | $HOME | ||
+ | | | ||
+ | ApplicationBuilds | ||
+ | | | ||
+ | ---------------------- | ||
+ | | | | ||
+ | gnucash-3.x build-gnucash-3.x | ||
+ | | | ||
+ | ------------------- | ||
+ | | | | ||
+ | CMakeLists.txt rest-of-sources | ||
+ | |||
+ | '''Relative''' ../gnucash-3.x | ||
+ | |||
+ | '''Absolute''' $HOME/APPlicationBuilds/gnucash-3.x | ||
+ | -------------------------------------------------------------- | ||
+ | |||
+ | $HOME | ||
+ | | | ||
+ | ApplicationBuilds | ||
+ | | | ||
+ | gnucash-3.x | ||
+ | | | ||
+ | ------------------------------------- | ||
+ | | | | | ||
+ | CMakeLists.txt rest-of-sources build-gnucash-3.x | ||
+ | |||
+ | '''Relative'''' .. or../ | ||
+ | |||
+ | '''Absolute''' $HOME/ApplicationBuilds/gnucash-3.x |
Revision as of 01:02, 4 May 2018
The cmake command sytax most relevant for building Gnucash is
cmake [<options>] <path-to-source>
More detailed information on CMake can be obtained from the | Cmake documentation.
The <options> switches relevant to building GnuCash are given in build options. As well other cmake switches are discussed in the above documentation, but are not generally needed to build GnuCash.
CMake does not allow in source builds, where the compiled files are built within the source tree structure, for projects building using CMake. It requires a separate build directory in which files generated by the build are placed. CMake generates files for the autotools make program (and other build systems e.g. Ninja). This simplifies rebuilding as the contents of the build directory can simply be deleted and rebuilt and the contents of the source directory are not altered in the cmake and build process.
The build directory can be located as desired within the users directory structure and there are no restrictions on the directory name. Only the build directory needs to be retained if you subsequently want to uninstall the version of GnuCash you have built using the make uninstall command as the install_manifest.txt file used to uninstall Gnucash is located within the build directory. For this reason it is probably wise to label the build directory with the application name and version if you place the build directory outside the source directory structure. E.g. "build-gnucash-3.x" to distinguish it from other applications built with CMake.
If you as a practice retain the sources of applications you build on your system, then you could locate the build directory within the top level source directory. If you download the tarball this will have a name like "gnucash-3.x". If you use git clone to obtain the sources from the GNuCash page on githubthe top level source directory will be named "gnucash". Another gnucash directory also exists under this top level directory named "gnucash-3.x" or "gnucash" - be careful do not use this as the top level directory in any of the following. (Note: x is one of {0, 1, 2,...}, i.e. the minor version number.)
The <path-to-source>, i.e. to the "gnucash-3.x" or "gnucash" top level directory in the cmake command can be either:
- an absolute path to this directory; or it may be
- a relative path from the build directory to the "gnucash-3.0" or "gnucash" directory which contains the top levelCMakeLists.txt file.
Three possible scenarios are illustrated below:
$HOME | -------------------------------------------------... Downloads ApplicationBuilds | | gnucash-3.x build-gnucash-3.x | --------------------- | | CMakeLists.txt rest of sources
Relative ../../Downloads/gnucash-3.x
Absolute $HOME/Downloads/gnucash-3.x
$HOME | ApplicationBuilds | ---------------------- | | gnucash-3.x build-gnucash-3.x | ------------------- | | CMakeLists.txt rest-of-sources
Relative ../gnucash-3.x
Absolute $HOME/APPlicationBuilds/gnucash-3.x
$HOME | ApplicationBuilds | gnucash-3.x | ------------------------------------- | | | CMakeLists.txt rest-of-sources build-gnucash-3.x
Relative' .. or../
Absolute $HOME/ApplicationBuilds/gnucash-3.x