mirror of
https://github.com/glfw/glfw.git
synced 2024-11-29 05:22:00 +00:00
CMake documentation work
This commit is contained in:
parent
7f7ad39e15
commit
b63b992fd6
@ -148,6 +148,10 @@ uses OpenGL and `glu32` if it uses GLU.
|
|||||||
|
|
||||||
@subsection build_link_cmake_source With CMake and GLFW source
|
@subsection build_link_cmake_source With CMake and GLFW source
|
||||||
|
|
||||||
|
This section is about using CMake to compile and link GLFW along with your
|
||||||
|
application. If you want to use an installed binary instead, see @ref
|
||||||
|
build_link_cmake_module.
|
||||||
|
|
||||||
With just a few changes to your `CMakeLists.txt` you can have the GLFW source
|
With just a few changes to your `CMakeLists.txt` you can have the GLFW source
|
||||||
tree built along with your application.
|
tree built along with your application.
|
||||||
|
|
||||||
@ -174,56 +178,54 @@ needs GLU, you can find it by requiring the OpenGL package.
|
|||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Once found, the GLU library path is stored in the `OPENGL_glu_LIBRARY` cache
|
If GLU is found, the `OPENGL_GLU_FOUND` variable is true and the
|
||||||
variable.
|
`OPENGL_INCLUDE_DIR` and `OPENGL_glu_LIBRARY` cache variables can be used.
|
||||||
|
|
||||||
@code{.cmake}
|
@code{.cmake}
|
||||||
target_link_libraries(myapp glfw ${OPENGL_glu_LIBRARY})
|
target_include_directories(myapp ${OPENGL_INCLUDE_DIR})
|
||||||
|
target_link_libraries(myapp ${OPENGL_glu_LIBRARY})
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
|
||||||
@subsection build_link_cmake_pkgconfig With CMake on Unix and installed GLFW binaries
|
@subsection build_link_cmake_module With CMake and installed GLFW binaries
|
||||||
|
|
||||||
CMake can import settings from pkg-config, which GLFW supports. When you
|
This section is about using CMake to link GLFW after it has been built and
|
||||||
installed GLFW, the pkg-config file `glfw3.pc` was installed along with it.
|
installed. If you want to build it along with your application instead, see
|
||||||
|
@ref build_link_cmake_source.
|
||||||
|
|
||||||
First you need to find the PkgConfig package. If this fails, you may need to
|
With just a few changes to your `CMakeLists.txt`, you can locate the module and
|
||||||
install the pkg-config package for your distribution.
|
target files generated when GLFW is installed.
|
||||||
|
|
||||||
@code{.cmake}
|
@code{.cmake}
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(glfw3 3.2 REQUIRED)
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
This creates the CMake commands to find pkg-config packages. Then you need to
|
Once GLFW has been located, link against it with the `glfw` target. This adds
|
||||||
find the GLFW package.
|
all link-time dependencies of GLFW as it is currently configured, the include
|
||||||
|
directory for the GLFW header and, when applicable, the
|
||||||
|
[GLFW_DLL](@ref build_macros) macro.
|
||||||
|
|
||||||
@code{.cmake}
|
@code{.cmake}
|
||||||
pkg_search_module(GLFW REQUIRED glfw3)
|
target_link_libraries(myapp glfw)
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
This creates the CMake variables you need to use GLFW. To be able to include
|
Note that it does not include GLU, as GLFW does not use it. If your application
|
||||||
the GLFW header, you need to tell your compiler where it is.
|
needs GLU, you can find it by requiring the OpenGL package.
|
||||||
|
|
||||||
@code{.cmake}
|
@code{.cmake}
|
||||||
include_directories(${GLFW_INCLUDE_DIRS})
|
find_package(OpenGL REQUIRED)
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
You also need to link against the correct libraries. If you are using the
|
If GLU is found, the `OPENGL_GLU_FOUND` variable is true and the
|
||||||
shared library version of GLFW, use the `GLFW_LIBRARIES` variable.
|
`OPENGL_INCLUDE_DIR` and `OPENGL_glu_LIBRARY` cache variables can be used.
|
||||||
|
|
||||||
@code{.cmake}
|
@code{.cmake}
|
||||||
target_link_libraries(simple ${GLFW_LIBRARIES})
|
target_include_directories(myapp ${OPENGL_INCLUDE_DIR})
|
||||||
@endcode
|
target_link_libraries(myapp ${OPENGL_glu_LIBRARY})
|
||||||
|
|
||||||
If you are using the static library version of GLFW, use the
|
|
||||||
`GLFW_STATIC_LIBRARIES` variable instead.
|
|
||||||
|
|
||||||
@code{.cmake}
|
|
||||||
target_link_libraries(simple ${GLFW_STATIC_LIBRARIES})
|
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
|
||||||
@subsection build_link_pkgconfig With pkg-config on OS X or other Unix
|
@subsection build_link_pkgconfig With makefiles and pkg-config on Unix
|
||||||
|
|
||||||
GLFW supports [pkg-config](http://www.freedesktop.org/wiki/Software/pkg-config/),
|
GLFW supports [pkg-config](http://www.freedesktop.org/wiki/Software/pkg-config/),
|
||||||
and the `glfw3.pc` pkf-config file is generated when the GLFW library is built
|
and the `glfw3.pc` pkf-config file is generated when the GLFW library is built
|
||||||
|
Loading…
Reference in New Issue
Block a user