Merge remote-tracking branch 'google/release'
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 93d3a73..17d38b4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@
# ----------------------------------------------------------------------------
# package information
set (PACKAGE_NAME "gflags")
-set (PACKAGE_VERSION "2.1.0")
+set (PACKAGE_VERSION "2.1.1")
set (PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set (PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}")
set (PACKAGE_BUGREPORT "https://code.google.com/p/gflags/issues/")
@@ -24,7 +24,15 @@
# ----------------------------------------------------------------------------
# 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 @@
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)
@@ -197,13 +206,22 @@
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})
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
@@ -273,7 +291,7 @@
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
@@ -374,21 +392,27 @@
set (CPACK_SYSTEM_NAME "win32")
endif ()
set (CPACK_PACKAGE_ARCHITECTURE)
+ elseif (APPLE)
+ set (CPACK_PACKAGE_ARCHITECTURE darwin)
else ()
string (TOLOWER "${CMAKE_SYSTEM_NAME}" CPACK_SYSTEM_NAME)
- execute_process (
- COMMAND dpkg --print-architecture
- RESULT_VARIABLE RV
- OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE
- )
- if (RV EQUAL 0)
- string (STRIP "${CPACK_PACKAGE_ARCHITECTURE}" CPACK_PACKAGE_ARCHITECTURE)
+ if (CMAKE_CXX_FLAGS MATCHES "-m32")
+ set (CPACK_PACKAGE_ARCHITECTURE i386)
else ()
- execute_process (COMMAND uname -m OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE)
- if (CPACK_PACKAGE_ARCHITECTURE MATCHES "x86_64")
- set (CPACK_PACKAGE_ARCHITECTURE amd64)
+ execute_process (
+ COMMAND dpkg --print-architecture
+ RESULT_VARIABLE RV
+ OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE
+ )
+ if (RV EQUAL 0)
+ string (STRIP "${CPACK_PACKAGE_ARCHITECTURE}" CPACK_PACKAGE_ARCHITECTURE)
else ()
- set (CPACK_PACKAGE_ARCHITECTURE i386)
+ execute_process (COMMAND uname -m OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE)
+ if (CPACK_PACKAGE_ARCHITECTURE MATCHES "x86_64")
+ set (CPACK_PACKAGE_ARCHITECTURE amd64)
+ else ()
+ set (CPACK_PACKAGE_ARCHITECTURE i386)
+ endif ()
endif ()
endif ()
endif ()
diff --git a/NEWS.txt b/NEWS.txt
index b9a68f3..7418607 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,12 +1,26 @@
+=== 30 March 2014 ===
+
+I've just released gflags 2.1.1.
+
+This release fixes a few bugs in the configuration of gflags_declare.h
+and adds a separate GFLAGS_INCLUDE_DIR CMake variable to the build configuration.
+Setting GFLAGS_NAMESPACE to "google" no longer changes also the include
+path of the public header files. This allows the use of the library with
+other Google projects such as glog which still use the deprecated "google"
+namespace for the gflags library, but include it as "gflags/gflags.h".
+
=== 20 March 2014 ===
-I've just released gflags 2.1.0.
+I've just released gflags 2.1.
The major changes are the use of CMake for the build configuration instead
-of the autotools and packaging support through CPack. This release compiles
-with all major compilers without warnings and passed the unit tests on
-Ubuntu 12.04, Windows 7 (Visual Studio 2008 and 2010, Cygwin, MinGW), and
-Mac OS X (Xcode 5.1).
+of the autotools and packaging support through CPack. The default namespace
+of all C++ symbols is now "gflags" instead of "google". This can be
+configured via the GFLAGS_NAMESPACE variable.
+
+This release compiles with all major compilers without warnings and passed
+the unit tests on Ubuntu 12.04, Windows 7 (Visual Studio 2008 and 2010,
+Cygwin, MinGW), and Mac OS X (Xcode 5.1).
The SVN repository on Google Code is now frozen and replaced by a Git
repository such that it can be used as Git submodule by projects. The main
@@ -21,9 +35,7 @@
with feature branch names prefixed by "feature/" and bugfix branch names
prefixed by "bugfix/", respectively.
-Binary and source distribution packages can be downloaded from
-[https://github.com/schuhschuh/gflags GitHub] as Google Code no longer
-permits the upload of such download packages.
+Binary and source [https://github.com/schuhschuh/gflags/releases packages] are available on GitHub.
=== 14 January 2013 ===
diff --git a/README.txt b/README.txt
index b5ecbbb..958c87e 100644
--- a/README.txt
+++ b/README.txt
@@ -2,5 +2,3 @@
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.
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 @@
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 @@
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 ()
diff --git a/src/gflags_declare.h.in b/src/gflags_declare.h.in
index b0548fa..b9ab9c7 100644
--- a/src/gflags_declare.h.in
+++ b/src/gflags_declare.h.in
@@ -113,13 +113,13 @@
DECLARE_VARIABLE(bool, B, name)
#define DECLARE_int32(name) \
- DECLARE_VARIABLE(GFLAGS_NAMESPACE::int32, I, name)
+ DECLARE_VARIABLE(::@GFLAGS_NAMESPACE@::int32, I, name)
#define DECLARE_int64(name) \
- DECLARE_VARIABLE(GFLAGS_NAMESPACE::int64, I64, name)
+ DECLARE_VARIABLE(::@GFLAGS_NAMESPACE@::int64, I64, name)
#define DECLARE_uint64(name) \
- DECLARE_VARIABLE(GFLAGS_NAMESPACE::uint64, U64, name)
+ DECLARE_VARIABLE(::@GFLAGS_NAMESPACE@::uint64, U64, name)
#define DECLARE_double(name) \
DECLARE_VARIABLE(double, D, name)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 49c97ea..ff07474 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -155,6 +155,13 @@
#add_gflags_test(deadlock_if_cant_lock 0 "PASS" "" gflags_unittest --deadlock_if_cant_lock)
# ----------------------------------------------------------------------------
+# use gflags_declare.h
+add_executable (gflags_declare_test gflags_declare_test.cc gflags_declare_flags.cc)
+
+add_test(NAME gflags_declare COMMAND gflags_declare_test --message "Hello gflags!")
+set_tests_properties(gflags_declare PROPERTIES PASS_REGULAR_EXPRESSION "Hello gflags!")
+
+# ----------------------------------------------------------------------------
# (negative) compilation tests
if (BUILD_NC_TESTS)
find_package (PythonInterp)
diff --git a/test/gflags_declare_flags.cc b/test/gflags_declare_flags.cc
new file mode 100644
index 0000000..dc53de5
--- /dev/null
+++ b/test/gflags_declare_flags.cc
@@ -0,0 +1,9 @@
+#include <iostream>
+#include <gflags/gflags_declare.h>
+
+DECLARE_string(message); // in gflags_delcare_test.cc
+
+void print_message()
+{
+ std::cout << FLAGS_message << std::endl;
+}
diff --git a/test/gflags_declare_test.cc b/test/gflags_declare_test.cc
new file mode 100644
index 0000000..707bcc0
--- /dev/null
+++ b/test/gflags_declare_test.cc
@@ -0,0 +1,12 @@
+#include <gflags/gflags.h>
+
+DEFINE_string(message, "", "The message to print");
+void print_message(); // in gflags_declare_flags.cc
+
+int main(int argc, char **argv)
+{
+ gflags::SetUsageMessage("Test compilation and use of gflags_declare.h");
+ gflags::ParseCommandLineFlags(&argc, &argv, true);
+ print_message();
+ return 0;
+}