glew/build/cmake/glew-config.cmake
Tamas Kenez d2e6823451 cmake: install config-module
Installs a config module if CMake verion >= 2.8.12.
The config-module creates the import library targets
built in the project (glew, glew_s, glewmx, glewmx_s)
but in accordance with the FindGLEW module shipped with
CMake, it also creates GLEW::GLEW and GLEW::GLEWMX.

GLEW::GLEW and GLEW::GLEWMX will be simply copies of
glew/glewmx or glew_s/glewmx_s. If both versions are
available they alias the shared versions.

The default behaviour can be changed either when installing
or when using the package:

- Set BUILD_SHARED_LIBS to OFF or ON when building and
  installing GLEW. This controls which libraries
  (shared or static) will be installed (and not which
  will be built).
- Set GLEW_USE_STATIC_LIBS to OFF or ON before calling
  `find_package(GLEW CONFIG REQUIRED)` to force
  the config-module to create GLEW::GLEW and GLEWMX
  as aliases to glew/glewmx or glew_s/glewmx_s

The script ./cmake-testbuild.sh is added to test the
CMake build and config-module. See instructions there.
2015-06-22 14:06:50 +02:00

47 lines
1.7 KiB
CMake

# This config-module creates the following import libraries:
#
# - GLEW::glew and GLEW::glewmx shared libs
# - GLEW::glew_s and GLEW::glewmx_s static libs
#
# Additionally GLEW::GLEW and GLEW::GLEWMX will be created as an
# copy of either the shared (default) or the static libs.
#
# Dependending on the setting of BUILD_SHARED_LIBS at GLEW build time
# either the static or shared versions may not be available.
#
# Set GLEW_USE_STATIC_LIBS to OFF or ON to force using the shared
# or static libs for GLEW::GLEW and GLEW::GLEWMX
#
include(${CMAKE_CURRENT_LIST_DIR}/glew-targets.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/CopyImportedTargetProperties.cmake)
# decide which import library (glew/glew_s and glewmx/glewmx_s)
# needs to be copied to GLEW::GLEW and GLEW::GLEWMX
set(_glew_target_postfix "")
set(_glew_target_type SHARED)
if(DEFINED GLEW_USE_STATIC_LIBS)
# if defined, use only static or shared
if(GLEW_USE_STATIC_LIBS)
set(_glew_target_postfix "_s")
endif()
# else use static only if no shared
elseif(NOT TARGET GLEW::glew AND TARGET GLEW::glew_s)
set(_glew_target_postfix "_s")
endif()
if(_glew_target_postfix STREQUAL "")
set(_glew_target_type SHARED)
else()
set(_glew_target_type STATIC)
endif()
# CMake doesn't allow creating ALIAS lib for an IMPORTED lib
# so create imported ones and copy the properties
foreach(_glew_target glew glewmx)
set(_glew_src_target "GLEW::${_glew_target}${_glew_target_postfix}")
string(TOUPPER "GLEW::${_glew_target}" _glew_dest_target)
add_library(${_glew_dest_target} ${_glew_target_type} IMPORTED)
# message(STATUS "add_library(${_glew_dest_target} ${_glew_target_type} IMPORTED)")
copy_imported_target_properties(${_glew_src_target} ${_glew_dest_target})
endforeach()