Unverified Commit d4a050d1 authored by Andreas Schuh's avatar Andreas Schuh Committed by GitHub

Merge pull request #247 from Mizux/master

parents 48677f93 f7228d77
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
## ##
## When this project is a subproject (GFLAGS_IS_SUBPROJECT is TRUE), the default ## When this project is a subproject (GFLAGS_IS_SUBPROJECT is TRUE), the default
## settings are such that only the static single-threaded library is built without ## settings are such that only the static single-threaded library is built without
## installation of the gflags files. The "gflags" target is in this case an ALIAS ## installation of the gflags files. The "gflags::gflags" target is in this case an ALIAS
## library target for the "gflags_nothreads_static" library target. Targets which ## library target for the "gflags_nothreads_static" library target. Targets which
## depend on the gflags library should link to the "gflags" library target. ## depend on the gflags library should link to the "gflags::gflags" library target.
## ##
## Example CMakeLists.txt of user project which requires separate gflags installation: ## Example CMakeLists.txt of user project which requires separate gflags installation:
## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) ## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
## find_package(gflags REQUIRED) ## find_package(gflags REQUIRED)
## ##
## add_executable(foo src/foo.cc) ## add_executable(foo src/foo.cc)
## target_link_libraries(foo gflags) ## target_link_libraries(foo gflags::gflags)
## ##
## Example CMakeLists.txt of user project which requires separate single-threaded static gflags installation: ## Example CMakeLists.txt of user project which requires separate single-threaded static gflags installation:
## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) ## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
## find_package(gflags COMPONENTS nothreads_static) ## find_package(gflags COMPONENTS nothreads_static)
## ##
## add_executable(foo src/foo.cc) ## add_executable(foo src/foo.cc)
## target_link_libraries(foo gflags) ## target_link_libraries(foo gflags::gflags)
## ##
## Example CMakeLists.txt of super-project which contains gflags source tree: ## Example CMakeLists.txt of super-project which contains gflags source tree:
## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) ## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
## add_subdirectory(gflags) ## add_subdirectory(gflags)
## ##
## add_executable(foo src/foo.cc) ## add_executable(foo src/foo.cc)
## target_link_libraries(foo gflags) ## target_link_libraries(foo gflags::gflags)
## ##
## Variables to configure the source files: ## Variables to configure the source files:
## - GFLAGS_IS_A_DLL ## - GFLAGS_IS_A_DLL
...@@ -70,12 +70,16 @@ ...@@ -70,12 +70,16 @@
## - GFLAGS_INSTALL_SHARED_LIBS ## - GFLAGS_INSTALL_SHARED_LIBS
## - GFLAGS_INSTALL_STATIC_LIBS ## - GFLAGS_INSTALL_STATIC_LIBS
cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) cmake_minimum_required (VERSION 3.0.2 FATAL_ERROR)
if (POLICY CMP0042) if (POLICY CMP0042)
cmake_policy (SET CMP0042 NEW) cmake_policy (SET CMP0042 NEW)
endif () endif ()
if (POLICY CMP0048)
cmake_policy (SET CMP0048 NEW)
endif ()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# includes # includes
include ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils.cmake") include ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils.cmake")
...@@ -90,7 +94,7 @@ set (PACKAGE_BUGREPORT "https://github.com/gflags/gflags/issues") ...@@ -90,7 +94,7 @@ set (PACKAGE_BUGREPORT "https://github.com/gflags/gflags/issues")
set (PACKAGE_DESCRIPTION "A commandline flags library that allows for distributed flags.") set (PACKAGE_DESCRIPTION "A commandline flags library that allows for distributed flags.")
set (PACKAGE_URL "http://gflags.github.io/gflags") set (PACKAGE_URL "http://gflags.github.io/gflags")
project (${PACKAGE_NAME} CXX) project (${PACKAGE_NAME} VERSION ${PACKAGE_VERSION} LANGUAGES CXX)
if (CMAKE_VERSION VERSION_LESS 3.4) if (CMAKE_VERSION VERSION_LESS 3.4)
# C language still needed because the following required CMake modules # C language still needed because the following required CMake modules
# (or their dependencies, respectively) are not correctly handling # (or their dependencies, respectively) are not correctly handling
...@@ -494,11 +498,11 @@ if (GFLAGS_IS_SUBPROJECT) ...@@ -494,11 +498,11 @@ if (GFLAGS_IS_SUBPROJECT)
foreach (type IN ITEMS static shared) foreach (type IN ITEMS static shared)
foreach (opts IN ITEMS "_nothreads" "") foreach (opts IN ITEMS "_nothreads" "")
if (TARGET gflags${opts}_${type}) if (TARGET gflags${opts}_${type})
add_library (gflags ALIAS gflags${opts}_${type}) add_library (gflags::gflags ALIAS gflags${opts}_${type})
break () break ()
endif () endif ()
endforeach () endforeach ()
if (TARGET gflags) if (TARGET gflags::gflags)
break () break ()
endif () endif ()
endforeach () endforeach ()
...@@ -545,7 +549,11 @@ if (INSTALL_HEADERS) ...@@ -545,7 +549,11 @@ if (INSTALL_HEADERS)
FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake" FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake"
DESTINATION ${CONFIG_INSTALL_DIR} DESTINATION ${CONFIG_INSTALL_DIR}
) )
install (EXPORT ${EXPORT_NAME} DESTINATION ${CONFIG_INSTALL_DIR}) install (
EXPORT ${EXPORT_NAME}
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})
endif () endif ()
...@@ -559,7 +567,10 @@ endif () ...@@ -559,7 +567,10 @@ endif ()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# support direct use of build tree # support direct use of build tree
set (INSTALL_PREFIX_REL2CONFIG_DIR .) set (INSTALL_PREFIX_REL2CONFIG_DIR .)
export (TARGETS ${TARGETS} FILE "${PROJECT_BINARY_DIR}/${EXPORT_NAME}.cmake") export (
TARGETS ${TARGETS}
NAMESPACE gflags::
FILE "${PROJECT_BINARY_DIR}/${EXPORT_NAME}.cmake")
if (REGISTER_BUILD_DIR) if (REGISTER_BUILD_DIR)
export (PACKAGE ${PACKAGE_NAME}) export (PACKAGE ${PACKAGE_NAME})
endif () endif ()
...@@ -572,7 +583,6 @@ configure_file (cmake/config.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-con ...@@ -572,7 +583,6 @@ configure_file (cmake/config.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-con
# testing - MUST follow the generation of the build tree config file # testing - MUST follow the generation of the build tree config file
if (BUILD_TESTING) if (BUILD_TESTING)
include (CTest) include (CTest)
enable_testing ()
add_subdirectory (test) add_subdirectory (test)
endif () endif ()
......
...@@ -49,7 +49,7 @@ if (NOT DEFINED @PACKAGE_PREFIX@_SHARED) ...@@ -49,7 +49,7 @@ if (NOT DEFINED @PACKAGE_PREFIX@_SHARED)
else () else ()
set (@PACKAGE_PREFIX@_SHARED FALSE) set (@PACKAGE_PREFIX@_SHARED FALSE)
endif () endif ()
elseif (TARGET @PACKAGE_NAME@_shared OR TARGET @PACKAGE_NAME@_nothreads_shared) elseif (TARGET gflags::@PACKAGE_NAME@_shared OR TARGET gflags::@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 +64,7 @@ if (NOT DEFINED @PACKAGE_PREFIX@_NOTHREADS) ...@@ -64,7 +64,7 @@ if (NOT DEFINED @PACKAGE_PREFIX@_NOTHREADS)
else () else ()
set (@PACKAGE_PREFIX@_NOTHREADS FALSE) set (@PACKAGE_PREFIX@_NOTHREADS FALSE)
endif () endif ()
elseif (TARGET @PACKAGE_NAME@_static OR TARGET @PACKAGE_NAME@_shared) elseif (TARGET gflags::@PACKAGE_NAME@_static OR TARGET gflags::@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 +77,15 @@ if (NOT @PACKAGE_PREFIX@_TARGET) ...@@ -77,15 +77,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 @PACKAGE_NAME@_nothreads_shared) set (@PACKAGE_PREFIX@_TARGET gflags::@PACKAGE_NAME@_nothreads_shared)
else () else ()
set (@PACKAGE_PREFIX@_TARGET @PACKAGE_NAME@_shared) set (@PACKAGE_PREFIX@_TARGET gflags::@PACKAGE_NAME@_shared)
endif () endif ()
else () else ()
if (@PACKAGE_PREFIX@_NOTHREADS) if (@PACKAGE_PREFIX@_NOTHREADS)
set (@PACKAGE_PREFIX@_TARGET @PACKAGE_NAME@_nothreads_static) set (@PACKAGE_PREFIX@_TARGET gflags::@PACKAGE_NAME@_nothreads_static)
else () else ()
set (@PACKAGE_PREFIX@_TARGET @PACKAGE_NAME@_static) set (@PACKAGE_PREFIX@_TARGET gflags::@PACKAGE_NAME@_static)
endif () endif ()
endif () endif ()
endif () endif ()
...@@ -94,12 +94,12 @@ if (NOT TARGET ${@PACKAGE_PREFIX@_TARGET}) ...@@ -94,12 +94,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 "@PACKAGE_NAME@" import target # add more convenient "gflags::@PACKAGE_NAME@" import target
if (NOT TARGET @PACKAGE_NAME@) if (NOT TARGET gflags::@PACKAGE_NAME@)
if (@PACKAGE_PREFIX@_SHARED) if (@PACKAGE_PREFIX@_SHARED)
add_library (@PACKAGE_NAME@ SHARED IMPORTED) add_library (gflags::@PACKAGE_NAME@ SHARED IMPORTED)
else () else ()
add_library (@PACKAGE_NAME@ STATIC IMPORTED) add_library (gflags::@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,20 +112,20 @@ if (NOT TARGET @PACKAGE_NAME@) ...@@ -112,20 +112,20 @@ if (NOT TARGET @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(@PACKAGE_NAME@ PROPERTIES set_target_properties(gflags::@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 (@PACKAGE_NAME@ PROPERTIES IMPORTED_CONFIGURATIONS "${_@PACKAGE_PREFIX@_CONFIGURATIONS}") set_target_properties (gflags::@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
LINK_DEPENDENT_LIBRARIES LINK_DEPENDENT_LIBRARIES
LINK_INTERFACE_LIBRARIES LINK_INTERFACE_LIBRARIES
LINK_INTERFACE_LANGUAGES LINK_INTERFACE_LANGUAGES
LINK_INTERFACE_MULTIPLICITY LINK_INTERFACE_MULTIPLICITY
NO_SONAME NO_SONAME
SONAME SONAME
...@@ -133,7 +133,7 @@ if (NOT TARGET @PACKAGE_NAME@) ...@@ -133,7 +133,7 @@ if (NOT TARGET @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(@PACKAGE_NAME@ PROPERTIES set_target_properties(gflags::@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 ()
......
...@@ -7,4 +7,4 @@ project (gflags_${TEST_NAME}) ...@@ -7,4 +7,4 @@ project (gflags_${TEST_NAME})
find_package (gflags REQUIRED) find_package (gflags REQUIRED)
add_executable (foo main.cc) add_executable (foo main.cc)
target_link_libraries (foo gflags) target_link_libraries (foo gflags::gflags)
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