Browse Source

Export transitive dependencies for static library

Nicholas Vitovitch 9 năm trước cách đây
mục cha
commit
453631773e
5 tập tin đã thay đổi với 17 bổ sung15 xóa
  1. 0 1
      CMakeLists.txt
  2. 14 9
      docs/build.dox
  3. 0 2
      examples/CMakeLists.txt
  4. 3 1
      src/CMakeLists.txt
  5. 0 2
      tests/CMakeLists.txt

+ 0 - 1
CMakeLists.txt

@@ -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()

+ 14 - 9
docs/build.dox

@@ -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
 
 

+ 0 - 2
examples/CMakeLists.txt

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

+ 3 - 1
src/CMakeLists.txt

@@ -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)

+ 0 - 2
tests/CMakeLists.txt

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