Hi Folks, Last year FindOpenGL gained imported targets:
FindOpenGL: Provide imported targets for GL and GLU http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b7804cb6 only to be reverted prior to release: FindOpenGL: Revert support for imported targets http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=02e34de2 due to this issue: FindOpenGL: need name-only imported targets on Windows http://www.cmake.org/Bug/view.php?id=15267 The problem is that we need a way to link to 'opengl32.lib' through an imported target without knowing the full path to the library file and instead ask the linker to search for it in the platform SDK directory at link time. Without a full path we cannot set the IMPORTED_LOCATION property of an imported OpenGL::GL target. We cannot lift the requirement that IMPORTED_LOCATION be a full path because that is fundamental to the design of imported targets and is needed for things like $<TARGET_FILE:...> to work correctly. The only kind of imported target that does not require an IMPORTED_LOCATION is an INTERFACE library, so on Windows the OpenGL::GL target will have to be an imported INTERFACE library. We could use INTERFACE_LINK_LIBRARIES to specify 'opengl32.lib', but that would not preserve the inline library ordering as using IMPORTED_LOCATION does. Instead I propose a new IMPORTED_LINK_ITEM[_<CONFIG>] property to take the place of IMPORTED_LOCATION[_<CONFIG>] for an imported INTERFACE library. It will allow one to specify exactly one raw item to be placed on the link line for the interface library since it has no location. For the above case this item would be just 'opengl32'. This could also be used for cases like FindThreads and '-pthread'. I've drafted an implementation of the approach here: Allow imported INTERFACE libraries to specify a link item http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a6edb953 and used it to provide the imported OpenGL::GL target: FindOpenGL: Provide imported targets for GL and GLU http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=65d0930e I'd appreciate feedback from others on this approach. Thanks, -Brad P.S. My original attempt at allowing link item specification was much more general. It was an INTERFACE_LINK_ITEMS property on INTERFACE libraries that could be specified on in-project targets and exported during installation: Allow INTERFACE libraries to specify link items http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e4adad1e I reverted it from 'next' and never merged it to 'master' due to overlap with possible LINK_OPTIONS/ARCHIVE_OPTIONS work discussed previously. Instead I propose the more narrow IMPORTED_LINK_ITEM approach to resolve the problem for FindOpenGL without tackling the larger design goals yet. Basically IMPORTED_LINK_ITEM completes the design of IMPORTED_LOCATION as might have been done if interface libraries existed when imported targets were first created. -- 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
