Export transitive dependencies for static library

This commit is contained in:
Nicholas Vitovitch 2016-02-02 00:41:20 +01:00 committed by Camilla Berglund
parent 8637612908
commit 453631773e
5 changed files with 17 additions and 15 deletions

View File

@ -354,7 +354,6 @@ endif()
#--------------------------------------------------------------------
# Export GLFW library dependencies
#--------------------------------------------------------------------
set(GLFW_LIBRARIES ${glfw_LIBRARIES} CACHE STRING "Dependencies of GLFW")
foreach(arg ${glfw_PKG_DEPS})
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}")
endforeach()

View File

@ -158,6 +158,14 @@ will add the `glfw` target and the necessary cache variables to your project.
add_subdirectory(path/to/glfw)
@endcode
Once GLFW has been added to the project, link against it with the `glfw` target.
This adds all link-time dependencies of GLFW as it is currently configured and,
when applicable, the [GLFW_DLL](@ref build_macros) macro.
@code{.cmake}
target_link_libraries(myapp glfw)
@endcode
To be able to include the GLFW header from your code, you need to tell the
compiler where to find it.
@ -165,21 +173,18 @@ compiler where to find it.
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.
Note that it does not include GLU, as GLFW does not use it. If your application
needs GLU, you can find it by requiring the OpenGL package.
@code{.cmake}
target_link_libraries(myapp glfw ${GLFW_LIBRARIES})
find_package(OpenGL REQUIRED)
@endcode
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
CMake files look for OpenGL.
Once found, the GLU library path is stored in the `OPENGL_glu_LIBRARY` cache
variable.
@code{.cmake}
target_link_libraries(myapp glfw ${OPENGL_glu_LIBRARY} ${GLFW_LIBRARIES})
target_link_libraries(myapp glfw ${OPENGL_glu_LIBRARY})
@endcode

View File

@ -3,8 +3,6 @@ link_libraries(glfw)
if (BUILD_SHARED_LIBS)
link_libraries("${MATH_LIBRARY}")
else()
link_libraries(${glfw_LIBRARIES})
endif()
if (MSVC)

View File

@ -100,7 +100,9 @@ if (BUILD_SHARED_LIBS)
endif()
target_compile_definitions(glfw INTERFACE -DGLFW_DLL)
target_link_libraries(glfw ${glfw_LIBRARIES})
target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES})
else()
target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES})
endif()
if (MSVC)

View File

@ -3,8 +3,6 @@ link_libraries(glfw)
if (BUILD_SHARED_LIBS)
link_libraries("${MATH_LIBRARY}")
else()
link_libraries(${glfw_LIBRARIES})
endif()
if (MSVC)