README 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. WELCOME TO CROSS-PLATFORM MAKE (CMake)
  2. -------------------------------------
  3. CMake is a cross-platform, extensible build environment. It currently
  4. generates Unix makefiles and Microsoft Visual C++ projects/workspaces. Other
  5. OS/compiler targets are being added to this open-source system, and you can
  6. add your own, if desired.
  7. To use CMake, create CMakeLists.txt in each directory that makes up your
  8. source repository. The CMakeLists.txt file contains commands. Each command
  9. does something different, like defining a list of source code, include
  10. directories, makefile targets, rules, etc. Once CMake has processed all the
  11. commands in all the CMakeLists.txt files, it generates the appropriate
  12. "makefile(s)" for the system/compiler that you are on.
  13. CMake Commands
  14. --------------
  15. The key to using CMake is to learn the commands. Each command has the
  16. same format:
  17. NAME_OF_COMMAND(args....)
  18. where args is a white-space separated listed of arguments. (Arguments
  19. containing spaces should be quoted). For example:
  20. INCLUDE_DIRECTORIES(./ d:/include "c:/Program Files/include")
  21. note that Unix-style slashes are used. The commands may reference CMake
  22. variables, either built-in or defined variables. Two important variables
  23. are built-in to CMake:
  24. CMAKE_SOURCE_DIR - The root directory of the source code
  25. directory tree.
  26. CMAKE_BINARY_DIR - The root directory of the build tree
  27. where binaries are placed. This includes
  28. object files, libraries, and executables.
  29. A rule might reference these as follows:
  30. INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
  31. using the ${} delimiters.
  32. Here is a list of current commands. You may also wish to view
  33. the Doxygen documentation (if available) or generate it with
  34. the doxygen.config file in this directory.
  35. Rules: (Generated with cmDumpDocumentation.cxx)
  36. ------------------------------------------
  37. ABSTRACT_FILES - A list of abstract classes, useful for wrappers.
  38. Usage: ABSTRACT_FILES(file1 file2 ..)
  39. ADD_TARGET - Add an extra target to the build system.
  40. Usage: ADD_TARGET(Name "command to run")
  41. AUX_SOURCE_DIRECTORY - Add all the source files found in the specified
  42. directory to the build.
  43. Usage: AUX_SOURCE_DIRECTORY(dir)
  44. EXECUTABLES - Add a list of executables files.
  45. Usage: EXECUTABLES(file1 file2 ...)
  46. FIND_INCLUDE - Find an include path.
  47. Usage: FIND_INCLUDE(DEFINE try1 try2 ...)
  48. FIND_LIBRARY - Find a library.
  49. Usage: FIND_LIBRARY(DEFINE try1 try2)
  50. FIND_PROGRARM - Find an executable program.
  51. Usage: FIND_PROGRAM(NAME executable1 executable2 ...)
  52. INCLUDE_DIRECTORIES - Add include directories to the build.
  53. Usage: INCLUDE_DIRECTORIES(dir1 dir2 ...)
  54. LIBRARY - Set a name for a library.
  55. Usage: LIBRARY(libraryname)
  56. LINK_DIRECTORIES - Specify link directories.
  57. Usage: Specify the paths to the libraries that will be linked in.
  58. LINK_DIRECTORIES(directory1 directory2 ...)
  59. The directories can use built in definitions like
  60. CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR.
  61. LINK_LIBRARIES - Specify a list of libraries to be linked into executables
  62. or shared objects.
  63. Usage: LINK_LIBRARIES(library1 library2)
  64. Specify a list of libraries to be linked into
  65. executables or shared objects. This command is passed
  66. down to all other commands. The library name should be
  67. the same as the name used in the LIBRARY(library) command.
  68. PROJECT - Set a name for the entire project. One argument.
  69. Usage: PROJECT(projectname)
  70. SOURCE_FILES - Add a list of source files.
  71. Usage: SOURCE_FILES(file1 file2 ...)
  72. SOURCE_FILES_REQUIRE - Add a list of source files if the required
  73. variables are set.
  74. Usage: SOURCE_FILES_REQUIRE(var1 var2 ... SOURCES_BEGIN file1 file2 ...)
  75. SUBDIRS - Add a list of subdirectories to the build.
  76. Usage: SUBDIRS(dir1 dir2 ...)
  77. Add a list of subdirectories to the build.
  78. This will cause any CMakeLists.txt files in the sub directories
  79. to be processed by CMake.
  80. TESTS - Add a list of executables files that are run as tests.
  81. Usage: TESTS(file1 file2 ...)
  82. UNIX_DEFINES - Add -D flags to the command line for Unix only.
  83. Usage: UNIX_DEFINES(-DFOO -DBAR)
  84. Add -D flags to the command line for Unix only.
  85. UNIX_LIBRARIES - Add libraries that are only used for Unix programs.
  86. Usage: UNIX_LIBRARIES(library -lm ...)
  87. WIN32_DEFINES - Add -D define flags to command line for Win32 environments.
  88. Usage: WIN32_DEFINES(-DFOO -DBAR ...)
  89. Add -D define flags to command line for Win32 environments.
  90. WIN32_LIBRARIES - Add libraries that are only used for Win32 programs.
  91. Usage: WIN32_LIBRARIES(library -lm ...)
  92. USING / BUILDING WITH CMAKE
  93. ---------------------------
  94. Windows:
  95. -------
  96. These programs are used to drive CMake on Windows:
  97. CMakeSetup.exe -> window MFC based GUI for configure on windows
  98. CMakeSetupCMD.exe -> windows command line version of CMakeConfigure
  99. To build a project on Windows:
  100. load CMake/Source/CMakeSetup.dsw
  101. Build it
  102. Run it
  103. Specify paths (i.e., CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR)
  104. Load (project).dsw (the PROJECT(project) command specified the name)
  105. Build the appropriate workspaces wihin the project.
  106. Unix:
  107. ----
  108. These programs/files are used to drive CMake on Unix:
  109. configure -> run on unix to configure for build
  110. CMakeBuildTargets -> Unix program to read CMakeLists.txt and
  111. generate CMakeTargets.make
  112. makefile fragments:
  113. CMakeMaster.make -> main file to be included by makefiles
  114. CMakeVariables.make -> all make varibles are set in this file
  115. CMakeRules.make -> All build rules are here (except Simple Rules)
  116. CMakeSimpleRules.make -> simple build rules for .o to .cxx, this is
  117. separate to be able to build CMakeBuildTargets
  118. itself.
  119. CMakeLocal.make -> Place for hand configuration
  120. CMakeTargets.make -> generated rules for make style build in each
  121. directory
  122. MakefileTemplate.make -> master makefile template used by configure to
  123. generate Makefiles
  124. Unix install:
  125. In-place builds (object files end up in source code directory):
  126. ./configure
  127. make
  128. Other-directory builds (object files are in another directory, and
  129. assuming that the source code is in ./project and the following
  130. procedure is performed starting in directory ./):
  131. mkdir project-build (project is the name of your project)
  132. cd project-build
  133. ../project/configure
  134. make
  135. ADDING COMMANDS
  136. ---------------
  137. Rules can be added to CMake by deriving new commands from the class cmCommand
  138. (defined in CMake/Source/cmCommand.h/.cxx).
  139. ADDING MAKEFILE SUPPORT
  140. -----------------------
  141. Different types of makefiles (corresponding to a different compiler and/or
  142. operating system) can be added by subclassing from cmMakefileGenerator
  143. (defined in cmMakefileGenerator.h/.cxx). Makefile generators process the
  144. information defined by the commands in CMakeLists.txt to generate the
  145. appropriate makefile(s).
  146. FOR MORE INFORMATION
  147. --------------------
  148. Contact Bill Hoffman [email protected] (principal developer)
  149. or Will Schroeder [email protected] (documentation grunt).