Commit 6f9d4563 authored by Hossain Mahmud's avatar Hossain Mahmud Committed by Christian Schulte zu Berge

"MERGED 4 commits - 1. cleaned up googletest 2. solved std_tuple issue with...

"MERGED 4 commits - 1. cleaned up googletest 2. solved std_tuple issue with four modified files from current beta googletest 3. MTd-MdT issue resolved with CMake flag 4. googletest produces two projects named gtest and gtest-main. a third project is created linked with gtest-main and all our testing libraries"
parent db69d006
......@@ -21,6 +21,8 @@ OPTION(CAMPVIS_BUILD_DOXYGEN "Build Doxygen Documentation"
OPTION(CAMPVIS_DEPLOY_SHADERS "Deploy Shader files to binary directory" OFF)
OPTION(CAMPVIS_GROUP_SOURCE_FILES "Group source files by directory" ON)
OPTION(CAMPVIS_BUILD_GOOGLETEST "Build googletest library" ON)
OPTION(CAMPVIS_BUILD_TEST_SOURCES "Build Unit Tests of gooogletest" ON)
IF(WIN32)
OPTION(CAMPVIS_COPY_EXTERNAL_DLLS "Copy external DLLs to bin directory?" ON)
......@@ -56,6 +58,14 @@ IF(CAMPVIS_BUILD_APPLICATION)
ADD_SUBDIRECTORY(application)
ENDIF()
IF(CAMPVIS_BUILD_GOOGLETEST)
ADD_SUBDIRECTORY(ext/gtest-1.7.0)
ENDIF()
IF(CAMPVIS_BUILD_TEST_SOURCES)
ADD_SUBDIRECTORY(test)
ENDIF()
IF(CAMPVIS_BUILD_DOXYGEN)
ADD_SUBDIRECTORY(doc EXCLUDE_FROM_ALL)
ENDIF()
......
......@@ -41,7 +41,7 @@ int main(int argc, char** argv) {
#ifdef Q_WS_X11
XInitThreads();
#endif
CampVisApplication app(argc, argv);
app.init();
int toReturn = app.run();
......
########################################################################
# CMake build script for Google Test.
#
# To run the tests for Google Test itself on Linux, use 'make test' or
# ctest. You can select which tests to run using 'ctest -R regex'.
# For more options, run 'ctest --help'.
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
# make it prominent in the GUI.
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
# When other libraries are using a shared version of runtime libraries,
# Google Test also has to use one.
option(
gtest_force_shared_crt
"Use shared (DLL) run-time lib even when Google Test is built as static lib."
ON)
##option(gtest_build_tests "Build all of gtest's own tests." OFF)
##option(gtest_build_samples "Build gtest's sample programs." OFF)
option(gtest_disable_pthreads "Disable uses of pthreads in gtest." OFF)
# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().
##include(cmake/hermetic_build.cmake OPTIONAL)
if (COMMAND pre_project_set_up_hermetic_build)
pre_project_set_up_hermetic_build()
endif()
########################################################################
#
# Project-wide settings
# Name of the project.
#
# CMake files in this project can refer to the root source directory
# as ${gtest_SOURCE_DIR} and to the root binary directory as
# ${gtest_BINARY_DIR}.
# Language "C" is required for find_package(Threads).
project(gtest CXX C)
cmake_minimum_required(VERSION 2.6.2)
if (COMMAND set_up_hermetic_build)
set_up_hermetic_build()
endif()
# Define helper functions and macros used by Google Test.
include(cmake/internal_utils.cmake)
config_compiler_and_linker() # Defined in internal_utils.cmake.
# Where Google Test's .h files can be found.
include_directories(
${gtest_SOURCE_DIR}/include
${gtest_SOURCE_DIR})
# Where Google Test's libraries can be found.
link_directories(${gtest_BINARY_DIR}/src)
# Summary of tuple support for Microsoft Visual Studio:
# Compiler version(MS) version(cmake) Support
# ---------- ----------- -------------- -----------------------------
# <= VS 2010 <= 10 <= 1600 Use Google Tests's own tuple.
# VS 2012 11 1700 std::tr1::tuple + _VARIADIC_MAX=10
# VS 2013 12 1800 std::tr1::tuple
if (MSVC AND MSVC_VERSION EQUAL 1700)
add_definitions(/D _VARIADIC_MAX=10)
endif()
########################################################################
#
# Defines the gtest & gtest_main libraries. User tests should link
# with one of them.
# Google Test libraries. We build them using more strict warnings than what
# are used for other targets, to ensure that gtest can be compiled by a user
# aggressive about warnings.
cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
target_link_libraries(gtest_main gtest)
########################################################################
#
# Samples on how to link user tests with gtest or gtest_main.
#
# They are not built by default. To build them, set the
# gtest_build_samples option to ON. You can do it by running ccmake
# or specifying the -Dgtest_build_samples=ON flag when running cmake.
##if (gtest_build_samples)
## cxx_executable(sample1_unittest samples gtest_main samples/sample1.cc)
## cxx_executable(sample2_unittest samples gtest_main samples/sample2.cc)
## cxx_executable(sample3_unittest samples gtest_main)
## cxx_executable(sample4_unittest samples gtest_main samples/sample4.cc)
## cxx_executable(sample5_unittest samples gtest_main samples/sample1.cc)
## cxx_executable(sample6_unittest samples gtest_main)
## cxx_executable(sample7_unittest samples gtest_main)
## cxx_executable(sample8_unittest samples gtest_main)
## cxx_executable(sample9_unittest samples gtest)
## cxx_executable(sample10_unittest samples gtest)
##endif()
########################################################################
#
# Google Test's own tests.
#
# You can skip this section if you aren't interested in testing
# Google Test itself.
#
# The tests are not built by default. To build them, set the
# gtest_build_tests option to ON. You can do it by running ccmake
# or specifying the -Dgtest_build_tests=ON flag when running cmake.
##if (gtest_build_tests)
## # This must be set in the root directory for the tests to be run by
## # 'make test' or ctest.
## enable_testing()
##
## ############################################################
## # C++ tests built with standard compiler flags.
##
## cxx_test(gtest-death-test_test gtest_main)
## cxx_test(gtest_environment_test gtest)
## cxx_test(gtest-filepath_test gtest_main)
## cxx_test(gtest-linked_ptr_test gtest_main)
## cxx_test(gtest-listener_test gtest_main)
## cxx_test(gtest_main_unittest gtest_main)
## cxx_test(gtest-message_test gtest_main)
## cxx_test(gtest_no_test_unittest gtest)
## cxx_test(gtest-options_test gtest_main)
## cxx_test(gtest-param-test_test gtest
## test/gtest-param-test2_test.cc)
## cxx_test(gtest-port_test gtest_main)
## cxx_test(gtest_pred_impl_unittest gtest_main)
## cxx_test(gtest_premature_exit_test gtest
## test/gtest_premature_exit_test.cc)
## cxx_test(gtest-printers_test gtest_main)
## cxx_test(gtest_prod_test gtest_main
## test/production.cc)
## cxx_test(gtest_repeat_test gtest)
## cxx_test(gtest_sole_header_test gtest_main)
## cxx_test(gtest_stress_test gtest)
## cxx_test(gtest-test-part_test gtest_main)
## cxx_test(gtest_throw_on_failure_ex_test gtest)
## cxx_test(gtest-typed-test_test gtest_main
## test/gtest-typed-test2_test.cc)
## cxx_test(gtest_unittest gtest_main)
## cxx_test(gtest-unittest-api_test gtest)
##
## ############################################################
## # C++ tests built with non-standard compiler flags.
##
## # MSVC 7.1 does not support STL with exceptions disabled.
## if (NOT MSVC OR MSVC_VERSION GREATER 1310)
## cxx_library(gtest_no_exception "${cxx_no_exception}"
## src/gtest-all.cc)
## cxx_library(gtest_main_no_exception "${cxx_no_exception}"
## src/gtest-all.cc src/gtest_main.cc)
## endif()
## cxx_library(gtest_main_no_rtti "${cxx_no_rtti}"
## src/gtest-all.cc src/gtest_main.cc)
##
## cxx_test_with_flags(gtest-death-test_ex_nocatch_test
## "${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=0"
## gtest test/gtest-death-test_ex_test.cc)
## cxx_test_with_flags(gtest-death-test_ex_catch_test
## "${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=1"
## gtest test/gtest-death-test_ex_test.cc)
##
## cxx_test_with_flags(gtest_no_rtti_unittest "${cxx_no_rtti}"
## gtest_main_no_rtti test/gtest_unittest.cc)
##
## cxx_shared_library(gtest_dll "${cxx_default}"
## src/gtest-all.cc src/gtest_main.cc)
##
## cxx_executable_with_flags(gtest_dll_test_ "${cxx_default}"
## gtest_dll test/gtest_all_test.cc)
## set_target_properties(gtest_dll_test_
## PROPERTIES
## COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
##
## if (NOT MSVC OR MSVC_VERSION LESS 1600) # 1600 is Visual Studio 2010.
## # Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that
## # conflict with our own definitions. Therefore using our own tuple does not
## # work on those compilers.
## cxx_library(gtest_main_use_own_tuple "${cxx_use_own_tuple}"
## src/gtest-all.cc src/gtest_main.cc)
##
## cxx_test_with_flags(gtest-tuple_test "${cxx_use_own_tuple}"
## gtest_main_use_own_tuple test/gtest-tuple_test.cc)
##
## cxx_test_with_flags(gtest_use_own_tuple_test "${cxx_use_own_tuple}"
## gtest_main_use_own_tuple
## test/gtest-param-test_test.cc test/gtest-param-test2_test.cc)
## endif()
##
## ############################################################
## # Python tests.
##
## cxx_executable(gtest_break_on_failure_unittest_ test gtest)
## py_test(gtest_break_on_failure_unittest)
##
## # Visual Studio .NET 2003 does not support STL with exceptions disabled.
## if (NOT MSVC OR MSVC_VERSION GREATER 1310) # 1310 is Visual Studio .NET 2003
## cxx_executable_with_flags(
## gtest_catch_exceptions_no_ex_test_
## "${cxx_no_exception}"
## gtest_main_no_exception
## test/gtest_catch_exceptions_test_.cc)
## endif()
##
## cxx_executable_with_flags(
## gtest_catch_exceptions_ex_test_
## "${cxx_exception}"
## gtest_main
## test/gtest_catch_exceptions_test_.cc)
## py_test(gtest_catch_exceptions_test)
##
## cxx_executable(gtest_color_test_ test gtest)
## py_test(gtest_color_test)
##
## cxx_executable(gtest_env_var_test_ test gtest)
## py_test(gtest_env_var_test)
##
## cxx_executable(gtest_filter_unittest_ test gtest)
## py_test(gtest_filter_unittest)
##
## cxx_executable(gtest_help_test_ test gtest_main)
## py_test(gtest_help_test)
##
## cxx_executable(gtest_list_tests_unittest_ test gtest)
## py_test(gtest_list_tests_unittest)
##
## cxx_executable(gtest_output_test_ test gtest)
## py_test(gtest_output_test)
##
## cxx_executable(gtest_shuffle_test_ test gtest)
## py_test(gtest_shuffle_test)
##
## # MSVC 7.1 does not support STL with exceptions disabled.
## if (NOT MSVC OR MSVC_VERSION GREATER 1310)
## cxx_executable(gtest_throw_on_failure_test_ test gtest_no_exception)
## set_target_properties(gtest_throw_on_failure_test_
## PROPERTIES
## COMPILE_FLAGS "${cxx_no_exception}")
## py_test(gtest_throw_on_failure_test)
## endif()
##
## cxx_executable(gtest_uninitialized_test_ test gtest)
## py_test(gtest_uninitialized_test)
##
## cxx_executable(gtest_xml_outfile1_test_ test gtest_main)
## cxx_executable(gtest_xml_outfile2_test_ test gtest_main)
## py_test(gtest_xml_outfiles_test)
##
## cxx_executable(gtest_xml_output_unittest_ test gtest)
## py_test(gtest_xml_output_unittest)
##endif()
\ No newline at end of file
Copyright 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.
Google C++ Testing Framework
============================
http://code.google.com/p/googletest/
Overview
--------
Google's framework for writing C++ tests on a variety of platforms
(Linux, Mac OS X, Windows, Windows CE, Symbian, etc). Based on the
xUnit architecture. Supports automatic test discovery, a rich set of
assertions, user-defined assertions, death tests, fatal and non-fatal
failures, various options for running the tests, and XML test report
generation.
Please see the project page above for more information as well as the
mailing list for questions, discussions, and development. There is
also an IRC channel on OFTC (irc.oftc.net) #gtest available. Please
join us!
Requirements for End Users
--------------------------
Google Test is designed to have fairly minimal requirements to build
and use with your projects, but there are some. Currently, we support
Linux, Windows, Mac OS X, and Cygwin. We will also make our best
effort to support other platforms (e.g. Solaris, AIX, and z/OS).
However, since core members of the Google Test project have no access
to these platforms, Google Test may have outstanding issues there. If
you notice any problems on your platform, please notify
googletestframework@googlegroups.com. Patches for fixing them are
even more welcome!
### Linux Requirements ###
These are the base requirements to build and use Google Test from a source
package (as described below):
* GNU-compatible Make or gmake
* POSIX-standard shell
* POSIX(-2) Regular Expressions (regex.h)
* A C++98-standard-compliant compiler
### Windows Requirements ###
* Microsoft Visual C++ 7.1 or newer
### Cygwin Requirements ###
* Cygwin 1.5.25-14 or newer
### Mac OS X Requirements ###
* Mac OS X 10.4 Tiger or newer
* Developer Tools Installed
Also, you'll need CMake 2.6.4 or higher if you want to build the
samples using the provided CMake script, regardless of the platform.
Requirements for Contributors
-----------------------------
We welcome patches. If you plan to contribute a patch, you need to
build Google Test and its own tests from an SVN checkout (described
below), which has further requirements:
* Python version 2.3 or newer (for running some of the tests and
re-generating certain source files from templates)
* CMake 2.6.4 or newer
Getting the Source
------------------
There are two primary ways of getting Google Test's source code: you
can download a stable source release in your preferred archive format,
or directly check out the source from our Subversion (SVN) repositary.
The SVN checkout requires a few extra steps and some extra software
packages on your system, but lets you track the latest development and
make patches much more easily, so we highly encourage it.
### Source Package ###
Google Test is released in versioned source packages which can be
downloaded from the download page [1]. Several different archive
formats are provided, but the only difference is the tools used to
manipulate them, and the size of the resulting file. Download
whichever you are most comfortable with.
[1] http://code.google.com/p/googletest/downloads/list
Once the package is downloaded, expand it using whichever tools you
prefer for that type. This will result in a new directory with the
name "gtest-X.Y.Z" which contains all of the source code. Here are
some examples on Linux:
tar -xvzf gtest-X.Y.Z.tar.gz
tar -xvjf gtest-X.Y.Z.tar.bz2
unzip gtest-X.Y.Z.zip
### SVN Checkout ###
To check out the main branch (also known as the "trunk") of Google
Test, run the following Subversion command:
svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn
Setting up the Build
--------------------
To build Google Test and your tests that use it, you need to tell your
build system where to find its headers and source files. The exact
way to do it depends on which build system you use, and is usually
straightforward.
### Generic Build Instructions ###
Suppose you put Google Test in directory ${GTEST_DIR}. To build it,
create a library build target (or a project as called by Visual Studio
and Xcode) to compile
${GTEST_DIR}/src/gtest-all.cc
with ${GTEST_DIR}/include in the system header search path and ${GTEST_DIR}
in the normal header search path. Assuming a Linux-like system and gcc,
something like the following will do:
g++ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \
-pthread -c ${GTEST_DIR}/src/gtest-all.cc
ar -rv libgtest.a gtest-all.o
(We need -pthread as Google Test uses threads.)
Next, you should compile your test source file with
${GTEST_DIR}/include in the system header search path, and link it
with gtest and any other necessary libraries:
g++ -isystem ${GTEST_DIR}/include -pthread path/to/your_test.cc libgtest.a \
-o your_test
As an example, the make/ directory contains a Makefile that you can
use to build Google Test on systems where GNU make is available
(e.g. Linux, Mac OS X, and Cygwin). It doesn't try to build Google
Test's own tests. Instead, it just builds the Google Test library and
a sample test. You can use it as a starting point for your own build
script.
If the default settings are correct for your environment, the
following commands should succeed:
cd ${GTEST_DIR}/make
make
./sample1_unittest
If you see errors, try to tweak the contents of make/Makefile to make
them go away. There are instructions in make/Makefile on how to do
it.
### Using CMake ###
Google Test comes with a CMake build script (CMakeLists.txt) that can
be used on a wide range of platforms ("C" stands for cross-platofrm.).
If you don't have CMake installed already, you can download it for
free from http://www.cmake.org/.
CMake works by generating native makefiles or build projects that can
be used in the compiler environment of your choice. The typical
workflow starts with:
mkdir mybuild # Create a directory to hold the build output.
cd mybuild
cmake ${GTEST_DIR} # Generate native build scripts.
If you want to build Google Test's samples, you should replace the
last command with
cmake -Dgtest_build_samples=ON ${GTEST_DIR}
If you are on a *nix system, you should now see a Makefile in the
current directory. Just type 'make' to build gtest.
If you use Windows and have Vistual Studio installed, a gtest.sln file
and several .vcproj files will be created. You can then build them
using Visual Studio.
On Mac OS X with Xcode installed, a .xcodeproj file will be generated.
### Legacy Build Scripts ###
Before settling on CMake, we have been providing hand-maintained build
projects/scripts for Visual Studio, Xcode, and Autotools. While we
continue to provide them for convenience, they are not actively
maintained any more. We highly recommend that you follow the
instructions in the previous two sections to integrate Google Test
with your existing build system.
If you still need to use the legacy build scripts, here's how:
The msvc\ folder contains two solutions with Visual C++ projects.
Open the gtest.sln or gtest-md.sln file using Visual Studio, and you
are ready to build Google Test the same way you build any Visual
Studio project. Files that have names ending with -md use DLL
versions of Microsoft runtime libraries (the /MD or the /MDd compiler
option). Files without that suffix use static versions of the runtime
libraries (the /MT or the /MTd option). Please note that one must use
the same option to compile both gtest and the test code. If you use
Visual Studio 2005 or above, we recommend the -md version as /MD is
the default for new projects in these versions of Visual Studio.
On Mac OS X, open the gtest.xcodeproj in the xcode/ folder using
Xcode. Build the "gtest" target. The universal binary framework will
end up in your selected build directory (selected in the Xcode
"Preferences..." -> "Building" pane and defaults to xcode/build).
Alternatively, at the command line, enter:
xcodebuild
This will build the "Release" configuration of gtest.framework in your
default build location. See the "xcodebuild" man page for more
information about building different configurations and building in
different locations.
If you wish to use the Google Test Xcode project with Xcode 4.x and
above, you need to either:
* update the SDK configuration options in xcode/Config/General.xconfig.
Comment options SDKROOT, MACOS_DEPLOYMENT_TARGET, and GCC_VERSION. If
you choose this route you lose the ability to target earlier versions
of MacOS X.
* Install an SDK for an earlier version. This doesn't appear to be
supported by Apple, but has been reported to work
(http://stackoverflow.com/questions/5378518).
Tweaking Google Test
--------------------
Google Test can be used in diverse environments. The default
configuration may not work (or may not work well) out of the box in
some environments. However, you can easily tweak Google Test by
defining control macros on the compiler command line. Generally,
these macros are named like GTEST_XYZ and you define them to either 1
or 0 to enable or disable a certain feature.
We list the most frequently used macros below. For a complete list,
see file include/gtest/internal/gtest-port.h.
### Choosing a TR1 Tuple Library ###
Some Google Test features require the C++ Technical Report 1 (TR1)
tuple library, which is not yet available with all compilers. The
good news is that Google Test implements a subset of TR1 tuple that's
enough for its own need, and will automatically use this when the
compiler doesn't provide TR1 tuple.
Usually you don't need to care about which tuple library Google Test
uses. However, if your project already uses TR1 tuple, you need to
tell Google Test to use the same TR1 tuple library the rest of your
project uses, or the two tuple implementations will clash. To do
that, add
-DGTEST_USE_OWN_TR1_TUPLE=0
to the compiler flags while compiling Google Test and your tests. If
you want to force Google Test to use its own tuple library, just add
-DGTEST_USE_OWN_TR1_TUPLE=1
to the compiler flags instead.
If you don't want Google Test to use tuple at all, add
-DGTEST_HAS_TR1_TUPLE=0
and all features using tuple will be disabled.
### Multi-threaded Tests ###
Google Test is thread-safe where the pthread library is available.
After #include "gtest/gtest.h", you can check the GTEST_IS_THREADSAFE
macro to see whether this is the case (yes if the macro is #defined to
1, no if it's undefined.).
If Google Test doesn't correctly detect whether pthread is available
in your environment, you can force it with
-DGTEST_HAS_PTHREAD=1
or
-DGTEST_HAS_PTHREAD=0
When Google Test uses pthread, you may need to add flags to your
compiler and/or linker to select the pthread library, or you'll get
link errors. If you use the CMake script or the deprecated Autotools
script, this is taken care of for you. If you use your own build
script, you'll need to read your compiler and linker's manual to
figure out what flags to add.
### As a Shared Library (DLL) ###
Google Test is compact, so most users can build and link it as a
static library for the simplicity. You can choose to use Google Test
as a shared library (known as a DLL on Windows) if you prefer.
To compile *gtest* as a shared library, add
-DGTEST_CREATE_SHARED_LIBRARY=1
to the compiler flags. You'll also need to tell the linker to produce
a shared library instead - consult your linker's manual for how to do
it.
To compile your *tests* that use the gtest shared library, add
-DGTEST_LINKED_AS_SHARED_LIBRARY=1
to the compiler flags.
Note: while the above steps aren't technically necessary today when