source.rst 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 **3.8** 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 supports compiling as C++98 in addition to C++11 and C++14.
  20. In order to support building on older toolchains some constructs
  21. need to be handled with care:
  22. * Use ``CM_AUTO_PTR`` instead of ``std::auto_ptr``.
  23. The ``std::auto_ptr`` template is deprecated in C++11. We want to use it
  24. so we can build on C++98 compilers but we do not want to turn off compiler
  25. warnings about deprecated interfaces in general. Use the ``CM_AUTO_PTR``
  26. macro instead.
  27. * Use ``size_t`` instead of ``std::size_t``.
  28. Various implementations have differing implementation of ``size_t``.
  29. When assigning the result of ``.size()`` on a container for example,
  30. the result should be assigned to ``size_t`` not to ``std::size_t``,
  31. ``unsigned int`` or similar types.