mirror of
https://github.com/Perlmint/glew-cmake.git
synced 2024-11-11 09:33:49 +00:00
d2e6823451
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.
89 lines
3.1 KiB
CMake
89 lines
3.1 KiB
CMake
#.rst:
|
|
# CopyImportedTargetProperties
|
|
# --------------------------
|
|
#
|
|
# Copies the `INTERFACE*` and `IMPORTED*` properties from a target
|
|
# to another one.
|
|
# This function can be used to duplicate an `IMPORTED` or an `ALIAS` library
|
|
# with a different name since ``add_library(... ALIAS ...)`` does not work
|
|
# for those targets.
|
|
#
|
|
# ::
|
|
#
|
|
# copy_imported_target_properties(<source-target> <destination-target>)
|
|
#
|
|
# The function copies all the `INTERFACE*` and `IMPORTED*` target
|
|
# properties from `<source-target>` to `<destination-target>`.
|
|
#
|
|
# The function uses the `IMPORTED_CONFIGURATIONS` property to determine
|
|
# which configuration-dependent properties should be copied
|
|
# (`IMPORTED_LOCATION_<CONFIG>`, etc...)
|
|
#
|
|
# Example:
|
|
#
|
|
# Internally the CMake project of ZLIB builds the ``zlib`` and
|
|
# ``zlibstatic`` targets which can be exported in the ``ZLIB::`` namespace
|
|
# with the ``install(EXPORT ...)`` command.
|
|
#
|
|
# The config-module will then create the import libraries ``ZLIB::zlib`` and
|
|
# ``ZLIB::zlibstatic``. To use ``ZLIB::zlibstatic`` under the standard
|
|
# ``ZLIB::ZLIB`` name we need to create the ``ZLIB::ZLIB`` imported library
|
|
# and copy the appropriate properties:
|
|
#
|
|
# add_library(ZLIB::ZLIB STATIC IMPORTED)
|
|
# copy_imported_target_properties(ZLIB::zlibstatic ZLIB::ZLIB)
|
|
#
|
|
|
|
function(copy_imported_target_properties src_target dest_target)
|
|
|
|
set(config_dependent_props
|
|
IMPORTED_IMPLIB
|
|
IMPORTED_LINK_DEPENDENT_LIBRARIES
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES
|
|
IMPORTED_LINK_INTERFACE_LIBRARIES
|
|
IMPORTED_LINK_INTERFACE_MULTIPLICITY
|
|
IMPORTED_LOCATION
|
|
IMPORTED_NO_SONAME
|
|
IMPORTED_SONAME
|
|
)
|
|
|
|
# copy configuration-independent properties
|
|
foreach(prop
|
|
${config_dependent_props}
|
|
IMPORTED_CONFIGURATIONS
|
|
INTERFACE_AUTOUIC_OPTIONS
|
|
INTERFACE_COMPILE_DEFINITIONS
|
|
INTERFACE_COMPILE_FEATURES
|
|
INTERFACE_COMPILE_OPTIONS
|
|
INTERFACE_INCLUDE_DIRECTORIES
|
|
INTERFACE_LINK_LIBRARIES
|
|
INTERFACE_POSITION_INDEPENDENT_CODE
|
|
INTERFACE_SOURCES
|
|
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
|
|
)
|
|
get_property(is_set TARGET ${src_target} PROPERTY ${prop} SET)
|
|
if(is_set)
|
|
get_target_property(v ${src_target} ${prop})
|
|
set_target_properties(${dest_target} PROPERTIES ${prop} "${v}")
|
|
# message(STATUS "set_target_properties(${dest_target} PROPERTIES ${prop} ${v})")
|
|
endif()
|
|
endforeach()
|
|
|
|
# copy configuration-dependent properties
|
|
get_target_property(imported_configs ${src_target}
|
|
IMPORTED_CONFIGURATIONS)
|
|
|
|
foreach(config ${imported_configs})
|
|
foreach(prop_prefix ${config_dependent_props})
|
|
set(prop ${prop_prefix}_${config})
|
|
get_property(is_set TARGET ${src_target} PROPERTY ${prop} SET)
|
|
if(is_set)
|
|
get_target_property(v ${src_target} ${prop})
|
|
set_target_properties(${dest_target}
|
|
PROPERTIES ${prop} "${v}")
|
|
# message(STATUS "set_target_properties(${dest_target} PROPERTIES ${prop} ${v})")
|
|
endif()
|
|
endforeach()
|
|
endforeach()
|
|
endfunction()
|