mirror of
https://github.com/gflags/gflags.git
synced 2025-04-05 05:25:04 +00:00
cmake: Change CMake package configuration variable name prefix to GFLAGS_
This commit is contained in:
parent
91e16eeff1
commit
2de6bf3904
1 changed files with 85 additions and 60 deletions
|
@ -1,10 +1,10 @@
|
|||
## gflags CMake configuration file
|
||||
|
||||
# library version information
|
||||
set (@PACKAGE_NAME@_VERSION_STRING "@PACKAGE_VERSION@")
|
||||
set (@PACKAGE_NAME@_VERSION_MAJOR @PACKAGE_VERSION_MAJOR@)
|
||||
set (@PACKAGE_NAME@_VERSION_MINOR @PACKAGE_VERSION_MINOR@)
|
||||
set (@PACKAGE_NAME@_VERSION_PATCH @PACKAGE_VERSION_PATCH@)
|
||||
set (@PACKAGE_PREFIX@_VERSION_STRING "@PACKAGE_VERSION@")
|
||||
set (@PACKAGE_PREFIX@_VERSION_MAJOR @PACKAGE_VERSION_MAJOR@)
|
||||
set (@PACKAGE_PREFIX@_VERSION_MINOR @PACKAGE_VERSION_MINOR@)
|
||||
set (@PACKAGE_PREFIX@_VERSION_PATCH @PACKAGE_VERSION_PATCH@)
|
||||
|
||||
# import targets
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/@PACKAGE_NAME@-export.cmake")
|
||||
|
@ -18,94 +18,119 @@ get_filename_component (_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_PREF
|
|||
# Newer versions of CMake set the INTERFACE_INCLUDE_DIRECTORIES property
|
||||
# of the imported targets. It is hence not necessary to add this path
|
||||
# manually to the include search path for targets which link to gflags.
|
||||
set (@PACKAGE_NAME@_INCLUDE_DIR "${_INSTALL_PREFIX}/@INCLUDE_INSTALL_DIR@")
|
||||
set (@PACKAGE_PREFIX@_INCLUDE_DIR "${_INSTALL_PREFIX}/@INCLUDE_INSTALL_DIR@")
|
||||
|
||||
# default settings
|
||||
if (NOT DEFINED @PACKAGE_NAME@_SHARED)
|
||||
if (TARGET @PACKAGE_NAME@-static OR TARGET @PACKAGE_NAME@_nothreads-static)
|
||||
set (@PACKAGE_NAME@_SHARED FALSE)
|
||||
if (NOT DEFINED @PACKAGE_PREFIX@_SHARED)
|
||||
if (DEFINED @PACKAGE_NAME@_SHARED)
|
||||
set (@PACKAGE_PREFIX@_SHARED ${@PACKAGE_NAME@_SHARED})
|
||||
elseif (TARGET @PACKAGE_NAME@-static OR TARGET @PACKAGE_NAME@_nothreads-static)
|
||||
set (@PACKAGE_PREFIX@_SHARED FALSE)
|
||||
else ()
|
||||
set (@PACKAGE_NAME@_SHARED TRUE)
|
||||
set (@PACKAGE_PREFIX@_SHARED TRUE)
|
||||
endif ()
|
||||
endif ()
|
||||
if (NOT DEFINED @PACKAGE_NAME@_NOTHREADS)
|
||||
if (TARGET @PACKAGE_NAME@-static OR TARGET @PACKAGE_NAME@-shared)
|
||||
set (@PACKAGE_NAME@_NOTHREADS FALSE)
|
||||
if (NOT DEFINED @PACKAGE_PREFIX@_NOTHREADS)
|
||||
if (DEFINED @PACKAGE_NAME@_NOTHREADS)
|
||||
set (@PACKAGE_PREFIX@_NOTHREADS ${@PACKAGE_NAME@_NOTHREADS})
|
||||
elseif (TARGET @PACKAGE_NAME@-static OR TARGET @PACKAGE_NAME@-shared)
|
||||
set (@PACKAGE_PREFIX@_NOTHREADS FALSE)
|
||||
else ()
|
||||
set (@PACKAGE_NAME@_NOTHREADS TRUE)
|
||||
set (@PACKAGE_PREFIX@_NOTHREADS TRUE)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# choose imported library target
|
||||
if (NOT @PACKAGE_NAME@_TARGET)
|
||||
if (@PACKAGE_NAME@_SHARED)
|
||||
if (@PACKAGE_NAME@_NOTHREADS)
|
||||
set (@PACKAGE_NAME@_TARGET @PACKAGE_NAME@_nothreads-shared)
|
||||
if (NOT @PACKAGE_PREFIX@_TARGET)
|
||||
if (@PACKAGE_NAME@_TARGET)
|
||||
set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_NAME@_TARGET})
|
||||
elseif (@PACKAGE_PREFIX@_SHARED)
|
||||
if (@PACKAGE_PREFIX@_NOTHREADS)
|
||||
set (@PACKAGE_PREFIX@_TARGET @PACKAGE_NAME@_nothreads-shared)
|
||||
else ()
|
||||
set (@PACKAGE_NAME@_TARGET @PACKAGE_NAME@-shared)
|
||||
set (@PACKAGE_PREFIX@_TARGET @PACKAGE_NAME@-shared)
|
||||
endif ()
|
||||
else ()
|
||||
if (@PACKAGE_NAME@_NOTHREADS)
|
||||
set (@PACKAGE_NAME@_TARGET @PACKAGE_NAME@_nothreads-static)
|
||||
if (@PACKAGE_PREFIX@_NOTHREADS)
|
||||
set (@PACKAGE_PREFIX@_TARGET @PACKAGE_NAME@_nothreads-static)
|
||||
else ()
|
||||
set (@PACKAGE_NAME@_TARGET @PACKAGE_NAME@-static)
|
||||
set (@PACKAGE_PREFIX@_TARGET @PACKAGE_NAME@-static)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
if (NOT TARGET ${@PACKAGE_NAME@_TARGET})
|
||||
message (FATAL_ERROR "Your @PACKAGE_NAME@ installation does not contain a ${@PACKAGE_NAME@_TARGET} library target!"
|
||||
" Try a different combination of @PACKAGE_NAME@_SHARED and @PACKAGE_NAME@_NOTHREADS.")
|
||||
if (NOT TARGET ${@PACKAGE_PREFIX@_TARGET})
|
||||
message (FATAL_ERROR "Your @PACKAGE_NAME@ installation does not contain a ${@PACKAGE_PREFIX@_TARGET} library target!"
|
||||
" Try a different combination of @PACKAGE_PREFIX@_SHARED and @PACKAGE_PREFIX@_NOTHREADS.")
|
||||
endif ()
|
||||
|
||||
# add more convenient "@PACKAGE_NAME@" import target
|
||||
if (NOT TARGET @PACKAGE_NAME@)
|
||||
if (@PACKAGE_NAME@_SHARED)
|
||||
if (@PACKAGE_PREFIX@_SHARED)
|
||||
add_library (@PACKAGE_NAME@ SHARED IMPORTED)
|
||||
else ()
|
||||
add_library (@PACKAGE_NAME@ STATIC IMPORTED)
|
||||
endif ()
|
||||
# INTERFACE_INCLUDE_DIRECTORIES
|
||||
get_target_property (_@PACKAGE_NAME@_INCLUDES ${@PACKAGE_NAME@_TARGET} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if (_@PACKAGE_NAME@_INCLUDES)
|
||||
set_target_properties(@PACKAGE_NAME@ PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_@PACKAGE_NAME@_INCLUDES}"
|
||||
)
|
||||
endif ()
|
||||
unset (_@PACKAGE_NAME@_INCLUDES)
|
||||
# set configuration specific properties
|
||||
get_target_property (_@PACKAGE_NAME@_CONFIGURATIONS ${@PACKAGE_NAME@_TARGET} IMPORTED_CONFIGURATIONS)
|
||||
set_target_properties (@PACKAGE_NAME@ PROPERTIES IMPORTED_CONFIGURATIONS "${_@PACKAGE_NAME@_CONFIGURATIONS}")
|
||||
foreach (_@PACKAGE_NAME@_CONFIG IN LISTS _@PACKAGE_NAME@_CONFIGURATIONS)
|
||||
# IMPORTED_LOCATION_<config>
|
||||
get_target_property (_@PACKAGE_NAME@_LOCATION ${@PACKAGE_NAME@_TARGET} IMPORTED_LOCATION_${_@PACKAGE_NAME@_CONFIG})
|
||||
if (_@PACKAGE_NAME@_LOCATION)
|
||||
# copy INTERFACE_* properties
|
||||
foreach (_@PACKAGE_PREFIX@_PROPERTY_NAME IN ITEMS
|
||||
COMPILE_DEFINITIONS
|
||||
COMPILE_FEATURES
|
||||
COMPILE_OPTIONS
|
||||
INCLUDE_DIRECTORIES
|
||||
LINK_LIBRARIES
|
||||
POSITION_INDEPENDENT_CODE
|
||||
)
|
||||
get_target_property (_@PACKAGE_PREFIX@_PROPERTY_VALUE ${@PACKAGE_PREFIX@_TARGET} INTERFACE_${_@PACKAGE_PREFIX@_PROPERTY_NAME})
|
||||
if (_@PACKAGE_PREFIX@_PROPERTY_VALUE)
|
||||
set_target_properties(@PACKAGE_NAME@ PROPERTIES
|
||||
IMPORTED_LOCATION_${_@PACKAGE_NAME@_CONFIG} "${_@PACKAGE_NAME@_LOCATION}"
|
||||
INTERFACE_${_@PACKAGE_PREFIX@_PROPERTY_NAME} "${_@PACKAGE_PREFIX@_PROPERTY_VALUE}"
|
||||
)
|
||||
endif ()
|
||||
unset (_@PACKAGE_NAME@_LOCATION)
|
||||
# IMPORTED_LINK_INTERFACE_LANGUAGES_<config> (static)
|
||||
get_target_property (_@PACKAGE_NAME@_LANGUAGES ${@PACKAGE_NAME@_TARGET} IMPORTED_LINK_INTERFACE_LANGUAGES_${_@PACKAGE_NAME@_CONFIG})
|
||||
if (_@PACKAGE_NAME@_LANGUAGES)
|
||||
set_target_properties(@PACKAGE_NAME@ PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_${_@PACKAGE_NAME@_CONFIG} "${_@PACKAGE_NAME@_LANGUAGES}"
|
||||
)
|
||||
endif ()
|
||||
unset (_@PACKAGE_NAME@_LANGUAGES)
|
||||
# IMPORTED_SONAME_<config> (shared)
|
||||
get_target_property (_@PACKAGE_NAME@_SONAME ${@PACKAGE_NAME@_TARGET} IMPORTED_SONAME_${_@PACKAGE_NAME@_CONFIG})
|
||||
if (_@PACKAGE_NAME@_SONAME)
|
||||
set_target_properties(@PACKAGE_NAME@ PROPERTIES
|
||||
IMPORTED_SONAME_${_@PACKAGE_NAME@_CONFIG} "${_@PACKAGE_NAME@_SONAME}"
|
||||
)
|
||||
endif ()
|
||||
unset (_@PACKAGE_NAME@_SONAME)
|
||||
endforeach ()
|
||||
unset (_@PACKAGE_NAME@_CONFIGURATIONS)
|
||||
# copy IMPORTED_*_<CONFIG> properties
|
||||
get_target_property (_@PACKAGE_PREFIX@_CONFIGURATIONS ${@PACKAGE_PREFIX@_TARGET} IMPORTED_CONFIGURATIONS)
|
||||
set_target_properties (@PACKAGE_NAME@ PROPERTIES IMPORTED_CONFIGURATIONS "${_@PACKAGE_PREFIX@_CONFIGURATIONS}")
|
||||
foreach (_@PACKAGE_PREFIX@_PROPERTY_NAME IN ITEMS
|
||||
LOCATION
|
||||
LINK_DEPENDENT_LIBRARIES
|
||||
LINK_INTERFACE_LIBRARIES
|
||||
LINK_INTERFACE_LANGUAGES
|
||||
LINK_INTERFACE_MULTIPLICITY
|
||||
NO_SONAME
|
||||
SONAME
|
||||
)
|
||||
foreach (_@PACKAGE_PREFIX@_CONFIG IN LISTS _@PACKAGE_PREFIX@_CONFIGURATIONS)
|
||||
get_target_property (_@PACKAGE_PREFIX@_PROPERTY_VALUE ${@PACKAGE_PREFIX@_TARGET} IMPORTED_${_@PACKAGE_PREFIX@_PROPERTY_NAME}_${_@PACKAGE_PREFIX@_CONFIG})
|
||||
if (_@PACKAGE_PREFIX@_PROPERTY_VALUE)
|
||||
set_target_properties(@PACKAGE_NAME@ PROPERTIES
|
||||
IMPORTED_${_@PACKAGE_PREFIX@_PROPERTY_NAME}_${_@PACKAGE_PREFIX@_CONFIG} "${_@PACKAGE_PREFIX@_PROPERTY_VALUE}"
|
||||
)
|
||||
endif ()
|
||||
endforeach ()
|
||||
endforeach ()
|
||||
unset (_@PACKAGE_PREFIX@_CONFIGURATIONS)
|
||||
unset (_@PACKAGE_PREFIX@_CONFIG)
|
||||
unset (_@PACKAGE_PREFIX@_PROPERTY_NAME)
|
||||
unset (_@PACKAGE_PREFIX@_PROPERTY_VALUE)
|
||||
endif ()
|
||||
|
||||
# alias for default import target to be compatible with older CMake package configurations
|
||||
set (@PACKAGE_NAME@_LIBRARIES "${@PACKAGE_NAME@_TARGET}")
|
||||
set (@PACKAGE_PREFIX@_LIBRARIES "${@PACKAGE_PREFIX@_TARGET}")
|
||||
|
||||
# set @PACKAGE_NAME@_* variables for backwards compatibility
|
||||
if (NOT "^@PACKAGE_NAME@$" STREQUAL "^@PACKAGE_PREFIX@$")
|
||||
foreach (_@PACKAGE_PREFIX@_VARIABLE IN ITEMS
|
||||
VERSION_STRING
|
||||
VERSION_MAJOR
|
||||
VERSION_MINOR
|
||||
VERSION_PATCH
|
||||
INCLUDE_DIR
|
||||
LIBRARIES
|
||||
TARGET
|
||||
)
|
||||
set (@PACKAGE_NAME@_${_@PACKAGE_PREFIX@_VARIABLE} "${@PACKAGE_PREFIX@_${_@PACKAGE_PREFIX@_VARIABLE}}")
|
||||
endforeach ()
|
||||
unset (_@PACKAGE_PREFIX@_VARIABLE)
|
||||
endif ()
|
||||
|
||||
# unset private variables
|
||||
unset (_INSTALL_PREFIX)
|
||||
|
|
Loading…
Add table
Reference in a new issue