From e5601f1619a6f1516cec504fe9d1d200510d666a Mon Sep 17 00:00:00 2001 From: "m@bitsnbites.eu" Date: Mon, 1 Feb 2016 10:34:10 +0100 Subject: [PATCH 1/2] Add GLFW includes to target_include_directories This makes it easier to build GLFW as a sub-project of another CMake based project. Instead of having to use include_directories(path/to/glfw/include) the project using GLFW will get the correct include path by just doing target_link_libraries(myapp glfw ${GLFW_LIBRARIES}). --- src/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 590a10f8e..93494952c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,6 +64,9 @@ target_include_directories(glfw PRIVATE "${GLFW_BINARY_DIR}/src" ${glfw_INCLUDE_DIRS}) +# Make the public GLFW includes available for users of the GLFW library. +target_include_directories(glfw PUBLIC "${GLFW_SOURCE_DIR}/include") + # HACK: When building on MinGW, WINVER and UNICODE need to be defined before # the inclusion of stddef.h (by glfw3.h), which is itself included before # win32_platform.h. We define them here until a saner solution can be found From 86e369763647fcaa47d7f29e66b794442971733f Mon Sep 17 00:00:00 2001 From: "m@bitsnbites.eu" Date: Mon, 1 Feb 2016 12:30:48 +0100 Subject: [PATCH 2/2] fixup! Add GLFW includes to target_include_directories Update the documentation too. --- docs/build.dox | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/docs/build.dox b/docs/build.dox index d14cf799b..339b28f87 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -158,13 +158,6 @@ will add the `glfw` target and the necessary cache variables to your project. add_subdirectory(path/to/glfw) @endcode -To be able to include the GLFW header from your code, you need to tell the -compiler where to find it. - -@code{.cmake} -include_directories(path/to/glfw/include) -@endcode - Once GLFW has been added to the project, the `GLFW_LIBRARIES` cache variable contains all link-time dependencies of GLFW as it is currently configured. To link against GLFW, link against them and the `glfw` target. @@ -173,6 +166,8 @@ link against GLFW, link against them and the `glfw` target. target_link_libraries(myapp glfw ${GLFW_LIBRARIES}) @endcode +This also makes the GLFW header available for inclusion from your code. + Note that `GLFW_LIBRARIES` does not include GLU, as GLFW does not use it. If your application needs GLU, you can add it to the list of dependencies with the `OPENGL_glu_LIBRARY` cache variable, which is implicitly created when the GLFW