The OpenGL Extension Wrangler Library (GLEW) is a cross-platform open-source C/C++ extension loading library. GLEW provides efficient run-time mechanisms for determining which OpenGL extensions are supported on the target platform. OpenGL core and extension functionality is exposed in a single header file. GLEW has been tested on a variety of operating systems, including Windows, Linux, Mac OS X, FreeBSD, Irix, and Solaris.
# This config-module creates the following import libraries:## - GLEW::glew shared lib# - GLEW::glew_s static lib## Additionally GLEW::GLEW 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 lib for GLEW::GLEW #include(${CMAKE_CURRENT_LIST_DIR}/glew-targets.cmake)include(${CMAKE_CURRENT_LIST_DIR}/CopyImportedTargetProperties.cmake)# decide which import library (glew/glew_s)# needs to be copied to GLEW::GLEWset(_glew_target_postfix"")set(_glew_target_typeSHARED)if(DEFINEDGLEW_USE_STATIC_LIBS)# if defined, use only static or sharedif(GLEW_USE_STATIC_LIBS)set(_glew_target_postfix"_s")endif()# else use static only if no sharedelseif(NOTTARGETGLEW::glewANDTARGETGLEW::glew_s)set(_glew_target_postfix"_s")endif()if(_glew_target_postfixSTREQUAL"")set(_glew_target_typeSHARED)else()set(_glew_target_typeSTATIC)endif()# CMake doesn't allow creating ALIAS lib for an IMPORTED lib# so create imported ones and copy the propertiesforeach(_glew_targetglew)set(_glew_src_target"GLEW::${_glew_target}${_glew_target_postfix}")string(TOUPPER"GLEW::${_glew_target}"_glew_dest_target)if(TARGET${_glew_dest_target})get_target_property(_glew_previous_src_target${_glew_dest_target}_GLEW_SRC_TARGET)if(NOT_glew_previous_src_targetSTREQUAL_glew_src_target)message(FATAL_ERROR"find_package(GLEW) was called the second time with ""different GLEW_USE_STATIC_LIBS setting. Previously, ""`glew-config.cmake` created ${_glew_dest_target} as a copy of ""${_glew_previous_src_target}. Now it attempted to copy it from ""${_glew_src_target}. ")endif()else()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})set_target_properties(${_glew_dest_target}PROPERTIES_GLEW_SRC_TARGET${_glew_src_target})endif()endforeach()
#.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_propertiessrc_targetdest_target)set(config_dependent_propsIMPORTED_IMPLIBIMPORTED_LINK_DEPENDENT_LIBRARIESIMPORTED_LINK_INTERFACE_LANGUAGESIMPORTED_LINK_INTERFACE_LIBRARIESIMPORTED_LINK_INTERFACE_MULTIPLICITYIMPORTED_LOCATIONIMPORTED_NO_SONAMEIMPORTED_SONAME)# copy configuration-independent propertiesforeach(prop${config_dependent_props}IMPORTED_CONFIGURATIONSINTERFACE_AUTOUIC_OPTIONSINTERFACE_COMPILE_DEFINITIONSINTERFACE_COMPILE_FEATURESINTERFACE_COMPILE_OPTIONSINTERFACE_INCLUDE_DIRECTORIESINTERFACE_LINK_LIBRARIESINTERFACE_POSITION_INDEPENDENT_CODEINTERFACE_SOURCESINTERFACE_SYSTEM_INCLUDE_DIRECTORIES)get_property(is_setTARGET${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 propertiesget_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_setTARGET${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()
PS D:\work\glew_work\ModernGlew\codes\cmakeinfo\05\build> cmake ..
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22631.
-- The C compiler identification is MSVC 19.38.33134.0
-- The CXX compiler identification is MSVC 19.38.33134.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found GLEW: C:/dev/glew/lib/cmake/glew/glew-config.cmake
-- my_import_targets=GLEW::glew;GLEW::glew_s;GLEW::GLEW
-- Configuring done (5.0s)
-- Generating done (0.0s)
-- Build files have been written to: D:/work/glew_work/ModernGlew/codes/cmakeinfo/05/build
PS D:\work\glew_work\ModernGlew\codes\cmakeinfo\06\build> cmake ..
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22631.
-- The C compiler identification is MSVC 19.38.33134.0
-- The CXX compiler identification is MSVC 19.38.33134.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found GLEW: C:/dev/glew/lib/cmake/glew/glew-config.cmake
-- my_import_targets=GLEW::glew;GLEW::glew_s;GLEW::GLEW
-- targetname = GLEW::glew
--
Properties for TARGET GLEW::glew:
GLEW::glew.INTERFACE_COMPILE_DEFINITIONS = <NOTFOUND>
--
Properties for TARGET GLEW::glew:
GLEW::glew.INTERFACE_INCLUDE_DIRECTORIES = "C:/dev/glew/include"
--
Properties for TARGET GLEW::glew:
GLEW::glew.INTERFACE_LINK_LIBRARIES = "opengl32;glu32"
--
Properties for TARGET GLEW::glew:
GLEW::glew.IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE = <NOTFOUND>
--
Properties for TARGET GLEW::glew:
GLEW::glew.IMPORTED_IMPLIB_RELEASE = "C:/dev/glew/lib/glew32.lib"
--
Properties for TARGET GLEW::glew:
GLEW::glew.IMPORTED_LOCATION_RELEASE = "C:/dev/glew/bin/glew32.dll"
-- Configuring done (5.1s)
-- Generating done (0.0s)
-- Build files have been written to: D:/work/glew_work/ModernGlew/codes/cmakeinfo/06/build