From 170b19870388f86e066ab3673ecb395c8ddc33cf Mon Sep 17 00:00:00 2001 From: Matt Raykowski Date: Wed, 12 May 2010 11:49:59 -0500 Subject: [PATCH] Fixed: #849 CMake now finds XF86VidMode and links OpenGL correctly. --- code/nel/CMakeLists.txt | 3 ++ code/nel/CMakeModules/FindXF86VidMode.cmake | 46 ++++++++++++++++++++ code/nel/src/3d/driver/opengl/CMakeLists.txt | 8 +++- 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 code/nel/CMakeModules/FindXF86VidMode.cmake diff --git a/code/nel/CMakeLists.txt b/code/nel/CMakeLists.txt index 6bf0aafce..46c351c1d 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -91,6 +91,9 @@ IF(WITH_3D) IF(WITH_DRIVER_OPENGL) FIND_PACKAGE(OpenGL) + IF(NOT WIN32) + FIND_PACKAGE(XF86VidMode) + ENDIF(NOT WIN32) ENDIF(WITH_DRIVER_OPENGL) IF(WITH_CEGUI) diff --git a/code/nel/CMakeModules/FindXF86VidMode.cmake b/code/nel/CMakeModules/FindXF86VidMode.cmake new file mode 100644 index 000000000..c84765bdd --- /dev/null +++ b/code/nel/CMakeModules/FindXF86VidMode.cmake @@ -0,0 +1,46 @@ +# - Locate Jpeg library +# This module defines +# XF86VidMode_LIBRARY, the library to link against +# XF86VidMode_FOUND, if false, do not try to link to XF86VidMode +# XF86VidMode_INCLUDE_DIR, where to find headers. + +IF(XF86VidMode_LIBRARY AND XF86VidMode_INCLUDE_DIR) + # in cache already + SET(XF86VidMode_FIND_QUIETLY TRUE) +ENDIF(XF86VidMode_LIBRARY AND XF86VidMode_INCLUDE_DIR) + + +FIND_PATH(XF86VidMode_INCLUDE_DIR + xf86vm.h + PATHS + $ENV{XF86VidMode_DIR}/include + /usr/include/X11/ + /usr/X11R6/include/ + PATH_SUFFIXES extensions +) + +FIND_LIBRARY(XF86VidMode_LIBRARY + Xxf86vm + PATHS + $ENV{XF86VidMode_DIR}/lib + /usr/X11R6/lib + /usr/lib + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + /usr/freeware/lib64 +) + +IF(XF86VidMode_LIBRARY AND XF86VidMode_INCLUDE_DIR) + SET(XF86VidMode_FOUND "YES") + SET(XF86VidMode_DEFINITIONS -DXF86VIDMODE) + IF(NOT XF86VidMode_FIND_QUIETLY) + MESSAGE(STATUS "Found XF86VidMode: ${XF86VidMode_LIBRARY}") + ENDIF(NOT XF86VidMode_FIND_QUIETLY) +ELSE(XF86VidMode_LIBRARY AND XF86VidMode_INCLUDE_DIR) + IF(NOT XF86VidMode_FIND_QUIETLY) + MESSAGE(STATUS "Warning: Unable to find XF86VidMode!") + ENDIF(NOT XF86VidMode_FIND_QUIETLY) +ENDIF(XF86VidMode_LIBRARY AND XF86VidMode_INCLUDE_DIR) + diff --git a/code/nel/src/3d/driver/opengl/CMakeLists.txt b/code/nel/src/3d/driver/opengl/CMakeLists.txt index f6d151619..f2ea8a6e3 100644 --- a/code/nel/src/3d/driver/opengl/CMakeLists.txt +++ b/code/nel/src/3d/driver/opengl/CMakeLists.txt @@ -24,6 +24,12 @@ IF(WIN32) RELEASE_POSTFIX "_r" LINK_FLAGS "/NODEFAULTLIB:libcmt") ADD_DEFINITIONS(/DDRIVER_OPENGL_EXPORTS) +ELSE(WIN32) + IF(XF86VidMode_FOUND) + INCLUDE_DIRECTORIES(${XF86VidMode_INCLUDE_DIR}) + ADD_DEFINITIONS(${XF86VidMode_DEFINITIONS}) + TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${XF86VidMode_LIBRARY}) + ENDIF(XF86VidMode_FOUND) ENDIF(WIN32) ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) @@ -31,4 +37,4 @@ ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) INSTALL(TARGETS ${NLDRV_OGL_LIB} LIBRARY DESTINATION lib RUNTIME DESTINATION bin COMPONENT drivers3d) IF(WITH_MAXPLUGIN) INSTALL(TARGETS ${NLDRV_OGL_LIB} RUNTIME DESTINATION maxplugin COMPONENT drivers3d) -ENDIF(WITH_MAXPLUGIN) \ No newline at end of file +ENDIF(WITH_MAXPLUGIN)