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)
EXPORT ${EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR})
ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}
)
endif ()
endforeach ()
endif ()
......@@ -537,7 +538,8 @@ if (BUILD_STATIC_LIBS AND INSTALL_STATIC_LIBS)
EXPORT ${EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR})
ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}
)
endif ()
endforeach ()
endif ()
......@@ -555,8 +557,13 @@ if (INSTALL_HEADERS)
)
install (
EXPORT ${EXPORT_NAME}
NAMESPACE ${PACKAGE_NAME}::
DESTINATION ${CONFIG_INSTALL_DIR}
)
install (
EXPORT ${EXPORT_NAME}
FILE ${EXPORT_NAME}-nonamespace.cmake
DESTINATION ${CONFIG_INSTALL_DIR}
NAMESPACE gflags::
)
if (UNIX)
install (PROGRAMS src/gflags_completions.sh DESTINATION ${RUNTIME_INSTALL_DIR})
......@@ -573,8 +580,13 @@ endif ()
set (INSTALL_PREFIX_REL2CONFIG_DIR .)
export (
TARGETS ${TARGETS}
NAMESPACE gflags::
FILE "${PROJECT_BINARY_DIR}/${EXPORT_NAME}.cmake")
NAMESPACE ${PACKAGE_NAME}::
FILE "${PROJECT_BINARY_DIR}/${EXPORT_NAME}.cmake"
)
export (
TARGETS ${TARGETS}
FILE "${PROJECT_BINARY_DIR}/${EXPORT_NAME}-nonamespace.cmake"
)
if (REGISTER_BUILD_DIR)
export (PACKAGE ${PACKAGE_NAME})
endif ()
......@@ -606,7 +618,8 @@ if (BUILD_PACKAGING)
"\n BUILD_STATIC_LIBS=ON"
"\n INSTALL_HEADERS=ON"
"\n INSTALL_SHARED_LIBS=ON"
"\n INSTALL_STATIC_LIBS=ON")
"\n INSTALL_STATIC_LIBS=ON"
)
endif ()
# default package generators
......
......@@ -7,7 +7,21 @@ set (@PACKAGE_PREFIX@_VERSION_MINOR @PACKAGE_VERSION_MINOR@)
set (@PACKAGE_PREFIX@_VERSION_PATCH @PACKAGE_VERSION_PATCH@)
# 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
get_filename_component (CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
......@@ -49,7 +63,7 @@ if (NOT DEFINED @PACKAGE_PREFIX@_SHARED)
else ()
set (@PACKAGE_PREFIX@_SHARED FALSE)
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)
else ()
set (@PACKAGE_PREFIX@_SHARED FALSE)
......@@ -64,7 +78,7 @@ if (NOT DEFINED @PACKAGE_PREFIX@_NOTHREADS)
else ()
set (@PACKAGE_PREFIX@_NOTHREADS FALSE)
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)
else ()
set (@PACKAGE_PREFIX@_NOTHREADS TRUE)
......@@ -77,15 +91,15 @@ if (NOT @PACKAGE_PREFIX@_TARGET)
set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_NAME@_TARGET})
elseif (@PACKAGE_PREFIX@_SHARED)
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 ()
set (@PACKAGE_PREFIX@_TARGET gflags::@PACKAGE_NAME@_shared)
set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_shared)
endif ()
else ()
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 ()
set (@PACKAGE_PREFIX@_TARGET gflags::@PACKAGE_NAME@_static)
set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_static)
endif ()
endif ()
endif ()
......@@ -94,12 +108,12 @@ if (NOT TARGET ${@PACKAGE_PREFIX@_TARGET})
" Try a different combination of @PACKAGE_PREFIX@_SHARED and @PACKAGE_PREFIX@_NOTHREADS.")
endif ()
# add more convenient "gflags::@PACKAGE_NAME@" import target
if (NOT TARGET gflags::@PACKAGE_NAME@)
# add more convenient "${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@" import target
if (NOT TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@)
if (@PACKAGE_PREFIX@_SHARED)
add_library (gflags::@PACKAGE_NAME@ SHARED IMPORTED)
add_library (${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ SHARED IMPORTED)
else ()
add_library (gflags::@PACKAGE_NAME@ STATIC IMPORTED)
add_library (${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ STATIC IMPORTED)
endif ()
# copy INTERFACE_* properties
foreach (_@PACKAGE_PREFIX@_PROPERTY_NAME IN ITEMS
......@@ -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})
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}"
)
endif ()
endforeach ()
# copy IMPORTED_*_<CONFIG> properties
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
IMPLIB
LOCATION
......@@ -133,7 +147,7 @@ if (NOT TARGET gflags::@PACKAGE_NAME@)
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(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}"
)
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