@@ -136,6 +136,12 @@ if (BUILD_WITH_PEDANTIC_WARNINGS)
136
136
target_compile_options (matplot PRIVATE /W4 /WX)
137
137
else ()
138
138
target_compile_options (matplot PRIVATE -Wall -Wextra -pedantic -Werror)
139
+ # Allow the warnings related to the bundled CImg
140
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
141
+ target_compile_options (matplot PRIVATE -Wno-null-pointer-arithmetic -Wno-char-subscripts)
142
+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
143
+ target_compile_options (matplot PRIVATE -Wno-error=class-memaccess -Wno-class-memaccess)
144
+ endif ()
139
145
endif ()
140
146
endif ()
141
147
@@ -173,25 +179,35 @@ if (BUILD_EXPERIMENTAL_OPENGL_BACKEND)
173
179
174
180
# https://github.com/Dav1dde/glad
175
181
find_package (GLAD QUIET )
176
- if (GLAD_FOUND)
177
- add_library (glad INTERFACE )
178
- target_include_directories (glad INTERFACE ${GLAD_INCLUDE_PATH} )
179
- target_link_libraries (glad INTERFACE ${GLAD_LIBRARIES} )
180
- else ()
181
- # Only if not found, to avoid ODR violations
182
+ if (NOT GLAD_FOUND AND NOT TARGET glad)
183
+ # Use CPM only if not found, to avoid ODR violations
182
184
# find_package(GLAD REQUIRE) would suffice if it worked well
183
185
CPMAddPackage(NAME glad GIT_REPOSITORY https://github.com/Dav1dde/glad GIT_TAG df8e9e16110b305479a875399cee13daa0ccadd9 VERSION 0.1.33)
184
- endif ()
186
+ else ()
187
+ # FindGLAD does not usually create a target, so we create an interface target
188
+ if (NOT TARGET glad)
189
+ add_library (glad INTERFACE )
190
+ target_include_directories (glad INTERFACE ${GLAD_INCLUDE_PATH} )
191
+ target_link_libraries (glad INTERFACE ${GLAD_LIBRARIES} )
192
+ endif ()
193
+ endif ()
185
194
195
+ # https://github.com/glfw/glfw
186
196
find_package (glfw3 REQUIRED)
197
+ if (NOT GLFW3_FOUND AND NOT TARGET glfw)
198
+ # Use CPM only if not found, to avoid ODR violations
199
+ # find_package(glfw3 REQUIRE) would suffice if it worked well
200
+ CPMAddPackage(NAME glfw3 GIT_REPOSITORY https://github.com/glfw/glfw VERSION 3.3.2 GIT_TAG 3.3.2 OPTIONS "GLFW_BUILD_DOCS OFF" "GLFW_BUILD_EXAMPLES OFF" "GLFW_BUILD_TESTS OFF" "GLFW_INSTALL OFF" )
201
+ endif ()
187
202
188
203
add_library (matplot_opengl
189
204
backend/opengl_embed.h
190
205
backend/opengl_embed.cpp
191
206
backend/opengl.h
192
- backend/opengl.cpp)
207
+ backend/opengl.cpp
208
+ )
193
209
target_include_directories (matplot_opengl PUBLIC matplot)
194
- target_link_libraries (matplot_opengl PUBLIC matplot glad glfw)
210
+ target_link_libraries (matplot_opengl PUBLIC matplot glad glfw ${CMAKE_DL_LIBS} )
195
211
endif ()
196
212
197
213
0 commit comments