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 # Export GLFW library dependencies
#-------------------------------------------------------------------- #--------------------------------------------------------------------
set(GLFW_LIBRARIES ${glfw_LIBRARIES} CACHE STRING "Dependencies of GLFW")
foreach(arg ${glfw_PKG_DEPS}) foreach(arg ${glfw_PKG_DEPS})
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}") set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}")
endforeach() 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) add_subdirectory(path/to/glfw)
@endcode @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 To be able to include the GLFW header from your code, you need to tell the
compiler where to find it. compiler where to find it.
@ -165,21 +173,18 @@ compiler where to find it.
include_directories(path/to/glfw/include) include_directories(path/to/glfw/include)
@endcode @endcode
Once GLFW has been added to the project, the `GLFW_LIBRARIES` cache variable Note that it does not include GLU, as GLFW does not use it. If your application
contains all link-time dependencies of GLFW as it is currently configured. To needs GLU, you can find it by requiring the OpenGL package.
link against GLFW, link against them and the `glfw` target.
@code{.cmake} @code{.cmake}
target_link_libraries(myapp glfw ${GLFW_LIBRARIES}) find_package(OpenGL REQUIRED)
@endcode @endcode
Note that `GLFW_LIBRARIES` does not include GLU, as GLFW does not use it. If Once found, the GLU library path is stored in the `OPENGL_glu_LIBRARY` cache
your application needs GLU, you can add it to the list of dependencies with the variable.
`OPENGL_glu_LIBRARY` cache variable, which is implicitly created when the GLFW
CMake files look for OpenGL.
@code{.cmake} @code{.cmake}
target_link_libraries(myapp glfw ${OPENGL_glu_LIBRARY} ${GLFW_LIBRARIES}) target_link_libraries(myapp glfw ${OPENGL_glu_LIBRARY})
@endcode @endcode

View File

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

View File

@ -100,7 +100,9 @@ if (BUILD_SHARED_LIBS)
endif() endif()
target_compile_definitions(glfw INTERFACE -DGLFW_DLL) 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() endif()
if (MSVC) if (MSVC)

View File

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