• Home
  • Raw
  • Download

Lines Matching +full:cmake +full:- +full:unix

11 ## Using CMake {#compile_cmake}
13 GLFW behaves like most other libraries that use CMake so this guide mostly
16 compile_deps and @ref compile_options sections for GLFW-specific information.
18 GLFW uses [CMake](https://cmake.org/) to generate project files or makefiles
20 files with CMake and then use them to compile the GLFW library.
23 CMake](https://cmake.org/download/) from their site.
25 If you are on a Unix-like system such as Linux, FreeBSD or Cygwin or have
26 a package system like Fink, MacPorts or Homebrew, you can install its CMake
29 CMake is a complex tool and this guide will only show a few of the possible ways
30 to set up and compile GLFW. The CMake project has their own much more detailed
31 [CMake user guide][cmake-guide] that includes everything in this guide not
34 [cmake-guide]: https://cmake.org/cmake/help/latest/guide/user-interaction/
40 all necessary dependencies for compiling GLFW, but on Unix-like systems like
46 By default, both the Wayland and X11 backends are enabled on Linux and other Unix-like
48 or @ref GLFW_BUILD_X11 CMake options in the next step when generating build files.
55 On Debian and derivatives like Ubuntu and Linux Mint you will need the `libwayland-dev`
56 and `libxkbcommon-dev` packages to compile for Wayland and the `xorg-dev` meta-package to
60 sudo apt install libwayland-dev libxkbcommon-dev xorg-dev
63 On Fedora and derivatives like Red Hat you will need the `wayland-devel` and
64 `libxkbcommon-devel` packages to compile for Wayland and the `libXcursor-devel`,
65 `libXi-devel`, `libXinerama-devel` and `libXrandr-devel` packages to compile for X11.
69 sudo dnf install wayland-devel libxkbcommon-devel libXcursor-devel libXi-devel libXinerama-devel li…
72 On FreeBSD you will need the `wayland`, `libxkbcommon` and `evdev-proto` packages to
73 compile for Wayland. The X11 headers are installed along the end-user X11 packages, so if
78 pkg install wayland libxkbcommon evdev-proto xorgproto
81 On Cygwin Wayland is not supported but you will need the `libXcursor-devel`,
82 `libXi-devel`, `libXinerama-devel`, `libXrandr-devel` and `libXrender-devel` packages to
89 ### Generating build files with CMake {#compile_generate}
92 files or makefiles for your development environment. CMake needs two paths for
95 - the path to the root directory of the GLFW source tree (not its `src`
97 - the path to the directory where the generated build files and compiled
100 If these are the same, it is called an in-tree build, otherwise it is called an
101 out-of-tree build.
103 Out-of-tree builds are recommended as they avoid cluttering up the source tree.
111 #### Generating with the CMake GUI {#compile_generate_gui}
113 Start the CMake GUI and set the paths to the source and build directories
116 If you wish change any CMake variables in the list, press _Configure_ and then
120 By default, GLFW will use Wayland and X11 on Linux and other Unix-like systems other than
129 #### Generating with command-line CMake {#compile_generate_cli}
131 To make a build directory, pass the source and build directories to the `cmake`
136 cmake -S path/to/glfw -B path/to/build
144 cmake -S . -B build
148 and makefiles on other platforms. You can choose other targets using the `-G`
152 cmake -S path/to/glfw -B path/to/build -G Xcode
155 By default, GLFW will use Wayland and X11 on Linux and other Unix-like systems other than
157 and/or @ref GLFW_BUILD_X11 CMake option.
160 cmake -S path/to/glfw -B path/to/build -D GLFW_BUILD_X11=0
176 With Linux, macOS and other forms of Unix, run `make`.
183 With MinGW, it is `mingw32-make`.
187 mingw32-make
190 Any CMake build directory can also be built with the `cmake` command and the
191 `--build` flag.
194 cmake --build path/to/build
203 ## CMake options {#compile_options}
205 The CMake files for GLFW provide a number of options, although not all are
207 among projects using CMake and so have no `GLFW_` prefix.
209 If you are using the GUI version of CMake, these are listed and can be changed
210 from there. If you are using the command-line version of CMake you can use the
213 `cmake-curses-gui` package.
215 Finally, if you don't want to use any GUI, you can set options from the `cmake`
216 command-line with the `-D` flag.
219 cmake -S path/to/glfw -B path/to/build -D BUILD_SHARED_LIBS=ON
223 ### Shared CMake options {#compile_options_shared}
229 is defined by CMake. If you want to change the library only for GLFW when it is
235 value of this option must be a valid CMake library type. Set it to `STATIC` to
237 / dynamic library / DLL, or `OBJECT` to make GLFW a CMake object library.
242 as a subproject of a larger CMake project.
247 built as a subproject of a larger CMake project.
252 [Doxygen](https://www.doxygen.nl/) is found by CMake during configuration.
255 ### Win32 specific CMake options {#compile_options_win32}
267 On CMake 3.15 and later you can set the standard CMake [CMAKE_MSVC_RUNTIME_LIBRARY][]
268 variable instead of this GLFW-specific option.
270 [CMAKE_MSVC_RUNTIME_LIBRARY]: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRA…
275 high-performance GPU on Nvidia Optimus and AMD PowerXpress systems. These symbols
281 ### macOS specific CMake options {#compile_options_macos}
289 ### Unix-like system specific CMake options {#compile_options_unix}
293 the library. This option is only available when compiling for Linux and other Unix-like
298 library. This option is only available when compiling for Linux and other Unix-like
302 ## Cross-compilation with CMake and MinGW {#compile_mingw_cross}
304 Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For
305 example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages
306 for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives
307 like Ubuntu have the `mingw-w64` package for both.
309 GLFW has CMake toolchain files in the `CMake` subdirectory that set up
310 cross-compilation of Windows binaries. To use these files you set the
311 `CMAKE_TOOLCHAIN_FILE` CMake variable with the `-D` flag add an option when
315 cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file
319 MinGW-w64 binaries on your system. You can usually see this in the /usr
320 directory. For example, both the Ubuntu and Cygwin MinGW-w64 packages have
321 `/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct invocation
325 cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake
329 passed to the `-S` flag, not to the current directory.
331 For more details see the [CMake toolchain guide][cmake-toolchains].
333 [cmake-toolchains]: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html
338 If you wish to compile GLFW without its CMake build environment then you will have to do
339 at least some platform-detection yourself. There are preprocessor macros for
341 platform-specific macros for various features.
344 on the command-line. The GLFW CMake files set these as private compile
351 - @b _GLFW_COCOA to use the Cocoa frameworks
352 - @b _GLFW_WIN32 to use the Win32 API
353 - @b _GLFW_WAYLAND to use the Wayland protocol
354 - @b _GLFW_X11 to use the X Window System
366 _GLFW_GLESV2_LIBRARY. Otherwise, GLFW will use the built-in default names.