config.cmake.in 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. ## gflags CMake configuration file
  2. # library version information
  3. set (@PACKAGE_PREFIX@_VERSION_STRING "@PACKAGE_VERSION@")
  4. set (@PACKAGE_PREFIX@_VERSION_MAJOR @PACKAGE_VERSION_MAJOR@)
  5. set (@PACKAGE_PREFIX@_VERSION_MINOR @PACKAGE_VERSION_MINOR@)
  6. set (@PACKAGE_PREFIX@_VERSION_PATCH @PACKAGE_VERSION_PATCH@)
  7. # import targets
  8. if (NOT DEFINED @PACKAGE_PREFIX@_USE_TARGET_NAMESPACE)
  9. set (@PACKAGE_PREFIX@_USE_TARGET_NAMESPACE FALSE)
  10. endif ()
  11. if (@PACKAGE_PREFIX@_USE_TARGET_NAMESPACE)
  12. include ("${CMAKE_CURRENT_LIST_DIR}/@EXPORT_NAME@.cmake")
  13. set (@PACKAGE_PREFIX@_TARGET_NAMESPACE @PACKAGE_NAME@)
  14. else ()
  15. include ("${CMAKE_CURRENT_LIST_DIR}/@PACKAGE_NAME@-nonamespace-targets.cmake")
  16. set (@PACKAGE_PREFIX@_TARGET_NAMESPACE)
  17. endif ()
  18. if (@PACKAGE_PREFIX@_TARGET_NAMESPACE)
  19. set (@PACKAGE_PREFIX@_TARGET_PREFIX ${@PACKAGE_PREFIX@_TARGET_NAMESPACE}::)
  20. else ()
  21. set (@PACKAGE_PREFIX@_TARGET_PREFIX)
  22. endif ()
  23. # installation prefix
  24. get_filename_component (CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
  25. get_filename_component (_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_PREFIX_REL2CONFIG_DIR@" ABSOLUTE)
  26. # include directory
  27. #
  28. # Newer versions of CMake set the INTERFACE_INCLUDE_DIRECTORIES property
  29. # of the imported targets. It is hence not necessary to add this path
  30. # manually to the include search path for targets which link to gflags.
  31. set (@PACKAGE_PREFIX@_INCLUDE_DIR "${_INSTALL_PREFIX}/@INCLUDE_INSTALL_DIR@")
  32. if (@PACKAGE_NAME@_FIND_COMPONENTS)
  33. foreach (@PACKAGE_NAME@_FIND_COMPONENT IN LISTS @PACKAGE_NAME@_FIND_COMPONENTS)
  34. if (@PACKAGE_NAME@_FIND_REQUIRED_${@PACKAGE_NAME@_FIND_COMPONENT} AND NOT TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_${@PACKAGE_NAME@_FIND_COMPONENT})
  35. message (FATAL_ERROR "Package @PACKAGE_NAME@ was installed without required component ${@PACKAGE_PREFIX@_TARGET_PREFIX}${@PACKAGE_NAME@_FIND_COMPONENT}!")
  36. endif ()
  37. endforeach ()
  38. list (GET @PACKAGE_NAME@_FIND_COMPONENTS 0 @PACKAGE_NAME@_FIND_COMPONENT)
  39. else ()
  40. set (@PACKAGE_NAME@_FIND_COMPONENT)
  41. endif ()
  42. # default settings of @PACKAGE_PREFIX@_SHARED and @PACKAGE_PREFIX@_NOTHREADS
  43. #
  44. # It is recommended to use either one of the following find_package commands
  45. # instead of setting the @PACKAGE_PREFIX@_(SHARED|NOTHREADS) variables:
  46. # - find_package(@PACKAGE_NAME@ REQUIRED)
  47. # - find_package(@PACKAGE_NAME@ COMPONENTS nothreads_static)
  48. # - find_package(@PACKAGE_NAME@ COMPONENTS nothreads_shared)
  49. # - find_package(@PACKAGE_NAME@ COMPONENTS static)
  50. # - find_package(@PACKAGE_NAME@ COMPONENTS shared)
  51. if (NOT DEFINED @PACKAGE_PREFIX@_SHARED)
  52. if (DEFINED @PACKAGE_NAME@_SHARED)
  53. set (@PACKAGE_PREFIX@_SHARED ${@PACKAGE_NAME@_SHARED})
  54. elseif (@PACKAGE_NAME@_FIND_COMPONENT)
  55. if (@PACKAGE_NAME@_FIND_COMPONENT MATCHES "shared")
  56. set (@PACKAGE_PREFIX@_SHARED TRUE)
  57. else ()
  58. set (@PACKAGE_PREFIX@_SHARED FALSE)
  59. endif ()
  60. elseif (TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_shared OR TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_nothreads_shared)
  61. set (@PACKAGE_PREFIX@_SHARED TRUE)
  62. else ()
  63. set (@PACKAGE_PREFIX@_SHARED FALSE)
  64. endif ()
  65. endif ()
  66. if (NOT DEFINED @PACKAGE_PREFIX@_NOTHREADS)
  67. if (DEFINED @PACKAGE_NAME@_NOTHREADS)
  68. set (@PACKAGE_PREFIX@_NOTHREADS ${@PACKAGE_NAME@_NOTHREADS})
  69. elseif (@PACKAGE_NAME@_FIND_COMPONENT)
  70. if (@PACKAGE_NAME@_FIND_COMPONENT MATCHES "nothreads")
  71. set (@PACKAGE_PREFIX@_NOTHREADS TRUE)
  72. else ()
  73. set (@PACKAGE_PREFIX@_NOTHREADS FALSE)
  74. endif ()
  75. elseif (TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_static OR TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_shared)
  76. set (@PACKAGE_PREFIX@_NOTHREADS FALSE)
  77. else ()
  78. set (@PACKAGE_PREFIX@_NOTHREADS TRUE)
  79. endif ()
  80. endif ()
  81. # choose imported library target
  82. if (NOT @PACKAGE_PREFIX@_TARGET)
  83. if (@PACKAGE_NAME@_TARGET)
  84. set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_NAME@_TARGET})
  85. elseif (@PACKAGE_PREFIX@_SHARED)
  86. if (@PACKAGE_PREFIX@_NOTHREADS)
  87. set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_nothreads_shared)
  88. else ()
  89. set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_shared)
  90. endif ()
  91. else ()
  92. if (@PACKAGE_PREFIX@_NOTHREADS)
  93. set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_nothreads_static)
  94. else ()
  95. set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_static)
  96. endif ()
  97. endif ()
  98. endif ()
  99. if (NOT TARGET ${@PACKAGE_PREFIX@_TARGET})
  100. message (FATAL_ERROR "Your @PACKAGE_NAME@ installation does not contain a ${@PACKAGE_PREFIX@_TARGET} library target!"
  101. " Try a different combination of @PACKAGE_PREFIX@_SHARED and @PACKAGE_PREFIX@_NOTHREADS.")
  102. endif ()
  103. # add more convenient "${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@" import target
  104. if (NOT TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@)
  105. if (@PACKAGE_PREFIX@_SHARED)
  106. add_library (${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ SHARED IMPORTED)
  107. else ()
  108. add_library (${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ STATIC IMPORTED)
  109. endif ()
  110. # copy INTERFACE_* properties
  111. foreach (_@PACKAGE_PREFIX@_PROPERTY_NAME IN ITEMS
  112. COMPILE_DEFINITIONS
  113. COMPILE_FEATURES
  114. COMPILE_OPTIONS
  115. INCLUDE_DIRECTORIES
  116. LINK_LIBRARIES
  117. POSITION_INDEPENDENT_CODE
  118. )
  119. get_target_property (_@PACKAGE_PREFIX@_PROPERTY_VALUE ${@PACKAGE_PREFIX@_TARGET} INTERFACE_${_@PACKAGE_PREFIX@_PROPERTY_NAME})
  120. if (_@PACKAGE_PREFIX@_PROPERTY_VALUE)
  121. set_target_properties(${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ PROPERTIES
  122. INTERFACE_${_@PACKAGE_PREFIX@_PROPERTY_NAME} "${_@PACKAGE_PREFIX@_PROPERTY_VALUE}"
  123. )
  124. endif ()
  125. endforeach ()
  126. # copy IMPORTED_*_<CONFIG> properties
  127. get_target_property (_@PACKAGE_PREFIX@_CONFIGURATIONS ${@PACKAGE_PREFIX@_TARGET} IMPORTED_CONFIGURATIONS)
  128. set_target_properties (${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ PROPERTIES IMPORTED_CONFIGURATIONS "${_@PACKAGE_PREFIX@_CONFIGURATIONS}")
  129. foreach (_@PACKAGE_PREFIX@_PROPERTY_NAME IN ITEMS
  130. IMPLIB
  131. LOCATION
  132. LINK_DEPENDENT_LIBRARIES
  133. LINK_INTERFACE_LIBRARIES
  134. LINK_INTERFACE_LANGUAGES
  135. LINK_INTERFACE_MULTIPLICITY
  136. NO_SONAME
  137. SONAME
  138. )
  139. foreach (_@PACKAGE_PREFIX@_CONFIG IN LISTS _@PACKAGE_PREFIX@_CONFIGURATIONS)
  140. get_target_property (_@PACKAGE_PREFIX@_PROPERTY_VALUE ${@PACKAGE_PREFIX@_TARGET} IMPORTED_${_@PACKAGE_PREFIX@_PROPERTY_NAME}_${_@PACKAGE_PREFIX@_CONFIG})
  141. if (_@PACKAGE_PREFIX@_PROPERTY_VALUE)
  142. set_target_properties(${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ PROPERTIES
  143. IMPORTED_${_@PACKAGE_PREFIX@_PROPERTY_NAME}_${_@PACKAGE_PREFIX@_CONFIG} "${_@PACKAGE_PREFIX@_PROPERTY_VALUE}"
  144. )
  145. endif ()
  146. endforeach ()
  147. endforeach ()
  148. unset (_@PACKAGE_PREFIX@_CONFIGURATIONS)
  149. unset (_@PACKAGE_PREFIX@_CONFIG)
  150. unset (_@PACKAGE_PREFIX@_PROPERTY_NAME)
  151. unset (_@PACKAGE_PREFIX@_PROPERTY_VALUE)
  152. endif ()
  153. # alias for default import target to be compatible with older CMake package configurations
  154. set (@PACKAGE_PREFIX@_LIBRARIES "${@PACKAGE_PREFIX@_TARGET}")
  155. # set @PACKAGE_NAME@_* variables for backwards compatibility
  156. if (NOT "^@PACKAGE_NAME@$" STREQUAL "^@PACKAGE_PREFIX@$")
  157. foreach (_@PACKAGE_PREFIX@_VARIABLE IN ITEMS
  158. VERSION_STRING
  159. VERSION_MAJOR
  160. VERSION_MINOR
  161. VERSION_PATCH
  162. INCLUDE_DIR
  163. LIBRARIES
  164. TARGET
  165. )
  166. set (@PACKAGE_NAME@_${_@PACKAGE_PREFIX@_VARIABLE} "${@PACKAGE_PREFIX@_${_@PACKAGE_PREFIX@_VARIABLE}}")
  167. endforeach ()
  168. unset (_@PACKAGE_PREFIX@_VARIABLE)
  169. endif ()
  170. # unset private variables
  171. unset (@PACKAGE_NAME@_FIND_COMPONENT)
  172. unset (_INSTALL_PREFIX)