cmake/FindOSGPlugins: Support lib-prefixed plugins

With a regular OSG build, the plugin names are prefixed with
`lib`, e.g. `libosgdb_jpeg.a` for a static build.

However, on Debian on Ubuntu they are not.

With this commit we now try both options.

Fixes #5972

Signed-off-by: Gleb Mazovetskiy <glex.spb@gmail.com>
pull/3043/head
Gleb Mazovetskiy 3 years ago
parent 7455dfb3a1
commit 11dfb9daff

@ -27,9 +27,12 @@ foreach(_library ${OSGPlugins_FIND_COMPONENTS})
string(TOUPPER ${_library} _library_uc)
set(_component OSGPlugins_${_library})
set(${_library_uc}_DIR ${OSGPlugins_LIB_DIR}) # to help function osg_find_library
# On some systems, notably Debian and Ubuntu, the OSG plugins do not have
# the usual "lib" prefix. We temporarily add the empty string to the list
# of prefixes CMake searches for (via osg_find_library) to support these systems.
set(_saved_lib_prefix ${CMAKE_FIND_LIBRARY_PREFIXES}) # save CMAKE_FIND_LIBRARY_PREFIXES
set(CMAKE_FIND_LIBRARY_PREFIXES "") # search libraries with no prefix
list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "") # search libraries with no prefix
set(${_library_uc}_DIR ${OSGPlugins_LIB_DIR}) # to help function osg_find_library
osg_find_library(${_library_uc} ${_library}) # find it into ${_library_uc}_LIBRARIES
set(CMAKE_FIND_LIBRARY_PREFIXES ${_saved_lib_prefix}) # restore prefix

Loading…
Cancel
Save