The APPLE part works, but definitely could be improved upon.
---
Modules/FindGLUT.cmake | 58 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 57 insertions(+), 1 deletion(-)
diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake
index be7c0cd..6098108 100644
--- a/Modules/FindGLUT.cmake
+++ b/Modules/FindGLUT.cmake
@@ -2,7 +2,20 @@
# FindGLUT
# --------
#
-# try to find glut library and include files
+# try to find glut library and include files.
+#
+# IMPORTED Targets
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines the :prop_tgt:`IMPORTED` targets:
+#
+# ``GLUT::GLUT``
+# Defined if the system has GLUT.
+#
+# Result Variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module sets the following variables:
#
# ::
#
@@ -66,6 +79,18 @@ else ()
/usr/openwin/lib
)
+ if(GLUT_Xi_LIBRARY AND NOT TARGET GLUT::Xi)
+ add_library(GLUT::Xi UNKNOWN IMPORTED)
+ set_target_properties(GLUT::Xi PROPERTIES
+ IMPORTED_LOCATION "${GLUT_Xi_LIBRARY}")
+ endif()
+
+ if(GLUT_Xmu_LIBRARY AND NOT TARGET GLUT::Xmu)
+ add_library(GLUT::Xmu UNKNOWN IMPORTED)
+ set_target_properties(GLUT::Xmu PROPERTIES
+ IMPORTED_LOCATION "${GLUT_Xmu_LIBRARY}")
+ endif()
+
endif ()
find_path( GLUT_INCLUDE_DIR GL/glut.h
@@ -102,6 +127,37 @@ if (GLUT_FOUND)
${GLUT_cocoa_LIBRARY}
)
+ if(NOT TARGET GLUT::GLUT)
+ add_library(GLUT::GLUT UNKNOWN IMPORTED)
+ set_target_properties(GLUT::GLUT PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${GLUT_INCLUDE_DIR}")
+ if(APPLE)
+ # Using the hardcoded paths is certainly not the best thing to
+ # do, but it is done the include path already.
+ set_target_properties(GLUT::GLUT PROPERTIES
+ IMPORTED_LOCATION "/System/Library/Frameworks/GLUT.framework/GLUT")
+ if(NOT TARGET GLUT::Cocoa)
+ add_library(GLUT::Cocoa UNKNOWN IMPORTED)
+ set_target_properties(GLUT::Cocoa PROPERTIES
+ IMPORTED_LOCATION "/System/Library/Frameworks/Cocoa.framework/Cocoa")
+ endif()
+ set_target_properties(GLUT::GLUT PROPERTIES
+ INTERFACE_LINK_LIBRARIES GLUT::Cocoa)
+ else()
+ set_target_properties(GLUT::GLUT PROPERTIES
+ IMPORTED_LOCATION "${GLUT_glut_LIBRARY}")
+ endif()
+
+ if(TARGET GLUT::Xmu)
+ set_property(TARGET GLUT::GLUT APPEND
+ PROPERTY INTERFACE_LINK_LIBRARIES GLUT::Xmu)
+ endif()
+ if(TARGET GLUT::Xi)
+ set_property(TARGET GLUT::GLUT APPEND
+ PROPERTY INTERFACE_LINK_LIBRARIES GLUT::Xi)
+ endif()
+ endif()
+
#The following deprecated settings are for backwards compatibility with CMake1.4
set (GLUT_LIBRARY ${GLUT_LIBRARIES})
set (GLUT_INCLUDE_PATH ${GLUT_INCLUDE_DIR})
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers