DOCUMENTATION.rst 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. ===============================
  2. CMake files structure and usage
  3. ===============================
  4. **********************************
  5. Directory structure of CMake files
  6. **********************************
  7. - /
  8. - CMakeLists.txt - Root CMake file
  9. - version.cmake - common cmake file where version variables are set
  10. - build-config.h.cmake - cmake generation template for build-config.h
  11. - cmake_modules/ - Directory storing modules and configurations for CMake
  12. - FindXXXXX.cmake - CMake find files used to locate libraries, headers, and binaries
  13. - commonSetup.cmake - common configuration settings for the entire project (contains configure time options)
  14. - docMacros.cmake - common documentation macros used for generating fop and pdf files
  15. - optionDefaults.cmake - contains common variables for the platform build
  16. - distrocheck.sh - script that determines if the OS uses DEB or RPM
  17. - getpackagerevisionarch.sh - script that returns OS version and arch in format used for packaging
  18. - dependencies/ - Directory storing dependency files used for package dependencies
  19. - <OS>.cmake - File containing either DEB or RPM dependencies for the given OS
  20. - build-utils/ - Directory for build related utilities
  21. - cleanDeb.sh - script that unpacks a deb file and rebuilds with fakeroot to clean up lintain errors/warnings
  22. Common Macros
  23. =============
  24. - MACRO_ENSURE_OUT_OF_SOURCE_BUILD - prevents building from with in source tree
  25. - HPCC_ADD_EXECUTABLE - simple wrapper around add_executable
  26. - HPCC_ADD_LIBRARY - simple wrapper around add_library
  27. - PARSE_ARGUMENTS - macro that can be used by other macros and functions for arg list parsing
  28. - HPCC_ADD_SUBDIRECTORY - argument controlled add subdirectory wrapper
  29. - HPCC_ADD_SUBDIRECTORY(test t1 t2 t3) - Will add the subdirectory test if t1,t2, or t3 are set to any value other then False/OFF/0
  30. - LOG_PLUGIN - used to log any code based plugin for the platform
  31. - ADD_PLUGIN - adds a plugin with optional build dependencies to the build if dependencies are found
  32. Documentation Macros
  33. ====================
  34. - RUN_XSLTPROC - Runs xsltproc using given args
  35. - RUN_FOP - Runs fop using given args
  36. - CLEAN_REL_BOOK - Uses a custom xsl and xsltproc to clean relative book paths from given xml file
  37. - CLEAN_REL_SET - Uses a custom xsl and xsltproc to clean relative set paths from given xml file
  38. - DOCBOOK_TO_PDF - Master macro used to generate pdf, uses above macros
  39. Initfiles macro
  40. ===============
  41. - GENERATE_BASH - used to run processor program on given files to replace ###<REPLACE>### with given variables FindXXXXX.cmake
  42. ****************************************************
  43. Some standard techniques used in Cmake project files
  44. ****************************************************
  45. Common looping
  46. ==============
  47. Use FOREACH::
  48. FOREACH( oITEMS
  49. item1
  50. item2
  51. item3
  52. item4
  53. item5
  54. )
  55. Actions on each item here.
  56. ENDFOREACH ( oITEMS )
  57. Common installs over just install
  58. =================================
  59. - install ( FILES ... ) - installs item with 664 permissions
  60. - install ( PROGRAMS ... ) - installs runable item with 755 permissions
  61. - install ( TARGETS ... ) - installs built target with 755 permissions
  62. - install ( DIRECTORY ... ) - installs directory with 777 permissions
  63. Common settings for generated source files
  64. ==========================================
  65. - set_source_files_properties(<file> PROPERTIES GENERATED TRUE) - Must be set on generated source files or dependency generation fails and increases build time.
  66. Using custom commands between multiple cmake files
  67. ==================================================
  68. - GET_TARGET_PROPERTY(<VAR from other cmake file> <var for this file> LOCATION)
  69. - GET_TARGET_PROPERTY(ESDL_EXE esdl LOCATION) - will get from the top level cache the ESDL_EXE value and set it in esdl for your current cmake file
  70. USE add_custom_command only when 100% needed.
  71. All directories in a cmake project should have a CMakeLists.txt file and be called from the
  72. upper level project with an add_subdirectory or HPCC_ADD_SUBDIRECTORY
  73. When you have a property that will be shared between cmake projects use define_property to
  74. set it in the top level cache.
  75. - define_property(GLOBAL PROPERTY TEST_TARGET BRIEF_DOCS "test doc" FULL_DOCS "Full test doc")
  76. - mark_as_advanced(TEST_TARGET) - this is required to force the property into the top level cache.CMake Layout:
  77. **********************
  78. FindXXXXX.cmake format
  79. **********************
  80. All of our Find scripts use the following format::
  81. NOT XXXXX_FOUND
  82. Externals set
  83. define needed vars for finding external based libraries/headers
  84. Use Native set
  85. use FIND_PATH to locate headers
  86. use FIND_LIBRARY to find libs
  87. Include Cmake macros file for package handling
  88. define package handling args for find return (This will set XXXXX_FOUND)
  89. XXXXX_FOUND
  90. perform any modifications you feel is needed for the find
  91. Mark defined variables used in package handling args as advanced for return
  92. Will define when done::
  93. XXXXX_FOUND
  94. XXXXX_INCLUDE_DIR
  95. XXXXX_LIBRARIES
  96. (more can be defined, but must be at min the previous unless looking for only a binary)
  97. For an example, see FindAPR.cmake