Skip to content

Commit 162bd6e

Browse files
aminyaalandefreitas
authored andcommitted
fix: fix the glad target installation
1 parent 0a74e69 commit 162bd6e

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

Matplot++Config.cmake.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ if(NOT ${MATPLOT_BUILT_SHARED})
1818
find_dependency(Filesystem COMPONENTS Experimental Final)
1919
# OpenGL backend
2020
if (@MATPLOTPP_BUILD_EXPERIMENTAL_OPENGL_BACKEND@)
21-
find_dependency(glad CONFIG)
22-
find_dependency(glfw3 CONFIG)
21+
find_dependency(glad)
22+
find_dependency(glfw3)
2323
endif()
2424
list(POP_BACK CMAKE_MODULE_PATH)
2525
endif()

source/matplot/CMakeLists.txt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,20 +226,21 @@ if (MATPLOTPP_BUILD_EXPERIMENTAL_OPENGL_BACKEND)
226226
# find_package(GLAD REQUIRE) would suffice if it worked well
227227
FetchContent_Declare(glad GIT_REPOSITORY https://github.com/Dav1dde/glad.git GIT_TAG v0.1.36)
228228
FetchContent_MakeAvailable(glad)
229-
else ()
230-
if(TARGET glad)
231-
add_library(glad::glad ALIAS glad)
232-
endif()
233-
if(NOT TARGET glad::glad)
234-
# FindGLAD does not usually create a target, so we create an interface target
235-
add_library(glad::glad INTERFACE)
236-
target_include_directories(glad::glad INTERFACE ${GLAD_INCLUDE_PATH})
237-
target_link_libraries(glad::glad INTERFACE ${GLAD_LIBRARIES})
238-
endif()
229+
endif()
230+
if(TARGET glad AND NOT TARGET glad::glad)
231+
# Alias glad to glad::glad
232+
add_library(glad::glad ALIAS glad)
233+
list(APPEND TARGETS glad)
234+
endif()
235+
if(NOT TARGET glad::glad)
236+
# FindGLAD does not usually create a target, so we create an interface target
237+
add_library(glad::glad INTERFACE)
238+
target_include_directories(glad::glad INTERFACE ${GLAD_INCLUDE_PATH})
239+
target_link_libraries(glad::glad INTERFACE ${GLAD_LIBRARIES})
239240
endif()
240241

241242
# https://github.com/glfw/glfw
242-
find_package(glfw3)
243+
find_package(glfw3 QUIET)
243244
if ((NOT glfw3_FOUND AND NOT GLFW3_FOUND) OR NOT TARGET glfw)
244245
# Use CPM only if not found, to avoid ODR violations
245246
# find_package(glfw3 REQUIRE) would suffice if it worked well

0 commit comments

Comments
 (0)