You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.2KB

  1. # This config-module creates the following import libraries:
  2. #
  3. # - GLEW::glew shared lib
  4. # - GLEW::glew_s static lib
  5. #
  6. # Additionally GLEW::GLEW will be created as an
  7. # copy of either the shared (default) or the static libs.
  8. #
  9. # Dependending on the setting of BUILD_SHARED_LIBS at GLEW build time
  10. # either the static or shared versions may not be available.
  11. #
  12. # Set GLEW_USE_STATIC_LIBS to OFF or ON to force using the shared
  13. # or static lib for GLEW::GLEW
  14. #
  15. include(${CMAKE_CURRENT_LIST_DIR}/glew-targets.cmake)
  16. include(${CMAKE_CURRENT_LIST_DIR}/CopyImportedTargetProperties.cmake)
  17. # decide which import library (glew/glew_s)
  18. # needs to be copied to GLEW::GLEW
  19. set(_glew_target_postfix "")
  20. set(_glew_target_type SHARED)
  21. if(DEFINED GLEW_USE_STATIC_LIBS)
  22. # if defined, use only static or shared
  23. if(GLEW_USE_STATIC_LIBS)
  24. set(_glew_target_postfix "_s")
  25. endif()
  26. # else use static only if no shared
  27. elseif(NOT TARGET GLEW::glew AND TARGET GLEW::glew_s)
  28. set(_glew_target_postfix "_s")
  29. endif()
  30. if(_glew_target_postfix STREQUAL "")
  31. set(_glew_target_type SHARED)
  32. else()
  33. set(_glew_target_type STATIC)
  34. endif()
  35. # CMake doesn't allow creating ALIAS lib for an IMPORTED lib
  36. # so create imported ones and copy the properties
  37. foreach(_glew_target glew)
  38. set(_glew_src_target "GLEW::${_glew_target}${_glew_target_postfix}")
  39. string(TOUPPER "GLEW::${_glew_target}" _glew_dest_target)
  40. if(TARGET ${_glew_dest_target})
  41. get_target_property(_glew_previous_src_target ${_glew_dest_target}
  42. _GLEW_SRC_TARGET)
  43. if(NOT _glew_previous_src_target STREQUAL _glew_src_target)
  44. message(FATAL_ERROR "find_package(GLEW) was called the second time with "
  45. "different GLEW_USE_STATIC_LIBS setting. Previously, "
  46. "`glew-config.cmake` created ${_glew_dest_target} as a copy of "
  47. "${_glew_previous_src_target}. Now it attempted to copy it from "
  48. "${_glew_src_target}. ")
  49. endif()
  50. else()
  51. add_library(${_glew_dest_target} ${_glew_target_type} IMPORTED)
  52. # message(STATUS "add_library(${_glew_dest_target} ${_glew_target_type} IMPORTED)")
  53. copy_imported_target_properties(${_glew_src_target} ${_glew_dest_target})
  54. set_target_properties(${_glew_dest_target} PROPERTIES
  55. _GLEW_SRC_TARGET ${_glew_src_target})
  56. endif()
  57. endforeach()