Commit 67dc01d3 authored by Andreas Schuh's avatar Andreas Schuh

Merge branch 'master' of github.com:schuhschuh/gflags into update-cmake-example

parents 04c73f86 02e8c78f
# treat all files in this repository as text files
# and normalize them to LF line endings when committed
* text
/xcode/
/build/
/build-*/
.DS_Store
CMakeCache.txt
DartConfiguration.tcl
Makefile
CMakeFiles/
/Testing/
/include/gflags/config.h
/include/gflags/gflags_completions.h
/include/gflags/gflags_declare.h
/include/gflags/gflags.h
/lib/
/test/gflags_unittest_main.cc
/test/gflags_unittest-main.cc
/packages/
[submodule "doc"]
path = doc
url = git@github.com:schuhschuh/gflags.git
branch = gh-pages
google-gflags@googlegroups.com
This diff is collapsed.
Copyright (c) 2006, Google Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* Sun Mar 20 2014 - Andreas Schuh <google-gflags@googlegroups.com>
- gflags: version 2.1.1
- Fixed issue 77: GFLAGS_IS_A_DLL expands to empty string in gflags_declare.h
- Fixed issue 79: GFLAGS_NAMESPACE not expanded to actual namespace in gflags_declare.h
- Fixed issue 80: Allow include path to differ from GFLAGS_NAMESPACE
* Thu Mar 20 2014 - Andreas Schuh <google-gflags@googlegroups.com>
- gflags: version 2.1.0
- Build system configuration using CMake instead of autotools
- CPack packaging support for Debian/Ubuntu, Red Hat, and Mac OS X
- Fixed issue 54: Fix "invalid suffix on literal" (C++11)
- Fixed issue 57: Use _strdup instead of strdup on Windows
- Fixed issue 62: Change all preprocessor include guards to start with GFLAGS_
- Fixed issue 64: Add DEFINE_validator macro
- Fixed issue 73: Warnings in Visual Studio 2010 and unable to compile unit test
* Wed Jan 25 2012 - Google Inc. <google-gflags@googlegroups.com>
- gflags: version 2.0
- Changed the 'official' gflags email in setup.py/etc
- Renamed google-gflags.sln to gflags.sln
- Changed copyright text to reflect Google's relinquished ownership
* Tue Dec 20 2011 - Google Inc. <opensource@google.com>
- google-gflags: version 1.7
- Add CommandLineFlagInfo::flag_ptr pointing to current storage (musji)
- PORTING: flush after writing to stderr, needed on cygwin
- PORTING: Clean up the GFLAGS_DLL_DECL stuff better
- Fix a bug in StringPrintf() that affected large strings (csilvers)
- Die at configure-time when g++ isn't installed
* Fri Jul 29 2011 - Google Inc. <opensource@google.com>
- google-gflags: version 1.6
- BUGFIX: Fix a bug where we were leaving out a required $(top_srcdir)
- Fix definition of clstring (jyrki)
- Split up flag declares into its own file (jyrki)
- Add --version support (csilvers)
- Update the README for gflags with static libs
- Update acx_pthread.m4 for nostdlib
- Change ReparseCommandLineFlags to return void (csilvers)
- Some doc typofixes and example augmentation (various)
* Mon Jan 24 2011 - Google Inc. <opensource@google.com>
- google-gflags: version 1.5
- Better reporting of current vs default value (handler)
- Add API for cleaning up of memory at program-exit (jmarantz)
- Fix macros to work inside namespaces (csilvers)
- Use our own string typedef in case string is redefined (csilvers)
- Updated to autoconf 2.65
* Wed Oct 13 2010 - Google Inc. <opensource@google.com>
- google-gflags: version 1.4
- Add a check to prevent passing 0 to DEFINE_string (jorg)
- Reduce compile (.o) size (jyrki)
- Some small changes to quiet debug compiles (alexk)
- PORTING: better support static linking on windows (csilvers)
- DOCUMENTATION: change default values, use validators, etc.
- Update the NEWS file to be non-empty
- Add pkg-config (.pc) files for libgflags and libgflags_nothreads
* Mon Jan 4 2010 - Google Inc. <opensource@google.com>
- google-gflags: version 1.3
- PORTABILITY: can now build and run tests under MSVC (csilvers)
- Remove the python gflags code, which is now its own package (tansell)
- Clarify that "last flag wins" in the docs (csilvers)
- Comment danger of using GetAllFlags in validators (wojtekm)
- PORTABILITY: Some fixes necessary for c++0x (mboerger)
- Makefile fix: $(srcdir) -> $(top_srcdir) in one place (csilvres)
- INSTALL: autotools to autoconf v2.64 + automake v1.11 (csilvers)
* Thu Sep 10 2009 - Google Inc. <opensource@google.com>
- google-gflags: version 1.2
- PORTABILITY: can now build and run tests under mingw (csilvers)
- Using a string arg for a bool flag is a compile-time error (rbayardo)
- Add --helpxml to gflags.py (salcianu)
- Protect against a hypothetical global d'tor mutex problem (csilvers)
- BUGFIX: can now define a flag after 'using namespace google' (hamaji)
* Tue Apr 14 2009 - Google Inc. <opensource@google.com>
- google-gflags: version 1.1
- Add both foo and nofoo for boolean flags, with --undefok (andychu)
- Better document how validators work (wojtekm)
- Improve binary-detection for bash-completion (mtamsky)
- Python: Add a concept of "key flags", used with --help (salcianu)
- Python: Robustify flag_values (salcianu)
- Python: Add a new DEFINE_bool alias (keir, andrewliu)
- Python: Do module introspection based on module name (dsturtevant)
- Fix autoconf a bit better, especially on windows and solaris (ajenjo)
- BUG FIX: gflags_nothreads was linking against the wrong lib (ajenjo)
- BUG FIX: threads-detection failed on FreeBSD; replace it (ajenjo)
- PORTABILITY: Quiet an internal compiler error with SUSE 10 (csilvers)
- PORTABILITY: Update deb.sh for more recenty debuilds (csilvers)
- PORTABILITY: #include more headers to satify new gcc's (csilvers)
- INSTALL: Updated to autoconf 2.61 and libtool 1.5.26 (csilvers)
* Fri Oct 3 2008 - Google Inc. <opensource@google.com>
- google-gflags: version 1.0
- Add a missing newline to an error string (bcmills)
- (otherwise exactly the same as gflags 1.0rc2)
* Thu Sep 18 2008 - Google Inc. <opensource@google.com>
- google-gflags: version 1.0rc2
- Report current flag values in --helpxml (hdn)
- Fix compilation troubles with gcc 4.3.3 (simonb)
- BUG FIX: I was missing a std:: in DECLARE_string (csilvers)
- BUG FIX: Clarify in docs how to specify --bool flags (csilvers)
- BUG FIX: Fix --helpshort for source files not in a subdir (csilvers)
- BUG FIX: Fix python unittest for 64-bit builds (bcmills)
* Tue Aug 19 2008 - Google Inc. <opensource@google.com>
- google-gflags: version 1.0rc1
- Move #include files from google/ to gflags/ (csilvers)
- Small optimizations to reduce binary (library) size (jyrki)
- BUGFIX: forgot a std:: in one of the .h files (csilvers)
- Speed up locking by making sure calls are inlined (ajenjo)
- 64-BIT COMPATIBILITY: Use %PRId64 instead of %lld (csilvers)
- PORTABILITY: fix Makefile to work with Cygwin (ajenjo)
- PORTABILITY: fix code to compile under Visual Studio (ajenjo)
- PORTABILITY: fix code to compile under Solaris 10 with CC (csilvers)
* Mon Jul 21 2008 - Google Inc. <opensource@google.com>
- google-gflags: version 0.9
- Add the ability to validate a command-line flag (csilvers)
- Add completion support for commandline flags in bash (daven)
- Add -W compile flags to Makefile, when using gcc (csilvers)
- Allow helpstring to be NULL (cristianoc)
- Improved documentation of classes in the .cc file (csilvers)
- Fix python bug with AppendFlagValues + shortnames (jjtswan)
- Use bool instead of int for boolean flags in gflags.py (bcmills)
- Simplify the way we declare flags, now more foolproof (csilvers)
- Better error messages when bool flags collide (colohan)
- Only evaluate DEFINE_foo macro args once (csilvers)
* Wed Mar 26 2008 - Google Inc. <opensource@google.com>
- google-gflags: version 0.8
- Export DescribeOneFlag() in the API
- Add support for automatic line wrapping at 80 cols for gflags.py
- Bugfix: do not treat an isolated "-" the same as an isolated "--"
- Update rpm spec to point to Google Code rather than sourceforge (!)
- Improve documentation (including documenting thread-safety)
- Improve #include hygiene
- Improve testing
* Thu Oct 18 2007 - Google Inc. <opensource@google.com>
- google-gflags: version 0.7
- Deal even more correctly with libpthread not linked in (csilvers)
- Add STRIP_LOG, an improved DO_NOT_SHOW_COMMANDLINE_HELP (sioffe)
- Be more accurate printing default flag values in --help (dsturtevant)
- Reduce .o file size a bit by using shorter namespace names (jeff)
- Use relative install path, so 'setup.py --home' works (csilvers)
- Notice when a boolean flag has a non-boolean default (bnmouli)
- Broaden --helpshort to match foo-main.cc and foo_main.cc (hendrie)
- Fix "no modules match" message for --helpshort, etc (hendrie)
* Wed Aug 15 2007 - Google Inc. <opensource@google.com>
- google-gflags: version 0.6
- Deal correctly with case that libpthread is not linked in (csilvers)
- Update Makefile/tests so we pass "make distcheck" (csilvers)
- Document and test that last assignment to a flag wins (wan)
* Tue Jun 12 2007 - Google Inc. <opensource@google.com>
- google-gflags: version 0.5
- Include all m4 macros in the distribution (csilvers)
- Python: Fix broken data_files field in setup.py (sidlon)
- Python: better string serliaizing and unparsing (abo, csimmons)
- Fix checks for NaN and inf to work with Mac OS X (csilvers)
* Thu Apr 19 2007 - Google Inc. <opensource@google.com>
- google-gflags: version 0.4
- Remove is_default from GetCommandLineFlagInfo (csilvers)
- Portability fixes: includes, strtoll, gcc4.3 errors (csilvers)
- A few doc typo cleanups (csilvers)
* Wed Mar 28 2007 - Google Inc. <opensource@google.com>
- google-gflags: version 0.3
- python portability fix: use popen instead of subprocess (csilvers)
- Add is_default to CommandLineFlagInfo (pchien)
- Make docs a bit prettier (csilvers)
- Actually include the python files in the distribution! :-/ (csilvers)
* Mon Jan 22 2007 - Google Inc. <opensource@google.com>
- google-gflags: version 0.2
- added support for python commandlineflags, as well as c++
- gflags2man, a script to turn flags into a man page (dchristian)
* Wed Dec 13 2006 - Google Inc. <opensource@google.com>
- google-gflags: version 0.1
Installing a binary distribution package
========================================
No official binary distribution packages are provided by the gflags developers.
There may, however, be binary packages available for your OS. Please consult
also the package repositories of your Linux distribution.
For example on Debian/Ubuntu Linux, gflags can be installed using the
following command:
sudo apt-get install gflags
Compiling the source code
=========================
The build system of gflags is since version 2.1 based on [CMake](http://cmake.org).
The common steps to build, test, and install software are therefore:
1. Extract source files.
2. Create build directory and change to it.
3. Run CMake to configure the build tree.
4. Build the software using selected build tool.
5. Test the built software.
6. Install the built files.
On Unix-like systems with GNU Make as build tool, these build steps can be
summarized by the following sequence of commands executed in a shell,
where ```$package``` and ```$version``` are shell variables which represent
the name of this package and the obtained version of the software.
$ tar xzf gflags-$version-source.tar.gz
$ cd gflags-$version
$ mkdir build && cd build
$ ccmake ..
- Press 'c' to configure the build system and 'e' to ignore warnings.
- Set CMAKE_INSTALL_PREFIX and other CMake variables and options.
- Continue pressing 'c' until the option 'g' is available.
- Then press 'g' to generate the configuration files for GNU Make.
$ make
$ make test (optional)
$ make install (optional)
In the following, only gflags-specific CMake settings available to
configure the build and installation are documented.
CMake Option | Description
---------------------- | -------------------------------------------------------
CMAKE_INSTALL_PREFIX | Installation directory, e.g., "/usr/local" on Unix and "C:\Program Files\gflags" on Windows.
GFLAGS_NAMESPACE | Name of the C++ namespace to be used by the gflags library. Note that the public source header files are installed in a subdirectory named after this namespace. To maintain backwards compatibility with the Google Commandline Flags, set this variable to "google". The default is "gflags".
GFLAGS_INCLUDE_DIR | Name of include subdirectory where headers are installed into.
This diff is collapsed.
This diff is collapsed.
#.rst:
# CheckLibraryExists
# ------------------
#
# Check if the function exists.
#
# CHECK_LIBRARY_EXISTS (LIBRARY FUNCTION LOCATION VARIABLE)
#
# ::
#
# LIBRARY - the name of the library you are looking for
# FUNCTION - the name of the function
# LOCATION - location where the library should be found
# VARIABLE - variable to store the result
#
#
#
# The following variables may be set before calling this macro to modify
# the way the check is run:
#
# ::
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
#=============================================================================
# Copyright 2002-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
macro(CHECK_CXX_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}")
set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY})
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_LIBRARY_EXISTS_LIBRARIES
${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES})
endif()
configure_file(${CMAKE_ROOT}/Modules/CheckFunctionExists.c
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckFunctionExists.cxx COPYONLY)
try_compile(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckFunctionExists.cxx
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}
-DLINK_DIRECTORIES:STRING=${LOCATION}
OUTPUT_VARIABLE OUTPUT)
if(${VARIABLE})
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found")
set(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
"passed with the following output:\n"
"${OUTPUT}\n\n")
else()
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found")
set(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
"failed with the following output:\n"
"${OUTPUT}\n\n")
endif()
endif()
endmacro()
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
void* runner(void*);
int res = 0;
#ifdef __CLASSIC_C__
int main(){
int ac;
char*av[];
#else
int main(int ac, char*av[]){
#endif
pthread_t tid[2];
pthread_create(&tid[0], 0, runner, (void*)1);
pthread_create(&tid[1], 0, runner, (void*)2);
#if defined(__BEOS__) && !defined(__ZETA__) // (no usleep on BeOS 5.)
usleep(1); // for strange behavior on single-processor sun
#endif
pthread_join(tid[0], 0);
pthread_join(tid[1], 0);
if(ac > 1000){return *av[0];}
return res;
}
void* runner(void* args)
{
int cc;
for ( cc = 0; cc < 10; cc ++ )
{
printf("%p CC: %d\n", args, cc);
}
res ++;
return 0;
}
@headers@
#undef KEY
#if defined(__i386)
# define KEY '_','_','i','3','8','6'
#elif defined(__x86_64)
# define KEY '_','_','x','8','6','_','6','4'
#elif defined(__ppc__)
# define KEY '_','_','p','p','c','_','_'
#elif defined(__ppc64__)
# define KEY '_','_','p','p','c','6','4','_','_'
#endif
#define SIZE (sizeof(@type@))
char info_size[] = {'I', 'N', 'F', 'O', ':', 's','i','z','e','[',
('0' + ((SIZE / 10000)%10)),
('0' + ((SIZE / 1000)%10)),
('0' + ((SIZE / 100)%10)),
('0' + ((SIZE / 10)%10)),
('0' + (SIZE % 10)),
']',
#ifdef KEY
' ','k','e','y','[', KEY, ']',
#endif
'\0'};
#ifdef __CLASSIC_C__
int main(argc, argv) int argc; char *argv[];
#else
int main(int argc, char *argv[])
#endif
{
int require = 0;
require += info_size[argc];
(void)argv;
return require;
}
# Copied from master branch of CMake (commit SHA 34a49dea) and
# modified to use CheckIncludeFileCXX instead of CheckIncludeFile
# when the LANGUAGE is CXX. Modified the try_compile call to
# not pass any LINK_LIBRARIES as this option is only supported by
# CMake since version 2.8.11
# -andreas
#.rst:
# CheckTypeSize
# -------------
#
# Check sizeof a type
#
# ::
#
# CHECK_TYPE_SIZE(TYPE VARIABLE [BUILTIN_TYPES_ONLY]
# [LANGUAGE <language>])
#
# Check if the type exists and determine its size. On return,
# "HAVE_${VARIABLE}" holds the existence of the type, and "${VARIABLE}"
# holds one of the following:
#
# ::
#
# <size> = type has non-zero size <size>
# "0" = type has arch-dependent size (see below)
# "" = type does not exist
#
# Furthermore, the variable "${VARIABLE}_CODE" holds C preprocessor code
# to define the macro "${VARIABLE}" to the size of the type, or leave
# the macro undefined if the type does not exist.
#
# The variable "${VARIABLE}" may be "0" when CMAKE_OSX_ARCHITECTURES has
# multiple architectures for building OS X universal binaries. This
# indicates that the type size varies across architectures. In this
# case "${VARIABLE}_CODE" contains C preprocessor tests mapping from
# each architecture macro to the corresponding type size. The list of
# architecture macros is stored in "${VARIABLE}_KEYS", and the value for
# each key is stored in "${VARIABLE}-${KEY}".
#
# If the BUILTIN_TYPES_ONLY option is not given, the macro checks for
# headers <sys/types.h>, <stdint.h>, and <stddef.h>, and saves results
# in HAVE_SYS_TYPES_H, HAVE_STDINT_H, and HAVE_STDDEF_H. The type size
# check automatically includes the available headers, thus supporting
# checks of types defined in the headers.
#
# If LANGUAGE is set, the specified compiler will be used to perform the
# check. Acceptable values are C and CXX
#
# Despite the name of the macro you may use it to check the size of more
# complex expressions, too. To check e.g. for the size of a struct
# member you can do something like this:
#
# ::
#
# check_type_size("((struct something*)0)->member" SIZEOF_MEMBER)
#
#
#
# The following variables may be set before calling this macro to modify
# the way the check is run:
#
# ::
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_EXTRA_INCLUDE_FILES = list of extra headers to include
#=============================================================================
# Copyright 2002-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
cmake_policy(PUSH)
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
get_filename_component(__check_type_size_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
#-----------------------------------------------------------------------------
# Helper function. DO NOT CALL DIRECTLY.
function(__check_type_size_impl type var map builtin language)
message(STATUS "Check size of ${type}")
# Include header files.
set(headers)
if(builtin)
if(HAVE_SYS_TYPES_H)
set(headers "${headers}#include <sys/types.h>\n")
endif()
if(HAVE_STDINT_H)
set(headers "${headers}#include <stdint.h>\n")
endif()
if(HAVE_STDDEF_H)
set(headers "${headers}#include <stddef.h>\n")
endif()
endif()
foreach(h ${CMAKE_EXTRA_INCLUDE_FILES})
set(headers "${headers}#include \"${h}\"\n")
endforeach()
# Perform the check.
if("${language}" STREQUAL "C")
set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.c)
elseif("${language}" STREQUAL "CXX")
set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.cpp)
else()
message(FATAL_ERROR "Unknown language:\n ${language}\nSupported languages: C, CXX.\n")
endif()
set(bin ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.bin)
configure_file(${__check_type_size_dir}/CheckTypeSize.c.in ${src} @ONLY)
try_compile(HAVE_${var} ${CMAKE_BINARY_DIR} ${src}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS
"-DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}"
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}"
OUTPUT_VARIABLE output
COPY_FILE ${bin}
)
if(HAVE_${var})
# The check compiled. Load information from the binary.
file(STRINGS ${bin} strings LIMIT_COUNT 10 REGEX "INFO:size")
# Parse the information strings.
set(regex_size ".*INFO:size\\[0*([^]]*)\\].*")
set(regex_key " key\\[([^]]*)\\]")
set(keys)
set(code)
set(mismatch)
set(first 1)
foreach(info ${strings})
if("${info}" MATCHES "${regex_size}")
# Get the type size.
string(REGEX REPLACE "${regex_size}" "\\1" size "${info}")
if(first)
set(${var} ${size})
elseif(NOT "${size}" STREQUAL "${${var}}")
set(mismatch 1)
endif()
set(first 0)
# Get the architecture map key.
string(REGEX MATCH "${regex_key}" key "${info}")
string(REGEX REPLACE "${regex_key}" "\\1" key "${key}")
if(key)
set(code "${code}\nset(${var}-${key} \"${size}\")")
list(APPEND keys ${key})
endif()
endif()
endforeach()
# Update the architecture-to-size map.
if(mismatch AND keys)
configure_file(${__check_type_size_dir}/CheckTypeSizeMap.cmake.in ${map} @ONLY)
set(${var} 0)
else()
file(REMOVE ${map})
endif()
if(mismatch AND NOT keys)
message(SEND_ERROR "CHECK_TYPE_SIZE found different results, consider setting CMAKE_OSX_ARCHITECTURES or CMAKE_TRY_COMPILE_OSX_ARCHITECTURES to one or no architecture !")
endif()
message(STATUS "Check size of ${type} - done")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining size of ${type} passed with the following output:\n${output}\n\n")
set(${var} "${${var}}" CACHE INTERNAL "CHECK_TYPE_SIZE: sizeof(${type})")
else()
# The check failed to compile.
message(STATUS "Check size of ${type} - failed")
file(READ ${src} content)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining size of ${type} failed with the following output:\n${output}\n${src}:\n${content}\n\n")
set(${var} "" CACHE INTERNAL "CHECK_TYPE_SIZE: ${type} unknown")
file(REMOVE ${map})
endif()
endfunction()
#-----------------------------------------------------------------------------
macro(CHECK_TYPE_SIZE TYPE VARIABLE)
# parse arguments
unset(doing)
foreach(arg ${ARGN})
if("x${arg}" STREQUAL "xBUILTIN_TYPES_ONLY")
set(_CHECK_TYPE_SIZE_${arg} 1)
unset(doing)
elseif("x${arg}" STREQUAL "xLANGUAGE") # change to MATCHES for more keys
set(doing "${arg}")
set(_CHECK_TYPE_SIZE_${doing} "")
elseif("x${doing}" STREQUAL "xLANGUAGE")
set(_CHECK_TYPE_SIZE_${doing} "${arg}")
unset(doing)
else()
message(FATAL_ERROR "Unknown argument:\n ${arg}\n")
endif()
endforeach()
if("x${doing}" MATCHES "^x(LANGUAGE)$")
message(FATAL_ERROR "Missing argument:\n ${doing} arguments requires a value\n")
endif()
if(DEFINED _CHECK_TYPE_SIZE_LANGUAGE)
if(NOT "x${_CHECK_TYPE_SIZE_LANGUAGE}" MATCHES "^x(C|CXX)$")
message(FATAL_ERROR "Unknown language:\n ${_CHECK_TYPE_SIZE_LANGUAGE}.\nSupported languages: C, CXX.\n")
endif()
set(_language ${_CHECK_TYPE_SIZE_LANGUAGE})
else()
set(_language C)
endif()
# Optionally check for standard headers.
if(_CHECK_TYPE_SIZE_BUILTIN_TYPES_ONLY)
set(_builtin 0)
else()
set(_builtin 1)
if ("x${_CHECK_TYPE_SIZE_LANGUAGE}" STREQUAL "xCXX")
check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H)
check_include_file_cxx(stdint.h HAVE_STDINT_H)
check_include_file_cxx(stddef.h HAVE_STDDEF_H)
else ()
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stddef.h HAVE_STDDEF_H)
endif ()
endif()
unset(_CHECK_TYPE_SIZE_BUILTIN_TYPES_ONLY)
unset(_CHECK_TYPE_SIZE_LANGUAGE)
# Compute or load the size or size map.
set(${VARIABLE}_KEYS)
set(_map_file ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${VARIABLE}.cmake)
if(NOT DEFINED HAVE_${VARIABLE})
__check_type_size_impl(${TYPE} ${VARIABLE} ${_map_file} ${_builtin} ${_language})
endif()
include(${_map_file} OPTIONAL)
set(_map_file)
set(_builtin)
# Create preprocessor code.
if(${VARIABLE}_KEYS)
set(${VARIABLE}_CODE)
set(_if if)
foreach(key ${${VARIABLE}_KEYS})
set(${VARIABLE}_CODE "${${VARIABLE}_CODE}#${_if} defined(${key})\n# define ${VARIABLE} ${${VARIABLE}-${key}}\n")
set(_if elif)
endforeach()
set(${VARIABLE}_CODE "${${VARIABLE}_CODE}#else\n# error ${VARIABLE} unknown\n#endif")
set(_if)
elseif(${VARIABLE})
set(${VARIABLE}_CODE "#define ${VARIABLE} ${${VARIABLE}}")
else()
set(${VARIABLE}_CODE "/* #undef ${VARIABLE} */")
endif()
endmacro()
#-----------------------------------------------------------------------------
cmake_policy(POP)
set(@var@_KEYS "@keys@")@code@
#.rst:
# FindThreads
# -----------
#
# This module determines the thread library of the system.
#
# The following variables are set
#
# ::
#
# CMAKE_THREAD_LIBS_INIT - the thread library
# CMAKE_USE_SPROC_INIT - are we using sproc?
# CMAKE_USE_WIN32_THREADS_INIT - using WIN32 threads?
# CMAKE_USE_PTHREADS_INIT - are we using pthreads
# CMAKE_HP_PTHREADS_INIT - are we using hp pthreads
#
# For systems with multiple thread libraries, caller can set
#
# ::
#
# CMAKE_THREAD_PREFER_PTHREAD
#=============================================================================
# Copyright 2002-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
include (CheckIncludeFileCXX)
include (CheckCXXLibraryExists)
include (CheckCXXSymbolExists)
set(Threads_FOUND FALSE)
# Do we have sproc?
if(CMAKE_SYSTEM MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD)
CHECK_INCLUDE_FILES_CXX("sys/types.h;sys/prctl.h" CMAKE_HAVE_SPROC_H)
endif()
if(CMAKE_HAVE_SPROC_H AND NOT CMAKE_THREAD_PREFER_PTHREAD)
# We have sproc
set(CMAKE_USE_SPROC_INIT 1)
else()
# Do we have pthreads?
CHECK_INCLUDE_FILE_CXX("pthread.h" CMAKE_HAVE_PTHREAD_H)
if(CMAKE_HAVE_PTHREAD_H)
#
# We have pthread.h
# Let's check for the library now.
#
set(CMAKE_HAVE_THREADS_LIBRARY)
if(NOT THREADS_HAVE_PTHREAD_ARG)
# Check if pthread functions are in normal C library
CHECK_CXX_SYMBOL_EXISTS(pthread_create pthread.h CMAKE_HAVE_LIBC_CREATE)
if(CMAKE_HAVE_LIBC_CREATE)
set(CMAKE_THREAD_LIBS_INIT "")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(Threads_FOUND TRUE)
endif()
if(NOT CMAKE_HAVE_THREADS_LIBRARY)
# Do we have -lpthreads
CHECK_CXX_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
if(CMAKE_HAVE_PTHREADS_CREATE)
set(CMAKE_THREAD_LIBS_INIT "-lpthreads")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(Threads_FOUND TRUE)
endif()
# Ok, how about -lpthread
CHECK_CXX_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
if(CMAKE_HAVE_PTHREAD_CREATE)
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(Threads_FOUND TRUE)
endif()
if(CMAKE_SYSTEM MATCHES "SunOS.*")
# On sun also check for -lthread
CHECK_CXX_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE)
if(CMAKE_HAVE_THR_CREATE)
set(CMAKE_THREAD_LIBS_INIT "-lthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(Threads_FOUND TRUE)
endif()
endif()
endif()
endif()
if(NOT CMAKE_HAVE_THREADS_LIBRARY)
# If we did not found -lpthread, -lpthreads, or -lthread, look for -pthread
if("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG")
message(STATUS "Check if compiler accepts -pthread")
configure_file ("${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.cxx"
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckForPthreads.cxx" COPYONLY)
try_run(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckForPthreads.cxx
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=-pthread;-DCMAKE_CXX_FLAGS:STRING=-fpermissive"
COMPILE_OUTPUT_VARIABLE OUTPUT)
if(THREADS_HAVE_PTHREAD_ARG)
if(THREADS_PTHREAD_ARG STREQUAL "2")
set(Threads_FOUND TRUE)
message(STATUS "Check if compiler accepts -pthread - yes")
else()
message(STATUS "Check if compiler accepts -pthread - no")
file(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if compiler accepts -pthread returned ${THREADS_PTHREAD_ARG} instead of 2. The compiler had the following output:\n${OUTPUT}\n\n")
endif()
else()
message(STATUS "Check if compiler accepts -pthread - no")
file(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if compiler accepts -pthread failed with the following output:\n${OUTPUT}\n\n")
endif()
endif()
if(THREADS_HAVE_PTHREAD_ARG)
set(Threads_FOUND TRUE)
set(CMAKE_THREAD_LIBS_INIT "-pthread")
endif()
endif()
endif()
endif()
if(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_CREATE)
set(CMAKE_USE_PTHREADS_INIT 1)
set(Threads_FOUND TRUE)
endif()
if(CMAKE_SYSTEM MATCHES "Windows")
set(CMAKE_USE_WIN32_THREADS_INIT 1)
set(Threads_FOUND TRUE)
endif()
if(CMAKE_USE_PTHREADS_INIT)
if(CMAKE_SYSTEM MATCHES "HP-UX-*")
# Use libcma if it exists and can be used. It provides more
# symbols than the plain pthread library. CMA threads
# have actually been deprecated:
# http://docs.hp.com/en/B3920-90091/ch12s03.html#d0e11395
# http://docs.hp.com/en/947/d8.html
# but we need to maintain compatibility here.
# The CMAKE_HP_PTHREADS setting actually indicates whether CMA threads
# are available.
CHECK_CXX_LIBRARY_EXISTS(cma pthread_attr_create "" CMAKE_HAVE_HP_CMA)
if(CMAKE_HAVE_HP_CMA)
set(CMAKE_THREAD_LIBS_INIT "-lcma")
set(CMAKE_HP_PTHREADS_INIT 1)
set(Threads_FOUND TRUE)
endif()
set(CMAKE_USE_PTHREADS_INIT 1)
endif()
if(CMAKE_SYSTEM MATCHES "OSF1-V*")
set(CMAKE_USE_PTHREADS_INIT 0)
set(CMAKE_THREAD_LIBS_INIT )
endif()
if(CMAKE_SYSTEM MATCHES "CYGWIN_NT*")
set(CMAKE_USE_PTHREADS_INIT 1)
set(Threads_FOUND TRUE)
set(CMAKE_THREAD_LIBS_INIT )
set(CMAKE_USE_WIN32_THREADS_INIT 0)
endif()
endif()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Threads DEFAULT_MSG Threads_FOUND)
This package contains runtime libraries only which are required
by applications that use these libraries for the commandline flags
processing. If you want to develop such application, download
and install the development package instead.
## gflags CMake configuration file
# library version information
set (@PACKAGE_NAME@_VERSION_STRING "@PACKAGE_VERSION@")
set (@PACKAGE_NAME@_VERSION_MAJOR @PACKAGE_VERSION_MAJOR@)
set (@PACKAGE_NAME@_VERSION_MINOR @PACKAGE_VERSION_MINOR@)
set (@PACKAGE_NAME@_VERSION_PATCH @PACKAGE_VERSION_PATCH@)
# import targets
include ("${CMAKE_CURRENT_LIST_DIR}/@PACKAGE_NAME@-export.cmake")
# installation prefix
get_filename_component (CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component (_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_PREFIX_REL2CONFIG_DIR@" ABSOLUTE)
# include directory
set (@PACKAGE_NAME@_INCLUDE_DIR "${_INSTALL_PREFIX}/@INCLUDE_INSTALL_DIR@")
# gflags library
set (@PACKAGE_NAME@_LIBRARIES gflags)
# unset private variables
unset (_INSTALL_PREFIX)
# ----------------------------------------------------------------------------
# sanitize string stored in variable for use in regular expression.
macro (sanitize_for_regex STRVAR)
string (REGEX REPLACE "([.+*?^$()])" "\\\\\\1" ${STRVAR} "${${STRVAR}}")
endmacro ()
# ----------------------------------------------------------------------------
# script arguments
if (NOT COMMAND)
message (FATAL_ERROR "Test command not specified!")
endif ()
if (NOT DEFINED EXPECTED_RC)
set (EXPECTED_RC 0)
endif ()
if (EXPECTED_OUTPUT)
sanitize_for_regex(EXPECTED_OUTPUT)
endif ()
if (UNEXPECTED_OUTPUT)
sanitize_for_regex(UNEXPECTED_OUTPUT)
endif ()
# ----------------------------------------------------------------------------
# set a few environment variables (useful for --tryfromenv)
set (ENV{FLAGS_undefok} "foo,bar")
set (ENV{FLAGS_weirdo} "")
set (ENV{FLAGS_version} "true")
set (ENV{FLAGS_help} "false")
# ----------------------------------------------------------------------------
# execute test command
execute_process(
COMMAND ${COMMAND}
RESULT_VARIABLE RC
OUTPUT_VARIABLE OUTPUT
ERROR_VARIABLE OUTPUT
)
if (OUTPUT)
message ("${OUTPUT}")
endif ()
# ----------------------------------------------------------------------------
# check test result
if (NOT RC EQUAL EXPECTED_RC)
string (REPLACE ";" " " COMMAND "${COMMAND}")
message (FATAL_ERROR "Command:\n\t${COMMAND}\nExit status is ${RC}, expected ${EXPECTED_RC}")
endif ()
if (EXPECTED_OUTPUT AND NOT OUTPUT MATCHES "${EXPECTED_OUTPUT}")
message (FATAL_ERROR "Test output does not match expected output: ${EXPECTED_OUTPUT}")
endif ()
if (UNEXPECTED_OUTPUT AND OUTPUT MATCHES "${UNEXPECTED_OUTPUT}")
message (FATAL_ERROR "Test output matches unexpected output: ${UNEXPECTED_OUTPUT}")
endif ()
\ No newline at end of file
# Per-generator CPack configuration file. See CPACK_PROJECT_CONFIG_FILE documented at
# http://www.cmake.org/cmake/help/v2.8.12/cpack.html#variable:CPACK_PROJECT_CONFIG_FILE
#
# All common CPACK_* variables are set in CMakeLists.txt already. This file only
# overrides some of these to provide package generator specific settings.
# whether package contains all development files or only runtime files
set (DEVEL @INSTALL_HEADERS@)
# ------------------------------------------------------------------------------
# Mac OS X package
if (CPACK_GENERATOR MATCHES "PackageMaker|DragNDrop")
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
if (DEVEL)
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-devel")
endif ()
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_PACKAGE_VERSION}")
# ------------------------------------------------------------------------------
# Debian package
elseif (CPACK_GENERATOR MATCHES "DEB")
set (CPACK_PACKAGE_FILE_NAME "lib${CPACK_PACKAGE_NAME}")
if (DEVEL)
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-dev")
else ()
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}0")
endif ()
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}_${CPACK_PACKAGE_VERSION}-1_${CPACK_PACKAGE_ARCHITECTURE}")
set (CPACK_DEBIAN_PACKAGE_DEPENDS)
set (CPACK_DEBIAN_PACKAGE_SECTION "devel")
set (CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set (CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_RPM_PACKAGE_URL}")
set (CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}")
set (CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_PACKAGE_ARCHITECTURE}")
# ------------------------------------------------------------------------------
# RPM package
elseif (CPACK_GENERATOR MATCHES "RPM")
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
if (DEVEL)
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-devel")
endif ()
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_PACKAGE_VERSION}-1.${CPACK_PACKAGE_ARCHITECTURE}")
endif ()
## Utility CMake functions.
# ----------------------------------------------------------------------------
## Convert boolean value to 0 or 1
macro (bool_to_int VAR)
if (${VAR})
set (${VAR} 1)
else ()
set (${VAR} 0)
endif ()
endmacro ()
# ----------------------------------------------------------------------------
## Extract version numbers from version string.
function (version_numbers version major minor patch)
if (version MATCHES "([0-9]+)(\\.[0-9]+)?(\\.[0-9]+)?(rc[1-9][0-9]*|[a-z]+)?")
if (CMAKE_MATCH_1)
set (_major ${CMAKE_MATCH_1})
else ()
set (_major 0)
endif ()
if (CMAKE_MATCH_2)
set (_minor ${CMAKE_MATCH_2})
string (REGEX REPLACE "^\\." "" _minor "${_minor}")
else ()
set (_minor 0)
endif ()
if (CMAKE_MATCH_3)
set (_patch ${CMAKE_MATCH_3})
string (REGEX REPLACE "^\\." "" _patch "${_patch}")
else ()
set (_patch 0)
endif ()
else ()
set (_major 0)
set (_minor 0)
set (_patch 0)
endif ()
set ("${major}" "${_major}" PARENT_SCOPE)
set ("${minor}" "${_minor}" PARENT_SCOPE)
set ("${patch}" "${_patch}" PARENT_SCOPE)
endfunction ()
# ----------------------------------------------------------------------------
## Configure public header files
function (configure_headers out)
set (tmp)
foreach (src IN LISTS ARGN)
if (IS_ABSOLUTE "${src}")
list (APPEND tmp "${src}")
elseif (EXISTS "${PROJECT_SOURCE_DIR}/src/${src}.in")
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_INCLUDE_DIR}/${src}" COPYONLY)
list (APPEND tmp "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/${src}")
endif ()
endforeach ()
set (${out} "${tmp}" PARENT_SCOPE)
endfunction ()
# ----------------------------------------------------------------------------
## Configure source files with .in suffix
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_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 ()
endforeach ()
set (${out} "${tmp}" PARENT_SCOPE)
endfunction ()
# ----------------------------------------------------------------------------
## Add usage test
#
# Using PASS_REGULAR_EXPRESSION and FAIL_REGULAR_EXPRESSION would
# do as well, but CMake/CTest does not allow us to specify an
# expected exit status. Moreover, the execute_test.cmake script
# sets environment variables needed by the --fromenv/--tryfromenv tests.
macro (add_gflags_test name expected_rc expected_output unexpected_output cmd)
set (args "--test_tmpdir=${PROJECT_BINARY_DIR}/Testing/Temporary"
"--srcdir=${PROJECT_SOURCE_DIR}/test")
add_test (
NAME ${name}
COMMAND "${CMAKE_COMMAND}" "-DCOMMAND:STRING=$<TARGET_FILE:${cmd}>;${args};${ARGN}"
"-DEXPECTED_RC:STRING=${expected_rc}"
"-DEXPECTED_OUTPUT:STRING=${expected_output}"
"-DUNEXPECTED_OUTPUT:STRING=${unexpected_output}"
-P "${PROJECT_SOURCE_DIR}/cmake/execute_test.cmake"
WORKING_DIRECTORY "${GFLAGS_FLAGFILES_DIR}"
)
endmacro ()
## gflags CMake configuration version file
# -----------------------------------------------------------------------------
# library version
set (PACKAGE_VERSION "@PACKAGE_VERSION@")
# -----------------------------------------------------------------------------
# check compatibility
# Perform compatibility check here using the input CMake variables.
# See example in http://www.cmake.org/Wiki/CMake_2.6_Notes.
set (PACKAGE_VERSION_COMPATIBLE TRUE)
set (PACKAGE_VERSION_UNSUITABLE FALSE)
if ("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL "@PACKAGE_VERSION_MAJOR@" AND
"${PACKAGE_FIND_VERSION_MINOR}" EQUAL "@PACKAGE_VERSION_MINOR@")
set (PACKAGE_VERSION_EXACT TRUE)
else ()
set (PACKAGE_VERSION_EXACT FALSE)
endif ()
Subproject commit 957f0d291c80acbf894eb5dad918798546db9c07
/* Generated from config.h.in during build configuration using CMake. */
// Note: This header file is only used internally. It is not part of public interface!
// ---------------------------------------------------------------------------
// System checks
// Define if you build this library for a MS Windows OS.
#cmakedefine OS_WINDOWS
// Define if you have the <stdint.h> header file.
#cmakedefine HAVE_STDINT_H
// Define if you have the <sys/types.h> header file.
#cmakedefine HAVE_SYS_TYPES_H
// Define if you have the <inttypes.h> header file.
#cmakedefine HAVE_INTTYPES_H
// Define if you have the <sys/stat.h> header file.
#cmakedefine HAVE_SYS_STAT_H
// Define if you have the <unistd.h> header file.
#cmakedefine HAVE_UNISTD_H
// Define if you have the <fnmatch.h> header file.
#cmakedefine HAVE_FNMATCH_H
// Define if you have the <shlwapi.h> header file (Windows 2000/XP).
#cmakedefine HAVE_SHLWAPI_H
// Define if you have the strtoll function.
#cmakedefine HAVE_STRTOLL
// Define if you have the strtoq function.
#cmakedefine HAVE_STRTOQ
// Define if you have the <pthread.h> header file.
#cmakedefine HAVE_PTHREAD
// Define if your pthread library defines the type pthread_rwlock_t
#cmakedefine HAVE_RWLOCK
// gcc requires this to get PRId64, etc.
#if defined(HAVE_INTTYPES_H) && !defined(__STDC_FORMAT_MACROS)
# define __STDC_FORMAT_MACROS 1
#endif
// ---------------------------------------------------------------------------
// Package information
// Name of package.
#define PACKAGE @PROJECT_NAME@
// Define to the full name of this package.
#define PACKAGE_NAME @PACKAGE_NAME@
// Define to the full name and version of this package.
#define PACKAGE_STRING @PACKAGE_STRING@
// Define to the one symbol short name of this package.
#define PACKAGE_TARNAME @PACKAGE_TARNAME@
// Define to the version of this package.
#define PACKAGE_VERSION @PACKAGE_VERSION@
// Version number of package.
#define VERSION PACKAGE_VERSION
// Define to the address where bug reports for this package should be sent.
#define PACKAGE_BUGREPORT @PACKAGE_BUGREPORT@
// ---------------------------------------------------------------------------
// Path separator
#ifndef PATH_SEPARATOR
# ifdef OS_WINDOWS
# define PATH_SEPARATOR '\\'
# else
# define PATH_SEPARATOR '/'
# endif
#endif
// ---------------------------------------------------------------------------
// Windows
// Whether gflags library is a DLL.
#ifndef GFLAGS_IS_A_DLL
# define GFLAGS_IS_A_DLL 0
#endif
// Always export symbols when compiling a shared library as this file is only
// included by internal modules when building the gflags library itself.
// The gflags_declare.h header file will set it to import these symbols otherwise.
#ifndef GFLAGS_DLL_DECL
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
# define GFLAGS_DLL_DECL __declspec(dllexport)
# else
# define GFLAGS_DLL_DECL
# endif
#endif
// Flags defined by the gflags library itself must be exported
#ifndef GFLAGS_DLL_DEFINE_FLAG
# define GFLAGS_DLL_DEFINE_FLAG GFLAGS_DLL_DECL
#endif
#ifdef OS_WINDOWS
// The unittests import the symbols of the shared gflags library
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
# define GFLAGS_DLL_DECL_FOR_UNITTESTS __declspec(dllimport)
# endif
# include "windows_port.h"
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// Copyright (c) 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---
//
// Implement helpful bash-style command line flag completions
//
// ** Functional API:
// HandleCommandLineCompletions() should be called early during
// program startup, but after command line flag code has been
// initialized, such as the beginning of HandleCommandLineHelpFlags().
// It checks the value of the flag --tab_completion_word. If this
// flag is empty, nothing happens here. If it contains a string,
// however, then HandleCommandLineCompletions() will hijack the
// process, attempting to identify the intention behind this
// completion. Regardless of the outcome of this deduction, the
// process will be terminated, similar to --helpshort flag
// handling.
//
// ** Overview of Bash completions:
// Bash can be told to programatically determine completions for the
// current 'cursor word'. It does this by (in this case) invoking a
// command with some additional arguments identifying the command
// being executed, the word being completed, and the previous word
// (if any). Bash then expects a sequence of output lines to be
// printed to stdout. If these lines all contain a common prefix
// longer than the cursor word, bash will replace the cursor word
// with that common prefix, and display nothing. If there isn't such
// a common prefix, bash will display the lines in pages using 'more'.
//
// ** Strategy taken for command line completions:
// If we can deduce either the exact flag intended, or a common flag
// prefix, we'll output exactly that. Otherwise, if information
// must be displayed to the user, we'll take the opportunity to add
// some helpful information beyond just the flag name (specifically,
// we'll include the default flag value and as much of the flag's
// description as can fit on a single terminal line width, as specified
// by the flag --tab_completion_columns). Furthermore, we'll try to
// make bash order the output such that the most useful or relevent
// flags are the most likely to be shown at the top.
//
// ** Additional features:
// To assist in finding that one really useful flag, substring matching
// was implemented. Before pressing a <TAB> to get completion for the
// current word, you can append one or more '?' to the flag to do
// substring matching. Here's the semantics:
// --foo<TAB> Show me all flags with names prefixed by 'foo'
// --foo?<TAB> Show me all flags with 'foo' somewhere in the name
// --foo??<TAB> Same as prior case, but also search in module
// definition path for 'foo'
// --foo???<TAB> Same as prior case, but also search in flag
// descriptions for 'foo'
// Finally, we'll trim the output to a relatively small number of
// flags to keep bash quiet about the verbosity of output. If one
// really wanted to see all possible matches, appending a '+' to the
// search word will force the exhaustive list of matches to be printed.
//
// ** How to have bash accept completions from a binary:
// Bash requires that it be informed about each command that programmatic
// completion should be enabled for. Example addition to a .bashrc
// file would be (your path to gflags_completions.sh file may differ):
/*
$ complete -o bashdefault -o default -o nospace -C \
'/home/build/eng/bash/bash_completions.sh --tab_completion_columns $COLUMNS' \
time env binary_name another_binary [...]
*/
// This would allow the following to work:
// $ /path/to/binary_name --vmodule<TAB>
// Or:
// $ ./bin/path/another_binary --gfs_u<TAB>
// (etc)
//
// Sadly, it appears that bash gives no easy way to force this behavior for
// all commands. That's where the "time" in the above example comes in.
// If you haven't specifically added a command to the list of completion
// supported commands, you can still get completions by prefixing the
// entire command with "env".
// $ env /some/brand/new/binary --vmod<TAB>
// Assuming that "binary" is a newly compiled binary, this should still
// produce the expected completion output.
#ifndef GFLAGS_COMPLETIONS_H_
#define GFLAGS_COMPLETIONS_H_
namespace @GFLAGS_NAMESPACE@ {
extern void HandleCommandLineCompletions(void);
}
#endif // GFLAGS_COMPLETIONS_H_
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
--version
\ No newline at end of file
--foo=bar
--nounused_bool
\ No newline at end of file
--flagfile=flagfile.2
\ No newline at end of file
#include <iostream>
#include <gflags/gflags_declare.h>
DECLARE_string(message); // in gflags_delcare_test.cc
void print_message()
{
std::cout << FLAGS_message << std::endl;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
--test_flag=1
--test_flag=2
This diff is collapsed.
This diff is collapsed.
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