From bbe1895559c61ea72faeabf1f083e0cb16bc3a6b Mon Sep 17 00:00:00 2001 From: Andreas Schuh Date: Sat, 22 Mar 2014 01:00:11 +0000 Subject: [PATCH 1/3] Remove devel package content summary from README --- README.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.txt b/README.txt index b5ecbbb..958c87e 100644 --- a/README.txt +++ b/README.txt @@ -2,5 +2,3 @@ This package contains a library that implements commandline flags processing. As such it's a replacement for getopt(). It has increased flexibility, including built-in support for C++ types like string, and the ability to define flags in the source file in which they're used. -The devel package contains static and debug libraries and header files -for developing applications that use the gflags package. From 38c4402f58ada036f4609ade095b9fb0ae3276e2 Mon Sep 17 00:00:00 2001 From: Andreas Schuh Date: Tue, 25 Mar 2014 15:29:56 +0000 Subject: [PATCH 2/3] Use GFLAGS_IS_A_DLL=1 in public headers if BUILD_SHARED_LIBS is enabled (Fixes issue #77). --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93d3a73..7ada98c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,6 +197,15 @@ else () set (GFLAGS_ATTRIBUTE_UNUSED) endif () +# whenever we build a shared library (DLL on Windows), configure the public +# headers of the API for use of this library rather than the optionally +# also build statically linked library; users can override GFLAGS_DLL_DECL +if (BUILD_SHARED_LIBS) + set (GFLAGS_IS_A_DLL 1) +else () + set (GFLAGS_IS_A_DLL 0) +endif () + configure_headers (PUBLIC_HDRS ${PUBLIC_HDRS}) configure_sources (PRIVATE_HDRS ${PRIVATE_HDRS}) configure_sources (GFLAGS_SRCS ${GFLAGS_SRCS}) From 0c6e5fdb3f94da4e26ab5212a0e6b01739ecc999 Mon Sep 17 00:00:00 2001 From: Andreas Schuh Date: Thu, 27 Mar 2014 01:09:20 +0000 Subject: [PATCH 3/3] Add GFLAGS_INCLUDE_DIR CMake variable (Fixes issue #80). Both GFLAGS_NAMESPACE and GFLAGS_INCLUDE_DIR can be used to customize the installation of the gflags library. One specifies the C++ namespace name of the gflags symbols, the other the include subdirectory path of the public header files. By default, both are set to "gflags", but other Google libraries still expect "google" as C++ namespace name, but not necessarily also include path. --- CMakeLists.txt | 15 ++++++++++++--- cmake/utils.cmake | 12 ++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ada98c..bb9f5e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,15 @@ version_numbers ( # ---------------------------------------------------------------------------- # options -set (GFLAGS_NAMESPACE "${PACKAGE_NAME}" CACHE STRING "C++ namespace identifier of gflags library.") +set (GFLAGS_NAMESPACE "${PACKAGE_NAME}" CACHE STRING "C++ namespace identifier of gflags library.") +set (GFLAGS_INCLUDE_DIR "${PACKAGE_NAME}" CACHE STRING "Include subdirectory of gflags header files.") + +if (IS_ABSOLUTE GFLAGS_INCLUDE_DIR) + message (FATAL_ERROR "GFLAGS_INCLUDE_DIR must be a path relative to CMAKE_INSTALL_PREFIX/include") +endif () +if (GFLAGS_INCLUDE_DIR MATCHES "^\\.\\.[/\\]") + message (FATAL_ERROR "GFLAGS_INCLUDE_DIR must not start with parent directory reference (../)") +endif () option (BUILD_SHARED_LIBS "Request build of shared libraries." OFF) option (BUILD_STATIC_LIBS "Request build of static libraries (default if BUILD_SHARED_LIBS is OFF)." OFF) @@ -38,6 +46,7 @@ option (INSTALL_HEADERS "Request packaging of headers and other devel mark_as_advanced (CLEAR CMAKE_INSTALL_PREFIX) mark_as_advanced (CMAKE_CONFIGURATION_TYPES GFLAGS_NAMESPACE + GFLAGS_INCLUDE_DIR BUILD_STATIC_LIBS BUILD_NC_TESTS INSTALL_HEADERS) @@ -212,7 +221,7 @@ configure_sources (GFLAGS_SRCS ${GFLAGS_SRCS}) include_directories ("${PROJECT_SOURCE_DIR}/src") include_directories ("${PROJECT_BINARY_DIR}/include") -include_directories ("${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}") +include_directories ("${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}") # ---------------------------------------------------------------------------- # output directories @@ -282,7 +291,7 @@ configure_file (cmake/version.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-co install (TARGETS ${TARGETS} DESTINATION ${LIBRARY_INSTALL_DIR} EXPORT gflags-lib) if (INSTALL_HEADERS) - install (FILES ${PUBLIC_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/${GFLAGS_NAMESPACE}) + install (FILES ${PUBLIC_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/${GFLAGS_INCLUDE_DIR}) install ( FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-install.cmake" RENAME ${PACKAGE_NAME}-config.cmake diff --git a/cmake/utils.cmake b/cmake/utils.cmake index ead2638..97c9a66 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -47,11 +47,11 @@ function (configure_headers out) set (tmp) foreach (src IN LISTS ARGN) if (EXISTS "${PROJECT_SOURCE_DIR}/src/${src}.in") - configure_file ("${PROJECT_SOURCE_DIR}/src/${src}.in" "${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}/${src}" @ONLY) - list (APPEND tmp "${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}/${src}") + configure_file ("${PROJECT_SOURCE_DIR}/src/${src}.in" "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/${src}" @ONLY) + list (APPEND tmp "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/${src}") else () - configure_file ("${PROJECT_SOURCE_DIR}/src/${src}" "${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}/${src}" COPYONLY) - list (APPEND tmp "${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}/${src}") + configure_file ("${PROJECT_SOURCE_DIR}/src/${src}" "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/${src}" COPYONLY) + list (APPEND tmp "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/${src}") endif () endforeach () set (${out} "${tmp}" PARENT_SCOPE) @@ -63,8 +63,8 @@ function (configure_sources out) set (tmp) foreach (src IN LISTS ARGN) if (src MATCHES ".h$" AND EXISTS "${PROJECT_SOURCE_DIR}/src/${src}.in") - configure_file ("${PROJECT_SOURCE_DIR}/src/${src}.in" "${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}/${src}" @ONLY) - list (APPEND tmp "${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}/${src}") + configure_file ("${PROJECT_SOURCE_DIR}/src/${src}.in" "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/${src}" @ONLY) + list (APPEND tmp "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/${src}") else () list (APPEND tmp "${PROJECT_SOURCE_DIR}/src/${src}") endif ()