From a8a3efa3be3ec6162495abc0ec0d6721a9fcdf5e Mon Sep 17 00:00:00 2001 From: Claudio Fantacci Date: Tue, 6 Aug 2019 12:55:52 +0200 Subject: FindGLEW: Fix macOS library suffix selection Fix logic added by commit a7d853868b (FindGLEW: Update implementation, 2019-03-13, v3.15.0-rc1~375^2~1) on macOS. macOS is recognized as both UNIX and APPLE. Consequently, the library suffix for shared and static library was set, respectively, as `.so` and `.a`, just like UNIX systems. Fix this by properly checking the OS type. Fixes: #19542 --- Modules/FindGLEW.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/FindGLEW.cmake b/Modules/FindGLEW.cmake index 2e9a052..18320b4 100644 --- a/Modules/FindGLEW.cmake +++ b/Modules/FindGLEW.cmake @@ -72,9 +72,9 @@ endif() function(__glew_set_find_library_suffix shared_or_static) - if(UNIX AND "${shared_or_static}" MATCHES "SHARED") + if((UNIX AND NOT APPLE) AND "${shared_or_static}" MATCHES "SHARED") set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" PARENT_SCOPE) - elseif(UNIX AND "${shared_or_static}" MATCHES "STATIC") + elseif((UNIX AND NOT APPLE) AND "${shared_or_static}" MATCHES "STATIC") set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" PARENT_SCOPE) elseif(APPLE AND "${shared_or_static}" MATCHES "SHARED") set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib;.so" PARENT_SCOPE) -- cgit v0.12 From ab822a9b48d43ffec3cc775eb8c8028ac4a96d2e Mon Sep 17 00:00:00 2001 From: Claudio Fantacci Date: Tue, 6 Aug 2019 12:57:50 +0200 Subject: FindGLEW: Add required OpenGL dependency in macOS macOS requires OpenGL as INTERFACE_LINK_LIBRARIES dependency in the GLEW targets. This commit fixes this issue. --- Modules/FindGLEW.cmake | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Modules/FindGLEW.cmake b/Modules/FindGLEW.cmake index 18320b4..0c4dc80 100644 --- a/Modules/FindGLEW.cmake +++ b/Modules/FindGLEW.cmake @@ -70,6 +70,22 @@ if(GLEW_VERBOSE) message(STATUS "FindGLEW: did not find GLEW CMake config file. Searching for libraries.") endif() +if(APPLE) + find_package(OpenGL QUIET) + + if(OpenGL_FOUND) + if(GLEW_VERBOSE) + message(STATUS "FindGLEW: Found OpenGL Framework.") + message(STATUS "FindGLEW: OPENGL_LIBRARIES: ${OPENGL_LIBRARIES}") + endif() + else() + if(GLEW_VERBOSE) + message(STATUS "FindGLEW: could not find GLEW library.") + endif() + return() + endif() +endif() + function(__glew_set_find_library_suffix shared_or_static) if((UNIX AND NOT APPLE) AND "${shared_or_static}" MATCHES "SHARED") @@ -210,6 +226,11 @@ if(NOT TARGET GLEW::glew AND NOT GLEW_USE_STATIC_LIBS) set_target_properties(GLEW::glew PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}") + if(APPLE) + set_target_properties(GLEW::glew + PROPERTIES INTERFACE_LINK_LIBRARIES OpenGL::GL) + endif() + if(GLEW_SHARED_LIBRARY_RELEASE) set_property(TARGET GLEW::glew APPEND @@ -238,6 +259,11 @@ elseif(NOT TARGET GLEW::glew_s AND GLEW_USE_STATIC_LIBS) set_target_properties(GLEW::glew_s PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}") + if(APPLE) + set_target_properties(GLEW::glew_s + PROPERTIES INTERFACE_LINK_LIBRARIES OpenGL::GL) + endif() + if(GLEW_STATIC_LIBRARY_RELEASE) set_property(TARGET GLEW::glew_s APPEND @@ -267,6 +293,11 @@ if(NOT TARGET GLEW::GLEW) set_target_properties(GLEW::GLEW PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}") + if(APPLE) + set_target_properties(GLEW::GLEW + PROPERTIES INTERFACE_LINK_LIBRARIES OpenGL::GL) + endif() + if(TARGET GLEW::glew) if(GLEW_SHARED_LIBRARY_RELEASE) set_property(TARGET GLEW::GLEW -- cgit v0.12 From feeb0381bcd73dfffd3ccf4f57d78caf518528ff Mon Sep 17 00:00:00 2001 From: Claudio Fantacci Date: Tue, 6 Aug 2019 12:59:35 +0200 Subject: FindGLEW: Fix typo in verbose log message --- Modules/FindGLEW.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindGLEW.cmake b/Modules/FindGLEW.cmake index 0c4dc80..bd69819 100644 --- a/Modules/FindGLEW.cmake +++ b/Modules/FindGLEW.cmake @@ -210,7 +210,7 @@ find_package_handle_standard_args(GLEW if(NOT GLEW_FOUND) if(GLEW_VERBOSE) - message(STATUS "FindGLEW: could not found GLEW library.") + message(STATUS "FindGLEW: could not find GLEW library.") endif() return() endif() -- cgit v0.12