Next revision | Previous revision |
public:user_software:documentation:lofar-cmake [2016-12-15 09:15] – Document moved from engineering:software:lofar-cmake Arno Schoenmakers | public:user_software:documentation:lofar-cmake [2017-03-09 09:16] (current) – [Available Options] Arno Schoenmakers |
---|
For general information on CMake, please refer to the [[http://www.cmake.org/cmake/help/documentation.html|CMake documentation pages]]. | For general information on CMake, please refer to the [[http://www.cmake.org/cmake/help/documentation.html|CMake documentation pages]]. |
| |
For the old guys among us: See [[.lofar-cmake:rationale|Why we migrated from Autotools to CMake]] for some information about the rationale of moving from Autotools to CMake in the past... | For the old guys among us: See [[engineering:software:lofar-cmake:rationale|Why we migrated from Autotools to CMake]] for some information about the rationale of moving from Autotools to CMake in the past... |
| |
| |
| |
=== Step 1 === | === Step 1 === |
Make sure you have a working copy of (part of) the LOFAR software tree. Please refer to [[engineering:software:lofarsvn|The LOFAR Subversion Repository]] page for more information on how to check out LOFAR software. | Make sure you have a working copy of (part of) the LOFAR software tree. Please refer to [[lofarsvn|The LOFAR Subversion Repository]] page for more information on how to check out LOFAR software. |
| |
<code> | <code> |
$ svn update LOFAR/CMake | $ svn update LOFAR/CMake |
</code> | </code> |
| **Note** On newer versions of svn you should probably use ''--depth=immediates'' instead of -N, but I can't get this to work with it. - Adriaan |
| |
| |
=== Step 2 === | === Step 2 === |
| ''USE_SOCKETS'' | Use network sockets | ''ON'' | | | ''USE_SOCKETS'' | Use network sockets | ''ON'' | |
| ''USE_THREADS'' | Use thread support | ''ON'' | | | ''USE_THREADS'' | Use thread support | ''ON'' | |
| | ''USE_CASACORE'' | Use Casacore installation | ''ON'' | |
| |
Some options are mutually exclusive (e.g., ''USE_LOG4CPLUS'', and ''LOG4CXX'' cannot be used simultaneously). These restrictions are checked by the [[.lofar-cmake:macros#lofaroptions|LofarOptions]] macro. Furthermore, this macro calls ''lofar_find_package'' for each package that is marked to be used. It is a fatal error if that package cannot be found. | Some options are mutually exclusive (e.g., ''USE_LOG4CPLUS'', and ''LOG4CXX'' cannot be used simultaneously). These restrictions are checked by the [[engineering:software:lofar-cmake:macros#lofaroptions|LofarOptions]] macro. Furthermore, this macro calls ''lofar_find_package'' for each package that is marked to be used. It is a fatal error if that package cannot be found. |
| |
''LOFAR_SVN_UPDATE'' uses three states. When ''<undefined>'', only files that are missing but needed are updated. When ''OFF'', files are //never// updated (this is useful if you don't have access to the SVN server, or if you're working with an exported source tree). When ''ON'', files are //always// updated. | ''LOFAR_SVN_UPDATE'' uses three states. When ''<undefined>'', only files that are missing but needed are updated. When ''OFF'', files are //never// updated (this is useful if you don't have access to the SVN server, or if you're working with an exported source tree). When ''ON'', files are //always// updated. |
| |
== Define the package == | == Define the package == |
A leaf-package must be defined using the macro ''lofar_package'' (see [[.lofar-cmake:macros#lofarpackage|LofarPackage]]). Calling this macro ensures that dependent packages are added to the build, and that the compiler's include path and the list of libraries to link against are setup correctly. The package name must be unique in the complete source tree. | A leaf-package must be defined using the macro ''lofar_package'' (see [[engineering:software:lofar-cmake:macros#lofarpackage|LofarPackage]]). Calling this macro ensures that dependent packages are added to the build, and that the compiler's include path and the list of libraries to link against are setup correctly. The package name must be unique in the complete source tree. |
| |
For example: | For example: |
| |
== Define external dependencies == | == Define external dependencies == |
Dependencies on external packages must be defined using the macro ''lofar_find_package'' (see [[.lofar-cmake:macros#lofarfindpackage|LofarFindPackage]]), which is a wrapper around the CMake command [[http://www.cmake.org/cmake/help/cmake2.6docs.html#command:find_package|find_package]]. | Dependencies on external packages must be defined using the macro ''lofar_find_package'' (see [[engineering:software:lofar-cmake:macros#lofarfindpackage|LofarFindPackage]]), which is a wrapper around the CMake command [[http://www.cmake.org/cmake/help/cmake2.6docs.html#command:find_package|find_package]]. |
<code cmake> | <code cmake> |
include(LofarFindPackage) | include(LofarFindPackage) |
| |
== LofarPackageVersion == | == LofarPackageVersion == |
[[.lofar-cmake:macros#lofarpackageversion|LofarPackageVersion]] is responsible for generating and/or updating the files ''%%Package__Version.h%%'', ''%%Package__Version.cc%%'', and ''%%version<pkg>%%'' (where ''<pkg>'' is the name of the current package). | [[engineering:software:lofar-cmake:macros#lofarpackageversion|LofarPackageVersion]] is responsible for generating and/or updating the files ''%%Package__Version.h%%'', ''%%Package__Version.cc%%'', and ''%%version<pkg>%%'' (where ''<pkg>'' is the name of the current package). |
<code> | <code> |
include(LofarPackageVersion) | include(LofarPackageVersion) |
include(LofarCTest) | include(LofarCTest) |
</code> | </code> |
[[.lofar-cmake:macros#lofarctest|This]] macro will add the current source directory to the compiler's include path, and generate a wrapper script around the ''runtest.sh'' script to define some required environment variables. | [[engineering:software:lofar-cmake:macros#lofarctest|This]] macro will add the current source directory to the compiler's include path, and generate a wrapper script around the ''runtest.sh'' script to define some required environment variables. |
| |
== Add tests == | == Add tests == |
| |
=== Adding a package === | === Adding a package === |
Packages are added to the build with the CMake macro ''lofar_add_package'' (see [[.lofar-cmake:macros#lofarpackage|LofarPackage]]). | Packages are added to the build with the CMake macro ''lofar_add_package'' (see [[engineering:software:lofar-cmake:macros#lofarpackage|LofarPackage]]). |
| |
For example, the ''CMakeLists.txt'' file for the ''Calibration'' meta-package contains the following two lines: | For example, the ''CMakeLists.txt'' file for the ''Calibration'' meta-package contains the following two lines: |
| |
== LofarInit == | == LofarInit == |
Next we include the [[.lofar-cmake:macros#lofarinit|LofarInit]] macro file. This file //must// be included //before// the ''project'' command, because it will define the compilers to use (by reading the variants files). Note that at this stage the CMake variable ''CMAKE_MODULE_PATH'' is not yet set, so we need to specify the full path and filename to ''LofarInit''. | Next we include the [[engineering:software:lofar-cmake:macros#lofarinit|LofarInit]] macro file. This file //must// be included //before// the ''project'' command, because it will define the compilers to use (by reading the variants files). Note that at this stage the CMake variable ''CMAKE_MODULE_PATH'' is not yet set, so we need to specify the full path and filename to ''LofarInit''. |
<code> | <code> |
include(CMake/LofarInit.cmake) | include(CMake/LofarInit.cmake) |
| |
== LofarGeneral == | == LofarGeneral == |
Then we include the [[.lofar-cmake:macros#lofargeneral|LofarGeneral]] macro file, which mainly performs a number of checks for the presence of system header files. This file //must// be included immediately //after// the ''project'' command. | Then we include the [[engineering:software:lofar-cmake:macros#lofargeneral|LofarGeneral]] macro file, which mainly performs a number of checks for the presence of system header files. This file //must// be included immediately //after// the ''project'' command. |
<code> | <code> |
include(LofarGeneral) | include(LofarGeneral) |
| |
== LofarPackage == | == LofarPackage == |
First, we need to include the file [[.lofar-cmake:macros#lofarpackage|LofarPackage]], which defines two important macros: ''lofar_package'' and ''lofar_add_package''. | First, we need to include the file [[engineering:software:lofar-cmake:macros#lofarpackage|LofarPackage]], which defines two important macros: ''lofar_package'' and ''lofar_add_package''. |
<code> | <code> |
include(LofarPackage) | include(LofarPackage) |
* [[engineering:software:lofar-cmake:macros|LOFAR CMake Macros]] | * [[engineering:software:lofar-cmake:macros|LOFAR CMake Macros]] |
* [[engineering:software:lofar-cmake:cmake-equiv-autotools|CMake Equivalent of Autotools Commands and Options]] | * [[engineering:software:lofar-cmake:cmake-equiv-autotools|CMake Equivalent of Autotools Commands and Options]] |
* [[engineering:software:lofarsvn|The LOFAR Subversion Repository]] | * [[lofarsvn|The LOFAR Subversion Repository]] |