source.rst 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. CMake Source Code Guide
  2. ***********************
  3. The following is a guide to the CMake source code for developers.
  4. See documentation on `CMake Development`_ for more information.
  5. .. _`CMake Development`: README.rst
  6. C++ Code Style
  7. ==============
  8. We use `clang-format`_ version **6.0** to define our style for C++ code in
  9. the CMake source tree. See the `.clang-format`_ configuration file for our
  10. style settings. Use the `Utilities/Scripts/clang-format.bash`_ script to
  11. format source code. It automatically runs ``clang-format`` on the set of
  12. source files for which we enforce style. The script also has options to
  13. format only a subset of files, such as those that are locally modified.
  14. .. _`clang-format`: http://clang.llvm.org/docs/ClangFormat.html
  15. .. _`.clang-format`: ../../.clang-format
  16. .. _`Utilities/Scripts/clang-format.bash`: ../../Utilities/Scripts/clang-format.bash
  17. C++ Subset Permitted
  18. ====================
  19. CMake requires compiling as C++11 or above. However, in order to support
  20. building on older toolchains some constructs need to be handled with care:
  21. * Do not use ``std::auto_ptr``.
  22. The ``std::auto_ptr`` template is deprecated in C++11. Use ``std::unique_ptr``.
  23. * Use ``CM_DISABLE_COPY(Class)`` to mark classes as non-copyable.
  24. The ``CM_DISABLE_COPY`` macro should be used in the private section of a
  25. class to make sure that attempts to copy or assign an instance of the class
  26. lead to compiler errors even if the compiler does not support *deleted*
  27. functions. As a guideline, all polymorphic classes should be made
  28. non-copyable in order to avoid slicing. Classes that are composed of or
  29. derived from non-copyable classes must also be made non-copyable explicitly
  30. with ``CM_DISABLE_COPY``.
  31. Source Tree Layout
  32. ==================
  33. The CMake source tree is organized as follows.
  34. * ``Auxiliary/``:
  35. Shell and editor integration files.
  36. * ``Help/``:
  37. Documentation. See the `CMake Documentation Guide`_.
  38. * ``Help/dev/``:
  39. Developer documentation.
  40. * ``Help/release/dev/``:
  41. Release note snippets for development since last release.
  42. * ``Licenses/``:
  43. License files for third-party libraries in binary distributions.
  44. * ``Modules/``:
  45. CMake language modules installed with CMake.
  46. * ``Packaging/``:
  47. Files used for packaging CMake itself for distribution.
  48. * ``Source/``:
  49. Source code of CMake itself.
  50. * ``Templates/``:
  51. Files distributed with CMake as implementation details for generators,
  52. packagers, etc.
  53. * ``Tests/``:
  54. The test suite. See `Tests/README.rst`_.
  55. * ``Utilities/``:
  56. Scripts, third-party source code.
  57. * ``Utilities/Sphinx/``:
  58. Sphinx configuration to build CMake user documentation.
  59. * ``Utilities/Release/``:
  60. Scripts used to package CMake itself for distribution on ``cmake.org``.
  61. .. _`CMake Documentation Guide`: documentation.rst
  62. .. _`Tests/README.rst`: ../../Tests/README.rst