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