Difference between revisions of "CMake Addressing"

From GnuCash
Jump to: navigation, search
(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)
m (fix link appearance)
 
(2 intermediate revisions by one other user not shown)
Line 3: Line 3:
 
cmake [<options>] <path-to-source>
 
cmake [<options>] <path-to-source>
 
</SyntaxHighlight>
 
</SyntaxHighlight>
More detailed information on CMake can be obtained from the [https://cmake.org/cmake/help/v3.0/index.html | Cmake documentation].
+
More detailed information on CMake can be obtained from the [https://cmake.org/cmake/help/v3.0/index.html Cmake documentation].
  
The <options> switches relevant to building GnuCash are given in [[Gnucash Build Options | build options]]. As well other cmake switches are discussed in the above documentation, but are not generally needed to build GnuCash.
+
The <options> switches relevant to building GnuCash are detailed in [[Gnucash Build Options | build options]]. As well, other cmake switches are discussed in the CMake documentation linked above, but these 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.
+
CMake does not allow in source builds, i.e. where the compiled files and Makefiles 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 by 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.
+
The build directory can be located as desired within the users directory structure and there are no restrictions on the name of the directory. 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 and the Makefiles used to uninstall Gnucash are 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/projects 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.)
+
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 reference this sub-directory instead of the top level directory in any of the following or as the <path-to-source> of the cmake command.  
 +
 
 +
'''Note:'''- x is one of {0, 1, 2,...}, i.e. the minor version number which should be substituted for <x> in any commands.
 +
 +
'''Note:'''- Problems have been experienced when the build directory was located under the top level source directory(gnucash-3.<x> for the intltools library used in the GnuCash documentation but not currently in the GnuCash program.
  
 
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:  
Line 19: Line 23:
 
Three possible scenarios are illustrated below:
 
Three possible scenarios are illustrated below:
  
 
+
'''Sources in Downloads and Build directory in another user directory ApplicationBuilds in User's home directory'''
  
 
                           $HOME                                                               
 
                           $HOME                                                               
 
                             |                                                                                             
 
                             |                                                                                             
       -------------------------------------------------...                                                    
+
       -------------------------------------------------...  
 +
      |                                            |                                                   
 
   Downloads                                  ApplicationBuilds                                                         
 
   Downloads                                  ApplicationBuilds                                                         
       |                                       |                                                   
+
       |                                           |                                                   
   gnucash-3.x                                build-gnucash-3.x                                             
+
   '''gnucash-3.x'''                               '''build-gnucash-3.x'''                                              
 
       |
 
       |
 
       ---------------------
 
       ---------------------
Line 39: Line 44:
  
 
---------------------------------------------------------------
 
---------------------------------------------------------------
 +
 +
'''Sources and build directory in the same parent directory ApplicationBuilds'''
  
 
                           $HOME
 
                           $HOME
Line 46: Line 53:
 
                   ----------------------  
 
                   ----------------------  
 
                   |                    |
 
                   |                    |
             gnucash-3.x      build-gnucash-3.x
+
             '''gnucash-3.x'''       '''build-gnucash-3.x'''
 
                   |  
 
                   |  
 
         -------------------
 
         -------------------
Line 56: Line 63:
 
'''Absolute'''    $HOME/APPlicationBuilds/gnucash-3.x
 
'''Absolute'''    $HOME/APPlicationBuilds/gnucash-3.x
 
--------------------------------------------------------------
 
--------------------------------------------------------------
 +
 +
'''Build directory in the top level Sources directory under a parent ApplicationBuilds directory'''
  
 
                             $HOME
 
                             $HOME
Line 61: Line 70:
 
                       ApplicationBuilds
 
                       ApplicationBuilds
 
                               |
 
                               |
                         gnucash-3.x
+
                         '''gnucash-3.x'''
 
                               |
 
                               |
 
             -------------------------------------
 
             -------------------------------------
 
             |                  |                |
 
             |                  |                |
       CMakeLists.txt    rest-of-sources      build-gnucash-3.x
+
       CMakeLists.txt    rest-of-sources      '''build-gnucash-3.x'''
  
 
'''Relative''''          .. or../
 
'''Relative''''          .. or../
  
 
'''Absolute'''      $HOME/ApplicationBuilds/gnucash-3.x
 
'''Absolute'''      $HOME/ApplicationBuilds/gnucash-3.x

Latest revision as of 04:06, 3 November 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 detailed in build options. As well, other cmake switches are discussed in the CMake documentation linked above, but these are not generally needed to build GnuCash.

CMake does not allow in source builds, i.e. where the compiled files and Makefiles 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 by 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 name of the directory. 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 and the Makefiles used to uninstall Gnucash are 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/projects 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 reference this sub-directory instead of the top level directory in any of the following or as the <path-to-source> of the cmake command.

Note:- x is one of {0, 1, 2,...}, i.e. the minor version number which should be substituted for <x> in any commands.

Note:- Problems have been experienced when the build directory was located under the top level source directory(gnucash-3.<x> for the intltools library used in the GnuCash documentation but not currently in the GnuCash program.

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:

Sources in Downloads and Build directory in another user directory ApplicationBuilds in User's home directory

                         $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


Sources and build directory in the same parent directory ApplicationBuilds

                          $HOME
                            |
                    ApplicationBuilds
                            |
                  ---------------------- 
                 |                     |
            gnucash-3.x       build-gnucash-3.x
                 | 
        -------------------
        |                 |
    CMakeLists.txt    rest-of-sources

Relative ../gnucash-3.x

Absolute $HOME/APPlicationBuilds/gnucash-3.x


Build directory in the top level Sources directory under a parent ApplicationBuilds directory

                           $HOME
                             |
                     ApplicationBuilds
                             |
                        gnucash-3.x
                             |
            -------------------------------------
            |                  |                 |
     CMakeLists.txt    rest-of-sources      build-gnucash-3.x

Relative' .. or../

Absolute $HOME/ApplicationBuilds/gnucash-3.x