Skip to content

Commit 0a74e69

Browse files
aminyaalandefreitas
authored andcommitted
fix: reduce if checks for OpenGL deps and update the versions
1 parent f9961b9 commit 0a74e69

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

source/matplot/CMakeLists.txt

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -220,34 +220,31 @@ if (MATPLOTPP_BUILD_EXPERIMENTAL_OPENGL_BACKEND)
220220
find_package(glad CONFIG)
221221
if (NOT glad_FOUND)
222222
find_package(GLAD QUIET)
223-
if (NOT GLAD_FOUND AND NOT TARGET glad)
224-
# Use CPM only if not found, to avoid ODR violations
225-
# find_package(GLAD REQUIRE) would suffice if it worked well
226-
FetchContent_Declare(glad GIT_REPOSITORY https://github.com/Dav1dde/glad.git GIT_TAG df8e9e16110b305479a875399cee13daa0ccadd9)
227-
FetchContent_MakeAvailable(glad)
228-
else ()
229-
if(TARGET glad)
230-
add_library(glad::glad ALIAS glad)
231-
endif()
232-
if(NOT TARGET glad::glad)
233-
# FindGLAD does not usually create a target, so we create an interface target
234-
add_library(glad::glad INTERFACE)
235-
target_include_directories(glad::glad INTERFACE ${GLAD_INCLUDE_PATH})
236-
target_link_libraries(glad::glad INTERFACE ${GLAD_LIBRARIES})
237-
endif()
223+
endif()
224+
if (NOT glad_FOUND AND NOT GLAD_FOUND)
225+
# Use CPM only if not found, to avoid ODR violations
226+
# find_package(GLAD REQUIRE) would suffice if it worked well
227+
FetchContent_Declare(glad GIT_REPOSITORY https://github.com/Dav1dde/glad.git GIT_TAG v0.1.36)
228+
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})
238238
endif()
239239
endif()
240240

241241
# https://github.com/glfw/glfw
242-
find_package(glfw3 CONFIG)
243-
if (NOT glfw3_FOUND)
244-
find_package(glfw3 QUIET)
245-
if (NOT GLFW3_FOUND AND NOT TARGET glfw)
246-
# Use CPM only if not found, to avoid ODR violations
247-
# find_package(glfw3 REQUIRE) would suffice if it worked well
248-
FetchContent_Declare(glfw3 GIT_REPOSITORY https://github.com/glfw/glfw.git GIT_TAG 3.3.2)
249-
FetchContent_MakeAvailable(glfw3)
250-
endif ()
242+
find_package(glfw3)
243+
if ((NOT glfw3_FOUND AND NOT GLFW3_FOUND) OR NOT TARGET glfw)
244+
# Use CPM only if not found, to avoid ODR violations
245+
# find_package(glfw3 REQUIRE) would suffice if it worked well
246+
FetchContent_Declare(glfw3 GIT_REPOSITORY https://github.com/glfw/glfw.git GIT_TAG 3.3.8)
247+
FetchContent_MakeAvailable(glfw3)
251248
endif()
252249

253250
add_library(matplot_opengl

0 commit comments

Comments
 (0)