add_library (gflags ${GFLAGS_SRCS})
# ----------------------------------------------------------------------------
+# testing
+
+# TODO(andreas) Replace Bash scripts such that tests can be run on Windows (e.g., Python).
+# The gflags_unittest.sh script should best be replaced by multiple
+# add_test commands in the test/CMakeLists.txt file.
+if (UNIX)
+ include (CTest)
+ if (BUILD_TESTING)
+ enable_testing ()
+ add_subdirectory (test)
+ endif ()
+endif ()
+
+# ----------------------------------------------------------------------------
# installation
if (WIN32)
set (RUNTIME_INSTALL_DIR Bin)
--- /dev/null
+## gflags tests
+
+# ----------------------------------------------------------------------------
+# output directories
+set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Testing/bin")
+set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Testing/lib")
+set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Testing/lib")
+
+set (TEMPDIR "${PROJECT_BINARY_DIR}/Testing/Temporary")
+
+# ----------------------------------------------------------------------------
+# common link libraries
+link_libraries (gflags)
+
+# ----------------------------------------------------------------------------
+# test executables
+add_executable (strip_flags gflags_strip_flags_test.cc)
+add_executable (unittest gflags_unittest.cc)
+
+# ----------------------------------------------------------------------------
+# test commands
+add_test (
+ NAME strip_flags
+ COMMAND /bin/bash "${CMAKE_CURRENT_SOURCE_DIR}/gflags_strip_flags_test.sh"
+ "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/strip_flags"
+)
+
+add_test (
+ NAME unittest
+ COMMAND /bin/bash "${CMAKE_CURRENT_SOURCE_DIR}/gflags_unittest.sh"
+ "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest"
+ "${CMAKE_CURRENT_SOURCE_DIR}" # <srcdir>
+ "${TEMPDIR}/unittest" # <tempdir>
+)
// works. But don't bother on windows; the windows port is so new
// it never had the old location-names.
#ifndef _MSC_VER
-#include <google/gflags_completions.h>
-void (*unused_fn)() = &GOOGLE_NAMESPACE::HandleCommandLineCompletions;
+#include <gflags/gflags_completions.h>
+void (*unused_fn)() = &GFLAGS_NAMESPACE::HandleCommandLineCompletions;
#endif
using std::string;
using std::vector;
-using GOOGLE_NAMESPACE::int32;
-using GOOGLE_NAMESPACE::FlagRegisterer;
-using GOOGLE_NAMESPACE::StringFromEnv;
-using GOOGLE_NAMESPACE::RegisterFlagValidator;
-using GOOGLE_NAMESPACE::CommandLineFlagInfo;
-using GOOGLE_NAMESPACE::GetAllFlags;
+using GFLAGS_NAMESPACE::int32;
+using GFLAGS_NAMESPACE::FlagRegisterer;
+using GFLAGS_NAMESPACE::StringFromEnv;
+using GFLAGS_NAMESPACE::RegisterFlagValidator;
+using GFLAGS_NAMESPACE::CommandLineFlagInfo;
+using GFLAGS_NAMESPACE::GetAllFlags;
DEFINE_string(test_tmpdir, "/tmp/gflags_unittest", "Dir we use for temp files");
#ifdef _MSC_VER // in MSVC, we run from the vsprojects directory
}
using fLI::FLAGS_tldflag2;
-_START_GOOGLE_NAMESPACE_
+namespace GFLAGS_NAMESPACE {
namespace {
// Must be called after ParseCommandLineFlags().
static const char* GetFlagFileFlag() {
#ifdef _MSC_VER
- static const string flagfile = FLAGS_srcdir + "\\src\\gflags_unittest_flagfile";
+ static const string flagfile = FLAGS_srcdir + "\\gflags_unittest_flagfile";
#else
- static const string flagfile = FLAGS_srcdir + "/src/gflags_unittest_flagfile";
+ static const string flagfile = FLAGS_srcdir + "/gflags_unittest_flagfile";
#endif
static const string flagfile_flag = string("--flagfile=") + flagfile;
return flagfile_flag.c_str();
return exit_status;
}
-_END_GOOGLE_NAMESPACE_
+} // GFLAGS_NAMESPACE
int main(int argc, char** argv) {
- return GOOGLE_NAMESPACE::main(argc, argv);
+ return GFLAGS_NAMESPACE::main(argc, argv);
}