[CMake] Externally hooking a FindXYZ module
Mike Jackson
mike.jackson at bluequartz.net
Mon Aug 25 15:58:53 EDT 2008
I thought I read somewhere that with the latest leopard updates you
no longer need to add all this stuff.. I think..
Maybe it was on the X11 Users list at Apple?
----------------------------------------
Mike Jackson - BlueQuartz Software Consulting
<www.bluequartz.net>
mike.jackson at bluequartz.net
On Aug 25, 2008, at 3:07 PM, Fernando Cacciola wrote:
> Hi people,
>
> It turns out that Mac's Leopard OS needs a fix for OpenGL. The fix
> itself has been discussed in this list a while back:
>
> http://www.mail-archive.com/cmake@cmake.org/msg09358.html
>
>
> I need to incorporate that fix into production code, and I don't
> want to distribute my own hacked up version FindOpenGL.cmake, not a
> real one at
> least, so I wonder, is there a way to hook into the find_package
> behaviour?
>
>
> The only hack I could come up was stubbing a Find module
> in this way:
>
> (1)
> At the most top level CMakeLists.txt:
>
> # Save aside the default modules path.
> set(ORIGINAL_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} )
>
> # Prepend a project specific path so my modules take precedence
> set(CMAKE_MODULE_PATH "cmake_modules" ${CMAKE_MODULE_PATH} )
>
>
>
> (2)
> Then at the local cmake_modules folder, add a "FindOpenGL.cmake"
> stub with this:
>
>
> # Avoid recursion
> if ( NOT FIND_OPENGL_WRAPPER )
>
> set ( FIND_OPENGL_WRAPPER 1 )
>
> set(SAVED_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} )
>
> set(CMAKE_MODULE_PATH ${ORIGINAL_CMAKE_MODULE_PATH} )
>
> # This calls the real module.
> find_package(OpenGL)
>
> # Here is the post-processing to "fix" OpenGL for leopard
>
> if ( OPENGL_FOUND AND APPLE_LEOPARD )
>
> set (CMAKE_SHARED_LINKER_FLAGS "-Wl,-dylib_file,/System/
> Library/Frameworks/OpenGL.framework/Versions/A/Libraries/
> libGL.dylib:/ System/Library/Frameworks/OpenGL.framework/Versions/A/
> Libraries/libGL.dylib")
>
> endif()
>
> # reset the modules path.
> set(CMAKE_MODULE_PATH ${SAVED_CMAKE_MODULE_PATH} )
>
> endif()
>
>
> Is there a better way??
>
> TIA
>
> Fernando Cacciola
>
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list