PageRenderTime 54ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/docs/compile.dox

https://github.com/boscorillium/glfw
Unknown | 266 lines | 181 code | 85 blank | 0 comment | 0 complexity | 105f1d84284cf4d3431de7ed43cec969 MD5 | raw file
  1. /*!
  2. @page compile Compiling GLFW
  3. @tableofcontents
  4. This is about compiling the GLFW library itself. For information on how to
  5. build programs that use GLFW, see the @ref build guide.
  6. @section compile_deps Dependencies
  7. To compile GLFW and the accompanying example programs, you will need **CMake**,
  8. which will generate the project files or makefiles for your particular
  9. development environment. If you are on a Unix-like system such as Linux or
  10. FreeBSD or have a package system like Fink, MacPorts, Cygwin or Homebrew, you
  11. can simply install its CMake package. If not, you can get installers for
  12. Windows and OS X from the [CMake website](http://www.cmake.org/).
  13. Additional dependencies are listed below.
  14. If you wish to compile GLFW without CMake, see @ref compile_manual.
  15. @subsection compile_deps_msvc Dependencies using Visual C++ on Windows
  16. The Microsoft Platform SDK that is installed along with Visual C++ contains all
  17. the necessary headers, link libraries and tools except for CMake.
  18. @subsection compile_deps_mingw Dependencies with MinGW or MinGW-w64 on Windows
  19. Both the MinGW and the MinGW-w64 packages contain all the necessary headers,
  20. link libraries and tools except for CMake.
  21. @subsection compile_deps_mingw_cross Dependencies using MinGW or MinGW-w64 cross-compilation
  22. Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For
  23. example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages
  24. for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives
  25. like Ubuntu have the `mingw-w64` package for both.
  26. GLFW has CMake toolchain files in the `CMake/` directory that allow for easy
  27. cross-compilation of Windows binaries. To use these files you need to add a
  28. special parameter when generating the project files or makefiles:
  29. cmake -DCMAKE_TOOLCHAIN_FILE=<toolchain-file> .
  30. The exact toolchain file to use depends on the prefix used by the MinGW or
  31. MinGW-w64 binaries on your system. You can usually see this in the /usr
  32. directory. For example, both the Debian/Ubuntu and Cygwin MinGW-w64 packages
  33. have `/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct
  34. invocation would be:
  35. cmake -DCMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake .
  36. For more details see the article
  37. [CMake Cross Compiling](http://www.paraview.org/Wiki/CMake_Cross_Compiling) on
  38. the CMake wiki.
  39. @subsection compile_deps_xcode Dependencies using Xcode on OS X
  40. Xcode contains all necessary tools except for CMake. The necessary headers and
  41. libraries are included in the core OS frameworks. Xcode can be downloaded from
  42. the Mac App Store or from the ADC Member Center.
  43. @subsection compile_deps_x11 Dependencies using Linux and X11
  44. To compile GLFW for X11, you need to have the X11 and OpenGL header packages
  45. installed, as well as the basic development tools like GCC and make. For
  46. example, on Ubuntu and other distributions based on Debian GNU/Linux, you need
  47. to install the `xorg-dev` and `libglu1-mesa-dev` packages. The former pulls in
  48. all X.org header packages and the latter pulls in the Mesa OpenGL and GLU
  49. packages. GLFW itself doesn't need or use GLU, but some of the examples do.
  50. Note that using header files and libraries from Mesa during compilation *will
  51. not* tie your binaries to the Mesa implementation of OpenGL.
  52. @section compile_cmake Generating files with CMake
  53. Once you have all necessary dependencies it is time to generate the project
  54. files or makefiles for your development environment. CMake needs to know two
  55. paths for this: the path to the *root* directory of the GLFW source tree (i.e.
  56. *not* the `src` subdirectory) and the target path for the generated files and
  57. compiled binaries. If these are the same, it is called an in-tree build,
  58. otherwise it is called an out-of-tree build.
  59. One of several advantages of out-of-tree builds is that you can generate files
  60. and compile for different development environments using a single source tree.
  61. @subsection compile_cmake_cli Generating files with the CMake command-line tool
  62. To make an in-tree build, enter the *root* directory of the GLFW source tree
  63. (i.e. *not* the `src` subdirectory) and run CMake. The current directory is
  64. used as target path, while the path provided as an argument is used to find the
  65. source tree.
  66. cd <glfw-root-dir>
  67. cmake .
  68. To make an out-of-tree build, make another directory, enter it and run CMake
  69. with the (relative or absolute) path to the root of the source tree as an
  70. argument.
  71. cd <glfw-root-dir>
  72. mkdir build
  73. cd build
  74. cmake ..
  75. @subsection compile_cmake_gui Generating files with the CMake GUI
  76. If you are using the GUI version, choose the root of the GLFW source tree as
  77. source location and the same directory or another, empty directory as the
  78. destination for binaries. Choose *Configure*, change any options you wish to,
  79. *Configure* again to let the changes take effect and then *Generate*.
  80. @section compile_options CMake options
  81. The CMake files for GLFW provide a number of options, although not all are
  82. available on all supported platforms. Some of these are de facto standards
  83. among CMake users and so have no `GLFW_` prefix.
  84. If you are using the GUI version of CMake, these are listed and can be changed
  85. from there. If you are using the command-line version, use the `ccmake` tool.
  86. Some package systems like Ubuntu and other distributions based on Debian
  87. GNU/Linux have this tool in a separate `cmake-curses-gui` package.
  88. @subsection compile_options_shared Shared CMake options
  89. `BUILD_SHARED_LIBS` determines whether GLFW is built as a static
  90. library or as a DLL / shared library / dynamic library.
  91. `LIB_SUFFIX` affects where the GLFW shared /dynamic library is installed. If it
  92. is empty, it is installed to `${CMAKE_INSTALL_PREFIX}/lib`. If it is set to
  93. `64`, it is installed to `${CMAKE_INSTALL_PREFIX}/lib64`.
  94. `GLFW_CLIENT_LIBRARY` determines which client API library to use. If set to
  95. `opengl` the OpenGL library is used, if set to `glesv1` for the OpenGL ES 1.x
  96. library is used, or if set to `glesv2` the OpenGL ES 2.0 library is used. The
  97. selected library and its header files must be present on the system for this to
  98. work.
  99. `GLFW_BUILD_EXAMPLES` determines whether the GLFW examples are built
  100. along with the library.
  101. `GLFW_BUILD_TESTS` determines whether the GLFW test programs are
  102. built along with the library.
  103. `GLFW_BUILD_DOCS` determines whether the GLFW documentation is built along with
  104. the library.
  105. @subsection compile_options_osx OS X specific CMake options
  106. `GLFW_USE_CHDIR` determines whether `glfwInit` changes the current
  107. directory of bundled applications to the `Contents/Resources` directory.
  108. `GLFW_USE_MENUBAR` determines whether the first call to
  109. `glfwCreateWindow` sets up a minimal menu bar.
  110. `GLFW_USE_RETINA` determines whether windows will use the full resolution of
  111. Retina displays.
  112. `GLFW_BUILD_UNIVERSAL` determines whether to build Universal Binaries.
  113. @subsection compile_options_win32 Windows specific CMake options
  114. `USE_MSVC_RUNTIME_LIBRARY_DLL` determines whether to use the DLL version or the
  115. static library version of the Visual C++ runtime library. If set to `ON`, the
  116. DLL version of the Visual C++ library is used. It is recommended to set this to
  117. `ON`, as this keeps the executable smaller and benefits from security and bug
  118. fix updates of the Visual C++ runtime.
  119. `GLFW_USE_DWM_SWAP_INTERVAL` determines whether the swap interval is set even
  120. when DWM compositing is enabled. If this is `ON`, the swap interval is set even
  121. if DWM is enabled. It is recommended to set this to `OFF`, as doing otherwise
  122. can lead to severe jitter.
  123. `GLFW_USE_OPTIMUS_HPG` determines whether to export the `NvOptimusEnablement`
  124. symbol, which forces the use of the high-performance GPU on nVidia Optimus
  125. systems.
  126. @subsection compile_options_egl EGL specific CMake options
  127. `GLFW_USE_EGL` determines whether to use EGL instead of the platform-specific
  128. context creation API. Note that EGL is not yet provided on all supported
  129. platforms.
  130. @section compile_manual Compiling GLFW manually
  131. If you wish to compile GLFW without its CMake build environment then you will
  132. have to do at least some of the platform detection yourself. GLFW needs
  133. a number of configuration macros to be defined in order to know what it's being
  134. compiled for and has many optional, platform-specific ones for various features.
  135. When building with CMake, the `glfw_config.h` configuration header is generated
  136. based on the current platform and CMake options. The GLFW CMake environment
  137. defines `_GLFW_USE_CONFIG_H`, which causes this header to be included by
  138. `internal.h`. Without this macro, GLFW will expect the necessary configuration
  139. macros to be defined on the command-line.
  140. Three macros *must* be defined when compiling GLFW: one for selecting the window
  141. creation API, one selecting the context creation API and one client library.
  142. Exactly one of each kind must be defined for GLFW to compile and link.
  143. The window creation API is used to create windows, handle input, monitors, gamma
  144. ramps and clipboard. The options are:
  145. - `_GLFW_COCOA` to use the Cocoa frameworks
  146. - `_GLFW_WIN32` to use the Win32 API
  147. - `_GLFW_X11` to use the X Window System
  148. The context creation API is used to enumerate pixel formats / framebuffer
  149. configurations and to create contexts. The options are:
  150. - `_GLFW_NSGL` to use the Cocoa OpenGL framework
  151. - `_GLFW_WGL` to use the Win32 WGL API
  152. - `_GLFW_GLX` to use the X11 GLX API
  153. - `_GLFW_EGL` to use the EGL API (experimental)
  154. The client library is the one providing the OpenGL or OpenGL ES API, which is
  155. used by GLFW to probe the created context. This is not the same thing as the
  156. client API, as many desktop OpenGL client libraries now expose the OpenGL ES API
  157. through extensions. The options are:
  158. - `_GLFW_USE_OPENGL` for the desktop OpenGL (opengl32.dll, libGL.so or
  159. OpenGL.framework)
  160. - `_GLFW_USE_GLESV1` for OpenGL ES 1.x (experimental)
  161. - `_GLFW_USE_GLESV2` for OpenGL ES 2.x (experimental)
  162. Note that `_GLFW_USE_GLESV1` and `_GLFW_USE_GLESV2` may only be used with EGL,
  163. as the other context creation APIs do not interface with OpenGL ES client
  164. libraries.
  165. If you are building GLFW as a shared library / dynamic library / DLL then you
  166. must also define `_GLFW_BUILD_DLL`. Otherwise, you may not define it.
  167. If you are using the X11 window creation API then you *must* also select an entry
  168. point retrieval mechanism.
  169. - `_GLFW_HAS_GLXGETPROCADDRESS` to use `glXGetProcAddress` (recommended)
  170. - `_GLFW_HAS_GLXGETPROCADDRESSARB` to use `glXGetProcAddressARB` (legacy)
  171. - `_GLFW_HAS_GLXGETPROCADDRESSEXT` to use `glXGetProcAddressEXT` (legacy)
  172. - `_GLFW_HAS_DLOPEN` to do manual retrieval with `dlopen` (fallback)
  173. If you are using the Cocoa window creation API, the following options are
  174. available:
  175. - `_GLFW_USE_CHDIR` to `chdir` to the `Resources` subdirectory of the
  176. application bundle during @ref glfwInit (recommended)
  177. - `_GLFW_USE_MENUBAR` to create and populate the menu bar when the first window
  178. is created (recommended)
  179. - `_GLFW_USE_RETINA` to have windows use the full resolution of Retina displays
  180. (recommended)
  181. */