Commit f1ea012a authored by Andreas Schuh's avatar Andreas Schuh

fix: Import with or without gflags:: namespace

parent b0c4cd29
...@@ -526,7 +526,8 @@ if (BUILD_SHARED_LIBS AND INSTALL_SHARED_LIBS) ...@@ -526,7 +526,8 @@ if (BUILD_SHARED_LIBS AND INSTALL_SHARED_LIBS)
EXPORT ${EXPORT_NAME} EXPORT ${EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR} LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}) ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}
)
endif () endif ()
endforeach () endforeach ()
endif () endif ()
...@@ -537,7 +538,8 @@ if (BUILD_STATIC_LIBS AND INSTALL_STATIC_LIBS) ...@@ -537,7 +538,8 @@ if (BUILD_STATIC_LIBS AND INSTALL_STATIC_LIBS)
EXPORT ${EXPORT_NAME} EXPORT ${EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR} LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}) ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}
)
endif () endif ()
endforeach () endforeach ()
endif () endif ()
...@@ -555,8 +557,13 @@ if (INSTALL_HEADERS) ...@@ -555,8 +557,13 @@ if (INSTALL_HEADERS)
) )
install ( install (
EXPORT ${EXPORT_NAME} EXPORT ${EXPORT_NAME}
NAMESPACE ${PACKAGE_NAME}::
DESTINATION ${CONFIG_INSTALL_DIR}
)
install (
EXPORT ${EXPORT_NAME}
FILE ${EXPORT_NAME}-nonamespace.cmake
DESTINATION ${CONFIG_INSTALL_DIR} DESTINATION ${CONFIG_INSTALL_DIR}
NAMESPACE gflags::
) )
if (UNIX) if (UNIX)
install (PROGRAMS src/gflags_completions.sh DESTINATION ${RUNTIME_INSTALL_DIR}) install (PROGRAMS src/gflags_completions.sh DESTINATION ${RUNTIME_INSTALL_DIR})
...@@ -573,8 +580,13 @@ endif () ...@@ -573,8 +580,13 @@ endif ()
set (INSTALL_PREFIX_REL2CONFIG_DIR .) set (INSTALL_PREFIX_REL2CONFIG_DIR .)
export ( export (
TARGETS ${TARGETS} TARGETS ${TARGETS}
NAMESPACE gflags:: NAMESPACE ${PACKAGE_NAME}::
FILE "${PROJECT_BINARY_DIR}/${EXPORT_NAME}.cmake") FILE "${PROJECT_BINARY_DIR}/${EXPORT_NAME}.cmake"
)
export (
TARGETS ${TARGETS}
FILE "${PROJECT_BINARY_DIR}/${EXPORT_NAME}-nonamespace.cmake"
)
if (REGISTER_BUILD_DIR) if (REGISTER_BUILD_DIR)
export (PACKAGE ${PACKAGE_NAME}) export (PACKAGE ${PACKAGE_NAME})
endif () endif ()
...@@ -606,7 +618,8 @@ if (BUILD_PACKAGING) ...@@ -606,7 +618,8 @@ if (BUILD_PACKAGING)
"\n BUILD_STATIC_LIBS=ON" "\n BUILD_STATIC_LIBS=ON"
"\n INSTALL_HEADERS=ON" "\n INSTALL_HEADERS=ON"
"\n INSTALL_SHARED_LIBS=ON" "\n INSTALL_SHARED_LIBS=ON"
"\n INSTALL_STATIC_LIBS=ON") "\n INSTALL_STATIC_LIBS=ON"
)
endif () endif ()
# default package generators # default package generators
......
...@@ -7,7 +7,21 @@ set (@PACKAGE_PREFIX@_VERSION_MINOR @PACKAGE_VERSION_MINOR@) ...@@ -7,7 +7,21 @@ set (@PACKAGE_PREFIX@_VERSION_MINOR @PACKAGE_VERSION_MINOR@)
set (@PACKAGE_PREFIX@_VERSION_PATCH @PACKAGE_VERSION_PATCH@) set (@PACKAGE_PREFIX@_VERSION_PATCH @PACKAGE_VERSION_PATCH@)
# import targets # import targets
include ("${CMAKE_CURRENT_LIST_DIR}/@EXPORT_NAME@.cmake") if (NOT DEFINED @PACKAGE_PREFIX@_USE_TARGET_NAMESPACE)
set (@PACKAGE_PREFIX@_USE_TARGET_NAMESPACE FALSE)
endif ()
if (@PACKAGE_PREFIX@_USE_TARGET_NAMESPACE)
include ("${CMAKE_CURRENT_LIST_DIR}/@EXPORT_NAME@.cmake")
set (@PACKAGE_PREFIX@_TARGET_NAMESPACE @PACKAGE_NAME@)
else ()
include ("${CMAKE_CURRENT_LIST_DIR}/@EXPORT_NAME@-nonamespace.cmake")
set (@PACKAGE_PREFIX@_TARGET_NAMESPACE)
endif ()
if (@PACKAGE_PREFIX@_TARGET_NAMESPACE)
set (@PACKAGE_PREFIX@_TARGET_PREFIX ${@PACKAGE_PREFIX@_TARGET_NAMESPACE}::)
else ()
set (@PACKAGE_PREFIX@_TARGET_PREFIX)
endif ()
# installation prefix # installation prefix
get_filename_component (CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) get_filename_component (CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
...@@ -49,7 +63,7 @@ if (NOT DEFINED @PACKAGE_PREFIX@_SHARED) ...@@ -49,7 +63,7 @@ if (NOT DEFINED @PACKAGE_PREFIX@_SHARED)
else () else ()
set (@PACKAGE_PREFIX@_SHARED FALSE) set (@PACKAGE_PREFIX@_SHARED FALSE)
endif () endif ()
elseif (TARGET gflags::@PACKAGE_NAME@_shared OR TARGET gflags::@PACKAGE_NAME@_nothreads_shared) elseif (TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_shared OR TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_nothreads_shared)
set (@PACKAGE_PREFIX@_SHARED TRUE) set (@PACKAGE_PREFIX@_SHARED TRUE)
else () else ()
set (@PACKAGE_PREFIX@_SHARED FALSE) set (@PACKAGE_PREFIX@_SHARED FALSE)
...@@ -64,7 +78,7 @@ if (NOT DEFINED @PACKAGE_PREFIX@_NOTHREADS) ...@@ -64,7 +78,7 @@ if (NOT DEFINED @PACKAGE_PREFIX@_NOTHREADS)
else () else ()
set (@PACKAGE_PREFIX@_NOTHREADS FALSE) set (@PACKAGE_PREFIX@_NOTHREADS FALSE)
endif () endif ()
elseif (TARGET gflags::@PACKAGE_NAME@_static OR TARGET gflags::@PACKAGE_NAME@_shared) elseif (TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}PACKAGE_NAME@_static OR TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_shared)
set (@PACKAGE_PREFIX@_NOTHREADS FALSE) set (@PACKAGE_PREFIX@_NOTHREADS FALSE)
else () else ()
set (@PACKAGE_PREFIX@_NOTHREADS TRUE) set (@PACKAGE_PREFIX@_NOTHREADS TRUE)
...@@ -77,15 +91,15 @@ if (NOT @PACKAGE_PREFIX@_TARGET) ...@@ -77,15 +91,15 @@ if (NOT @PACKAGE_PREFIX@_TARGET)
set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_NAME@_TARGET}) set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_NAME@_TARGET})
elseif (@PACKAGE_PREFIX@_SHARED) elseif (@PACKAGE_PREFIX@_SHARED)
if (@PACKAGE_PREFIX@_NOTHREADS) if (@PACKAGE_PREFIX@_NOTHREADS)
set (@PACKAGE_PREFIX@_TARGET gflags::@PACKAGE_NAME@_nothreads_shared) set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_nothreads_shared)
else () else ()
set (@PACKAGE_PREFIX@_TARGET gflags::@PACKAGE_NAME@_shared) set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_shared)
endif () endif ()
else () else ()
if (@PACKAGE_PREFIX@_NOTHREADS) if (@PACKAGE_PREFIX@_NOTHREADS)
set (@PACKAGE_PREFIX@_TARGET gflags::@PACKAGE_NAME@_nothreads_static) set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_nothreads_static)
else () else ()
set (@PACKAGE_PREFIX@_TARGET gflags::@PACKAGE_NAME@_static) set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_static)
endif () endif ()
endif () endif ()
endif () endif ()
...@@ -94,12 +108,12 @@ if (NOT TARGET ${@PACKAGE_PREFIX@_TARGET}) ...@@ -94,12 +108,12 @@ if (NOT TARGET ${@PACKAGE_PREFIX@_TARGET})
" Try a different combination of @PACKAGE_PREFIX@_SHARED and @PACKAGE_PREFIX@_NOTHREADS.") " Try a different combination of @PACKAGE_PREFIX@_SHARED and @PACKAGE_PREFIX@_NOTHREADS.")
endif () endif ()
# add more convenient "gflags::@PACKAGE_NAME@" import target # add more convenient "${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@" import target
if (NOT TARGET gflags::@PACKAGE_NAME@) if (NOT TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@)
if (@PACKAGE_PREFIX@_SHARED) if (@PACKAGE_PREFIX@_SHARED)
add_library (gflags::@PACKAGE_NAME@ SHARED IMPORTED) add_library (${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ SHARED IMPORTED)
else () else ()
add_library (gflags::@PACKAGE_NAME@ STATIC IMPORTED) add_library (${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ STATIC IMPORTED)
endif () endif ()
# copy INTERFACE_* properties # copy INTERFACE_* properties
foreach (_@PACKAGE_PREFIX@_PROPERTY_NAME IN ITEMS foreach (_@PACKAGE_PREFIX@_PROPERTY_NAME IN ITEMS
...@@ -112,14 +126,14 @@ if (NOT TARGET gflags::@PACKAGE_NAME@) ...@@ -112,14 +126,14 @@ if (NOT TARGET gflags::@PACKAGE_NAME@)
) )
get_target_property (_@PACKAGE_PREFIX@_PROPERTY_VALUE ${@PACKAGE_PREFIX@_TARGET} INTERFACE_${_@PACKAGE_PREFIX@_PROPERTY_NAME}) get_target_property (_@PACKAGE_PREFIX@_PROPERTY_VALUE ${@PACKAGE_PREFIX@_TARGET} INTERFACE_${_@PACKAGE_PREFIX@_PROPERTY_NAME})
if (_@PACKAGE_PREFIX@_PROPERTY_VALUE) if (_@PACKAGE_PREFIX@_PROPERTY_VALUE)
set_target_properties(gflags::@PACKAGE_NAME@ PROPERTIES set_target_properties(${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ PROPERTIES
INTERFACE_${_@PACKAGE_PREFIX@_PROPERTY_NAME} "${_@PACKAGE_PREFIX@_PROPERTY_VALUE}" INTERFACE_${_@PACKAGE_PREFIX@_PROPERTY_NAME} "${_@PACKAGE_PREFIX@_PROPERTY_VALUE}"
) )
endif () endif ()
endforeach () endforeach ()
# copy IMPORTED_*_<CONFIG> properties # copy IMPORTED_*_<CONFIG> properties
get_target_property (_@PACKAGE_PREFIX@_CONFIGURATIONS ${@PACKAGE_PREFIX@_TARGET} IMPORTED_CONFIGURATIONS) get_target_property (_@PACKAGE_PREFIX@_CONFIGURATIONS ${@PACKAGE_PREFIX@_TARGET} IMPORTED_CONFIGURATIONS)
set_target_properties (gflags::@PACKAGE_NAME@ PROPERTIES IMPORTED_CONFIGURATIONS "${_@PACKAGE_PREFIX@_CONFIGURATIONS}") set_target_properties (${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ PROPERTIES IMPORTED_CONFIGURATIONS "${_@PACKAGE_PREFIX@_CONFIGURATIONS}")
foreach (_@PACKAGE_PREFIX@_PROPERTY_NAME IN ITEMS foreach (_@PACKAGE_PREFIX@_PROPERTY_NAME IN ITEMS
IMPLIB IMPLIB
LOCATION LOCATION
...@@ -133,7 +147,7 @@ if (NOT TARGET gflags::@PACKAGE_NAME@) ...@@ -133,7 +147,7 @@ if (NOT TARGET gflags::@PACKAGE_NAME@)
foreach (_@PACKAGE_PREFIX@_CONFIG IN LISTS _@PACKAGE_PREFIX@_CONFIGURATIONS) 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}) get_target_property (_@PACKAGE_PREFIX@_PROPERTY_VALUE ${@PACKAGE_PREFIX@_TARGET} IMPORTED_${_@PACKAGE_PREFIX@_PROPERTY_NAME}_${_@PACKAGE_PREFIX@_CONFIG})
if (_@PACKAGE_PREFIX@_PROPERTY_VALUE) if (_@PACKAGE_PREFIX@_PROPERTY_VALUE)
set_target_properties(gflags::@PACKAGE_NAME@ PROPERTIES set_target_properties(${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ PROPERTIES
IMPORTED_${_@PACKAGE_PREFIX@_PROPERTY_NAME}_${_@PACKAGE_PREFIX@_CONFIG} "${_@PACKAGE_PREFIX@_PROPERTY_VALUE}" IMPORTED_${_@PACKAGE_PREFIX@_PROPERTY_NAME}_${_@PACKAGE_PREFIX@_CONFIG} "${_@PACKAGE_PREFIX@_PROPERTY_VALUE}"
) )
endif () endif ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment