Showing preview only (789K chars total). Download the full file or copy to clipboard to get everything.
Repository: ttroy50/cmake-examples
Branch: master
Commit: 2b27fc75c404
Files: 184
Total size: 736.6 KB
Directory structure:
gitextract_noztjd02/
├── .gitignore
├── .travis.yml
├── 01-basic/
│ ├── A-hello-cmake/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ └── main.cpp
│ ├── B-hello-headers/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ ├── include/
│ │ │ └── Hello.h
│ │ └── src/
│ │ ├── Hello.cpp
│ │ └── main.cpp
│ ├── C-static-library/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ ├── include/
│ │ │ └── static/
│ │ │ └── Hello.h
│ │ └── src/
│ │ ├── Hello.cpp
│ │ └── main.cpp
│ ├── D-shared-library/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ ├── include/
│ │ │ └── shared/
│ │ │ └── Hello.h
│ │ └── src/
│ │ ├── Hello.cpp
│ │ └── main.cpp
│ ├── E-installing/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ ├── cmake-examples.conf
│ │ ├── include/
│ │ │ └── installing/
│ │ │ └── Hello.h
│ │ └── src/
│ │ ├── Hello.cpp
│ │ └── main.cpp
│ ├── F-build-type/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ └── main.cpp
│ ├── G-compile-flags/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ └── main.cpp
│ ├── H-third-party-library/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ └── main.cpp
│ ├── I-compiling-with-clang/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ ├── main.cpp
│ │ ├── pre_test.sh
│ │ └── run_test.sh
│ ├── J-building-with-ninja/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ ├── main.cpp
│ │ ├── pre_test.sh
│ │ └── run_test.sh
│ ├── K-imported-targets/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ ├── main.cpp
│ │ └── run_test.sh
│ ├── L-cpp-standard/
│ │ ├── README.adoc
│ │ ├── i-common-method/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── README.adoc
│ │ │ └── main.cpp
│ │ ├── ii-cxx-standard/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── README.adoc
│ │ │ └── main.cpp
│ │ └── iii-compile-features/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ └── main.cpp
│ └── README.adoc
├── 02-sub-projects/
│ ├── A-basic/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ ├── subbinary/
│ │ │ ├── CMakeLists.txt
│ │ │ └── main.cpp
│ │ ├── sublibrary1/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── include/
│ │ │ │ └── sublib1/
│ │ │ │ └── sublib1.h
│ │ │ └── src/
│ │ │ └── sublib1.cpp
│ │ └── sublibrary2/
│ │ ├── CMakeLists.txt
│ │ └── include/
│ │ └── sublib2/
│ │ └── sublib2.h
│ └── README.adoc
├── 03-code-generation/
│ ├── README.adoc
│ ├── configure-files/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ ├── main.cpp
│ │ ├── path.h.in
│ │ └── ver.h.in
│ └── protobuf/
│ ├── AddressBook.proto
│ ├── CMakeLists.txt
│ ├── README.adoc
│ └── main.cpp
├── 04-static-analysis/
│ ├── README.adoc
│ ├── clang-analyzer/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ ├── run_test.sh
│ │ ├── subproject1/
│ │ │ ├── CMakeLists.txt
│ │ │ └── main1.cpp
│ │ └── subproject2/
│ │ ├── CMakeLists.txt
│ │ └── main2.cpp
│ ├── clang-format/
│ │ ├── .clang-format
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ ├── cmake/
│ │ │ ├── modules/
│ │ │ │ ├── FindClangFormat.cmake
│ │ │ │ └── clang-format.cmake
│ │ │ └── scripts/
│ │ │ ├── clang-format-check-changed
│ │ │ └── clang-format-check-changed.py
│ │ ├── run_test.sh
│ │ ├── subproject1/
│ │ │ ├── CMakeLists.txt
│ │ │ └── main1.cpp
│ │ └── subproject2/
│ │ ├── CMakeLists.txt
│ │ └── main2.cpp
│ ├── cppcheck/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ ├── cmake/
│ │ │ ├── analysis.cmake
│ │ │ └── modules/
│ │ │ └── FindCppCheck.cmake
│ │ ├── run_test.sh
│ │ ├── subproject1/
│ │ │ ├── CMakeLists.txt
│ │ │ └── main1.cpp
│ │ └── subproject2/
│ │ ├── CMakeLists.txt
│ │ └── main2.cpp
│ └── cppcheck-compile-commands/
│ ├── .cppcheck_suppressions
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── cmake/
│ │ └── modules/
│ │ └── FindCppCheck.cmake
│ ├── run_test.sh
│ ├── subproject1/
│ │ ├── CMakeLists.txt
│ │ └── main1.cpp
│ └── subproject2/
│ ├── CMakeLists.txt
│ └── main2.cpp
├── 05-unit-testing/
│ ├── README.adoc
│ ├── boost/
│ │ ├── CMakeLists.txt
│ │ ├── Palindrome.cpp
│ │ ├── Palindrome.h
│ │ ├── README.adoc
│ │ ├── Reverse.cpp
│ │ ├── Reverse.h
│ │ ├── main.cpp
│ │ ├── post_test.sh
│ │ └── unit_tests.cpp
│ ├── catch2-vendored/
│ │ ├── 3rd_party/
│ │ │ └── catch2/
│ │ │ ├── CMakeLists.txt
│ │ │ └── catch2/
│ │ │ └── catch.hpp
│ │ ├── CMakeLists.txt
│ │ ├── Palindrome.cpp
│ │ ├── Palindrome.h
│ │ ├── README.adoc
│ │ ├── Reverse.cpp
│ │ ├── Reverse.h
│ │ ├── main.cpp
│ │ ├── post_test.sh
│ │ └── unit_tests.cpp
│ └── google-test-download/
│ ├── 3rd_party/
│ │ └── google-test/
│ │ ├── CMakeLists.txt
│ │ └── CMakeLists.txt.in
│ ├── CMakeLists.txt
│ ├── Palindrome.cpp
│ ├── Palindrome.h
│ ├── README.adoc
│ ├── Reverse.cpp
│ ├── Reverse.h
│ ├── main.cpp
│ ├── post_test.sh
│ ├── run_test.sh
│ └── unit_tests.cpp
├── 06-installer/
│ ├── README.adoc
│ └── deb/
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── cmake-examples.conf
│ ├── include/
│ │ └── Hello.h
│ ├── post_test.sh
│ └── src/
│ ├── Hello.cpp
│ └── main.cpp
├── 07-package-management/
│ ├── A-using-system-provide-packages/
│ │ └── README.adoc
│ ├── B-vendoring-code/
│ │ └── README.adoc
│ ├── C-external-project-add/
│ │ └── README.adoc
│ ├── D-conan/
│ │ ├── README.adoc
│ │ ├── i-basic/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── README.adoc
│ │ │ ├── conanfile.txt
│ │ │ ├── main.cpp
│ │ │ └── run_test.sh
│ │ └── ii-basic-targets/
│ │ ├── CMakeLists.txt
│ │ ├── README.adoc
│ │ ├── conanfile.txt
│ │ ├── main.cpp
│ │ └── run_test.sh
│ └── README.adoc
├── LICENSE
├── README.adoc
├── cmake-examples.sublime-project
├── dockerfiles/
│ ├── README.adoc
│ ├── setup.sh
│ ├── ubuntu14.04-cmake-3.4.3
│ ├── ubuntu14.04-default-2.8.12.2
│ ├── ubuntu16.04-cmake-3.10.3
│ └── ubuntu16.04-default-cmake-3.5.1
└── test.sh
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
CMakeCache.txt
CMakeFiles
Makefile
cmake_install.cmake
install_manifest.txt
#
# Sublime Test
#
# cache files for sublime text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
# workspace files are user-specific
*.sublime-workspace
# project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using SublimeText
# *.sublime-project
#
# C / C++
#
# Compiled Object files
*.slo
*.lo
*.o
*.obj
*.ko
*.elf
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
*.so.*
*.dylib
# Fortran module files
*.mod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
*.lo
# Executables
*.exe
*.out
*.app
/**/build
/**/build.*
.tags
.vscode
================================================
FILE: .travis.yml
================================================
language: cpp
services:
- docker
sudo: required
compiler:
- gcc
before_install:
- docker pull matrim/cmake-examples:3.5.1
- docker pull matrim/cmake-examples:3.10.3
script:
- docker run --rm -v $PWD:/data/code -e DEV_UID=`id -u` -e DEV_GID=`id -g` -it matrim/cmake-examples:3.5.1 /data/code/test.sh
- docker run --rm -v $PWD:/data/code -e DEV_UID=`id -u` -e DEV_GID=`id -g` -it matrim/cmake-examples:3.10.3 /data/code/test.sh
branches:
except:
- gh-pages
notifications:
email: true
os:
- linux
================================================
FILE: 01-basic/A-hello-cmake/CMakeLists.txt
================================================
# Set the minimum version of CMake that can be used
# To find the cmake version run
# $ cmake --version
cmake_minimum_required(VERSION 3.5)
# Set the project name
project (hello_cmake)
# Add an executable
add_executable(hello_cmake main.cpp)
================================================
FILE: 01-basic/A-hello-cmake/README.adoc
================================================
= Hello CMake
:toc:
:toc-placement!:
toc::[]
# Introduction
Shows a very basic hello world example.
The files in this tutorial are below:
```
A-hello-cmake$ tree
.
├── CMakeLists.txt
├── main.cpp
```
* link:CMakeLists.txt[CMakeLists.txt] - Contains the CMake commands you wish to run
* link:main.cpp[main.cpp] - A simple "Hello World" cpp file.
# Concepts
### CMakeLists.txt
CMakeLists.txt is the file which should store all your CMake commands. When
cmake is run in a folder it will look for this file and if it does not exist cmake
will exit with an error.
### Minimum CMake version
When creating a project using CMake, you can specify the minimum version
of CMake that is supported.
[source,cmake]
----
cmake_minimum_required(VERSION 3.5)
----
### Projects
A CMake build can include a project name to make referencing certain
variables easier when using multiple projects.
[source,cmake]
----
project (hello_cmake)
----
### Creating an Executable
The +add_executable()+ command specifies that an executable should be
build from the specified source files, in this example main.cpp. The
first argument to the +add_executable()+ function is the name of the
executable to be built, and the second argument is the list of source files to compile.
[source,cmake]
----
add_executable(hello_cmake main.cpp)
----
[NOTE]
====
A shorthand that some people use is to have the project name and
executable name the same. This allows you to specify the CMakeLists.txt
as follows,
[source,cmake]
----
cmake_minimum_required(VERSION 2.6)
project (hello_cmake)
add_executable(${PROJECT_NAME} main.cpp)
----
In this example, the +project()+ function, will create a variable
+${PROJECT_NAME}+ with the value hello_cmake. This can then be passed to
the +add_executable()+ function to output a 'hello_cmake' executable.
====
### Binary Directory
The root or top level folder that you run the cmake command from is known as your
CMAKE_BINARY_DIR and is the root folder for all your binary files.
CMake supports building and generating your binary files both in-place and also
out-of-source.
#### In-Place Build
In-place builds generate all temporary build files in the same directory structure
as the source code. This means that all Makefiles and object files are interspersed
with your normal code. To create an in-place build target run the cmake command
in your root directory. For example:
[source,bash]
----
A-hello-cmake$ cmake .
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/A-hello-cmake
A-hello-cmake$ tree
.
├── CMakeCache.txt
├── CMakeFiles
│ ├── 2.8.12.2
│ │ ├── CMakeCCompiler.cmake
│ │ ├── CMakeCXXCompiler.cmake
│ │ ├── CMakeDetermineCompilerABI_C.bin
│ │ ├── CMakeDetermineCompilerABI_CXX.bin
│ │ ├── CMakeSystem.cmake
│ │ ├── CompilerIdC
│ │ │ ├── a.out
│ │ │ └── CMakeCCompilerId.c
│ │ └── CompilerIdCXX
│ │ ├── a.out
│ │ └── CMakeCXXCompilerId.cpp
│ ├── cmake.check_cache
│ ├── CMakeDirectoryInformation.cmake
│ ├── CMakeOutput.log
│ ├── CMakeTmp
│ ├── hello_cmake.dir
│ │ ├── build.make
│ │ ├── cmake_clean.cmake
│ │ ├── DependInfo.cmake
│ │ ├── depend.make
│ │ ├── flags.make
│ │ ├── link.txt
│ │ └── progress.make
│ ├── Makefile2
│ ├── Makefile.cmake
│ ├── progress.marks
│ └── TargetDirectories.txt
├── cmake_install.cmake
├── CMakeLists.txt
├── main.cpp
├── Makefile
----
#### Out-of-Source Build
Out-of-source builds allow you to create a single build folder that can be anywhere on
your file system. All temporary build and object files are located in this directory keeping
your source tree clean. To create an out-of-source build run the cmake command in
the build folder and point it to the directory with your root CMakeLists.txt file.
Using out-of-source builds if you want to recreate your cmake environment
from scratch, you only need to delete your build directory and then rerun cmake.
For example:
[source,bash]
----
A-hello-cmake$ mkdir build
A-hello-cmake$ cd build/
matrim@freyr:~/workspace/cmake-examples/01-basic/A-hello-cmake/build$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/A-hello-cmake/build
A-hello-cmake/build$ cd ..
A-hello-cmake$ tree
.
├── build
│ ├── CMakeCache.txt
│ ├── CMakeFiles
│ │ ├── 2.8.12.2
│ │ │ ├── CMakeCCompiler.cmake
│ │ │ ├── CMakeCXXCompiler.cmake
│ │ │ ├── CMakeDetermineCompilerABI_C.bin
│ │ │ ├── CMakeDetermineCompilerABI_CXX.bin
│ │ │ ├── CMakeSystem.cmake
│ │ │ ├── CompilerIdC
│ │ │ │ ├── a.out
│ │ │ │ └── CMakeCCompilerId.c
│ │ │ └── CompilerIdCXX
│ │ │ ├── a.out
│ │ │ └── CMakeCXXCompilerId.cpp
│ │ ├── cmake.check_cache
│ │ ├── CMakeDirectoryInformation.cmake
│ │ ├── CMakeOutput.log
│ │ ├── CMakeTmp
│ │ ├── hello_cmake.dir
│ │ │ ├── build.make
│ │ │ ├── cmake_clean.cmake
│ │ │ ├── DependInfo.cmake
│ │ │ ├── depend.make
│ │ │ ├── flags.make
│ │ │ ├── link.txt
│ │ │ └── progress.make
│ │ ├── Makefile2
│ │ ├── Makefile.cmake
│ │ ├── progress.marks
│ │ └── TargetDirectories.txt
│ ├── cmake_install.cmake
│ └── Makefile
├── CMakeLists.txt
├── main.cpp
----
All examples in this tutorial will use out-of-source builds.
# Building the Examples
Below is sample output from building this example.
[source,bash]
----
$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /workspace/cmake-examples/01-basic/hello_cmake/build
$ make
Scanning dependencies of target hello_cmake
[100%] Building CXX object CMakeFiles/hello_cmake.dir/hello_cmake.cpp.o
Linking CXX executable hello_cmake
[100%] Built target hello_cmake
$ ./hello_cmake
Hello CMake!
----
================================================
FILE: 01-basic/A-hello-cmake/main.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello CMake!" << std::endl;
return 0;
}
================================================
FILE: 01-basic/B-hello-headers/CMakeLists.txt
================================================
# Set the minimum version of CMake that can be used
# To find the cmake version run
# $ cmake --version
cmake_minimum_required(VERSION 3.5)
# Set the project name
project (hello_headers)
# Create a sources variable with a link to all cpp files to compile
set(SOURCES
src/Hello.cpp
src/main.cpp
)
# Add an executable with the above sources
add_executable(hello_headers ${SOURCES})
# Set the directories that should be included in the build command for this target
# when running g++ these will be included as -I/directory/path/
target_include_directories(hello_headers
PRIVATE
${PROJECT_SOURCE_DIR}/include
)
================================================
FILE: 01-basic/B-hello-headers/README.adoc
================================================
= Hello Headers
:toc:
:toc-placement!:
toc::[]
# Introduction
Shows a hello world example which uses a different folder for source and include
files.
The files in this tutorial include:
```
B-hello-headers$ tree
.
├── CMakeLists.txt
├── include
│ └── Hello.h
└── src
├── Hello.cpp
└── main.cpp
```
* link:CMakeLists.txt[CMakeLists.txt] - Contains the CMake commands you wish to run.
* link:include/Hello.h[include/Hello.h] - The header file to include.
* link:src/Hello.cpp[src/Hello.cpp] - A source file to compile.
* link:src/main.cpp[src/main.cpp] - The source file with main.
# Concepts
## Directory Paths
CMake syntax specifies a number of https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/Useful-Variables[variables]
which can be used to help find useful directories in your project or source tree.
Some of these include:
[cols=",",options="header",]
|=======================================================================
|Variable |Info
|CMAKE_SOURCE_DIR |The root source directory
|CMAKE_CURRENT_SOURCE_DIR |The current source directory if using
sub-projects and directories.
|PROJECT_SOURCE_DIR |The source directory of the current cmake project.
|CMAKE_BINARY_DIR |The root binary / build directory. This is the
directory where you ran the cmake command.
|CMAKE_CURRENT_BINARY_DIR |The build directory you are currently in.
|PROJECT_BINARY_DIR |The build directory for the current project.
|=======================================================================
## Source Files Variable
Creating a variable which includes the source files allows you to be
clearer about these files and easily add them to multiple commands, for example,
the +add_executable()+ function.
[source,cmake]
----
# Create a sources variable with a link to all cpp files to compile
set(SOURCES
src/Hello.cpp
src/main.cpp
)
add_executable(${PROJECT_NAME} ${SOURCES})
----
[NOTE]
====
An alternative to setting specific file names in the +SOURCES+ variable is
to use a GLOB command to find files using wildcard pattern matching.
[source,cmake]
----
file(GLOB SOURCES "src/*.cpp")
----
====
[TIP]
====
For modern CMake it is NOT recommended to use a variable for sources. Instead it is
typical to directly declare the sources in the add_xxx function.
This is particularly important for glob commands which may not always show you the
correct results if you add a new source file.
====
## Including Directories
When you have different include folders, you can make your compiler aware of them using the
+target_include_directories()+ link:https://cmake.org/cmake/help/v3.0/command/target_include_directories.html[function]. When compiling this target this will add these directories to the compiler with the -I flag e.g. `-I/directory/path`
[source,cmake]
----
target_include_directories(target
PRIVATE
${PROJECT_SOURCE_DIR}/include
)
----
The +PRIVATE+ identifier specifies the scope of the include. This is important for libraries and is explained in the next example. More details on the function is available link:https://cmake.org/cmake/help/v3.0/command/target_include_directories.html[here]
# Building the Example
## Standard Output
The standard output from building this example is presented below.
[source,bash]
----
$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build
$ make
Scanning dependencies of target hello_headers
[ 50%] Building CXX object CMakeFiles/hello_headers.dir/src/Hello.cpp.o
[100%] Building CXX object CMakeFiles/hello_headers.dir/src/main.cpp.o
Linking CXX executable hello_headers
[100%] Built target hello_headers
$ ./hello_headers
Hello Headers!
----
## Verbose Output
In the previous examples, when running the make command the output only
shows the status of the build. To see the full output for debugging
purposes you can add +VERBOSE=1+ flag when running make.
The VERBOSE output is show below, and a examination of the output shows
the include directories being added to the c++ compiler command.
[source,bash]
----
$ make clean
$ make VERBOSE=1
/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/01-basic/hello_headers -B/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build'
make -f CMakeFiles/hello_headers.dir/build.make CMakeFiles/hello_headers.dir/depend
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build'
cd /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/matrim/workspace/cmake-examples/01-basic/hello_headers /home/matrim/workspace/cmake-examples/01-basic/hello_headers /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles/hello_headers.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build'
make -f CMakeFiles/hello_headers.dir/build.make CMakeFiles/hello_headers.dir/build
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles 1
[ 50%] Building CXX object CMakeFiles/hello_headers.dir/src/Hello.cpp.o
/usr/bin/c++ -I/home/matrim/workspace/cmake-examples/01-basic/hello_headers/include -o CMakeFiles/hello_headers.dir/src/Hello.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/hello_headers/src/Hello.cpp
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles 2
[100%] Building CXX object CMakeFiles/hello_headers.dir/src/main.cpp.o
/usr/bin/c++ -I/home/matrim/workspace/cmake-examples/01-basic/hello_headers/include -o CMakeFiles/hello_headers.dir/src/main.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/hello_headers/src/main.cpp
Linking CXX executable hello_headers
/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_headers.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/hello_headers.dir/src/Hello.cpp.o CMakeFiles/hello_headers.dir/src/main.cpp.o -o hello_headers -rdynamic
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles 1 2
[100%] Built target hello_headers
make[1]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build'
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles 0
----
================================================
FILE: 01-basic/B-hello-headers/include/Hello.h
================================================
#ifndef __HELLO_H__
#define __HELLO_H__
class Hello
{
public:
void print();
};
#endif
================================================
FILE: 01-basic/B-hello-headers/src/Hello.cpp
================================================
#include <iostream>
#include "Hello.h"
void Hello::print()
{
std::cout << "Hello Headers!" << std::endl;
}
================================================
FILE: 01-basic/B-hello-headers/src/main.cpp
================================================
#include "Hello.h"
int main(int argc, char *argv[])
{
Hello hi;
hi.print();
return 0;
}
================================================
FILE: 01-basic/C-static-library/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.5)
project(hello_library)
############################################################
# Create a library
############################################################
#Generate the static library from the library sources
add_library(hello_library STATIC
src/Hello.cpp
)
target_include_directories(hello_library
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
############################################################
# Create an executable
############################################################
# Add an executable with the above sources
add_executable(hello_binary
src/main.cpp
)
# link the new hello_library target with the hello_binary target
target_link_libraries( hello_binary
PRIVATE
hello_library
)
================================================
FILE: 01-basic/C-static-library/README.adoc
================================================
= Static Library
:toc:
:toc-placement!:
toc::[]
# Introduction
Shows a hello world example which first creates and links a static library. This is a
simplified example showing the library and binary in the same folder. Typically
these would be in sub-projects as described in section link:../../02-sub-projects[02-sub-projects]
The files in this tutorial are below:
```
$ tree
.
├── CMakeLists.txt
├── include
│ └── static
│ └── Hello.h
└── src
├── Hello.cpp
└── main.cpp
```
* link:CMakeLists.txt[] - Contains the CMake commands you wish to run
* link:include/static/Hello.h[] - The header file to include
* link:src/Hello.cpp[] - A source file to compile
* link:src/main.cpp[] - The source file with main
# Concepts
## Adding a Static Library
The +add_library()+ function is used to create a library from some source files.
This is called as follows:
[source,cmake]
----
add_library(hello_library STATIC
src/Hello.cpp
)
----
This will be used to create a static library with the name libhello_library.a with
the sources in the +add_library+ call.
[NOTE]
====
As mentioned in the previous example, we pass the source files directly to the
+add_library+ call, as recommended for modern CMake.
====
## Populating Including Directories
In this example, we include directories in the library using the +target_include_directories()+ function with the scope set to +PUBLIC+.
[source,cmake]
----
target_include_directories(hello_library
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
----
This will cause the included directory used in the following places:
* When compiling the library
* When compiling any additional target that links the library.
The meaning of scopes are:
* +PRIVATE+ - the directory is added to this target's include directories
* +INTERFACE+ - the directory is added to the include directories for any targets that link this library.
* +PUBLIC+ - As above, it is included in this library and also any targets that link this library.
[TIP]
====
For public headers it is often a good idea to have your include folder be "namespaced"
with sub-directories.
The directory passed to +target_include_directories+ will be the root of your
include directory tree and your C++ files should include the path from there to your header.
For this example you can see that we do it as follows:
[source,cpp]
----
#include "static/Hello.h"
----
Using this method means that there is less chance of header filename clashes when
you use multiple libraries in your project.
====
## Linking a Library
When creating an executable that will use your library you must tell the compiler
about the library. This can be done using the +target_link_libraries()+ function.
[source,cmake]
----
add_executable(hello_binary
src/main.cpp
)
target_link_libraries( hello_binary
PRIVATE
hello_library
)
----
This tells CMake to link the hello_library against the hello_binary executable
during link time. It will also propagate any include directories with +PUBLIC+ or +INTERFACE+ scope
from the linked library target.
An example of this being called by the compiler is
```
/usr/bin/c++ CMakeFiles/hello_binary.dir/src/main.cpp.o -o hello_binary -rdynamic libhello_library.a
```
# Building the Example
[source,bash]
----
$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/C-static-library/build
$ make
Scanning dependencies of target hello_library
[ 50%] Building CXX object CMakeFiles/hello_library.dir/src/Hello.cpp.o
Linking CXX static library libhello_library.a
[ 50%] Built target hello_library
Scanning dependencies of target hello_binary
[100%] Building CXX object CMakeFiles/hello_binary.dir/src/main.cpp.o
Linking CXX executable hello_binary
[100%] Built target hello_binary
$ ls
CMakeCache.txt CMakeFiles cmake_install.cmake hello_binary libhello_library.a Makefile
$ ./hello_binary
Hello Static Library!
----
================================================
FILE: 01-basic/C-static-library/include/static/Hello.h
================================================
#ifndef __HELLO_H__
#define __HELLO_H__
class Hello
{
public:
void print();
};
#endif
================================================
FILE: 01-basic/C-static-library/src/Hello.cpp
================================================
#include <iostream>
#include "static/Hello.h"
void Hello::print()
{
std::cout << "Hello Static Library!" << std::endl;
}
================================================
FILE: 01-basic/C-static-library/src/main.cpp
================================================
#include "static/Hello.h"
int main(int argc, char *argv[])
{
Hello hi;
hi.print();
return 0;
}
================================================
FILE: 01-basic/D-shared-library/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.5)
project(hello_library)
############################################################
# Create a library
############################################################
#Generate the shared library from the library sources
add_library(hello_library SHARED
src/Hello.cpp
)
add_library(hello::library ALIAS hello_library)
target_include_directories(hello_library
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
############################################################
# Create an executable
############################################################
# Add an executable with the above sources
add_executable(hello_binary
src/main.cpp
)
# link the new hello_library target with the hello_binary target
target_link_libraries( hello_binary
PRIVATE
hello::library
)
================================================
FILE: 01-basic/D-shared-library/README.adoc
================================================
= Shared Library
:toc:
:toc-placement!:
toc::[]
# Introduction
Shows a hello world example which first creates and links a shared library.
This also shows how to create an link:https://cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#alias-targets[alias target]
The files in this tutorial are below:
```
$ tree
.
├── CMakeLists.txt
├── include
│ └── shared
│ └── Hello.h
└── src
├── Hello.cpp
└── main.cpp
```
* link:CMakeLists.txt[] - Contains the CMake commands you wish to run
* link:include/shared/Hello.h[] - The header file to include
* link:src/Hello.cpp[] - A source file to compile
* link:src/main.cpp[] - The source file with main
# Concepts
## Adding a Shared Library
As with the previous example on static libraries, the +add_library()+ function
is also used to create a shared library from some source files.
This is called as follows:
[source,cmake]
----
add_library(hello_library SHARED
src/Hello.cpp
)
----
This will be used to create a shared library with the name libhello_library.so with
the sources passed to the +add_library()+ function.
## Alias Target
As the name suggests an link:https://cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#alias-targets[alias target] is an alternative name for a target that can be used instead of the real target name in read-only contexts.
[source,cmake]
----
add_library(hello::library ALIAS hello_library)
----
As shown below, this allows you to reference the target using the alias name when linking it against other targets.
## Linking a Shared Library
Linking a shared library is the same as linking a static library. When creating your
executable use the the +target_link_library()+ function to point to your library
[source,cmake]
----
add_executable(hello_binary
src/main.cpp
)
target_link_libraries(hello_binary
PRIVATE
hello::library
)
----
This tells CMake to link the hello_library against the hello_binary executable using the alias target name.
An example of this being called by the linker is
```
/usr/bin/c++ CMakeFiles/hello_binary.dir/src/main.cpp.o -o hello_binary -rdynamic libhello_library.so -Wl,-rpath,/home/matrim/workspace/cmake-examples/01-basic/D-shared-library/build
```
# Building the Example
[source,bash]
----
$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/D-shared-library/build
$ make
Scanning dependencies of target hello_library
[ 50%] Building CXX object CMakeFiles/hello_library.dir/src/Hello.cpp.o
Linking CXX shared library libhello_library.so
[ 50%] Built target hello_library
Scanning dependencies of target hello_binary
[100%] Building CXX object CMakeFiles/hello_binary.dir/src/main.cpp.o
Linking CXX executable hello_binary
[100%] Built target hello_binary
$ ls
CMakeCache.txt CMakeFiles cmake_install.cmake hello_binary libhello_library.so Makefile
$ ./hello_binary
Hello Shared Library!
----
================================================
FILE: 01-basic/D-shared-library/include/shared/Hello.h
================================================
#ifndef __HELLO_H__
#define __HELLO_H__
class Hello
{
public:
void print();
};
#endif
================================================
FILE: 01-basic/D-shared-library/src/Hello.cpp
================================================
#include <iostream>
#include "shared/Hello.h"
void Hello::print()
{
std::cout << "Hello Shared Library!" << std::endl;
}
================================================
FILE: 01-basic/D-shared-library/src/main.cpp
================================================
#include "shared/Hello.h"
int main(int argc, char *argv[])
{
Hello hi;
hi.print();
return 0;
}
================================================
FILE: 01-basic/E-installing/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.5)
project(cmake_examples_install)
############################################################
# Create a library
############################################################
#Generate the shared library from the library sources
add_library(cmake_examples_inst SHARED
src/Hello.cpp
)
target_include_directories(cmake_examples_inst
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
############################################################
# Create an executable
############################################################
# Add an executable with the above sources
add_executable(cmake_examples_inst_bin
src/main.cpp
)
# link the new hello_library target with the hello_binary target
target_link_libraries( cmake_examples_inst_bin
PRIVATE
cmake_examples_inst
)
############################################################
# Install
############################################################
# Binaries
install (TARGETS cmake_examples_inst_bin
DESTINATION bin)
# Library
# Note: may not work on windows
install (TARGETS cmake_examples_inst
LIBRARY DESTINATION lib)
# Header files
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
DESTINATION include)
# Config
install (FILES cmake-examples.conf
DESTINATION etc)
================================================
FILE: 01-basic/E-installing/README.adoc
================================================
= Installing
:toc:
:toc-placement!:
toc::[]
# Introduction
This example shows how to generate a `make install` target to install files and
binaries on your system. This is based on the previous shared library example.
The files in this tutorial are below:
```
$ tree
.
├── cmake-examples.conf
├── CMakeLists.txt
├── include
│ └── installing
│ └── Hello.h
├── README.adoc
└── src
├── Hello.cpp
└── main.cpp
```
* link:CMakeLists.txt[] - Contains the CMake commands you wish to run
* link:cmake-examples.conf[] - An example configuration file
* link:include/installing/Hello.h[] - The header file to include
* link:src/Hello.cpp[] - A source file to compile
* link:src/main.cpp[] - The source file with main
# Concepts
## Installing
CMake offers the ability to add a `make install` target to allow a user to
install binaries, libraries and other files. The base install location is controlled
by the variable +CMAKE_INSTALL_PREFIX+ which can be set using ccmake or by calling
cmake with `cmake .. -DCMAKE_INSTALL_PREFIX=/install/location`
The files that are installed are controlled by the https://cmake.org/cmake/help/v3.0/command/install.html[+install()+] function.
[source,cmake]
----
install (TARGETS cmake_examples_inst_bin
DESTINATION bin)
----
Install the binary generated from the target cmake_examples_inst_bin target to
the destination +${CMAKE_INSTALL_PREFIX}/bin+
[source,cmake]
----
install (TARGETS cmake_examples_inst
LIBRARY DESTINATION lib)
----
Install the shared library generated from the target cmake_examples_inst target to
the destination +${CMAKE_INSTALL_PREFIX}/lib+
[NOTE]
====
This may not work on windows. On platforms that have DLL targets you
may need to add the following
[source,cmake]
----
install (TARGETS cmake_examples_inst
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
----
====
[source,cmake]
----
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
DESTINATION include)
----
Install the header files for developing against the +cmake_examples_inst+ library
into the +${CMAKE_INSTALL_PREFIX}/include+ directory.
[source,cmake]
----
install (FILES cmake-examples.conf
DESTINATION etc)
----
Install a configuration file to the destination +${CMAKE_INSTALL_PREFIX}/etc+
After `make install` has been run, CMake generates an install_manifest.txt file
which includes details on all installed files.
[NOTE]
====
If you run the `make install` command as root, the install_manifest.txt file will
be owned by root.
====
# Building the Example
[source,bash]
----
$ mkdir build
$ cd build/
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/E-installing/build
$ make
Scanning dependencies of target cmake_examples_inst
[ 50%] Building CXX object CMakeFiles/cmake_examples_inst.dir/src/Hello.cpp.o
Linking CXX shared library libcmake_examples_inst.so
[ 50%] Built target cmake_examples_inst
Scanning dependencies of target cmake_examples_inst_bin
[100%] Building CXX object CMakeFiles/cmake_examples_inst_bin.dir/src/main.cpp.o
Linking CXX executable cmake_examples_inst_bin
[100%] Built target cmake_examples_inst_bin
$ sudo make install
[sudo] password for matrim:
[ 50%] Built target cmake_examples_inst
[100%] Built target cmake_examples_inst_bin
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/bin/cmake_examples_inst_bin
-- Removed runtime path from "/usr/local/bin/cmake_examples_inst_bin"
-- Installing: /usr/local/lib/libcmake_examples_inst.so
-- Installing: /usr/local/etc/cmake-examples.conf
$ cat install_manifest.txt
/usr/local/bin/cmake_examples_inst_bin
/usr/local/lib/libcmake_examples_inst.so
/usr/local/etc/cmake-examples.conf
$ ls /usr/local/bin/
cmake_examples_inst_bin
$ ls /usr/local/lib
libcmake_examples_inst.so
$ ls /usr/local/etc/
cmake-examples.conf
$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib cmake_examples_inst_bin
Hello Install!
----
[NOTE]
====
If `/usr/local/lib` is not in your library path you may need to add it to the
path before running the binary.
====
[[extra-notes]]
Extra Notes
~~~~~~~~~~~
[[default-location]]
Overriding the default install location
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
As mentioned the default install location is set from the +CMAKE_INSTALL_PREFIX+,
which defaults to `/usr/local/`
If you want to change this default location for all users you can add the
following code to your top level CMakeLists.txt before adding any binaries or
libraries.
[source,cmake]
----
if( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
message(STATUS "Setting default CMAKE_INSTALL_PREFIX path to ${CMAKE_BINARY_DIR}/install")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE STRING "The path to use for make install" FORCE)
endif()
----
This example sets the default install location to under your build directory.
[[destdir]]
DESTDIR
^^^^^^^
If you wish to stage your install to confirm that all files are included the
`make install` target supports the DESTDIR argument.
```
make install DESTDIR=/tmp/stage
```
This will create the install path `${DESTDIR}/${CMAKE_INSTALL_PREFIX}` for all
your installation files. In this example, it would install all files under the
path `/tmp/stage/usr/local`
```
$ tree /tmp/stage
/tmp/stage
└── usr
└── local
├── bin
│ └── cmake_examples_inst_bin
├── etc
│ └── cmake-examples.conf
└── lib
└── libcmake_examples_inst.so
```
[[uninstall]]
Uninstall
^^^^^^^^^
By default CMake does not add a `make uninstall` target. For details on how to generate
an uninstall target see this https://cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F[FAQ]
For an easy way to remove the files from this example, you can use:
```
sudo xargs rm < install_manifest.txt
```
================================================
FILE: 01-basic/E-installing/cmake-examples.conf
================================================
# Sample configuration file that could be installed
================================================
FILE: 01-basic/E-installing/include/installing/Hello.h
================================================
#ifndef __HELLO_H__
#define __HELLO_H__
class Hello
{
public:
void print();
};
#endif
================================================
FILE: 01-basic/E-installing/src/Hello.cpp
================================================
#include <iostream>
#include "installing/Hello.h"
void Hello::print()
{
std::cout << "Hello Install!" << std::endl;
}
================================================
FILE: 01-basic/E-installing/src/main.cpp
================================================
#include "installing/Hello.h"
int main(int argc, char *argv[])
{
Hello hi;
hi.print();
return 0;
}
================================================
FILE: 01-basic/F-build-type/CMakeLists.txt
================================================
# Set the minimum version of CMake that can be used
# To find the cmake version run
# $ cmake --version
cmake_minimum_required(VERSION 3.5)
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message("Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
# Set the project name
project (build_type)
# Add an executable
add_executable(cmake_examples_build_type main.cpp)
================================================
FILE: 01-basic/F-build-type/README.adoc
================================================
= Build Type
:toc:
:toc-placement!:
toc::[]
# Introduction
CMake has a number of built in build configurations which can be used to compile
your project. These specify the optimization levels and if debug information is
to be included in the binary.
The levels provided are:
* Release - Adds the `-O3 -DNDEBUG` flags to the compiler
* Debug - Adds the `-g` flag
* MinSizeRel - Adds `-Os -DNDEBUG`
* RelWithDebInfo - Adds `-O2 -g -DNDEBUG` flags
The files in this tutorial are below:
```
$ tree
.
├── CMakeLists.txt
├── main.cpp
```
* link:CMakeLists.txt[] - Contains the CMake commands you wish to run
* link:main.cpp[] - The source file with main
# Concepts
## Set Build Type
The build type can be set using the following methods.
- Using a gui tool such as ccmake / cmake-gui
image::cmake-gui-build-type.png[cmake-gui build type]
- Passing into cmake
[source,cmake]
----
cmake .. -DCMAKE_BUILD_TYPE=Release
----
## Set Default Build Type
The default build type provided by CMake is to include no compiler flags for
optimization. For some projects you may want to
set a default build type so that you do not have to remember to set it.
To do this you can add the following to your top level CMakeLists.txt
[source,cmake]
----
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message("Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
----
# Building the Example
[source,bash]
----
$ mkdir build
$ cd build/
$ cmake ..
Setting build type to 'RelWithDebInfo' as none was specified.
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build
$ make VERBOSE=1
/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/01-basic/F-build-type -B/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'
make -f CMakeFiles/cmake_examples_build_type.dir/build.make CMakeFiles/cmake_examples_build_type.dir/depend
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'
cd /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/matrim/workspace/cmake-examples/01-basic/F-build-type /home/matrim/workspace/cmake-examples/01-basic/F-build-type /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/DependInfo.cmake --color=
Dependee "/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/DependInfo.cmake" is newer than depender "/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/depend.internal".
Dependee "/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/depend.internal".
Scanning dependencies of target cmake_examples_build_type
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'
make -f CMakeFiles/cmake_examples_build_type.dir/build.make CMakeFiles/cmake_examples_build_type.dir/build
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles 1
[100%] Building CXX object CMakeFiles/cmake_examples_build_type.dir/main.cpp.o
/usr/bin/c++ -O2 -g -DNDEBUG -o CMakeFiles/cmake_examples_build_type.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/F-build-type/main.cpp
Linking CXX executable cmake_examples_build_type
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmake_examples_build_type.dir/link.txt --verbose=1
/usr/bin/c++ -O2 -g -DNDEBUG CMakeFiles/cmake_examples_build_type.dir/main.cpp.o -o cmake_examples_build_type -rdynamic
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles 1
[100%] Built target cmake_examples_build_type
make[1]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles 0$ mkdir build
$ cd build/
/build$ cmake ..
Setting build type to 'RelWithDebInfo' as none was specified.
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build
/build$ make VERBOSE=1
/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/01-basic/F-build-type -B/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'
make -f CMakeFiles/cmake_examples_build_type.dir/build.make CMakeFiles/cmake_examples_build_type.dir/depend
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'
cd /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/matrim/workspace/cmake-examples/01-basic/F-build-type /home/matrim/workspace/cmake-examples/01-basic/F-build-type /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/DependInfo.cmake --color=
Dependee "/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/DependInfo.cmake" is newer than depender "/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/depend.internal".
Dependee "/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/depend.internal".
Scanning dependencies of target cmake_examples_build_type
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'
make -f CMakeFiles/cmake_examples_build_type.dir/build.make CMakeFiles/cmake_examples_build_type.dir/build
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles 1
[100%] Building CXX object CMakeFiles/cmake_examples_build_type.dir/main.cpp.o
/usr/bin/c++ -O2 -g -DNDEBUG -o CMakeFiles/cmake_examples_build_type.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/F-build-type/main.cpp
Linking CXX executable cmake_examples_build_type
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmake_examples_build_type.dir/link.txt --verbose=1
/usr/bin/c++ -O2 -g -DNDEBUG CMakeFiles/cmake_examples_build_type.dir/main.cpp.o -o cmake_examples_build_type -rdynamic
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles 1
[100%] Built target cmake_examples_build_type
make[1]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles 0
----
================================================
FILE: 01-basic/F-build-type/main.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello Build Type!" << std::endl;
return 0;
}
================================================
FILE: 01-basic/G-compile-flags/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.5)
# Set a default C++ compile flag
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEX2" CACHE STRING "Set C++ Compiler Flags" FORCE)
# Set the project name
project (compile_flags)
# Add an executable
add_executable(cmake_examples_compile_flags main.cpp)
target_compile_definitions(cmake_examples_compile_flags
PRIVATE EX3
)
================================================
FILE: 01-basic/G-compile-flags/README.adoc
================================================
= Compile Flags
:toc:
:toc-placement!:
toc::[]
# Introduction
CMake supports setting compile flags in a number of different ways:
* using +target_compile_definitions()+ function
* using the +CMAKE_C_FLAGS+ and +CMAKE_CXX_FLAGS+ variables.
The files in this tutorial are below:
```
$ tree
.
├── CMakeLists.txt
├── main.cpp
```
* link:CMakeLists.txt[] - Contains the CMake commands you wish to run
* link:main.cpp[] - The source file with main
# Concepts
# Set Per-Target C++ Flags
The recommended way to set C++ flags in modern CMake is to use per-target flags which can be populated to other targets
through the +target_compile_definitions()+ link:https://cmake.org/cmake/help/v3.0/command/target_compile_definitions.html?highlight=target_compile_definitions[function]. This will populate the link:https://cmake.org/cmake/help/v3.0/prop_tgt/INTERFACE_COMPILE_DEFINITIONS.html#prop_tgt:INTERFACE_COMPILE_DEFINITIONS[INTERFACE_COMPILE_DEFINITIONS] for the library and push the definition to the linked target depending on the scope.
[source,cmake]
----
target_compile_definitions(cmake_examples_compile_flags
PRIVATE EX3
)
----
This will cause the compiler to add the definition +-DEX3+ when compiling the target.
If the target was a library and the scope +PUBLIC+ or +INTERFACE+ has been chosen the definition would also be included in any executables that link this target.
For compiler options you can also use the +target_compile_options()+ link:https://cmake.org/cmake/help/v3.0/command/target_compile_options.html[function].
## Set Default C++ Flags
The default `CMAKE_CXX_FLAGS` is either empty or contains the appropriate flags
for the build type.
To set additional default compile flags you can add the following to your
top level CMakeLists.txt
[source,cmake]
----
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEX2" CACHE STRING "Set C++ Compiler Flags" FORCE)
----
Similarly to +CMAKE_CXX_FLAGS+ other options include:
* Setting C compiler flags using +CMAKE_C_FLAGS+
* Setting linker flags using +CMAKE_LINKER_FLAGS+.
[NOTE]
====
The values `CACHE STRING "Set C++ Compiler Flags" FORCE` from the above command
are used to force this variable to be set in the CMakeCache.txt file.
For more details, see https://cmake.org/cmake/help/v3.0/command/set.html[here]
====
Once set the +CMAKE_C_FLAGS+ and +CMAKE_CXX_FLAGS+ will set a compiler flag / definition globally for all targets in this directory or any included sub-directories. This method is not recommended for general usage now and the +target_compile_definitions+ function is preferred.
### Set CMake Flags
Similar to the build type a global C++ compiler flag can be set using the following methods.
- Using a gui tool such as ccmake / cmake-gui
image::cmake-gui-set-cxx-flag.png[cmake-gui set cxx flag]
- Passing into cmake
[source,cmake]
----
cmake .. -DCMAKE_CXX_FLAGS="-DEX3"
----
# Building the Example
[source,bash]
----
$ mkdir build
$ cd build/
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build
$ make VERBOSE=1
/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags -B/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build'
make -f CMakeFiles/cmake_examples_compile_flags.dir/build.make CMakeFiles/cmake_examples_compile_flags.dir/depend
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build'
cd /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles/cmake_examples_compile_flags.dir/DependInfo.cmake --color=
Dependee "/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles/cmake_examples_compile_flags.dir/DependInfo.cmake" is newer than depender "/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles/cmake_examples_compile_flags.dir/depend.internal".
Dependee "/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles/cmake_examples_compile_flags.dir/depend.internal".
Scanning dependencies of target cmake_examples_compile_flags
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build'
make -f CMakeFiles/cmake_examples_compile_flags.dir/build.make CMakeFiles/cmake_examples_compile_flags.dir/build
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles 1
[100%] Building CXX object CMakeFiles/cmake_examples_compile_flags.dir/main.cpp.o
/usr/bin/c++ -DEX2 -o CMakeFiles/cmake_examples_compile_flags.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/main.cpp
Linking CXX executable cmake_examples_compile_flags
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmake_examples_compile_flags.dir/link.txt --verbose=1
/usr/bin/c++ -DEX2 CMakeFiles/cmake_examples_compile_flags.dir/main.cpp.o -o cmake_examples_compile_flags -rdynamic
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles 1
[100%] Built target cmake_examples_compile_flags
make[1]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build'
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles 0
----
================================================
FILE: 01-basic/G-compile-flags/main.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello Compile Flags!" << std::endl;
// only print if compile flag set
#ifdef EX2
std::cout << "Hello Compile Flag EX2!" << std::endl;
#endif
#ifdef EX3
std::cout << "Hello Compile Flag EX3!" << std::endl;
#endif
return 0;
}
================================================
FILE: 01-basic/H-third-party-library/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.5)
# Set the project name
project (third_party_include)
# find a boost install with the libraries filesystem and system
find_package(Boost 1.46.1 REQUIRED COMPONENTS filesystem system)
# check if boost was found
if(Boost_FOUND)
message ("boost found")
else()
message (FATAL_ERROR "Cannot find Boost")
endif()
# Add an executable
add_executable(third_party_include main.cpp)
# link against the boost libraries
target_link_libraries( third_party_include
PRIVATE
Boost::filesystem
)
================================================
FILE: 01-basic/H-third-party-library/README.adoc
================================================
= Including Third Party Library
:toc:
:toc-placement!:
toc::[]
# Introduction
Nearly all non-trivial projects will have a requirement for including third party
libraries, headers, or programs. CMake has support for finding the path to these tools using
the `find_package()` function. This will search for CMake modules in the format
"FindXXX.cmake" from the list of folders in `CMAKE_MODULE_PATH`. On linux the
default search path will include `/usr/share/cmake/Modules`. On my system this
includes support for approximately 142 common third party libraries.
The files in this tutorial are below:
```
$ tree
.
├── CMakeLists.txt
├── main.cpp
```
* link:CMakeLists.txt[] - Contains the CMake commands you wish to run
* link:main.cpp[] - The source file with main
# Requirements
This example requires the boost libraries to be installed in a default system
location.
# Concepts
## Finding a Package
As mentioned above the `find_package()` function will search for CMake modules in the formant
"FindXXX.cmake" from the list of folders in `CMAKE_MODULE_PATH`. The exact
format of the arguments to `find_package` will depend on the module you are looking
for. This is typically documented at the top of the `FindXXX.cmake` file.
A basic example of finding boost is below:
[source,cmake]
----
find_package(Boost 1.46.1 REQUIRED COMPONENTS filesystem system)
----
The arguments are:
* Boost - Name of the library. This is part of used to find the module file FindBoost.cmake
* 1.46.1 - The minimum version of boost to find
* REQUIRED - Tells the module that this is required and to fail if it cannot be found
* COMPONENTS - The list of components to find in the library.
Boost includes can take more arguments and also make use of other variables.
More complex setups are provided in later examples.
## Checking if the package is found
Most included packages will set a variable `XXX_FOUND`, which can be used to check
if the package is available on the system.
In this example the variable is `Boost_FOUND`:
[source,cmake]
----
if(Boost_FOUND)
message ("boost found")
include_directories(${Boost_INCLUDE_DIRS})
else()
message (FATAL_ERROR "Cannot find Boost")
endif()
----
## Exported Variables
After a package is found it will often export variables which can inform the user
where to find the library, header, or executable files. Similar to the `XXX_FOUND`
variable, these are package specific and are typically documented at the top of the
`FindXXX.cmake` file.
The variables exported in this example include:
* `Boost_INCLUDE_DIRS` - The path to the boost header files.
In some cases you can also check these variables by examining the cache using
ccmake or cmake-gui.
## Alias / Imported targets
Most modern CMake libraries link:https://cmake.org/cmake/help/v3.6/prop_tgt/IMPORTED.html#prop_tgt:IMPORTED[export] +ALIAS+ targets in their module files.
The benefit of imported targets are that they can also populate include directories and linked libraries.
For example, starting from v3.5+ of CMake, the
Boost module supports this. Similar to using your own ALIAS target for libraires, an +ALIAS+ in a module can make referencing found targets easier.
In the case of Boost, all targets are exported using the `Boost::` identifier and then the name
of the subsystem. For example you can use:
* `Boost::boost` for header only libraries
* `Boost::system` for the boost system library.
* `Boost::filesystem` for filesystem library.
As with your own targets, these targets include their dependencies, so linking against
`Boost::filesystem` will automatically add `Boost::boost` and `Boost::system` dependencies.
To link against an imported target you can use the following:
[source,cmake]
----
target_link_libraries( third_party_include
PRIVATE
Boost::filesystem
)
----
## Non-alias targets
While most modern libraries use imported targets, not all modules have been updated. In the
case where a library hasn't been updated you will often find the following variables available:
* xxx_INCLUDE_DIRS - A variable pointing to the include directory for the library.
* xxx_LIBRARY - A variable pointing to the library path.
These can then be added to your +target_include_directories+ and +target_link_libraries+ as:
[source,cmake]
----
# Include the boost headers
target_include_directories( third_party_include
PRIVATE ${Boost_INCLUDE_DIRS}
)
# link against the boost libraries
target_link_libraries( third_party_include
PRIVATE
${Boost_SYSTEM_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
)
----
# Building the Example
[source,bash]
----
$ mkdir build
$ cd build/
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.54.0
-- Found the following Boost libraries:
-- filesystem
-- system
boost found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/H-third-party-library/build
$ make
Scanning dependencies of target third_party_include
[100%] Building CXX object CMakeFiles/third_party_include.dir/main.cpp.o
Linking CXX executable third_party_include
[100%] Built target third_party_include
matrim@freyr:~/workspace/cmake-examples/01-basic/H-third-party-library/build$ ./
CMakeFiles/ third_party_include
matrim@freyr:~/workspace/cmake-examples/01-basic/H-third-party-library/build$ ./third_party_include
Hello Third Party Include!
Path is not relative
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.54.0
-- Found the following Boost libraries:
-- filesystem
-- system
boost found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/H-third-party-library/build
$ make
Scanning dependencies of target third_party_include
[100%] Building CXX object CMakeFiles/third_party_include.dir/main.cpp.o
Linking CXX executable third_party_include
[100%] Built target third_party_include
$ ./third_party_include
Hello Third Party Include!
Path is not relative
----
================================================
FILE: 01-basic/H-third-party-library/main.cpp
================================================
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <boost/filesystem.hpp>
int main(int argc, char *argv[])
{
std::cout << "Hello Third Party Include!" << std::endl;
// use a shared ptr
boost::shared_ptr<int> isp(new int(4));
// trivial use of boost filesystem
boost::filesystem::path path = "/usr/share/cmake/modules";
if(path.is_relative())
{
std::cout << "Path is relative" << std::endl;
}
else
{
std::cout << "Path is not relative" << std::endl;
}
return 0;
}
================================================
FILE: 01-basic/I-compiling-with-clang/CMakeLists.txt
================================================
# Set the minimum version of CMake that can be used
# To find the cmake version run
# $ cmake --version
cmake_minimum_required(VERSION 3.5)
# Set the project name
project (hello_cmake)
# Add an executable
add_executable(hello_cmake main.cpp)
================================================
FILE: 01-basic/I-compiling-with-clang/README.adoc
================================================
= Compiling with clang
:toc:
:toc-placement!:
toc::[]
# Introduction
When building with CMake it is possible to set the C and C++ compiler. This example
is the same as the link:../A-hello-cmake[hello-cmake] example except that it shows the most basic
method of changing the compiler from the default gcc to http://clang.llvm.org/[clang].
The files in this tutorial are below:
```
$ tree
.
├── CMakeLists.txt
├── main.cpp
```
* link:CMakeLists.txt[] - Contains the CMake commands you wish to run
* link:main.cpp[] - A simple "Hello World" cpp file.
# Concepts
### Compiler Option
CMake exposes options to control the programs used to compile and link your code. These
programs include:
* CMAKE_C_COMPILER - The program used to compile c code.
* CMAKE_CXX_COMPILER - The program used to compile c++ code.
* CMAKE_LINKER - The program used to link your binary.
[NOTE]
====
In this example clang-3.6 is installed via the command `sudo apt-get install clang-3.6`
====
[NOTE]
====
This is the most basic and easiest way to invoke clang. Future examples will show better
ways to invoke the compiler.
====
### Setting Flags
As described in the link:../F-build-type[Build Type] example, you can set CMake options
using either a cmake gui or by passing from the command line.
Below is an example of passing the compiler via the command line.
[source,cmake]
----
cmake .. -DCMAKE_C_COMPILER=clang-3.6 -DCMAKE_CXX_COMPILER=clang++-3.6
----
After setting these options, when your run `make` clang will be used to compile your binary. This
can be seen from the following lines in the make output.
[source,bash]
----
/usr/bin/clang++-3.6 -o CMakeFiles/hello_cmake.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/main.cpp
Linking CXX executable hello_cmake
/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_cmake.dir/link.txt --verbose=1
/usr/bin/clang++-3.6 CMakeFiles/hello_cmake.dir/main.cpp.o -o hello_cmake -rdynamic
----
# Building the Examples
Below is sample output from building this example.
[source,bash]
----
$ mkdir build.clang
$ cd build.clang/
$ cmake .. -DCMAKE_C_COMPILER=clang-3.6 -DCMAKE_CXX_COMPILER=clang++-3.6
-- The C compiler identification is Clang 3.6.0
-- The CXX compiler identification is Clang 3.6.0
-- Check for working C compiler: /usr/bin/clang-3.6
-- Check for working C compiler: /usr/bin/clang-3.6 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++-3.6
-- Check for working CXX compiler: /usr/bin/clang++-3.6 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang
$ make VERBOSE=1
/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang -B/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang'
make -f CMakeFiles/hello_cmake.dir/build.make CMakeFiles/hello_cmake.dir/depend
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang'
cd /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles/hello_cmake.dir/DependInfo.cmake --color=
Dependee "/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles/hello_cmake.dir/DependInfo.cmake" is newer than depender "/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles/hello_cmake.dir/depend.internal".
Dependee "/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles/hello_cmake.dir/depend.internal".
Scanning dependencies of target hello_cmake
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang'
make -f CMakeFiles/hello_cmake.dir/build.make CMakeFiles/hello_cmake.dir/build
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles 1
[100%] Building CXX object CMakeFiles/hello_cmake.dir/main.cpp.o
/usr/bin/clang++-3.6 -o CMakeFiles/hello_cmake.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/main.cpp
Linking CXX executable hello_cmake
/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_cmake.dir/link.txt --verbose=1
/usr/bin/clang++-3.6 CMakeFiles/hello_cmake.dir/main.cpp.o -o hello_cmake -rdynamic
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles 1
[100%] Built target hello_cmake
make[1]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang'
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles 0
$ ./hello_cmake
Hello CMake!
----
================================================
FILE: 01-basic/I-compiling-with-clang/main.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello CMake!" << std::endl;
return 0;
}
================================================
FILE: 01-basic/I-compiling-with-clang/pre_test.sh
================================================
#!/bin/bash
ROOT_DIR=`pwd`
dir="01-basic/I-compiling-with-clang"
if [ -d "$ROOT_DIR/$dir/build.clang" ]; then
echo "deleting $dir/build.clang"
rm -r $dir/build.clang
fi
================================================
FILE: 01-basic/I-compiling-with-clang/run_test.sh
================================================
#!/bin/bash
# Ubuntu supports multiple versions of clang to be installed at the same time.
# The tests need to determine the clang binary before calling cmake
clang_bin=`which clang`
clang_xx_bin=`which clang++`
if [ -z $clang_bin ]; then
clang_ver=`dpkg --get-selections | grep clang | grep -v -m1 libclang | cut -f1 | cut -d '-' -f2`
clang_bin="clang-$clang_ver"
clang_xx_bin="clang++-$clang_ver"
fi
echo "Will use clang [$clang_bin] and clang++ [$clang_xx_bin]"
mkdir -p build.clang && cd build.clang && \
cmake .. -DCMAKE_C_COMPILER=$clang_bin -DCMAKE_CXX_COMPILER=$clang_xx_bin && make
================================================
FILE: 01-basic/J-building-with-ninja/CMakeLists.txt
================================================
# Set the minimum version of CMake that can be used
# To find the cmake version run
# $ cmake --version
cmake_minimum_required(VERSION 3.5)
# Set the project name
project (hello_cmake)
# Add an executable
add_executable(hello_cmake main.cpp)
================================================
FILE: 01-basic/J-building-with-ninja/README.adoc
================================================
= Building with ninja
:toc:
:toc-placement!:
toc::[]
# Introduction
As mentioned, CMake is a meta-build system that can be used to
create the build files for many other build tools. This example shows how
to have CMake use the https://ninja-build.org/[ninja build] tool.
The files in this tutorial are below:
```
$ tree
.
├── CMakeLists.txt
├── main.cpp
```
* link:CMakeLists.txt[] - Contains the CMake commands you wish to run
* link:main.cpp[] - A simple "Hello World" cpp file.
# Concepts
### Generators
CMake https://cmake.org/cmake/help/v3.0/manual/cmake-generators.7.html[generators] are
responsible for writing the input files (e.g. Makefiles) for the underlying build system. Running `cmake --help`
will show the generators available. For cmake v2.8.12.2 the generators supported
on my system include:
[source,bash]
----
Generators
The following generators are available on this platform:
Unix Makefiles = Generates standard UNIX makefiles.
Ninja = Generates build.ninja files (experimental).
CodeBlocks - Ninja = Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles
= Generates Eclipse CDT 4.0 project files.
KDevelop3 = Generates KDevelop 3 project files.
KDevelop3 - Unix Makefiles = Generates KDevelop 3 project files.
Sublime Text 2 - Ninja = Generates Sublime Text 2 project files.
Sublime Text 2 - Unix Makefiles
= Generates Sublime Text 2 project files.Generators
----
As specified in this https://stackoverflow.com/questions/25941536/what-is-a-cmake-generator[post],
CMake includes different types of generators such as Command-Line, IDE, and Extra generators.
#### Command-Line Build Tool Generators
These generators are for command-line build tools, like Make and Ninja. The chosen tool chain must be configured prior to generating the build system with CMake.
The supported generators include:
* Borland Makefiles
* MSYS Makefiles
* MinGW Makefiles
* NMake Makefiles
* NMake Makefiles JOM
* Ninja
* Unix Makefiles
* Watcom WMake
#### IDE Build Tool Generators
These generators are for Integrated Development Environments that include their own compiler. Examples are Visual Studio and Xcode which include a compiler natively.
The supported generators include:
* Visual Studio 6
* Visual Studio 7
* Visual Studio 7 .NET 2003
* Visual Studio 8 2005
* Visual Studio 9 2008
* Visual Studio 10 2010
* Visual Studio 11 2012
* Visual Studio 12 2013
* Xcode
#### Extra Generators
These are generators create a configuration to work with an alternative IDE tool and must be included with either an IDE or Command-Line generator.
The supported generators include:
* CodeBlocks
* CodeLite
* Eclipse CDT4
* KDevelop3
* Kate
* Sublime Text 2
[NOTE]
====
In this example ninja is installed via the command `sudo apt-get install ninja-build`
====
### Calling a Generator
To call a CMake generator you can use the `-G` command line switch, for example:
[source,cmake]
----
cmake .. -G Ninja
----
After doing the above CMake will generate the required Ninja build files, which can be run
from using the `ninja` command.
[source,bash]
----
$ cmake .. -G Ninja
$ ls
build.ninja CMakeCache.txt CMakeFiles cmake_install.cmake rules.ninja
----
# Building the Examples
Below is sample output from building this example.
[source,bash]
----
$ mkdir build.ninja
$ cd build.ninja/
$ cmake .. -G Ninja
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/J-building-with-ninja/build.ninja
$ ninja -v
[1/2] /usr/bin/c++ -MMD -MT CMakeFiles/hello_cmake.dir/main.cpp.o -MF "CMakeFiles/hello_cmake.dir/main.cpp.o.d" -o CMakeFiles/hello_cmake.dir/main.cpp.o -c ../main.cpp
[2/2] : && /usr/bin/c++ CMakeFiles/hello_cmake.dir/main.cpp.o -o hello_cmake -rdynamic && :
$ ls
build.ninja CMakeCache.txt CMakeFiles cmake_install.cmake hello_cmake rules.ninja
$ ./hello_cmake
Hello CMake!
----
================================================
FILE: 01-basic/J-building-with-ninja/main.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello CMake!" << std::endl;
return 0;
}
================================================
FILE: 01-basic/J-building-with-ninja/pre_test.sh
================================================
#!/bin/bash
ROOT_DIR=`pwd`
dir="01-basic/J-building-with-ninja"
if [ -d "$ROOT_DIR/$dir/build.ninja" ]; then
echo "deleting $dir/build.ninja"
rm -r $dir/build.ninja
fi
================================================
FILE: 01-basic/J-building-with-ninja/run_test.sh
================================================
#!/bin/bash
# Travis-ci cmake version doesn't support ninja, so first check if it's supported
ninja_supported=`cmake --help | grep Ninja`
if [ -z $ninja_supported ]; then
echo "Ninja not supported"
exit
fi
mkdir -p build.ninja && cd build.ninja && \
cmake .. -G Ninja && ninja
================================================
FILE: 01-basic/K-imported-targets/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.5)
# Set the project name
project (imported_targets)
# find a boost install with the libraries filesystem and system
find_package(Boost 1.46.1 REQUIRED COMPONENTS filesystem system)
# check if boost was found
if(Boost_FOUND)
message ("boost found")
else()
message (FATAL_ERROR "Cannot find Boost")
endif()
# Add an executable
add_executable(imported_targets main.cpp)
# link against the boost libraries
target_link_libraries( imported_targets
PRIVATE
Boost::filesystem
)
================================================
FILE: 01-basic/K-imported-targets/README.adoc
================================================
= Imported Targets
:toc:
:toc-placement!:
toc::[]
# Introduction
As previously mentioned in the link:../H-third-party-library[third party library], newer
versions of CMake allow you to link third party libraries using link:https://cmake.org/cmake/help/v3.6/prop_tgt/IMPORTED.html#prop_tgt:IMPORTED[imported] +ALIAS+ targets.
The files in this tutorial are below:
```
$ tree
.
├── CMakeLists.txt
├── main.cpp
```
* link:CMakeLists.txt[] - Contains the CMake commands you wish to run
* link:main.cpp[] - The source file with main
# Requirements
This example requires the following:
* CMake v3.5+
* The boost libraries to be installed in a default system location.
# Concepts
## Imported Target
Imported targets are read-only targets that are exported by FindXXX modules.
To include boost filesystem you can do the following:
[source,cmake]
----
target_link_libraries( imported_targets
PRIVATE
Boost::filesystem
)
----
This will automtaically link the Boost::filesystem and Boost::system libraries while also including the
Boost include directories.
# Building the Example
[source,bash]
----
$ mkdir build
$ cd build/
$ cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Boost version: 1.58.0
-- Found the following Boost libraries:
-- filesystem
-- system
boost found
-- Configuring done
-- Generating done
-- Build files have been written to: /data/code/01-basic/K-imported-targets/build
$ make
Scanning dependencies of target imported_targets
[ 50%] Building CXX object CMakeFiles/imported_targets.dir/main.cpp.o
[100%] Linking CXX executable imported_targets
[100%] Built target imported_targets
$ ./imported_targets
Hello Third Party Include!
Path is not relative
----
================================================
FILE: 01-basic/K-imported-targets/main.cpp
================================================
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <boost/filesystem.hpp>
int main(int argc, char *argv[])
{
std::cout << "Hello Third Party Include!" << std::endl;
// use a shared ptr
boost::shared_ptr<int> isp(new int(4));
// trivial use of boost filesystem
boost::filesystem::path path = "/usr/share/cmake/modules";
if(path.is_relative())
{
std::cout << "Path is relative" << std::endl;
}
else
{
std::cout << "Path is not relative" << std::endl;
}
return 0;
}
================================================
FILE: 01-basic/K-imported-targets/run_test.sh
================================================
#!/bin/bash
# Make sure we have the minimum cmake version
cmake_version=`cmake --version | grep version | cut -d" " -f3`
[[ "$cmake_version" =~ ([3-9][.][5-9.][.][0-9]) ]] || exit 0
echo "correct version of cmake"
mkdir -p build && cd build && cmake .. && make
if [ $? -ne 0 ]; then
echo "Error running example"
exit 1
fi
================================================
FILE: 01-basic/L-cpp-standard/README.adoc
================================================
= C++ Standard
Since the release of C+\+11 and C++14 a common use case is to invoke the compiler to use these standards. As CMake has evolved, it has added features to make this easier and new versions of CMake have changed how this is achieved.
The following examples show different methods of setting the C++ standard and what versions of CMake they are available from.
The examples include:
- link:i-common-method[common-method]. A simple version that should work with most versions of CMake.
- link:ii-cxx-standard[cxx-standard]. Using the `CMAKE_CXX_STANDARD` variable introduced in CMake v3.1.
- link:iii-compile-features[compile-features]. Using the `target_compile_features` function introduced in CMake v3.1.
================================================
FILE: 01-basic/L-cpp-standard/i-common-method/CMakeLists.txt
================================================
# Set the minimum version of CMake that can be used
# To find the cmake version run
# $ cmake --version
cmake_minimum_required(VERSION 2.8)
# Set the project name
project (hello_cpp11)
# try conditional compilation
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
# check results and add flag
if(COMPILER_SUPPORTS_CXX11)#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
# Add an executable
add_executable(hello_cpp11 main.cpp)
================================================
FILE: 01-basic/L-cpp-standard/i-common-method/README.adoc
================================================
= C++ Standard Common Method
:toc:
:toc-placement!:
toc::[]
# Introduction
This example shows a common method to set the C++ Standard. This can be used with most versions of CMake. However, if you are targeting a recent version of CMake there are more convenient methods available.
The files in this tutorial are below:
```
A-hello-cmake$ tree
.
├── CMakeLists.txt
├── main.cpp
```
* link:CMakeLists.txt[CMakeLists.txt] - Contains the CMake commands you wish to run
* link:main.cpp[main.cpp] - A simple "Hello World" cpp file targeting C++11.
# Concepts
## Checking Compile flags
CMake has support for attempting to compile a program with any flags you pass into the function `CMAKE_CXX_COMPILER_FLAG`. The result is then stored in a variable that you pass in.
For example:
[source,cmake]
----
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
----
This example will attempt to compile a program with the flag `-std=c++11` and store the result in the variable `COMPILER_SUPPORTS_CXX11`.
The line `include(CheckCXXCompilerFlag)` tells CMake to include this function to make it available for use.
## Adding the flag
Once you have determined if the compile supports a flag, you can then use the link:../../G-compile-flags/[standard cmake methods] to add this flag to a target. In this example we use the `CMAKE_CXX_FLAGS` to propegate the flag to all targets .
[source,cmake]
----
if(COMPILER_SUPPORTS_CXX11)#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
----
The above example only checks for the gcc version of the compile flags and supports fallback from C+\+11 to the pre-standardisation C+\+0x flag. In real usage you may want to check for C++14, or add support for different methods of setting the compile, e.g. `-std=gnu++11`
# Building the Examples
Below is sample output from building this example.
[source,bash]
----
$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Performing Test COMPILER_SUPPORTS_CXX11
-- Performing Test COMPILER_SUPPORTS_CXX11 - Success
-- Performing Test COMPILER_SUPPORTS_CXX0X
-- Performing Test COMPILER_SUPPORTS_CXX0X - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /data/code/01-basic/L-cpp-standard/i-common-method/build
$ make VERBOSE=1
/usr/bin/cmake -H/data/code/01-basic/L-cpp-standard/i-common-method -B/data/code/01-basic/L-cpp-standard/i-common-method/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles /data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/data/code/01-basic/L-cpp-standard/i-common-method/build'
make -f CMakeFiles/hello_cpp11.dir/build.make CMakeFiles/hello_cpp11.dir/depend
make[2]: Entering directory `/data/code/01-basic/L-cpp-standard/i-common-method/build'
cd /data/code/01-basic/L-cpp-standard/i-common-method/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /data/code/01-basic/L-cpp-standard/i-common-method /data/code/01-basic/L-cpp-standard/i-common-method /data/code/01-basic/L-cpp-standard/i-common-method/build /data/code/01-basic/L-cpp-standard/i-common-method/build /data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles/hello_cpp11.dir/DependInfo.cmake --color=
Dependee "/data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles/hello_cpp11.dir/DependInfo.cmake" is newer than depender "/data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles/hello_cpp11.dir/depend.internal".
Dependee "/data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles/hello_cpp11.dir/depend.internal".
Scanning dependencies of target hello_cpp11
make[2]: Leaving directory `/data/code/01-basic/L-cpp-standard/i-common-method/build'
make -f CMakeFiles/hello_cpp11.dir/build.make CMakeFiles/hello_cpp11.dir/build
make[2]: Entering directory `/data/code/01-basic/L-cpp-standard/i-common-method/build'
/usr/bin/cmake -E cmake_progress_report /data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles 1
[100%] Building CXX object CMakeFiles/hello_cpp11.dir/main.cpp.o
/usr/bin/c++ -std=c++11 -o CMakeFiles/hello_cpp11.dir/main.cpp.o -c /data/code/01-basic/L-cpp-standard/i-common-method/main.cpp
Linking CXX executable hello_cpp11
/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_cpp11.dir/link.txt --verbose=1
/usr/bin/c++ -std=c++11 CMakeFiles/hello_cpp11.dir/main.cpp.o -o hello_cpp11 -rdynamic
make[2]: Leaving directory `/data/code/01-basic/L-cpp-standard/i-common-method/build'
/usr/bin/cmake -E cmake_progress_report /data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles 1
[100%] Built target hello_cpp11
make[1]: Leaving directory `/data/code/01-basic/L-cpp-standard/i-common-method/build'
/usr/bin/cmake -E cmake_progress_start /data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles 0
----
================================================
FILE: 01-basic/L-cpp-standard/i-common-method/main.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
auto message = "Hello C++11";
std::cout << message << std::endl;
return 0;
}
================================================
FILE: 01-basic/L-cpp-standard/ii-cxx-standard/CMakeLists.txt
================================================
# Set the minimum version of CMake that can be used
# To find the cmake version run
# $ cmake --version
cmake_minimum_required(VERSION 3.1)
# Set the project name
project (hello_cpp11)
# set the C++ standard to C++ 11
set(CMAKE_CXX_STANDARD 11)
# Add an executable
add_executable(hello_cpp11 main.cpp)
================================================
FILE: 01-basic/L-cpp-standard/ii-cxx-standard/README.adoc
================================================
= Set C++ Standard
:toc:
:toc-placement!:
toc::[]
# Introduction
This example shows how to set the C++ standard using the `CMAKE_CXX_STANDARD` variable. This is available since CMake v3.1
The files in this tutorial are below:
```
A-hello-cmake$ tree
.
├── CMakeLists.txt
├── main.cpp
```
* link:CMakeLists.txt[CMakeLists.txt] - Contains the CMake commands you wish to run
* link:main.cpp[main.cpp] - A simple "Hello World" cpp file targeting C++11.
# Concepts
## Using CXX_STANDARD property
Setting the link:https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_STANDARD.html[CMAKE_CXX_STANDARD] variable causes the `CXX_STANDARD` property on all targets. This causes CMake to set the appropriate flag at compille time.
[NOTE]
====
The `CMAKE_CXX_STANDARD` variable falls back to the closest appropriate standard without a failure. For example, if you request `-std=gnu++11` you may end up with `-std=gnu++0x`.
This can result in an unexpected failure at compile time.
====
# Building the Examples
Below is sample output from building this example.
[source,bash]
----
$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build
$ make VERBOSE=1
/usr/bin/cmake -H/data/code/01-basic/L-cpp-standard/ii-cxx-standard -B/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build'
make -f CMakeFiles/hello_cpp11.dir/build.make CMakeFiles/hello_cpp11.dir/depend
make[2]: Entering directory '/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build'
cd /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /data/code/01-basic/L-cpp-standard/ii-cxx-standard /data/code/01-basic/L-cpp-standard/ii-cxx-standard /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles/hello_cpp11.dir/DependInfo.cmake --color=
Dependee "/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles/hello_cpp11.dir/DependInfo.cmake" is newer than depender "/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles/hello_cpp11.dir/depend.internal".
Dependee "/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles/hello_cpp11.dir/depend.internal".
Scanning dependencies of target hello_cpp11
make[2]: Leaving directory '/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build'
make -f CMakeFiles/hello_cpp11.dir/build.make CMakeFiles/hello_cpp11.dir/build
make[2]: Entering directory '/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build'
[ 50%] Building CXX object CMakeFiles/hello_cpp11.dir/main.cpp.o
/usr/bin/c++ -std=gnu++11 -o CMakeFiles/hello_cpp11.dir/main.cpp.o -c /data/code/01-basic/L-cpp-standard/ii-cxx-standard/main.cpp
[100%] Linking CXX executable hello_cpp11
/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_cpp11.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/hello_cpp11.dir/main.cpp.o -o hello_cpp11 -rdynamic
make[2]: Leaving directory '/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build'
[100%] Built target hello_cpp11
make[1]: Leaving directory '/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build'
----
================================================
FILE: 01-basic/L-cpp-standard/ii-cxx-standard/main.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
auto message = "Hello C++11";
std::cout << message << std::endl;
return 0;
}
================================================
FILE: 01-basic/L-cpp-standard/iii-compile-features/CMakeLists.txt
================================================
# Set the minimum version of CMake that can be used
# To find the cmake version run
# $ cmake --version
cmake_minimum_required(VERSION 3.1)
# Set the project name
project (hello_cpp11)
# Add an executable
add_executable(hello_cpp11 main.cpp)
# set the C++ standard to the appropriate standard for using auto
target_compile_features(hello_cpp11 PUBLIC cxx_auto_type)
# Print the list of known compile features for this version of CMake
message("List of compile features: ${CMAKE_CXX_COMPILE_FEATURES}")
================================================
FILE: 01-basic/L-cpp-standard/iii-compile-features/README.adoc
================================================
= Set C++ Standard
:toc:
:toc-placement!:
toc::[]
# Introduction
This example shows how to set the C++ standard using the `target_compile_features` function. This is available since CMake v3.1
The files in this tutorial are below:
```
A-hello-cmake$ tree
.
├── CMakeLists.txt
├── main.cpp
```
* link:CMakeLists.txt[CMakeLists.txt] - Contains the CMake commands you wish to run
* link:main.cpp[main.cpp] - A simple "Hello World" cpp file targeting C++11.
# Concepts
## Using target_compile_features
Calling the link:https://cmake.org/cmake/help/v3.1/command/target_compile_features.html[target_compile_features] function on a target will look at the passed in feature and determine the correct compiler flag to use for your target.
[source,cmake]
----
target_compile_features(hello_cpp11 PUBLIC cxx_auto_type)
----
As with other `target_*` functions, you can specify the scope of the feature for the selected target. This populates the link:https://cmake.org/cmake/help/v3.1/prop_tgt/INTERFACE_COMPILE_FEATURES.html#prop_tgt:INTERFACE_COMPILE_FEATURES[INTERFACE_COMPILE_FEATURES] property for the target.
The list of available features can be found from the link:https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_COMPILE_FEATURES.html#variable:CMAKE_CXX_COMPILE_FEATURES[CMAKE_CXX_COMPILE_FEATURES] variable. You can obtain a list of the available features using the following code:
[source,cmake]
----
message("List of compile features: ${CMAKE_CXX_COMPILE_FEATURES}")
----
# Building the Examples
Below is sample output from building this example.
[source,bash]
----
$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
List of compile features: cxx_template_template_parameters;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates
-- Configuring done
-- Generating done
-- Build files have been written to: /data/code/01-basic/L-cpp-standard/iii-compile-features/build
$ make VERBOSE=1
/usr/bin/cmake -H/data/code/01-basic/L-cpp-standard/iii-compile-features -B/data/code/01-basic/L-cpp-standard/iii-compile-features/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles /data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/data/code/01-basic/L-cpp-standard/iii-compile-features/build'
make -f CMakeFiles/hello_cpp11.dir/build.make CMakeFiles/hello_cpp11.dir/depend
make[2]: Entering directory '/data/code/01-basic/L-cpp-standard/iii-compile-features/build'
cd /data/code/01-basic/L-cpp-standard/iii-compile-features/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /data/code/01-basic/L-cpp-standard/iii-compile-features /data/code/01-basic/L-cpp-standard/iii-compile-features /data/code/01-basic/L-cpp-standard/iii-compile-features/build /data/code/01-basic/L-cpp-standard/iii-compile-features/build /data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles/hello_cpp11.dir/DependInfo.cmake --color=
Dependee "/data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles/hello_cpp11.dir/DependInfo.cmake" is newer than depender "/data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles/hello_cpp11.dir/depend.internal".
Dependee "/data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles/hello_cpp11.dir/depend.internal".
Scanning dependencies of target hello_cpp11
make[2]: Leaving directory '/data/code/01-basic/L-cpp-standard/iii-compile-features/build'
make -f CMakeFiles/hello_cpp11.dir/build.make CMakeFiles/hello_cpp11.dir/build
make[2]: Entering directory '/data/code/01-basic/L-cpp-standard/iii-compile-features/build'
[ 50%] Building CXX object CMakeFiles/hello_cpp11.dir/main.cpp.o
/usr/bin/c++ -std=gnu++11 -o CMakeFiles/hello_cpp11.dir/main.cpp.o -c /data/code/01-basic/L-cpp-standard/iii-compile-features/main.cpp
[100%] Linking CXX executable hello_cpp11
/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_cpp11.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/hello_cpp11.dir/main.cpp.o -o hello_cpp11 -rdynamic
make[2]: Leaving directory '/data/code/01-basic/L-cpp-standard/iii-compile-features/build'
[100%] Built target hello_cpp11
make[1]: Leaving directory '/data/code/01-basic/L-cpp-standard/iii-compile-features/build'
/usr/bin/cmake -E cmake_progress_start /data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles 0
----
================================================
FILE: 01-basic/L-cpp-standard/iii-compile-features/main.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
auto message = "Hello C++11";
std::cout << message << std::endl;
return 0;
}
================================================
FILE: 01-basic/README.adoc
================================================
= Basic Examples
The basic examples in this directory show how the setup a CMake project,
set compile flags, create and link executables and libraries, and install them.
The examples included are
- link:A-hello-cmake[hello-cmake]. A hello world example.
- link:B-hello-headers[hello-headers]. A slightly more complicated hello world example, using separate source and include folders.
- link:C-static-library[static-library]. An example using a static library.
- link:D-shared-library[shared-library]. An example using a shared library.
- link:E-installing[installing]. Shows how to create a 'make install' target that will install binaries and libraries.
- link:F-build-type[build-type]. An example showing how to set a default build and optimization flags for your project.
- link:G-compile-flags[compile-flags]. Shows how to set additional compile flags.
- link:H-third-party-library[third-party-library]. Shows an example of how to link third party libraries.
- link:I-compiling-with-clang[compiling-with-clang]. An example of invoking the clang compiler.
- link:J-building-with-ninja[building-with-ninja] - Shows how to generate ninja build files
- link:K-imported-targets[imported-targets] - Shows how to link boost using the new imported targets
- link:L-cpp-standard[cpp-standard] - Shows various methods to set the C++ standard
================================================
FILE: 02-sub-projects/A-basic/CMakeLists.txt
================================================
cmake_minimum_required (VERSION 3.5)
project(subprojects)
# Add sub directories
add_subdirectory(sublibrary1)
add_subdirectory(sublibrary2)
add_subdirectory(subbinary)
================================================
FILE: 02-sub-projects/A-basic/README.adoc
================================================
= Basic Sub-Project
:toc:
:toc-placement!:
toc::[]
# Introduction
This example shows how to setup a CMake project that includes sub-projects. The
top level CMakeLists.txt calls the CMakeLists.txt in the sub directories to
create the following:
* sublibrary1 - A static library
* sublibrary2 - A header only library
* subbinary - An executable
The files included in this example are:
```
$ tree
.
├── CMakeLists.txt
├── subbinary
│ ├── CMakeLists.txt
│ └── main.cpp
├── sublibrary1
│ ├── CMakeLists.txt
│ ├── include
│ │ └── sublib1
│ │ └── sublib1.h
│ └── src
│ └── sublib1.cpp
└── sublibrary2
├── CMakeLists.txt
└── include
└── sublib2
└── sublib2.h
```
* link:CMakeLists.txt[] - Top level CMakeLists.txt
* link:subbinary/CMakeLists.txt[] - to make the executable
* link:subbinary/main.cpp[] - source for the executable
* link:sublibrary1/CMakeLists.txt[] - to make a static library
* link:sublibrary1/include/sublib1/sublib1.h[]
* link:sublibrary1/src/sublib1.cpp[]
* link:sublibrary2/CMakeLists.txt[] - to setup header only library
* link:sublibrary2/include/sublib2/sublib2.h[]
[TIP]
====
In this example I have moved the header files to a subfolder under each projects +include+
directory, while leaving the target include as the root +include+ folder. This is a good idea to prevent
filename clashes because you have to include a file like below:
[source,cpp]
----
#include "sublib1/sublib1.h"
----
This also means that if you install your library for other users the default install location would be
+/usr/local/include/sublib1/sublib1.h+.
====
# Concepts
## Adding a Sub-Directory
A CMakeLists.txt file can include and call sub-directories which include a CMakeLists.txt
files.
[source,cmake]
----
add_subdirectory(sublibrary1)
add_subdirectory(sublibrary2)
add_subdirectory(subbinary)
----
## Referencing Sub-Project Directories
When a project is created using the `project()` command, CMake will automatically
create a number of variables which can be used to reference details about the project.
These variables can then be used by other sub-projects or the main project. For example,
to reference the source directory for a different project you can use.
[source,cmake]
----
${sublibrary1_SOURCE_DIR}
${sublibrary2_SOURCE_DIR}
----
The variables created by CMake include:
[cols=",",options="header",]
|=======================================================================
|Variable |Info
|PROJECT_NAME | The name of the project set by the current `project()`.
|CMAKE_PROJECT_NAME |the name of the first project set by the `project()`
command, i.e. the top level project.
|PROJECT_SOURCE_DIR |The source director of the current project.
|PROJECT_BINARY_DIR |The build directory for the current project.
|name_SOURCE_DIR | The source directory of the project called "name".
In this example the source directories created would be `sublibrary1_SOURCE_DIR`,
`sublibrary2_SOURCE_DIR`, and `subbinary_SOURCE_DIR`
|name_BINARY_DIR | The binary directory of the project called "name".
In this example the binary directories created would be `sublibrary1_BINARY_DIR`,
`sublibrary2_BINARY_DIR`, and `subbinary_BINARY_DIR`
|=======================================================================
## Header only Libraries
If you have a library that is created as a header only library, cmake supports the +INTERFACE+
target to allow creating a target without any build output. More details can be found from
link:https://cmake.org/cmake/help/v3.4/command/add_library.html#interface-libraries[here]
[source,cmake]
----
add_library(${PROJECT_NAME} INTERFACE)
----
When creating the target you can also include directories for that target using
the +INTERFACE+ scope. The +INTERFACE+ scope is use to make target requirements that are used in any Libraries
that link this target but not in the compilation of the target itself.
[source,cmake]
----
target_include_directories(${PROJECT_NAME}
INTERFACE
${PROJECT_SOURCE_DIR}/include
)
----
## Referencing Libraries from Sub-Projects
If a sub-project creates a library, it can be referenced by other projects by
calling the name of the target in the `target_link_libraries()` command. This
means that you don't have to reference the full path of the new library and it
is added as a dependency.
[source,cmake]
----
target_link_libraries(subbinary
PUBLIC
sublibrary1
)
----
Alternatively, you can create an alias target which allows you to reference the
target in read only contexts.
To create an alias target run:
[source,cmake]
----
add_library(sublibrary2)
add_library(sub::lib2 ALIAS sublibrary2)
----
To reference the alias, just it as follows:
[source,cmake]
----
target_link_libraries(subbinary
sub::lib2
)
----
## Include directories from sub-projects
When adding the libraries from the sub-projects, starting from cmake v3, there is
no need to add the projects include directories in the include directories of the
binary using them.
This is controlled by the scope in the `target_include_directories()` command when creating
the libraries. In this example because the subbinary executable links the sublibrary1
and sublibrary2 libraries it will automatically include the `${sublibrary1_SOURCE_DIR}/include`
and `${sublibrary2_SOURCE_DIR}/include` folders as they are exported with the
+PUBLIC+ and +INTERFACE+ scopes of the libraries.
# Building the example
[source,bash]
----
$ mkdir build
$ cd build/
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/02-sub-projects/A-basic/build
$ make
Scanning dependencies of target sublibrary1
[ 50%] Building CXX object sublibrary1/CMakeFiles/sublibrary1.dir/src/sublib1.cpp.o
Linking CXX static library libsublibrary1.a
[ 50%] Built target sublibrary1
Scanning dependencies of target subbinary
[100%] Building CXX object subbinary/CMakeFiles/subbinary.dir/main.cpp.o
Linking CXX executable subbinary
[100%] Built target subbinary
----
================================================
FILE: 02-sub-projects/A-basic/subbinary/CMakeLists.txt
================================================
project(subbinary)
# Create the executable
add_executable(${PROJECT_NAME} main.cpp)
# Link the static library from subproject1 using its alias sub::lib1
# Link the header only library from subproject2 using its alias sub::lib2
# This will cause the include directories for that target to be added to this project
target_link_libraries(${PROJECT_NAME}
sub::lib1
sub::lib2
)
================================================
FILE: 02-sub-projects/A-basic/subbinary/main.cpp
================================================
#include "sublib1/sublib1.h"
#include "sublib2/sublib2.h"
int main(int argc, char *argv[])
{
sublib1 hi;
hi.print();
sublib2 howdy;
howdy.print();
return 0;
}
================================================
FILE: 02-sub-projects/A-basic/sublibrary1/CMakeLists.txt
================================================
# Set the project name
project (sublibrary1)
# Add a library with the above sources
add_library(${PROJECT_NAME} src/sublib1.cpp)
add_library(sub::lib1 ALIAS ${PROJECT_NAME})
target_include_directories( ${PROJECT_NAME}
PUBLIC ${PROJECT_SOURCE_DIR}/include
)
================================================
FILE: 02-sub-projects/A-basic/sublibrary1/include/sublib1/sublib1.h
================================================
#ifndef __SUBLIB_1_H__
#define __SUBLIB_1_H__
class sublib1
{
public:
void print();
};
#endif
================================================
FILE: 02-sub-projects/A-basic/sublibrary1/src/sublib1.cpp
================================================
#include <iostream>
#include "sublib1/sublib1.h"
void sublib1::print()
{
std::cout << "Hello sub-library 1!" << std::endl;
}
================================================
FILE: 02-sub-projects/A-basic/sublibrary2/CMakeLists.txt
================================================
# Set the project name
project (sublibrary2)
add_library(${PROJECT_NAME} INTERFACE)
add_library(sub::lib2 ALIAS ${PROJECT_NAME})
target_include_directories(${PROJECT_NAME}
INTERFACE
${PROJECT_SOURCE_DIR}/include
)
================================================
FILE: 02-sub-projects/A-basic/sublibrary2/include/sublib2/sublib2.h
================================================
#ifndef __SUBLIB_2_H__
#define __SUBLIB_2_H__
#include <iostream>
class sublib2
{
public:
void print()
{
std::cout << "Hello header only sub-library 2!" << std::endl;
}
};
#endif
================================================
FILE: 02-sub-projects/README.adoc
================================================
= Sub-Project Examples
Many large projects are made up of different libraries and binaries. These
can be organised into multiple folders and sub-projects to ease development.
The examples included are
- link:A-basic[basic] - This basic example includes a static library, a header only library
and an executable
================================================
FILE: 03-code-generation/README.adoc
================================================
= Code Generation
Code generation can be useful to create source code in different languages from a common description file. This can reduce the amount of manual code to write and increase interoperability.
Examples showing code generation using variables from CMake and also using some common tools.
* link:configure-files[configure-file] - Using the CMake configure_file function to inject CMake variables.
* link:protobuf[Protocol Buffers] - Using Google Protocol Buffers to generate C++ source.
================================================
FILE: 03-code-generation/configure-files/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.5)
# Set the project name
project (cf_example)
# set a project version
set (cf_example_VERSION_MAJOR 0)
set (cf_example_VERSION_MINOR 2)
set (cf_example_VERSION_PATCH 1)
set (cf_example_VERSION "${cf_example_VERSION_MAJOR}.${cf_example_VERSION_MINOR}.${cf_example_VERSION_PATCH}")
# Call configure files on ver.h.in to set the version.
# Uses the standard ${VARIABLE} syntax in the file
configure_file(ver.h.in ${PROJECT_BINARY_DIR}/ver.h)
# configure the path.h.in file.
# This file can only use the @VARIABLE@ syntax in the file
configure_file(path.h.in ${PROJECT_BINARY_DIR}/path.h @ONLY)
# Add an executable
add_executable(cf_example
main.cpp
)
# include the directory with the new files
target_include_directories( cf_example
PUBLIC
${CMAKE_BINARY_DIR}
)
================================================
FILE: 03-code-generation/configure-files/README.adoc
================================================
= Configure Files Generation
:toc:
:toc-placement!:
toc::[]
# Introduction
During the call to cmake it is possible to create files that use variables from
the CMakeLists.txt and cmake cache. During CMake generation the file is copied to a
new location and any cmake variables are replaced.
The files in this tutorial are below:
```
$ tree
.
├── CMakeLists.txt
├── main.cpp
├── path.h.in
├── ver.h.in
```
* link:CMakeLists.txt[] - Contains the CMake commands you wish to run
* link:main.cpp[] - The source file with main
* link:path.h.in[] - File to contain a path to the build directory
* link:ver.h.in[] - File to contain the version of the project
# Concepts
## Configure Files
To do variable substitution in a file you can use the `configure_file()` function
in CMake. This core arguments for this function are source file and destination file.
[source,cmake]
----
configure_file(ver.h.in ${PROJECT_BINARY_DIR}/ver.h)
configure_file(path.h.in ${PROJECT_BINARY_DIR}/path.h @ONLY)
----
The first example above, allows the variable to be defined like a CMake variables using
the `${}` syntax or an `@@` in the ver.h.in file. After generation a new file ver.h will be available
in the `PROJECT_BINARY_DIR`.
```
const char* ver = "${cf_example_VERSION}";
```
The second example, only allows variables to be defined using the `@@` syntax in the path.h.in file.
After generation a new file path.h will be available in the `PROJECT_BINARY_DIR`.
```
const char* path = "@CMAKE_SOURCE_DIR@";
```
# Building the Example
[source,bash]
----
$ mkdir build
$ cd build/
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/03-code-generation/configure-files/build
$ ls
CMakeCache.txt CMakeFiles cmake_install.cmake Makefile path.h ver.h
$ cat path.h
#ifndef __PATH_H__
#define __PATH_H__
// version variable that will be substituted by cmake
// This shows an example using the @ variable type
const char* path = "/home/matrim/workspace/cmake-examples/03-code-generation/configure-files";
#endif
$ cat ver.h
#ifndef __VER_H__
#define __VER_H__
// version variable that will be substituted by cmake
// This shows an example using the $ variable type
const char* ver = "0.2.1";
#endif
$ make
Scanning dependencies of target cf_example
[100%] Building CXX object CMakeFiles/cf_example.dir/main.cpp.o
Linking CXX executable cf_example
[100%] Built target cf_example
$ ./cf_example
Hello Version 0.2.1!
Path is /home/matrim/workspace/cmake-examples/03-code-generation/configure-files
----
================================================
FILE: 03-code-generation/configure-files/main.cpp
================================================
#include <iostream>
#include "ver.h"
#include "path.h"
int main(int argc, char *argv[])
{
std::cout << "Hello Version " << ver << "!" << std::endl;
std::cout << "Path is " << path << std::endl;
return 0;
}
================================================
FILE: 03-code-generation/configure-files/path.h.in
================================================
#ifndef __PATH_H__
#define __PATH_H__
// version variable that will be substituted by cmake
// This shows an example using the @ variable type
const char* path = "@CMAKE_SOURCE_DIR@";
#endif
================================================
FILE: 03-code-generation/configure-files/ver.h.in
================================================
#ifndef __VER_H__
#define __VER_H__
// version variable that will be substituted by cmake
// This shows an example using the $ variable type
const char* ver = "${cf_example_VERSION}";
#endif
================================================
FILE: 03-code-generation/protobuf/AddressBook.proto
================================================
package tutorial;
message Person {
required string name = 1;
required int32 id = 2;
optional string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber {
required string number = 1;
optional PhoneType type = 2 [default = HOME];
}
repeated PhoneNumber phone = 4;
}
message AddressBook {
repeated Person person = 1;
}
================================================
FILE: 03-code-generation/protobuf/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.5)
# Set the project name
project (protobuf_example)
# find the protobuf compiler and libraries
find_package(Protobuf REQUIRED)
# check if protobuf was found
if(PROTOBUF_FOUND)
message ("protobuf found")
else()
message (FATAL_ERROR "Cannot find Protobuf")
endif()
# Generate the .h and .cxx files
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS AddressBook.proto)
# Print path to generated files
message ("PROTO_SRCS = ${PROTO_SRCS}")
message ("PROTO_HDRS = ${PROTO_HDRS}")
# Add an executable
add_executable(protobuf_example
main.cpp
${PROTO_SRCS}
${PROTO_HDRS})
target_include_directories(protobuf_example
PUBLIC
${PROTOBUF_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
)
# link the exe against the libraries
target_link_libraries(protobuf_example
PUBLIC
${PROTOBUF_LIBRARIES}
)
================================================
FILE: 03-code-generation/protobuf/README.adoc
================================================
= Protobuf Code Generation
:toc:
:toc-placement!:
toc::[]
# Introduction
This example shows how to generate source files using https://github.com/google/protobuf[protobuf].
Protocol Buffers is a data serialization format from Google. A user provides a
`.proto` file with a description of the data. Then using the protobuf compiler, the proto file
can be translated into source code in a number of languages including C++.
The files in this tutorial are below:
```
$ tree
.
├── AddressBook.proto
├── CMakeLists.txt
├── main.cpp
```
* link:AddressBook.proto[] - proto file from main protocol buffer https://developers.google.com/protocol-buffers/docs/cpptutorial[example]
* link:CMakeLists.txt[] - Contains the CMake commands you wish to run
* link:main.cpp[] - The source file from the protobuf example.
# Requirements
This example requires the protocol buffers binary and libraries to be installed.
This can be installed on Ubuntu using
[source,bash]
----
sudo apt-get install protobuf-compiler libprotobuf-dev
----
# Concepts
## Exported Variables
The variables exported by the CMake protobuf package and used in this example include:
* `PROTOBUF_FOUND` - If Protocol Buffers is installed
* `PROTOBUF_INCLUDE_DIRS` - The protobuf header files
* `PROTOBUF_LIBRARIES` - The protobuf library
More variables are defined and can be found by examining the documentation at the
top of your `FindProtobuf.cmake` file.
## Generating Source
The protobuf CMake package includes a number of helper functions to make the
code generation easier. In this example we are generating C++ source and use
the following code:
[source,cmake]
----
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS AddressBook.proto)
----
The arguments are:
* PROTO_SRCS - Name of the variable that will store the .pb.cc files.
* PROTO_HDRS- Name of the variable that will store the .pb.h files.
* AddressBook.proto - The .proto file to generate code from.
## Generated Files
After the `PROTOBUF_GENERATE_CPP` function is called, you will have the above
mentioned variables available. These will be marked as the output to a custom command
which calls the protobuf compiler binary to generate them.
To then have the files generated you should add them to a library or executable.
For example:
[source,cmake]
----
add_executable(protobuf_example
main.cpp
${PROTO_SRCS}
${PROTO_HDRS})
----
This will cause the protobuf compiler to be called when you call `make` on that
executables target.
When changes are made to the .proto file, the associated source files will be
autogenerated again. However, if no changes are made to the .proto file and you re-run
make, then nothing will be done.
# Building the Example
[source,bash]
----
$ mkdir build
$ cd build/
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found PROTOBUF: /usr/lib/x86_64-linux-gnu/libprotobuf.so
protobuf found
PROTO_SRCS = /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/AddressBook.pb.cc
PROTO_HDRS = /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/AddressBook.pb.h
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build
$ ls
CMakeCache.txt CMakeFiles cmake_install.cmake Makefile
$ make VERBOSE=1
/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/03-code-generation/protobuf -B/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'
make -f CMakeFiles/protobuf_example.dir/build.make CMakeFiles/protobuf_example.dir/depend
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 1
[ 33%] Running C++ protocol buffer compiler on AddressBook.proto
/usr/bin/protoc --cpp_out /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build -I /home/matrim/workspace/cmake-examples/03-code-generation/protobuf /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/AddressBook.proto
cd /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/matrim/workspace/cmake-examples/03-code-generation/protobuf /home/matrim/workspace/cmake-examples/03-code-generation/protobuf /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/DependInfo.cmake --color=
Dependee "/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/DependInfo.cmake" is newer than depender "/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/depend.internal".
Dependee "/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/depend.internal".
Scanning dependencies of target protobuf_example
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'
make -f CMakeFiles/protobuf_example.dir/build.make CMakeFiles/protobuf_example.dir/build
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 2
[ 66%] Building CXX object CMakeFiles/protobuf_example.dir/main.cpp.o
/usr/bin/c++ -I/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build -o CMakeFiles/protobuf_example.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/main.cpp
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 3
[100%] Building CXX object CMakeFiles/protobuf_example.dir/AddressBook.pb.cc.o
/usr/bin/c++ -I/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build -o CMakeFiles/protobuf_example.dir/AddressBook.pb.cc.o -c /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/AddressBook.pb.cc
Linking CXX executable protobuf_example
/usr/bin/cmake -E cmake_link_script CMakeFiles/protobuf_example.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/protobuf_example.dir/main.cpp.o CMakeFiles/protobuf_example.dir/AddressBook.pb.cc.o -o protobuf_example -rdynamic -lprotobuf -lpthread
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 1 2 3
[100%] Built target protobuf_example
make[1]: Leaving directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 0
$ make VERBOSE=1
/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/03-code-generation/protobuf -B/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'
make -f CMakeFiles/protobuf_example.dir/build.make CMakeFiles/protobuf_example.dir/depend
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 1
[ 33%] Running C++ protocol buffer compiler on AddressBook.proto
/usr/bin/protoc --cpp_out /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build -I /home/matrim/workspace/cmake-examples/03-code-generation/protobuf /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/AddressBook.proto
cd /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/matrim/workspace/cmake-examples/03-code-generation/protobuf /home/matrim/workspace/cmake-examples/03-code-generation/protobuf /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/DependInfo.cmake --color=
Dependee "/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/DependInfo.cmake" is newer than depender "/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/depend.internal".
Dependee "/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/depend.internal".
Scanning dependencies of target protobuf_example
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'
make -f CMakeFiles/protobuf_example.dir/build.make CMakeFiles/protobuf_example.dir/build
make[2]: Entering directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 2
[ 66%] Building CXX object CMakeFiles/protobuf_example.dir/main.cpp.o
/usr/bin/c++ -I/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build -o CMakeFiles/protobuf_example.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/main.cpp
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 3
[100%] Building CXX object CMakeFiles/protobuf_example.dir/AddressBook.pb.cc.o
/usr/bin/c++ -I/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build -o CMakeFiles/protobuf_example.dir/AddressBook.pb.cc.o -c /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/AddressBook.pb.cc
Linking CXX executable protobuf_example
/usr/bin/cmake -E cmake_link_script CMakeFiles/protobuf_example.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/protobuf_example.dir/main.cpp.o CMakeFiles/protobuf_example.dir/AddressBook.pb.cc.o -o protobuf_example -rdynamic -lprotobuf -lpthread
make[2]: Leaving directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'
/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 1 2 3
[100%] Built target protobuf_example
make[1]: Leaving directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'
/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 0
$ ls
AddressBook.pb.cc CMakeCache.txt cmake_install.cmake protobuf_example
AddressBook.pb.h CMakeFiles Makefile
$ ./protobuf_example test.db
test.db: File not found. Creating a new file.
Enter person ID number: 11
Enter name: John Doe
Enter email address (blank for none): wolly@sheep.ie
Enter a phone number (or leave blank to finish):
$ ls
AddressBook.pb.cc CMakeCache.txt cmake_install.cmake protobuf_example
AddressBook.pb.h CMakeFiles Makefile test.db
----
================================================
FILE: 03-code-generation/protobuf/main.cpp
================================================
#include <iostream>
#include <fstream>
#include <string>
#include "AddressBook.pb.h"
using namespace std;
// This function fills in a Person message based on user input.
void PromptForAddress(tutorial::Person* person) {
cout << "Enter person ID number: ";
int id;
cin >> id;
person->set_id(id);
cin.ignore(256, '\n');
cout << "Enter name: ";
getline(cin, *person->mutable_name());
cout << "Enter email address (blank for none): ";
string email;
getline(cin, email);
if (!email.empty()) {
person->set_email(email);
}
while (true) {
cout << "Enter a phone number (or leave blank to finish): ";
string number;
getline(cin, number);
if (number.empty()) {
break;
}
tutorial::Person::PhoneNumber* phone_number = person->add_phone();
phone_number->set_number(number);
cout << "Is this a mobile, home, or work phone? ";
string type;
getline(cin, type);
if (type == "mobile") {
phone_number->set_type(tutorial::Person::MOBILE);
} else if (type == "home") {
phone_number->set_type(tutorial::Person::HOME);
} else if (type == "work") {
phone_number->set_type(tutorial::Person::WORK);
} else {
cout << "Unknown phone type. Using default." << endl;
}
}
}
// Main function: Reads the entire address book from a file,
// adds one person based on user input, then writes it back out to the same
// file.
int main(int argc, char* argv[]) {
// Verify that the version of the library that we linked against is
// compatible with the version of the headers we compiled against.
GOOGLE_PROTOBUF_VERIFY_VERSION;
if (argc != 2) {
cerr << "Usage: " << argv[0] << " ADDRESS_BOOK_FILE" << endl;
return -1;
}
tutorial::AddressBook address_book;
{
// Read the existing address book.
fstream input(argv[1], ios::in | ios::binary);
if (!input) {
cout << argv[1] << ": File not found. Creating a new file." << endl;
} else if (!address_book.ParseFromIstream(&input)) {
cerr << "Failed to parse address book." << endl;
return -1;
}
}
// Add an address.
PromptForAddress(address_book.add_person());
{
// Write the new address book back to disk.
fstream output(argv[1], ios::out | ios::trunc | ios::binary);
if (!address_book.SerializeToOstream(&output)) {
cerr << "Failed to write address book." << endl;
return -1;
}
}
// Optional: Delete all global objects allocated by libprotobuf.
google::protobuf::ShutdownProtobufLibrary();
return 0;
}
================================================
FILE: 04-static-analysis/README.adoc
================================================
= Static Analysis
:toc:
:toc-placement!:
toc::[]
# Introduction
Static analysis is the analysis of code without executing it. It can be
used to find common programming errors and enforce coding guidelines.
Examples of errors that can be found using static analysis tools
include:
* Out of bounds errors
* Memory leaks
* Usage of uninitialized variables
* Use of unsafe functions
Analysis tools can detect errors early and are becoming a standard tool
in most build chains. Some build tools such as
http://clang-analyzer.llvm.org/[Clang] include a build in static
analysis tool. However standalone tools also exist.
The examples here include using the following tools:
* http://cppcheck.sourceforge.net/[CppCheck]
* https://clang-analyzer.llvm.org/[Clang Static Analyzer]
* https://clang.llvm.org/docs/ClangFormat.html[Clang Format]
================================================
FILE: 04-static-analysis/clang-analyzer/CMakeLists.txt
================================================
cmake_minimum_required (VERSION 3.5)
project(cppcheck_analysis)
# Use debug build as recommended
set(CMAKE_BUILD_TYPE Debug)
# Have cmake create a compile database
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Add sub directories
add_subdirectory(subproject1)
add_subdirectory(subproject2)
================================================
FILE: 04-static-analysis/clang-analyzer/README.adoc
================================================
= clang-analyzer
:toc:
:toc-placement!:
toc::[]
# Introduction
This example shows how to call the
https://clang-analyzer.llvm.org/[Clang Static Analyzer] to do static analysis using the
scan-build tool.
The files included in this example are:
```
$ tree
.
├── CMakeLists.txt
├── subproject1
│ ├── CMakeLists.txt
│ └── main1.cpp
└── subproject2
├── CMakeLists.txt
└── main2.cpp
```
* link:CMakeLists.txt[] - Top level CMakeLists.txt
* link:subproject1/CMakeLists.txt[] - CMake commands for subproject 1
* link:subproject1/main.cpp[] - source for a subproject with no errors
* link:subproject2/CMakeLists.txt[] - CMake commands for subproject 2
* link:subproject2/main2.cpp[] - source for a subproject that includes errors
# Requirements
To run this example you must have clang analyzer and the scan-build tool installed. This can be installed on Ubuntu using the following command.
[source,bash]
----
$ sudo apt-get install clang
----
It will result in the tool being available as:
[source,bash]
----
$ scan-build-3.6
----
# Concepts
## scan-build
To run clang static analyzer you can use the tool `scan-build` to run the analyzer when you
also run the compiler. This overrides the CC and CXX environment variables and replaces them with it's own tools. To run it you can do
[source,bash]
----
$ scan-build-3.6 cmake ..
$ scan-build-3.6 make
----
By default this will run the standard compiler for your platform, i.e. `gcc` on linux. However, if you want to override this you can change the command to:
[source,bash]
----
$ scan-build-3.6 --use-cc=clang-3.6 --use-c++=clang++-3.6 -o ./scanbuildout/ make
----
## scan-build output
scan-build will only output warnings during compile time and will also generate a list of HTML files which contain detailed analysis of the error.
[source,bash]
----
$ cd scanbuildout/
$ tree
.
└── 2017-07-03-213514-3653-1
├── index.html
├── report-42eba1.html
├── scanview.css
└── sorttable.js
1 directory, 4 files
----
By default these are output to +/tmp/scanbuildout/{run folder}+. You can change this using `scan-build -o /output/folder`.
# Building the example
[source,bash]
----
$ mkdir build
$ cd build/
$ scan-build-3.6 -o ./scanbuildout make
scan-build: Using '/usr/lib/llvm-3.6/bin/clang' for static analysis
make: *** No targets specified and no makefile found. Stop.
scan-build: Removing directory '/data/code/clang-analyzer/build/scanbuildout/2017-07-03-211632-937-1' because it contains no reports.
scan-build: No bugs found.
devuser@91457fbfa423:/data/code/clang-analyzer/build$ scan-build-3.6 -o ./scanbuildout cmake ..
scan-build: Using '/usr/lib/llvm-3.6/bin/clang' for static analysis
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/share/clang/scan-build-3.6/ccc-analyzer
-- Check for working C compiler: /usr/share/clang/scan-build-3.6/ccc-analyzer -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/share/clang/scan-build-3.6/c++-analyzer
-- Check for working CXX compiler: /usr/share/clang/scan-build-3.6/c++-analyzer -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found CPPCHECK: /usr/local/bin/cppcheck
cppcheck found. Use cppccheck-analysis targets to run it
-- Configuring done
-- Generating done
-- Build files have been written to: /data/code/clang-analyzer/build
scan-build: Removing directory '/data/code/clang-analyzer/build/scanbuildout/2017-07-03-211641-941-1' because it contains no reports.
scan-build: No bugs found.
$ $ scan-build-3.6 -o ./scanbuildout make
scan-build: Using '/usr/lib/llvm-3.6/bin/clang' for static analysis
Scanning dependencies of target subproject1
[ 25%] Building CXX object subproject1/CMakeFiles/subproject1.dir/main1.cpp.o
[ 50%] Linking CXX executable subproject1
[ 50%] Built target subproject1
Scanning dependencies of target subproject2
[ 75%] Building CXX object subproject2/CMakeFiles/subproject2.dir/main2.cpp.o
/data/code/clang-analyzer/subproject2/main2.cpp:7:17: warning: Dereference of null pointer (loaded from variable 'x')
std::cout << *x << std::endl;
^~
1 warning generated.
[100%] Linking CXX executable subproject2
[100%] Built target subproject2
scan-build: 1 bug found.
scan-build: Run 'scan-view /data/code/clang-analyzer/build/scanbuildout/2017-07-03-211647-1172-1' to examine bug reports.
$ cd scanbuildout/
$ tree
.
└── 2017-07-03-213514-3653-1
├── index.html
├── report-42eba1.html
├── scanview.css
└── sorttable.js
1 directory, 4 files
----
================================================
FILE: 04-static-analysis/clang-analyzer/run_test.sh
================================================
#!/bin/bash
mkdir -p build \
&& cd build \
&& scan-build-3.6 -o scanbuildout cmake .. \
&& scan-build-3.6 -o scanbuildout make
================================================
FILE: 04-static-analysis/clang-analyzer/subproject1/CMakeLists.txt
================================================
# Set the project name
project (subproject1)
# Add an executable with the above sources
add_executable(${PROJECT_NAME} main1.cpp)
================================================
FILE: 04-static-analysis/clang-analyzer/subproject1/main1.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello Main1!" << std::endl;
return 0;
}
================================================
FILE: 04-static-analysis/clang-analyzer/subproject2/CMakeLists.txt
================================================
# Set the project name
project (subproject2)
# Add an executable with the above sources
add_executable(${PROJECT_NAME} main2.cpp)
================================================
FILE: 04-static-analysis/clang-analyzer/subproject2/main2.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello Main2!" << std::endl;
int* x = NULL;
std::cout << *x << std::endl;
return 0;
}
================================================
FILE: 04-static-analysis/clang-format/.clang-format
================================================
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 120
CommentPragmas: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 3
NamespaceIndentation: All
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...
================================================
FILE: 04-static-analysis/clang-format/CMakeLists.txt
================================================
cmake_minimum_required (VERSION 3.5)
project(cppcheck_analysis)
# Add a custom CMake Modules directory
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules
${CMAKE_MODULE_PATH})
# Add sub directories
add_subdirectory(subproject1)
add_subdirectory(subproject2)
set(CLANG_FORMAT_BIN_NAME clang-format-3.6)
set(CLANG_FORMAT_EXCLUDE_PATTERNS "build/" ${CMAKE_BINARY_DIR})
find_package(ClangFormat)
================================================
FILE: 04-static-analysis/clang-format/README.adoc
================================================
= clang-format
:toc:
:toc-placement!:
toc::[]
# Introduction
This example shows how to call the
https://clang.llvm.org/docs/ClangFormat.html[Clang Format] to check if your source code
matches against your code style guidelines.
The files included in this example are:
```
$ tree
.
├── .clang-format
├── CMakeLists.txt
├── cmake
│ ├── modules
│ │ ├── clang-format.cmake
│ │ └── FindClangFormat.cmake
│ └── scripts
│ └── clang-format-check-changed
├── subproject1
│ ├── CMakeLists.txt
│ └── main1.cpp
└── subproject2
├── CMakeLists.txt
└── main2.cpp
```
* link:CMakeLists.txt[] - Top level CMakeLists.txt
* link:.clang-format[] - The file describing the style guide
* link:cmake/modules/FindClangFormat.cmake[] - Script to find the clang-format binary
* link:cmake/modules/clang-format.cmake[] - Script to setup the format targets
* link:cmake/scripts/clang-format-check-changed.py[] - A helper script to check against changed files in git
* link:cmake/scripts/clang-format-check-changed.py[] - An old simplified version of the above helper script
* link:subproject1/CMakeLists.txt[] - CMake commands for subproject 1
* link:subproject1/main1.cpp[] - source for a subproject with no style errors
* link:subproject2/CMakeLists.txt[] - CMake commands for subproject 2
* link:subproject2/main2.cpp[] - source for a subproject that includes style errors
# Requirements
To run this example you must have clang format tool installed. This can be installed on Ubuntu using the following command.
[source,bash]
----
$ sudo apt-get install clang-format-3.6
----
It will result in the tool being available as:
[source,bash]
----
$ clang-format-3.6
----
If you install a different version, you can edit the `CLANG_FORMAT_BIN_NAME` variable in the root CMakeLists.txt
# Concepts
## clang-format
+clang-format+ can scan a source file then find and optionally format it to match your
companys style guidelines. There are default styles build in but you can also setup a style guide using a custom file called +.clang-format+, for example a snipped from this
repositories +.clang-format+ is below:
[source]
----
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
----
## format style
As mentioned, the style in this example is based on the +.clang-format+ file. This can be changed by editing link:cmake/modules/clang-format.cmake[clang-format.cmake] and changing
the `-style=file` to the required style;
# Targets
This example will setup 3 targets:
* format
* format-check
* format-check-changed
## format
The format target will find any C++ source files and in place modify them to match the
+.clang-format+ style. The source files are found using the following cmake code
[source,cmake]
----
file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h *.cxx *.hxx *.hpp *.cc *.ipp)
# Don't include some common build folders
set(CLANG_FORMAT_EXCLUDE_PATTERNS ${CLANG_FORMAT_EXCLUDE_PATTERNS} "/CMakeFiles/" "cmake")
# get all project files file
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
foreach (EXCLUDE_PATTERN ${CLANG_FORMAT_EXCLUDE_PATTERNS})
string(FIND ${SOURCE_FILE} ${EXCLUDE_PATTERN} EXCLUDE_FOUND)
if (NOT ${EXCLUDE_FOUND} EQUAL -1)
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
endif ()
endforeach ()
endforeach ()
----
This will find files matching the common C++ suffixes and then remove any that match some
common CMake directories.
In the root `CMakeList.txt` we also exclude the build directory by adding the line
[source,cmake]
----
set(CLANG_FORMAT_EXCLUDE_PATTERNS "build/")
----
## format-check
This target will work as above but instead of formatting the files it will cause a failure
if any files don't match the clang-format style
## format-check-changed
This target will check the output of `git status` and scan the files to check if they match the style. This can be used by developers to make sure their changed files match the correct style.
In this example the actual check is done with a helper script +clang-format-check-changed.py+. This script will run `git status --porcelain --ignore-submodules`
to get a list of changed files, match them against the allowed extensions from the above list, and finally remove any
that match the exclude pattern from +CLANG_FORMAT_EXCLUDE_PATTERNS+. It will then run these files through clang-format and
exit with an error if the files do not match the style.
An example call to the +clang-format-check-changed.py+ script is:
[source,bash]
----
cmake/scripts/clang-format-check-changed.py --file-extensions ".cpp,*.cpp,*.h,*.cxx,*.hxx,*.hpp,*.cc,*.ipp" --exclude=build/ --exclude=/CMakeFiles/ --exclude=cmake --clang-format-bin /usr/bin/clang-format-3.6
----
[NOTE]
====
This will include all changed files in your git repository that match the patterns. In this example repository this can include files that
are part of different examples.
====
================================================
FILE: 04-static-analysis/clang-format/cmake/modules/FindClangFormat.cmake
================================================
# Find Clang format
#
#
if(NOT CLANG_FORMAT_BIN_NAME)
set(CLANG_FORMAT_BIN_NAME clang-format)
endif()
# if custom path check there first
if(CLANG_FORMAT_ROOT_DIR)
find_program(CLANG_FORMAT_BIN
NAMES
${CLANG_FORMAT_BIN_NAME}
PATHS
"${CLANG_FORMAT_ROOT_DIR}"
NO_DEFAULT_PATH)
endif()
find_program(CLANG_FORMAT_BIN NAMES ${CLANG_FORMAT_BIN_NAME})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
CLANG_FORMAT
DEFAULT_MSG
CLANG_FORMAT_BIN)
mark_as_advanced(
CLANG_FORMAT_BIN)
if(CLANG_FORMAT_FOUND)
# A CMake script to find all source files and setup clang-format targets for them
include(clang-format)
else()
message("clang-format not found. Not setting up format targets")
endif()
================================================
FILE: 04-static-analysis/clang-format/cmake/modules/clang-format.cmake
================================================
# A CMake script to find all source files and setup clang-format targets for them
# Find all source files
set(CLANG_FORMAT_CXX_FILE_EXTENSIONS ${CLANG_FORMAT_CXX_FILE_EXTENSIONS} *.cpp *.h *.cxx *.hxx *.hpp *.cc *.ipp)
file(GLOB_RECURSE ALL_SOURCE_FILES ${CLANG_FORMAT_CXX_FILE_EXTENSIONS})
# Don't include some common build folders
set(CLANG_FORMAT_EXCLUDE_PATTERNS ${CLANG_FORMAT_EXCLUDE_PATTERNS} "/CMakeFiles/" "cmake")
# get all project files file
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
foreach (EXCLUDE_PATTERN ${CLANG_FORMAT_EXCLUDE_PATTERNS})
string(FIND ${SOURCE_FILE} ${EXCLUDE_PATTERN} EXCLUDE_FOUND)
if (NOT ${EXCLUDE_FOUND} EQUAL -1)
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
endif ()
endforeach ()
endforeach ()
add_custom_target(format
COMMENT "Running clang-format to change files"
COMMAND ${CLANG_FORMAT_BIN}
-style=file
-i
${ALL_SOURCE_FILES}
)
add_custom_target(format-check
COMMENT "Checking clang-format changes"
# Use ! to negate the result for correct output
COMMAND !
${CLANG_FORMAT_BIN}
-style=file
-output-replacements-xml
${ALL_SOURCE_FILES}
| grep -q "replacement offset"
)
# Get the path to this file
get_filename_component(_clangcheckpath ${CMAKE_CURRENT_LIST_FILE} PATH)
# have at least one here by default
set(CHANGED_FILE_EXTENSIONS ".cpp")
foreach(EXTENSION ${CLANG_FORMAT_CXX_FILE_EXTENSIONS})
set(CHANGED_FILE_EXTENSIONS "${CHANGED_FILE_EXTENSIONS},${EXTENSION}" )
endforeach()
set(EXCLUDE_PATTERN_ARGS)
foreach(EXCLUDE_PATTERN ${CLANG_FORMAT_EXCLUDE_PATTERNS})
list(APPEND EXCLUDE_PATTERN_ARGS "--exclude=${EXCLUDE_PATTERN}")
endforeach()
# call the script to check changed files in git
add_custom_target(format-check-changed
COMMENT "Checking changed files in git"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${_clangcheckpath}/../scripts/clang-format-check-changed.py
--file-extensions \"${CHANGED_FILE_EXTENSIONS}\"
${EXCLUDE_PATTERN_ARGS}
--clang-format-bin ${CLANG_FORMAT_BIN}
)
================================================
FILE: 04-static-analysis/clang-format/cmake/scripts/clang-format-check-changed
================================================
#!/bin/bash
# Required because cmake root isn't git root in this example
CLANG_FORMAT_BIN=$1
GIT_ROOT=`git rev-parse --show-toplevel`
pushd ${GIT_ROOT} > /dev/null
git status --porcelain \
| egrep '*\.cpp|*\.h|*\.cxx|*\.hxx|*\.hpp|*\.cc' \
| awk -F " " '{print $NF}' \
| xargs -r ${CLANG_FORMAT_BIN} -style=file -output-replacements-xml \
| grep "replacement offset" 2>&1 > /dev/null
RET=$?
popd > /dev/null
exit ${RET}
================================================
FILE: 04-static-analysis/clang-format/cmake/scripts/clang-format-check-changed.py
================================================
#!/usr/bin/env python
import argparse
import os
import sys
import subprocess
def check_file(filename, excludes, extensions):
"""
Check if a file should be included in our check
"""
name, ext = os.path.splitext(filename)
if len(ext) > 0 and ext in extensions:
if len(excludes) == 0:
return True
for exclude in excludes:
if exclude in filename:
return False
return True
return False
def check_directory(directory, excludes, extensions):
output = []
if len(excludes) > 0:
for exclude in excludes:
if exclude in directory:
directory_excluded = False
return output
for root, _, files in os.walk(directory):
for file in files:
filename = os.path.join(root, file)
if check_file(filename, excludes, extensions):
print("Will check file [{}]".format(filename))
output.append(filename)
return output
def get_git_root(git_bin):
cmd = [git_bin, "rev-parse", "--show-toplevel"]
try:
return subprocess.check_output(cmd).strip()
except subprocess.CalledProcessError, e:
print("Error calling git [{}]".format(e))
raise
def clean_git_filename(line):
"""
Takes a line from git status --porcelain and returns the filename
"""
file = None
git_status = line[:2]
# Not an exhaustive list of git status output but should
# be enough for this case
# check if this is a delete
if 'D' in git_status:
return None
# ignored file
if '!' in git_status:
return None
# Covers renamed files
if '->' in line:
file = line[3:].split('->')[-1].strip()
else:
file = line[3:].strip()
return file
def get_changed_files(git_bin, excludes, file_extensions):
"""
Run git status and return the list of changed files
"""
extensions = file_extensions.split(",")
# arguments coming from cmake will be *.xx. We want to remove the *
for i, extension in enumerate(extensions):
if extension[0] == '*':
extensions[i] = extension[1:]
git_root = get_git_root(git_bin)
cmd = [git_bin, "status", "--porcelain", "--ignore-submodules"]
print("git cmd = {}".format(cmd))
output = []
returncode = 0
try:
cmd_output = subprocess.check_output(cmd)
for line in cmd_output.split('\n'):
if len(line) > 0:
file = clean_git_filename(line)
if not file:
continue
file = os.path.join(git_root, file)
if file[-1] == "/":
directory_files = check_directory(
file, excludes, file_extensions)
output = output + directory_files
else:
if check_file(file, excludes, file_extensions):
print("Will check file [{}]".format(file))
output.append(file)
except subprocess.CalledProcessError, e:
print("Error calling git [{}]".format(e))
returncode = e.returncode
return output, returncode
def run_clang_format(clang_format_bin, changed_files):
"""
Run clang format on a list of files
@return 0 if formatted correctly.
"""
if len(changed_files) == 0:
return 0
cmd = [clang_format_bin, "-style=file",
"-output-replacements-xml"] + changed_files
print("clang-format cmd = {}".format(cmd))
try:
cmd_output = subprocess.check_output(cmd)
if "replacement offset" in cmd_output:
print("ERROR: Changed files don't match format")
return 1
except subprocess.CalledProcessError, e:
print("Error calling clang-format [{}]".format(e))
return e.returncode
return 0
def cli():
# global params
parser = argparse.ArgumentParser(prog='clang-format-check-changed',
description='Checks if files chagned in git match the .clang-format specification')
parser.add_argument("--file-extensions", type=str,
default=".cpp,.h,.cxx,.hxx,.hpp,.cc,.ipp",
help="Comma separated list of file extensions to check")
parser.add_argument('--exclude', action='append', default=[],
help='Will not match the files / directories with these in the name')
parser.add_argument('--clang-format-bin', type=str, default="clang-format",
help="The clang format binary")
parser.add_argument('--git-bin', type=str, default="git",
help="The git binary")
args = parser.parse_args()
# Run gcovr to get the .gcda files form .gcno
changed_files, returncode = get_changed_files(
args.git_bin, args.exclude, args.file_extensions)
if returncode != 0:
return returncode
return run_clang_format(args.clang_format_bin, changed_files)
if __name__ == '__main__':
sys.exit(cli())
================================================
FILE: 04-static-analysis/clang-format/run_test.sh
================================================
#!/bin/bash
mkdir -p build && cd build && cmake .. && make format-check
RET=$?
echo "return code was ${RET}"
if [ ${RET} == "0" ]; then
echo "test failed. Expected format-check to fail"
exit 1
else
echo "test success"
exit 0
fi
================================================
FILE: 04-static-analysis/clang-format/subproject1/CMakeLists.txt
================================================
# Set the project name
project (subproject1)
# Add an executable with the above sources
add_executable(${PROJECT_NAME} main1.cpp)
================================================
FILE: 04-static-analysis/clang-format/subproject1/main1.cpp
================================================
#include <iostream>
int main(int argc, char* argv[])
{
std::cout << "Hello Main1!" << std::endl;
return 0;
}
================================================
FILE: 04-static-analysis/clang-format/subproject2/CMakeLists.txt
================================================
# Set the project name
project (subproject2)
# Add an executable with the above sources
add_executable(${PROJECT_NAME} main2.cpp)
================================================
FILE: 04-static-analysis/clang-format/subproject2/main2.cpp
================================================
#include <iostream>
class TestClass {
public:
TestClass();
};
TestClass::TestClass() {
}
int main(int argc, char* argv[])
{
std::cout << "Hello Main2!" << std::endl;
int* x = NULL;
std::cout << *x << std::endl;
return 0;
}
================================================
FILE: 04-static-analysis/cppcheck/CMakeLists.txt
================================================
cmake_minimum_required (VERSION 3.5)
project(cppcheck_analysis)
# Add a custom CMake Modules directory
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules
${CMAKE_MODULE_PATH})
# find the cppcheck binary
find_package(CppCheck)
# static analysis. Should be before adding subprojects
set (ALL_ANALYSIS_TARGETS)
# Add sub directories
add_subdirectory(subproject1)
add_subdirectory(subproject2)
# Add the "make analysis" target
if( CPPCHECK_FOUND )
add_custom_target(analysis)
ADD_DEPENDENCIES(analysis ${ALL_ANALYSIS_TARGETS})
set_target_properties(analysis PROPERTIES EXCLUDE_FROM_ALL TRUE)
message("analysis analysis targets are ${ALL_ANALYSIS_TARGETS}")
endif()
================================================
FILE: 04-static-analysis/cppcheck/README.adoc
================================================
= CppCheck Static Analysis
:toc:
:toc-placement!:
toc::[]
# Introduction
This example shows how to call the
http://cppcheck.sourceforge.net/[CppCheck] tool to do static analysis.
This shows how to make an analysis target for each project in your repository.
It includes code to
* Find the cppcheck binary
* Add cppcheck with a target for each sub-projects
* Generate an overall `make analysis` target to do static
analysis on all sub-projects.
The files included in this example are:
```
$ tree
.
├── cmake
│ ├── analysis.cmake
│ └── modules
│ └── FindCppCheck.cmake
├── CMakeLists.txt
├── subproject1
│ ├── CMakeLists.txt
│ └── main1.cpp
└── subproject2
├── CMakeLists.txt
└── main2.cpp
```
* link:CMakeLists.txt[] - Top level CMakeLists.txt
* link:cmake/analysis.cmake[] - Includes functions to add analysis targets
* link:cmake/modules/FindCppCheck.cmake[] - A custom package module to find CppCheck
* link:subproject1/CMakeLists.txt[] - CMake commands for subproject 1
* link:subproject1/main.cpp[] - source for a subproject with no errors
* link:subproject2/CMakeLists.txt[] - CMake commands for subproject 2
* link:subproject2/main2.cpp[] - source for a subproject that includes errors
# Requirements
To run this example you must have the CppCheck utility installed. On
Ubuntu you can install it as
[source,bash]
----
$ sudo apt-get install cppcheck
----
# Concepts
## Adding Custom Package Modules
Custom modules can be used to find programs, libraries and header files
to include in your program.
### Adding a custom module
The `cmake/modules/FindCppCheck.cmake` file contains the code to initialise a
custom package module.
The following is a breakdown of the file:
[source,cmake,numbered]
----
find_program(CPPCHECK_BIN NAMES cppcheck)
----
Search the path for the cppcheck binary. Once found store the result in the
+CPPCHECK_BIN+ variable
[source,cmake,numbered]
----
set (CPPCHECK_THREADS "-j 4" CACHE STRING "The -j argument to have cppcheck use multiple threads / cores")
set (CPPCHECK_ARG "${CPPCHECK_THREADS}" CACHE STRING "The arguments to pass to cppcheck. If set will overwrite CPPCHECK_THREADS")
----
Set some custom arguments that can be later passed to cppcheck.
[source,cmake]
----
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
CPPCHECK
DEFAULT_MSG
CPPCHECK_BIN
CPPCHECK_THREADS
CPPCHECK_ARG)
mark_as_advanced(
CPPCHECK_BIN
CPPCHECK_THREADS
CPPCHECK_ARG)
----
Export the variables so that they can be seen from ccmake / cmake-gui
and set in the cache. By default these will not be visible unless the
view advanced flag is set.
### Setting path to custom modules
The default path that CMake will search for modules is `/usr/share/cmake/Modules`.
To include custom modules you must tell CMake where to search for them.
This can be done using the variable +${CMAKE_MODULE_PATH}+ which
contains the paths that CMake will search for modules.
[source,cmake]
----
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules
${CMAKE_MODULE_PATH})
----
To then add the package module to your CMakeLists.txt you can call
[source,cmake]
----
find_package(CppCheck)
----
## Parent Scope Variables
The scope of variables when they are declared / changed is typically in
the function of file the are called. To make a change to a variable
which is the caller of your scope, you should call it as follows:
[source,cmake]
----
set(ALL_ANALYSIS_TARGETS "${ALL_ANALYSIS_TARGETS}" PARENT_SCOPE)
----
## add_analysis macro
The +add_analysis()+ macro in `cmake/analysis.cmake` is the core idea for this
example. If cppcheck is available then a list of arguments are compiled
and added to a custom command that calls cppcheck on the sources. These
are then added to a custom target.
A breakdown of this macro is below:
[source,cmake]
----
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
LIST(APPEND cppcheck_includes "-I${dir}")
endforeach()
----
Find the include files from and calls to +include_directories()+ in the
same project.
[source,cmake]
----
LIST(APPEND ALL_ANALYSIS_TARGETS "${_target}_analysis")
set(ALL_ANALYSIS_TARGETS "${ALL_ANALYSIS_TARGETS}" PARENT_SCOPE)
----
Export the target name into a variable that can later be used to add a
global `make analysis` target.
[source,cmake]
----
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VESION} GREATER 2.7)
separate_arguments(tmp_args UNIX_COMMAND ${CPPCHECK_ARG})
else ()
# cmake 2.6 has different arguments
string(REPLACE " " ";" tmp_args ${CPPCHECK_ARG})
endif ()
----
Change the +CPPCHECK_ARG+ so that the can be added to command correctly in
the custom command.
[source,cmake]
----
add_custom_target(${_target}_analysis)
set_target_properties(${_target}_analysis PROPERTIES EXCLUDE_FROM_ALL TRUE)
----
Add a custom target with a name you have passed in followed by
_analysis. Do not include this in the all target.
[source,cmake]
----
add_custom_command(TARGET ${_target}_analysis PRE_BUILD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND ${CPPCHECK_BIN} ${tmp_args} ${cppcheck_includes} ${${_sources}}
DEPENDS ${${_sources}}
COMMENT "Running cppcheck: ${_target}"
VERBATIM)
----
Add a custom command which is called from the custom target added above.
This will call cppcheck with any includes, arguments and sources that
you have provided. The sources that are analysed come from a _sources
variable. This should be the name of the variable which holds your list
of source files.
To call the +add_analysis()+ marco add the following to your projects
CMakeLists.txt file:
[source,cmake]
----
include(${CMAKE_SOURCE_DIR}/cmake/analysis.cmake)
add_analysis(${PROJECT_NAME} SOURCES)
----
## Creating a target to call other targets
In the top level CMakeLists.txt a custom target is created, which will call
all other analysis targets. This allows you to call `make analysis` and
scan all sub projects.
To achieve this 2 things should be added to the top level CMakeLists.txt
First add an empty variable +ALL_ANALYSIS_TARGETS+ before calling your
+add_subdirectories()+ function.
[source,cmake]
----
set (ALL_ANALYSIS_TARGETS)
----
Second add the following after your +add_subdirectories()+ call.
[source,cmake]
----
if( CPPCHECK_FOUND )
add_custom_target(analysis)
ADD_DEPENDENCIES(analysis ${ALL_ANALYSIS_TARGETS})
set_target_properties(analysis PROPERTIES EXCLUDE_FROM_ALL TRUE)
message("analysis analysis targets are ${ALL_ANALYSIS_TARGETS}")
endif()
----
This adds the "make analysis" target which calls all the sub-targets.
# Building the example
[source,bash]
----
$ mkdir build
$ cd build/
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found CPPCHECK: /usr/bin/cppcheck
adding cppcheck analysys target for subproject1
adding cppcheck analysys target for subproject2
analysis analysis targets are subproject1_analysis;subproject2_analysis
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matrim/workspace/cmake-examples/04-static-analysis/cppcheck/build
$ make analysis
Scanning dependencies of target subproject1_analysis
Running cppcheck: subproject1
Checking main1.cpp...
Built target subproject1_analysis
Scanning dependencies of target subproject2_analysis
Running cppcheck: subproject2
Checking main2.cpp...
[main2.cpp:7]: (error) Array 'tmp[10]' accessed at index 11, which is out of bounds.
Built target subproject2_analysis
Scanning dependencies of target analysis
Built target analysis
----
The above calls cppcheck in both subproject folders as
[source,bash]
----
...
cd /path/to/subproject1 && /usr/bin/cppcheck -j 4 main1.cpp
...
cd /path/to/subproject2 && /usr/bin/cppcheck -j 4 main2.cpp
...
----
The main1.cpp has no errors so will complete correctly, however the
main2.cpp includes an out-of-bounds error. This is show with a warning as
------------------------------------------------------------------------------------
[main2.cpp:7]: (error) Array 'tmp[10]' accessed at index 11, which is out of bounds.
------------------------------------------------------------------------------------
By default cppcheck only prints warnings and exits with a successful
exit code. If the +${CPPCHECK_ARG}+ variable is set with
`--error-exitcode=1`, the make analysis will finish early as follows.
[source,bash]
----
$ make analysis
Running cppcheck: subproject2
Checking main2.cpp...
[main2.cpp:7]: (error) Array 'tmp[10]' accessed at index 11, which is out of bounds.
make[3]: *** [subproject2_analysis] Error 1
make[2]: *** [subproject2/CMakeFiles/subproject2_analysis.dir/all] Error 2
make[1]: *** [CMakeFiles/analysis.dir/rule] Error 2
make: *** [analysis] Error 2
----
# Extra Notes
## Multiple Folders
If you have a multiple folders levels, where one folder just points to
sub folders, such as below:
------------------------------
├── root
│ ├── CMakeLists.txt
│ ├── src
│ │ ├── CMakeLists.txt
│ │ ├── project1
│ │ │ ├── CMakeLists.txt
│ │ │ ├── main.cpp
│ │ ├── project2
│ │ │ ├── CMakeLists.txt
│ │ │ ├── main.cpp
------------------------------
To correctly generate the root `make analysis` target you must export the +ALL_ANALYSIS_TARGET+
variable to the parent scope in `src/CMakeLists.txt`.
[source,cmake]
----
add_subdirectory(project1)
add_subdirectory(project2)
set(ALL_ANALYSIS_TARGETS "${ALL_ANALYSIS_TARGETS}" PARENT_SCOPE)
----
## Include Directories
In the +add_analysis+ macro in `analysis.cmake` we extract the +INCLUDE_DIRECTORIES+ from the
target and add them to the call to cppcheck.
[source,cmake]
----
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
LIST(APPEND cppcheck_includes "-I${dir}")
endforeach()
----
This works for basic examples but if you use some CMake features such as
generator expressions this will not add the include directory.
================================================
FILE: 04-static-analysis/cppcheck/cmake/analysis.cmake
================================================
# Make sure cppcheck binary is available
if( NOT CPPCHECK_FOUND )
find_package(CppCheck)
endif()
# add a target for CppCheck
# _target - The name of the project that this is for. Will generate ${_target}_analysis
# _sources - The name of the variable holding the sources list.
# This is the name of the variable not the actual list
#
# Macro instead of function to make the PARENT_SCOPE stuff easier
macro(add_analysis _target _sources)
if( CPPCHECK_FOUND )
# Get the include files to also feed to cppcheck
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
LIST(APPEND cppcheck_includes "-I${dir}")
endforeach()
# Add to the all target to have a high level "make analysis"
LIST(APPEND ALL_ANALYSIS_TARGETS "${_target}_analysis")
set(ALL_ANALYSIS_TARGETS "${ALL_ANALYSIS_TARGETS}" PARENT_SCOPE)
# This is used to make the command run correctly on the command line.
# The COMMAND argument expects a list and this does the change
# I need to check which version works with 2.7
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VESION} GREATER 2.7)
separate_arguments(tmp_args UNIX_COMMAND ${CPPCHECK_ARG})
else ()
# cmake 2.6 has different arguments
string(REPLACE " " ";" tmp_args ${CPPCHECK_ARG})
endif ()
# add a custom _target_analysis target
add_custom_target(${_target}_analysis)
set_target_properties(${_target}_analysis PROPERTIES EXCLUDE_FROM_ALL TRUE)
# add the cppcheck command to the target
add_custom_command(TARGET ${_target}_analysis PRE_BUILD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND ${CPPCHECK_BIN} ${tmp_args} ${cppcheck_includes} ${${_sources}}
DEPENDS ${${_sources}}
COMMENT "Running cppcheck: ${_target}"
VERBATIM)
message("adding cppcheck analysys target for ${_target}")
endif()
endmacro()
================================================
FILE: 04-static-analysis/cppcheck/cmake/modules/FindCppCheck.cmake
================================================
# Locate cppcheck
#
# This module defines
# CPPCHECK_FOUND, if false, do not try to link to cppcheck --- if (CPPCHECK_FOUND)
# CPPCHECK_BIN, where to find cppcheck
#
# Exported argumets include
# CPPCHECK_THREADS
# CPPCHECK_ARG
#
# find the cppcheck binary
find_program(CPPCHECK_BIN NAMES cppcheck)
#
# Arguments are
# -j use multiple threads (and thread count)
# --quite only show errors / warnings etc
# --error-exitcode The code to exit with if an error shows up
# --enabled Comma separated list of the check types. Can include warning,performance,style
# Note nightly build on earth changes error-exitcode to 0
set (CPPCHECK_THREADS "-j 4" CACHE STRING "The -j argument to have cppcheck use multiple threads / cores")
set (CPPCHECK_ARG "${CPPCHECK_THREADS}" CACHE STRING "The arguments to pass to cppcheck. If set will overwrite CPPCHECK_THREADS")
# handle the QUIETLY and REQUIRED arguments and set YAMLCPP_FOUND to TRUE if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
CPPCHECK
DEFAULT_MSG
CPPCHECK_BIN
CPPCHECK_THREADS
CPPCHECK_ARG)
mark_as_advanced(
CPPCHECK_BIN
CPPCHECK_THREADS
CPPCHECK_ARG)
================================================
FILE: 04-static-analysis/cppcheck/run_test.sh
================================================
#!/bin/bash
mkdir -p build && cd build && cmake .. && make analysis
================================================
FILE: 04-static-analysis/cppcheck/subproject1/CMakeLists.txt
================================================
# Set the project name
project (subproject1)
# Create a sources variable with a link to all cpp files to compile
set(SOURCES
main1.cpp
)
# include the file with the function then call the macro
include(${CMAKE_SOURCE_DIR}/cmake/analysis.cmake)
add_analysis(${PROJECT_NAME} SOURCES)
# Add an executable with the above sources
add_executable(${PROJECT_NAME} ${SOURCES})
================================================
FILE: 04-static-analysis/cppcheck/subproject1/main1.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello Main1!" << std::endl;
return 0;
}
================================================
FILE: 04-static-analysis/cppcheck/subproject2/CMakeLists.txt
================================================
# Set the project name
project (subproject2)
# Create a sources variable with a link to all cpp files to compile
set(SOURCES
main2.cpp
)
# include the file with the function then call the macro
include(${CMAKE_SOURCE_DIR}/cmake/analysis.cmake)
add_analysis(${PROJECT_NAME} SOURCES)
# Add an executable with the above sources
add_executable(${PROJECT_NAME} ${SOURCES})
================================================
FILE: 04-static-analysis/cppcheck/subproject2/main2.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello Main2!" << std::endl;
char tmp[10];
tmp[11] = 's';
return 0;
}
================================================
FILE: 04-static-analysis/cppcheck-compile-commands/.cppcheck_suppressions
================================================
================================================
FILE: 04-static-analysis/cppcheck-compile-commands/CMakeLists.txt
================================================
cmake_minimum_required (VERSION 3.5)
project(cppcheck_analysis)
# Have cmake create a compile database
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Add a custom CMake Modules directory
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules
${CMAKE_MODULE_PATH})
# find the cppcheck binary
find_package(CppCheck)
# Add sub directories
add_subdirectory(subproject1)
add_subdirectory(subproject2)
================================================
FILE: 04-static-analysis/cppcheck-compile-commands/README.adoc
================================================
= CppCheck Static Analysis using Compile Commands
:toc:
:toc-placement!:
toc::[]
# Introduction
This example shows how to call the
http://cppcheck.sourceforge.net/[CppCheck] tool to do static analysis.
This shows how to use projects and a compile database.
Projects are available from cppcheck v1.77
It includes code to
* Find the cppcheck binary
* Generate an overall `make cppcheck-analysis` target to do static
analysis on all sub-projects.
The files included in this example are:
```
$ tree
.
├── cmake
│ └── modules
│ └── FindCppCheck.cmake
├── CMakeLists.txt
├── subproject1
│ ├── CMakeLists.txt
│ └── main1.cpp
└── subproject2
├── CMakeLists.txt
└── main2.cpp
```
* link:CMakeLists.txt[] - Top level CMakeLists.txt
* link:cmake/modules/FindCppCheck.cmake[] - A custom package module to find CppCheck
* link:subproject1/CMakeLists.txt[] - CMake commands for subproject 1
* link:subproject1/main1.cpp[] - source for a subproject with no errors
* link:subproject2/CMakeLists.txt[] - CMake commands for subproject 2
* link:subproject2/main2.cpp[] - source for a subproject that includes errors
# Requirements
To run this example you must have CppCheck of at least v1.77 installed. This is not
available by default on Ubuntu but can be compiled using the following command.
[source,bash]
----
$ wget https://github.com/danmar/cppcheck/archive/1.79.tar.gz \
&& tar xvf 1.79.tar.gz \
&& cd cppcheck-1.79 \
&& mkdir build \
&& cd build \
&& cmake .. \
&& sudo make install
----
# Concepts
## Adding Custom Package Modules
As with the previous example I use a custom module to find CppCheck. This version is slightly different to the previous one and
will automatically add a `make cppcheck-analysis` target.
[source,cmake]
----
if(CPPCHECK_FOUND)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/analysis/cppcheck)
add_custom_target(cppcheck-analysis
COMMAND ${CPPCHECK_COMMAND})
message("cppcheck found. Use cppccheck-analysis targets to run it")
else()
message("cppcheck not found. No cppccheck-analysis targets")
endif()
----
The variables available have also changed. For full details on the commands see the `FindCppCheck.cmake` module. Below are a subset of the available options:
### Suppressions
Adding a suppression file called `.cppcheck-suppressions` which must be in your +CMAKE_SOURCE_DIR+
### Error Exitcode
When cppcheck finds an error it can cause it to exit with a specific error. In this
example, by default, it will exit with `1`. To change this you can set the
+CPPCHECK_ERROR_EXITCODE_ARG+ argument when running CMake.
### Exitcode suppressions
Sometimes you wish to display an error in the log, but to not have that error cause a failed build. To do this you can create a file `.cppcheck_exitcode_suppressions` and add suppressions to it. This file must be in your +CMAKE_SOURCE_DIR+
### CppCheck arguments
The default enabled checks are `--enabled=warning`. To change this you can override the `CPPCHECK_CHECK_ARGS` variable before calling `find(cppcheck)`.
### Excluding files / folders
Many projects include some vendored 3rd party code. To exclude this from you check you can create a list `CPPCHECK_EXCLUDES` before calling the find module. This will add all files and folders in the list into the list of excluded folders.
### CppCheck build dir
In this example, we set +CPPCHECK_BUILD_DIR_ARG+, to `${PROJECT_BINARY_DIR}/analysis/cppcheck`. This will output details of the build to this folder and can be used to
increase the speed of rechecks if a file hasn't changed
## Compile Database
CMake allows you to export all https://cmake.org/cmake/help/v3.5/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html[compile commands]
that are used to build the project into a file called `compile_commands.json`
This can be done by setting the +CMAKE_EXPORT_COMPILE_COMMANDS+ variable to +ON+
as below:
[source,cmake]
----
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
----
The JSON file will look like:
[source,json]
----
[
{
"directory": "/home/user/development/project",
"command": "/usr/bin/c++ ... -c ../foo/foo.cc",
"file": "../foo/foo.cc"
},
...
{
"directory": "/home/user/development/project",
"command": "/usr/bin/c++ ... -c ../foo/bar.cc",
"file": "../foo/bar.cc"
}
]
----
[NOTE]
====
This is only available for the `Makefile` and `ninja` generators.
====
## CppCheck Projects
Starting with CppCheck v1.77, you can pass the `--project` flag pointing to the
compile database. This will cause CppCheck to run on al your cpp files using the same
include directories and compiler flags as your normal build.
[source,bash]
----
cppcheck --project=compile_comands.json
----
This will check all files in your project and sub-projects. There will be no analysis target per sub-project as with our previous example.
# Building the example
[source,bash]
----
$ mkdir build
$ cd build/
$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found CPPCHECK: /usr/local/bin/cppcheck
cppcheck found. Use cppccheck-analysis targets to run it
-- Configuring done
-- Generating done
-- Build files have been written to: /data/code/04-static-analysis/cppcheck-compile-commands/build
$ make cppcheck-analysis
Scanning dependencies of target cppcheck-analysis
[/data/code/04-static-analysis/cppcheck-compile-commands/subproject2/main2.cpp:7]: (error) Array 'tmp[10]' accessed at index 11, which is out of bounds.
make[3]: *** [CMakeFiles/cppcheck-analysis] Error 1
make[2]: *** [CMakeFiles/cppcheck-analysis.dir/all] Error 2
make[1]: *** [CMakeFiles/cppcheck-analysis.dir/rule] Error 2
make: *** [cppcheck-analysis] Error 2
================================================
FILE: 04-static-analysis/cppcheck-compile-commands/cmake/modules/FindCppCheck.cmake
================================================
# Locate cppcheck
#
# This module defines
# CPPCHECK_BIN, where to find cppcheck
#
# To help find the binary you can set CPPCHECK_ROOT_DIR to search a custom path
# Exported argumets include
# CPPCHECK_FOUND, if false, do not try to link to cppcheck --- if (CPPCHECK_FOUND)
#
# CPPCHECK_THREADS_ARG - Number of threads to use (e.g. -j 3)
# CPPCHECK_PROJECT_ARG - The project to use (compile_comands.json)
# CPPCHECK_BUILD_DIR_ARG - The build output directory
# CPPCHECK_ERROR_EXITCODE_ARG - The exit code if an error is found
# CPPCHECK_SUPPRESSIONS - A suppressiosn file to use
# CPPCHECK_CHECKS_ARGS - The checks to run
# CPPCHECK_OTHER_ARGS - Any other arguments
# CPPCHECK_COMMAND - The full command to run the default cppcheck configuration
# CPPCHECK_EXCLUDES - A list of files or folders to exclude from the scan. Must be the full path
#
# if CPPCHECK_XML_OUTPUT is set before calling this. CppCheck will create an xml file with that name
# find the cppcheck binary
# if custom path check there first
if(CPPCHECK_ROOT_DIR)
find_program(CPPCHECK_BIN
NAMES
cppcheck
PATHS
"${CPPCHECK_ROOT_DIR}"
NO_DEFAULT_PATH)
endif()
find_program(CPPCHECK_BIN NAMES cppcheck)
if(CPPCHECK_BIN)
execute_process(COMMAND ${CPPCHECK_BIN} --version
OUTPUT_VARIABLE CPPCHECK_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CPPCHECK_THREADS_ARG "-j4" CACHE STRING "The number of threads to use")
set(CPPCHECK_PROJECT_ARG "--project=${PROJECT_BINARY_DIR}/compile_commands.json")
set(CPPCHECK_BUILD_DIR_ARG "--cppcheck-build-dir=${PROJECT_BINARY_DIR}/analysis/cppcheck" CACHE STRING "The build directory to use")
# Don't show these errors
if(EXISTS "${CMAKE_SOURCE_DIR}/.cppcheck_suppressions")
set(CPPCHECK_SUPPRESSIONS "--suppressions-list=${CMAKE_SOURCE_DIR}/.cppcheck_suppressions" CACHE STRING "The suppressions file to use")
else()
set(CPPCHECK_SUPPRESSIONS "" CACHE STRING "The suppressions file to use")
endif()
# Show these errors but don't fail the build
# These are mainly going to be from the "warning" category that is enabled by default later
if(EXISTS "${CMAKE_SOURCE_DIR}/.cppcheck_exitcode_suppressions")
set(CPPCHECK_EXITCODE_SUPPRESSIONS "--exitcode-suppressions=${CMAKE_SOURCE_DIR}/.cppcheck_exitcode_suppressions" CACHE STRING "The exitcode suppressions file to use")
else()
set(CPPCHECK_EXITCODE_SUPPRESSIONS "" CACHE STRING "The exitcode suppressions file to use")
endif()
set(CPPCHECK_ERROR_EXITCODE_ARG "--error-exitcode=1" CACHE STRING "The exitcode to use if an error is found")
set(CPPCHECK_CHECKS_ARGS "--enable=warning" CACHE STRING "Arguments for the checks to run")
set(CPPCHECK_OTHER_ARGS "" CACHE STRING "Other arguments")
set(_CPPCHECK_EXCLUDES)
foreach(ex ${CPPCHECK_EXCLUDES})
list(APPEND _CPPCHECK_EXCLUDES "-i${ex}")
endforeach(ex)
set(CPPCHECK_ALL_ARGS
${CPPCHECK_THREADS_ARG}
${CPPCHECK_PROJECT_ARG}
${CPPCHECK_BUILD_DIR_ARG}
${CPPCHECK_ERROR_EXITCODE_ARG}
${CPPCHECK_SUPPRESSIONS}
${CPPCHECK_EXITCODE_SUPPRESSIONS}
${CPPCHECK_CHECKS_ARGS}
${CPPCHECK_OTHER_ARGS}
${_CPPCHECK_EXCLUDES}
)
if(NOT CPPCHECK_XML_OUTPUT)
set(CPPCHECK_COMMAND
${CPPCHECK_BIN}
${CPPCHECK_ALL_ARGS}
)
else()
set(CPPCHECK_COMMAND
${CPPCHECK_BIN}
${CPPCHECK_ALL_ARGS}
--xml
--xml-version=2
2> ${CPPCHECK_XML_OUTPUT})
endif()
endif()
# handle the QUIETLY and REQUIRED arguments and set YAMLCPP_FOUND to TRUE if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
CPPCHECK
DEFAULT_MSG
CPPCHECK_BIN)
mark_as_advanced(
CPPCHECK_BIN
CPPCHECK_THREADS_ARG
CPPCHECK_PROJECT_ARG
CPPCHECK_BUILD_DIR_ARG
CPPCHECK_ERROR_EXITCODE_ARG
CPPCHECK_SUPPRESSIONS
CPPCHECK_CHECKS_ARGS
CPPCHECK_OTHER_ARGS)
if(CPPCHECK_FOUND)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/analysis/cppcheck)
add_custom_target(cppcheck-analysis
COMMAND ${CPPCHECK_COMMAND})
message("cppcheck found. Use cppccheck-analysis targets to run it")
else()
message("cppcheck not found. No cppccheck-analysis targets")
endif()
================================================
FILE: 04-static-analysis/cppcheck-compile-commands/run_test.sh
================================================
#!/bin/bash
mkdir -p build && cd build && cmake -DCPPCHECK_ERROR_EXITCODE_ARG="" .. && make cppcheck-analysis
================================================
FILE: 04-static-analysis/cppcheck-compile-commands/subproject1/CMakeLists.txt
================================================
# Set the project name
project (subproject1)
# Add an executable with the above sources
add_executable(${PROJECT_NAME} main1.cpp)
================================================
FILE: 04-static-analysis/cppcheck-compile-commands/subproject1/main1.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello Main1!" << std::endl;
return 0;
}
================================================
FILE: 04-static-analysis/cppcheck-compile-commands/subproject2/CMakeLists.txt
================================================
# Set the project name
project (subproject2)
# Add an executable with the above sources
add_executable(${PROJECT_NAME} main2.cpp)
================================================
FILE: 04-static-analysis/cppcheck-compile-commands/subproject2/main2.cpp
================================================
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello Main2!" << std::endl;
char tmp[10];
tmp[11] = 's';
return 0;
}
================================================
FILE: 05-unit-testing/README.adoc
================================================
= Unit Testing
:toc:
:toc-placement!:
toc::[]
[[intro]]
Introduction
------------
Unit testing is a software development process in which the smallest testable parts of an
application, called units, are individually and independently scrutinized
for proper operation. This can involve taking a class, function, or algorithm
and writing test cases that can be run to verify that the unit is working correctly.
CMake includes a tool called link:https://cmake.org/Wiki/CMake/Testing_With_CTest[CTest]
which allows you to enable the `make test` target to run automated tests such as unit tests.
There are many unit-testing frameworks available which can be used to help automate
and ease the development of unit tests. In these examples I show how to use
some of these frameworks and call them using the CMake testing utility CTest.
The examples here include using the following frameworks:
* http://www.boost.org/doc/libs/1_56_0/libs/test/doc/html/utf/user-guide.html[Boost Unit Test Framework]
* https://github.com/google/googletest[Google Test - Download]
* https://github.com/catchorg/Catch2[Catch2]
================================================
FILE: 05-unit-testing/boost/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.5)
# Set the project name
project (boost_unit_test)
# find a boost install with the libraries unit_test_framework
find_package(Boost 1.46.1 REQUIRED COMPONENTS unit_test_framework)
# Add an library for the example classes
add_library(example_boost_unit_test
Reverse.cpp
Palindrome.cpp
)
target_include_directories(example_boost_unit_test
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(example_boost_unit_test
PUBLIC
Boost::boost
)
#############################################
# Unit tests
# enable CTest testing
enable_testing()
# Add a testing executable
add_executable(unit_tests unit_tests.cpp)
target_link_libraries(unit_tests
example_boost_unit_test
Boost::unit_te
gitextract_noztjd02/ ├── .gitignore ├── .travis.yml ├── 01-basic/ │ ├── A-hello-cmake/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ └── main.cpp │ ├── B-hello-headers/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── include/ │ │ │ └── Hello.h │ │ └── src/ │ │ ├── Hello.cpp │ │ └── main.cpp │ ├── C-static-library/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── include/ │ │ │ └── static/ │ │ │ └── Hello.h │ │ └── src/ │ │ ├── Hello.cpp │ │ └── main.cpp │ ├── D-shared-library/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── include/ │ │ │ └── shared/ │ │ │ └── Hello.h │ │ └── src/ │ │ ├── Hello.cpp │ │ └── main.cpp │ ├── E-installing/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── cmake-examples.conf │ │ ├── include/ │ │ │ └── installing/ │ │ │ └── Hello.h │ │ └── src/ │ │ ├── Hello.cpp │ │ └── main.cpp │ ├── F-build-type/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ └── main.cpp │ ├── G-compile-flags/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ └── main.cpp │ ├── H-third-party-library/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ └── main.cpp │ ├── I-compiling-with-clang/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── main.cpp │ │ ├── pre_test.sh │ │ └── run_test.sh │ ├── J-building-with-ninja/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── main.cpp │ │ ├── pre_test.sh │ │ └── run_test.sh │ ├── K-imported-targets/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── main.cpp │ │ └── run_test.sh │ ├── L-cpp-standard/ │ │ ├── README.adoc │ │ ├── i-common-method/ │ │ │ ├── CMakeLists.txt │ │ │ ├── README.adoc │ │ │ └── main.cpp │ │ ├── ii-cxx-standard/ │ │ │ ├── CMakeLists.txt │ │ │ ├── README.adoc │ │ │ └── main.cpp │ │ └── iii-compile-features/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ └── main.cpp │ └── README.adoc ├── 02-sub-projects/ │ ├── A-basic/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── subbinary/ │ │ │ ├── CMakeLists.txt │ │ │ └── main.cpp │ │ ├── sublibrary1/ │ │ │ ├── CMakeLists.txt │ │ │ ├── include/ │ │ │ │ └── sublib1/ │ │ │ │ └── sublib1.h │ │ │ └── src/ │ │ │ └── sublib1.cpp │ │ └── sublibrary2/ │ │ ├── CMakeLists.txt │ │ └── include/ │ │ └── sublib2/ │ │ └── sublib2.h │ └── README.adoc ├── 03-code-generation/ │ ├── README.adoc │ ├── configure-files/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── main.cpp │ │ ├── path.h.in │ │ └── ver.h.in │ └── protobuf/ │ ├── AddressBook.proto │ ├── CMakeLists.txt │ ├── README.adoc │ └── main.cpp ├── 04-static-analysis/ │ ├── README.adoc │ ├── clang-analyzer/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── run_test.sh │ │ ├── subproject1/ │ │ │ ├── CMakeLists.txt │ │ │ └── main1.cpp │ │ └── subproject2/ │ │ ├── CMakeLists.txt │ │ └── main2.cpp │ ├── clang-format/ │ │ ├── .clang-format │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── cmake/ │ │ │ ├── modules/ │ │ │ │ ├── FindClangFormat.cmake │ │ │ │ └── clang-format.cmake │ │ │ └── scripts/ │ │ │ ├── clang-format-check-changed │ │ │ └── clang-format-check-changed.py │ │ ├── run_test.sh │ │ ├── subproject1/ │ │ │ ├── CMakeLists.txt │ │ │ └── main1.cpp │ │ └── subproject2/ │ │ ├── CMakeLists.txt │ │ └── main2.cpp │ ├── cppcheck/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── cmake/ │ │ │ ├── analysis.cmake │ │ │ └── modules/ │ │ │ └── FindCppCheck.cmake │ │ ├── run_test.sh │ │ ├── subproject1/ │ │ │ ├── CMakeLists.txt │ │ │ └── main1.cpp │ │ └── subproject2/ │ │ ├── CMakeLists.txt │ │ └── main2.cpp │ └── cppcheck-compile-commands/ │ ├── .cppcheck_suppressions │ ├── CMakeLists.txt │ ├── README.adoc │ ├── cmake/ │ │ └── modules/ │ │ └── FindCppCheck.cmake │ ├── run_test.sh │ ├── subproject1/ │ │ ├── CMakeLists.txt │ │ └── main1.cpp │ └── subproject2/ │ ├── CMakeLists.txt │ └── main2.cpp ├── 05-unit-testing/ │ ├── README.adoc │ ├── boost/ │ │ ├── CMakeLists.txt │ │ ├── Palindrome.cpp │ │ ├── Palindrome.h │ │ ├── README.adoc │ │ ├── Reverse.cpp │ │ ├── Reverse.h │ │ ├── main.cpp │ │ ├── post_test.sh │ │ └── unit_tests.cpp │ ├── catch2-vendored/ │ │ ├── 3rd_party/ │ │ │ └── catch2/ │ │ │ ├── CMakeLists.txt │ │ │ └── catch2/ │ │ │ └── catch.hpp │ │ ├── CMakeLists.txt │ │ ├── Palindrome.cpp │ │ ├── Palindrome.h │ │ ├── README.adoc │ │ ├── Reverse.cpp │ │ ├── Reverse.h │ │ ├── main.cpp │ │ ├── post_test.sh │ │ └── unit_tests.cpp │ └── google-test-download/ │ ├── 3rd_party/ │ │ └── google-test/ │ │ ├── CMakeLists.txt │ │ └── CMakeLists.txt.in │ ├── CMakeLists.txt │ ├── Palindrome.cpp │ ├── Palindrome.h │ ├── README.adoc │ ├── Reverse.cpp │ ├── Reverse.h │ ├── main.cpp │ ├── post_test.sh │ ├── run_test.sh │ └── unit_tests.cpp ├── 06-installer/ │ ├── README.adoc │ └── deb/ │ ├── CMakeLists.txt │ ├── README.adoc │ ├── cmake-examples.conf │ ├── include/ │ │ └── Hello.h │ ├── post_test.sh │ └── src/ │ ├── Hello.cpp │ └── main.cpp ├── 07-package-management/ │ ├── A-using-system-provide-packages/ │ │ └── README.adoc │ ├── B-vendoring-code/ │ │ └── README.adoc │ ├── C-external-project-add/ │ │ └── README.adoc │ ├── D-conan/ │ │ ├── README.adoc │ │ ├── i-basic/ │ │ │ ├── CMakeLists.txt │ │ │ ├── README.adoc │ │ │ ├── conanfile.txt │ │ │ ├── main.cpp │ │ │ └── run_test.sh │ │ └── ii-basic-targets/ │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── conanfile.txt │ │ ├── main.cpp │ │ └── run_test.sh │ └── README.adoc ├── LICENSE ├── README.adoc ├── cmake-examples.sublime-project ├── dockerfiles/ │ ├── README.adoc │ ├── setup.sh │ ├── ubuntu14.04-cmake-3.4.3 │ ├── ubuntu14.04-default-2.8.12.2 │ ├── ubuntu16.04-cmake-3.10.3 │ └── ubuntu16.04-default-cmake-3.5.1 └── test.sh
Copy disabled (too large)
Download .txt
Showing preview only (39,890K chars total). Download the full file to get everything.
SYMBOL INDEX (1245 symbols across 48 files)
FILE: 01-basic/A-hello-cmake/main.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 01-basic/B-hello-headers/include/Hello.h
function class (line 4) | class Hello
FILE: 01-basic/B-hello-headers/src/main.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 01-basic/C-static-library/include/static/Hello.h
function class (line 4) | class Hello
FILE: 01-basic/C-static-library/src/main.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 01-basic/D-shared-library/include/shared/Hello.h
function class (line 4) | class Hello
FILE: 01-basic/D-shared-library/src/main.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 01-basic/E-installing/include/installing/Hello.h
function class (line 4) | class Hello
FILE: 01-basic/E-installing/src/main.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 01-basic/F-build-type/main.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 01-basic/G-compile-flags/main.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 01-basic/H-third-party-library/main.cpp
function main (line 5) | int main(int argc, char *argv[])
FILE: 01-basic/I-compiling-with-clang/main.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 01-basic/J-building-with-ninja/main.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 01-basic/K-imported-targets/main.cpp
function main (line 5) | int main(int argc, char *argv[])
FILE: 01-basic/L-cpp-standard/i-common-method/main.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 01-basic/L-cpp-standard/ii-cxx-standard/main.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 01-basic/L-cpp-standard/iii-compile-features/main.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 02-sub-projects/A-basic/subbinary/main.cpp
function main (line 4) | int main(int argc, char *argv[])
FILE: 02-sub-projects/A-basic/sublibrary1/include/sublib1/sublib1.h
function class (line 4) | class sublib1
FILE: 02-sub-projects/A-basic/sublibrary2/include/sublib2/sublib2.h
function class (line 6) | class sublib2
FILE: 03-code-generation/configure-files/main.cpp
function main (line 5) | int main(int argc, char *argv[])
FILE: 03-code-generation/protobuf/main.cpp
function PromptForAddress (line 8) | void PromptForAddress(tutorial::Person* person) {
function main (line 54) | int main(int argc, char* argv[]) {
FILE: 04-static-analysis/clang-analyzer/subproject1/main1.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 04-static-analysis/clang-analyzer/subproject2/main2.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 04-static-analysis/clang-format/cmake/scripts/clang-format-check-changed.py
function check_file (line 9) | def check_file(filename, excludes, extensions):
function check_directory (line 28) | def check_directory(directory, excludes, extensions):
function get_git_root (line 45) | def get_git_root(git_bin):
function clean_git_filename (line 53) | def clean_git_filename(line):
function get_changed_files (line 76) | def get_changed_files(git_bin, excludes, file_extensions):
function run_clang_format (line 117) | def run_clang_format(clang_format_bin, changed_files):
function cli (line 139) | def cli():
FILE: 04-static-analysis/clang-format/subproject1/main1.cpp
function main (line 3) | int main(int argc, char* argv[])
FILE: 04-static-analysis/clang-format/subproject2/main2.cpp
class TestClass (line 3) | class TestClass {
function main (line 12) | int main(int argc, char* argv[])
FILE: 04-static-analysis/cppcheck-compile-commands/subproject1/main1.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 04-static-analysis/cppcheck-compile-commands/subproject2/main2.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 04-static-analysis/cppcheck/subproject1/main1.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 04-static-analysis/cppcheck/subproject2/main2.cpp
function main (line 3) | int main(int argc, char *argv[])
FILE: 05-unit-testing/boost/Palindrome.h
function class (line 9) | class Palindrome
FILE: 05-unit-testing/boost/Reverse.h
function class (line 10) | class Reverse
FILE: 05-unit-testing/boost/main.cpp
function main (line 5) | int main(int argc, char *argv[])
FILE: 05-unit-testing/boost/unit_tests.cpp
function BOOST_AUTO_TEST_CASE (line 10) | BOOST_AUTO_TEST_CASE( simple )
function BOOST_AUTO_TEST_CASE (line 22) | BOOST_AUTO_TEST_CASE( empty )
function BOOST_AUTO_TEST_CASE (line 37) | BOOST_AUTO_TEST_CASE( is_palindrome )
FILE: 05-unit-testing/catch2-vendored/3rd_party/catch2/catch2/catch.hpp
type Catch (line 94) | namespace Catch {
type CaseSensitive (line 386) | struct CaseSensitive { enum Choice {
type Choice (line 386) | enum Choice {
class NonCopyable (line 391) | class NonCopyable {
method NonCopyable (line 392) | NonCopyable( NonCopyable const& ) = delete;
method NonCopyable (line 393) | NonCopyable( NonCopyable && ) = delete;
method NonCopyable (line 394) | NonCopyable& operator = ( NonCopyable const& ) = delete;
method NonCopyable (line 395) | NonCopyable& operator = ( NonCopyable && ) = delete;
type SourceLineInfo (line 402) | struct SourceLineInfo {
method SourceLineInfo (line 404) | SourceLineInfo() = delete;
method SourceLineInfo (line 405) | SourceLineInfo( char const* _file, std::size_t _line ) noexcept
method SourceLineInfo (line 410) | SourceLineInfo( SourceLineInfo const& other ) = default;
method SourceLineInfo (line 411) | SourceLineInfo( SourceLineInfo && ) = default;
method SourceLineInfo (line 412) | SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
method SourceLineInfo (line 413) | SourceLineInfo& operator = ( SourceLineInfo && ) = default;
type StreamEndStop (line 434) | struct StreamEndStop {
function T (line 438) | T const& operator + ( T const& value, StreamEndStop ) {
type RegistrarForTagAliases (line 449) | struct RegistrarForTagAliases {
class TestSpec (line 470) | class TestSpec
type Pattern (line 3821) | struct Pattern {
class NamePattern (line 3827) | class NamePattern : public Pattern {
class TagPattern (line 3836) | class TagPattern : public Pattern {
class ExcludedPattern (line 3845) | class ExcludedPattern : public Pattern {
type Filter (line 3854) | struct Filter {
type ITestInvoker (line 472) | struct ITestInvoker {
class TestCase (line 479) | class TestCase
type IConfig (line 480) | struct IConfig
type ITestCaseRegistry (line 482) | struct ITestCaseRegistry {
class StringData (line 503) | class StringData
class StringRef (line 512) | class StringRef {
method StringRef (line 529) | StringRef() noexcept
method StringRef (line 533) | StringRef( StringRef const& other ) noexcept
method StringRef (line 538) | StringRef( StringRef&& other ) noexcept
method StringRef (line 548) | StringRef( char const* rawChars, size_type size ) noexcept
method StringRef (line 553) | StringRef( std::string const& stdString ) noexcept
method empty (line 581) | auto empty() const noexcept -> bool {
method size (line 584) | auto size() const noexcept -> size_type {
type is_unique (line 637) | struct is_unique : std::true_type{}
class TestInvokerAsMethod (line 720) | class TestInvokerAsMethod : public ITestInvoker {
method TestInvokerAsMethod (line 723) | TestInvokerAsMethod( void (C::*testAsMethod)() ) noexcept : m_testAs...
method invoke (line 725) | void invoke() const override {
function makeTestInvoker (line 734) | auto makeTestInvoker( void (C::*testAsMethod)() ) noexcept -> ITestInv...
type NameAndTags (line 738) | struct NameAndTags {
type AutoReg (line 744) | struct AutoReg : NonCopyable {
type ResultWas (line 894) | struct ResultWas { enum OfType {
type OfType (line 894) | enum OfType {
type ResultDisposition (line 918) | struct ResultDisposition { enum Flags {
type Flags (line 918) | enum Flags {
function isFalseTest (line 929) | inline bool isFalseTest( int flags ) { return ( flags & ResultDisposit...
type AssertionInfo (line 937) | struct AssertionInfo
class StringRef (line 972) | class StringRef
method StringRef (line 529) | StringRef() noexcept
method StringRef (line 533) | StringRef( StringRef const& other ) noexcept
method StringRef (line 538) | StringRef( StringRef&& other ) noexcept
method StringRef (line 548) | StringRef( char const* rawChars, size_type size ) noexcept
method StringRef (line 553) | StringRef( std::string const& stdString ) noexcept
method empty (line 581) | auto empty() const noexcept -> bool {
method size (line 584) | auto size() const noexcept -> size_type {
type IStream (line 974) | struct IStream {
class ReusableStringStream (line 981) | class ReusableStringStream {
method get (line 995) | auto get() -> std::ostream& { return *m_oss; }
type Detail (line 1057) | namespace Detail {
function rawMemoryToString (line 1064) | std::string rawMemoryToString( const T& object ) {
class IsStreamInsertable (line 1069) | class IsStreamInsertable {
function convertUnstreamable (line 1085) | typename std::enable_if<
function convertUnstreamable (line 1091) | typename std::enable_if<
function convertUnstreamable (line 1098) | typename std::enable_if<
function stringify (line 1149) | std::string stringify(const T& e) {
function convertUnknownEnumToString (line 1154) | std::string convertUnknownEnumToString( E e ) {
function rangeToString (line 1325) | std::string rangeToString(InputIterator first, InputIterator last) {
function stringify (line 1355) | inline std::string stringify( NSString* nsstring ) {
type TupleElementPrinter (line 1404) | struct TupleElementPrinter {
method print (line 1405) | static void print(const Tuple& tuple, std::ostream& os) {
type TupleElementPrinter<Tuple, N, false> (line 1416) | struct TupleElementPrinter<Tuple, N, false> {
method print (line 1417) | static void print(const Tuple&, std::ostream&) {}
class Approx (line 2470) | class Approx {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5349) | Approx Approx::custom() {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5353) | Approx Approx::operator-() const {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
type Endianness (line 11804) | struct Endianness {
type Arch (line 11805) | enum Arch { Big, Little }
method Arch (line 11807) | static Arch which() {
function rawMemoryToString (line 11819) | std::string rawMemoryToString( const void *object, std::size_t size ) {
type StringMaker (line 1120) | struct StringMaker {
method convert (line 1122) | static
method convert (line 1133) | static
type Detail (line 1144) | namespace Detail {
function rawMemoryToString (line 1064) | std::string rawMemoryToString( const T& object ) {
class IsStreamInsertable (line 1069) | class IsStreamInsertable {
function convertUnstreamable (line 1085) | typename std::enable_if<
function convertUnstreamable (line 1091) | typename std::enable_if<
function convertUnstreamable (line 1098) | typename std::enable_if<
function stringify (line 1149) | std::string stringify(const T& e) {
function convertUnknownEnumToString (line 1154) | std::string convertUnknownEnumToString( E e ) {
function rangeToString (line 1325) | std::string rangeToString(InputIterator first, InputIterator last) {
function stringify (line 1355) | inline std::string stringify( NSString* nsstring ) {
type TupleElementPrinter (line 1404) | struct TupleElementPrinter {
method print (line 1405) | static void print(const Tuple& tuple, std::ostream& os) {
type TupleElementPrinter<Tuple, N, false> (line 1416) | struct TupleElementPrinter<Tuple, N, false> {
method print (line 1417) | static void print(const Tuple&, std::ostream&) {}
class Approx (line 2470) | class Approx {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5349) | Approx Approx::custom() {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5353) | Approx Approx::operator-() const {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
type Endianness (line 11804) | struct Endianness {
type Arch (line 11805) | enum Arch { Big, Little }
method Arch (line 11807) | static Arch which() {
function rawMemoryToString (line 11819) | std::string rawMemoryToString( const void *object, std::size_t size ) {
type StringMaker<std::string> (line 1170) | struct StringMaker<std::string> {
type StringMaker<std::string_view> (line 1176) | struct StringMaker<std::string_view> {
type StringMaker<char const *> (line 1182) | struct StringMaker<char const *> {
type StringMaker<char *> (line 1186) | struct StringMaker<char *> {
type StringMaker<std::wstring> (line 1192) | struct StringMaker<std::wstring> {
type StringMaker<std::wstring_view> (line 1198) | struct StringMaker<std::wstring_view> {
type StringMaker<wchar_t const *> (line 1204) | struct StringMaker<wchar_t const *> {
type StringMaker<wchar_t *> (line 1208) | struct StringMaker<wchar_t *> {
type StringMaker<char[SZ]> (line 1216) | struct StringMaker<char[SZ]> {
method convert (line 1217) | static std::string convert(char const* str) {
type StringMaker<signed char[SZ]> (line 1222) | struct StringMaker<signed char[SZ]> {
method convert (line 1223) | static std::string convert(signed char const* str) {
type StringMaker<unsigned char[SZ]> (line 1228) | struct StringMaker<unsigned char[SZ]> {
method convert (line 1229) | static std::string convert(unsigned char const* str) {
type StringMaker<int> (line 1235) | struct StringMaker<int> {
type StringMaker<long> (line 1239) | struct StringMaker<long> {
type StringMaker<long long> (line 1243) | struct StringMaker<long long> {
type StringMaker<unsigned int> (line 1247) | struct StringMaker<unsigned int> {
type StringMaker<unsigned long> (line 1251) | struct StringMaker<unsigned long> {
type StringMaker<unsigned long long> (line 1255) | struct StringMaker<unsigned long long> {
type StringMaker<bool> (line 1260) | struct StringMaker<bool> {
type StringMaker<char> (line 1265) | struct StringMaker<char> {
type StringMaker<signed char> (line 1269) | struct StringMaker<signed char> {
type StringMaker<unsigned char> (line 1273) | struct StringMaker<unsigned char> {
type StringMaker<std::nullptr_t> (line 1278) | struct StringMaker<std::nullptr_t> {
type StringMaker<float> (line 1283) | struct StringMaker<float> {
type StringMaker<double> (line 1287) | struct StringMaker<double> {
type StringMaker<T*> (line 1292) | struct StringMaker<T*> {
method convert (line 1294) | static std::string convert(U* p) {
type StringMaker<R C::*> (line 1304) | struct StringMaker<R C::*> {
method convert (line 1305) | static std::string convert(R C::* p) {
type StringMaker<T^> (line 1316) | struct StringMaker<T^> {
method convert (line 1317) | static std::string convert( T^ ref ) {
type Detail (line 1323) | namespace Detail {
function rawMemoryToString (line 1064) | std::string rawMemoryToString( const T& object ) {
class IsStreamInsertable (line 1069) | class IsStreamInsertable {
function convertUnstreamable (line 1085) | typename std::enable_if<
function convertUnstreamable (line 1091) | typename std::enable_if<
function convertUnstreamable (line 1098) | typename std::enable_if<
function stringify (line 1149) | std::string stringify(const T& e) {
function convertUnknownEnumToString (line 1154) | std::string convertUnknownEnumToString( E e ) {
function rangeToString (line 1325) | std::string rangeToString(InputIterator first, InputIterator last) {
function stringify (line 1355) | inline std::string stringify( NSString* nsstring ) {
type TupleElementPrinter (line 1404) | struct TupleElementPrinter {
method print (line 1405) | static void print(const Tuple& tuple, std::ostream& os) {
type TupleElementPrinter<Tuple, N, false> (line 1416) | struct TupleElementPrinter<Tuple, N, false> {
method print (line 1417) | static void print(const Tuple&, std::ostream&) {}
class Approx (line 2470) | class Approx {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5349) | Approx Approx::custom() {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5353) | Approx Approx::operator-() const {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
type Endianness (line 11804) | struct Endianness {
type Arch (line 11805) | enum Arch { Big, Little }
method Arch (line 11807) | static Arch which() {
function rawMemoryToString (line 11819) | std::string rawMemoryToString( const void *object, std::size_t size ) {
type StringMaker<NSString*> (line 1340) | struct StringMaker<NSString*> {
method convert (line 1341) | static std::string convert(NSString * nsstring) {
type StringMaker<NSObject*> (line 1348) | struct StringMaker<NSObject*> {
method convert (line 1349) | static std::string convert(NSObject* nsObject) {
type Detail (line 1354) | namespace Detail {
function rawMemoryToString (line 1064) | std::string rawMemoryToString( const T& object ) {
class IsStreamInsertable (line 1069) | class IsStreamInsertable {
function convertUnstreamable (line 1085) | typename std::enable_if<
function convertUnstreamable (line 1091) | typename std::enable_if<
function convertUnstreamable (line 1098) | typename std::enable_if<
function stringify (line 1149) | std::string stringify(const T& e) {
function convertUnknownEnumToString (line 1154) | std::string convertUnknownEnumToString( E e ) {
function rangeToString (line 1325) | std::string rangeToString(InputIterator first, InputIterator last) {
function stringify (line 1355) | inline std::string stringify( NSString* nsstring ) {
type TupleElementPrinter (line 1404) | struct TupleElementPrinter {
method print (line 1405) | static void print(const Tuple& tuple, std::ostream& os) {
type TupleElementPrinter<Tuple, N, false> (line 1416) | struct TupleElementPrinter<Tuple, N, false> {
method print (line 1417) | static void print(const Tuple&, std::ostream&) {}
class Approx (line 2470) | class Approx {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5349) | Approx Approx::custom() {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5353) | Approx Approx::operator-() const {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
type Endianness (line 11804) | struct Endianness {
type Arch (line 11805) | enum Arch { Big, Little }
method Arch (line 11807) | static Arch which() {
function rawMemoryToString (line 11819) | std::string rawMemoryToString( const void *object, std::size_t size ) {
type StringMaker<std::pair<T1, T2> > (line 1380) | struct StringMaker<std::pair<T1, T2> > {
method convert (line 1381) | static std::string convert(const std::pair<T1, T2>& pair) {
type Detail (line 1398) | namespace Detail {
function rawMemoryToString (line 1064) | std::string rawMemoryToString( const T& object ) {
class IsStreamInsertable (line 1069) | class IsStreamInsertable {
function convertUnstreamable (line 1085) | typename std::enable_if<
function convertUnstreamable (line 1091) | typename std::enable_if<
function convertUnstreamable (line 1098) | typename std::enable_if<
function stringify (line 1149) | std::string stringify(const T& e) {
function convertUnknownEnumToString (line 1154) | std::string convertUnknownEnumToString( E e ) {
function rangeToString (line 1325) | std::string rangeToString(InputIterator first, InputIterator last) {
function stringify (line 1355) | inline std::string stringify( NSString* nsstring ) {
type TupleElementPrinter (line 1404) | struct TupleElementPrinter {
method print (line 1405) | static void print(const Tuple& tuple, std::ostream& os) {
type TupleElementPrinter<Tuple, N, false> (line 1416) | struct TupleElementPrinter<Tuple, N, false> {
method print (line 1417) | static void print(const Tuple&, std::ostream&) {}
class Approx (line 2470) | class Approx {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5349) | Approx Approx::custom() {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5353) | Approx Approx::operator-() const {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
type Endianness (line 11804) | struct Endianness {
type Arch (line 11805) | enum Arch { Big, Little }
method Arch (line 11807) | static Arch which() {
function rawMemoryToString (line 11819) | std::string rawMemoryToString( const void *object, std::size_t size ) {
type StringMaker<std::monostate> (line 1439) | struct StringMaker<std::monostate> {
method convert (line 1440) | static std::string convert(const std::monostate&) {
type not_this_one (line 1464) | struct not_this_one {}
type is_range (line 1474) | struct is_range {
type is_range<T^> (line 1482) | struct is_range<T^> {
function rangeToString (line 1488) | std::string rangeToString( Range const& range ) {
function rangeToString (line 1494) | std::string rangeToString( std::vector<bool, Allocator> const& v ) {
type StringMaker<R, typename std::enable_if<is_range<R>::value && !::Catch::Detail::IsStreamInsertable<R>::value>::type> (line 1510) | struct StringMaker<R, typename std::enable_if<is_range<R>::value && !:...
method convert (line 1511) | static std::string convert( R const& range ) {
type StringMaker<T[SZ]> (line 1517) | struct StringMaker<T[SZ]> {
method convert (line 1518) | static std::string convert(T const(&arr)[SZ]) {
type ratio_string (line 1534) | struct ratio_string {
type ratio_string<std::atto> (line 1546) | struct ratio_string<std::atto> {
type ratio_string<std::femto> (line 1550) | struct ratio_string<std::femto> {
type ratio_string<std::pico> (line 1554) | struct ratio_string<std::pico> {
type ratio_string<std::nano> (line 1558) | struct ratio_string<std::nano> {
type ratio_string<std::micro> (line 1562) | struct ratio_string<std::micro> {
type ratio_string<std::milli> (line 1566) | struct ratio_string<std::milli> {
type StringMaker<std::chrono::duration<Value, Ratio>> (line 1573) | struct StringMaker<std::chrono::duration<Value, Ratio>> {
method convert (line 1574) | static std::string convert(std::chrono::duration<Value, Ratio> const...
type StringMaker<std::chrono::duration<Value, std::ratio<1>>> (line 1581) | struct StringMaker<std::chrono::duration<Value, std::ratio<1>>> {
method convert (line 1582) | static std::string convert(std::chrono::duration<Value, std::ratio<1...
type StringMaker<std::chrono::duration<Value, std::ratio<60>>> (line 1589) | struct StringMaker<std::chrono::duration<Value, std::ratio<60>>> {
method convert (line 1590) | static std::string convert(std::chrono::duration<Value, std::ratio<6...
type StringMaker<std::chrono::duration<Value, std::ratio<3600>>> (line 1597) | struct StringMaker<std::chrono::duration<Value, std::ratio<3600>>> {
method convert (line 1598) | static std::string convert(std::chrono::duration<Value, std::ratio<3...
type StringMaker<std::chrono::time_point<Clock, Duration>> (line 1609) | struct StringMaker<std::chrono::time_point<Clock, Duration>> {
method convert (line 1610) | static std::string convert(std::chrono::time_point<Clock, Duration> ...
type StringMaker<std::chrono::time_point<std::chrono::system_clock, Duration>> (line 1616) | struct StringMaker<std::chrono::time_point<std::chrono::system_clock, ...
method convert (line 1617) | static std::string convert(std::chrono::time_point<std::chrono::syst...
type ITransientExpression (line 1659) | struct ITransientExpression {
method isBinaryExpression (line 1660) | auto isBinaryExpression() const -> bool { return m_isBinaryExpressio...
method getResult (line 1661) | auto getResult() const -> bool { return m_result; }
method ITransientExpression (line 1664) | ITransientExpression( bool isBinaryExpression, bool result )
class BinaryExpr (line 1681) | class BinaryExpr : public ITransientExpression {
method streamReconstructedExpression (line 1686) | void streamReconstructedExpression( std::ostream &os ) const override {
method BinaryExpr (line 1692) | BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs )
class UnaryExpr (line 1701) | class UnaryExpr : public ITransientExpression {
method streamReconstructedExpression (line 1704) | void streamReconstructedExpression( std::ostream &os ) const override {
method UnaryExpr (line 1709) | explicit UnaryExpr( LhsT lhs )
function compareEqual (line 1717) | auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return...
function compareEqual (line 1719) | auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == re...
function compareEqual (line 1721) | auto compareEqual( T* const& lhs, long rhs ) -> bool { return lhs == r...
function compareEqual (line 1723) | auto compareEqual( int lhs, T* const& rhs ) -> bool { return reinterpr...
function compareEqual (line 1725) | auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterp...
function compareNotEqual (line 1728) | auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return s...
function compareNotEqual (line 1730) | auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs !=...
function compareNotEqual (line 1732) | auto compareNotEqual( T* const& lhs, long rhs ) -> bool { return lhs !...
function compareNotEqual (line 1734) | auto compareNotEqual( int lhs, T* const& rhs ) -> bool { return reinte...
function compareNotEqual (line 1736) | auto compareNotEqual( long lhs, T* const& rhs ) -> bool { return reint...
class ExprLhs (line 1739) | class ExprLhs {
method ExprLhs (line 1742) | explicit ExprLhs( LhsT lhs ) : m_lhs( lhs ) {}
method makeUnaryExpr (line 1777) | auto makeUnaryExpr() const -> UnaryExpr<LhsT> {
function handleExpression (line 1785) | void handleExpression( ExprLhs<T> const& expr ) {
type Decomposer (line 1789) | struct Decomposer {
class AssertionResult (line 1813) | class AssertionResult
method AssertionResult (line 4154) | AssertionResult() = delete;
type AssertionInfo (line 1814) | struct AssertionInfo
type SectionInfo (line 1815) | struct SectionInfo
method SectionInfo (line 2221) | SectionInfo
type SectionEndInfo (line 1816) | struct SectionEndInfo
type MessageInfo (line 1817) | struct MessageInfo
type Counts (line 1818) | struct Counts
type BenchmarkInfo (line 1819) | struct BenchmarkInfo
type BenchmarkStats (line 1820) | struct BenchmarkStats
type AssertionReaction (line 1821) | struct AssertionReaction
type SourceLineInfo (line 1822) | struct SourceLineInfo
method SourceLineInfo (line 404) | SourceLineInfo() = delete;
method SourceLineInfo (line 405) | SourceLineInfo( char const* _file, std::size_t _line ) noexcept
method SourceLineInfo (line 410) | SourceLineInfo( SourceLineInfo const& other ) = default;
method SourceLineInfo (line 411) | SourceLineInfo( SourceLineInfo && ) = default;
method SourceLineInfo (line 412) | SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
method SourceLineInfo (line 413) | SourceLineInfo& operator = ( SourceLineInfo && ) = default;
type ITransientExpression (line 1824) | struct ITransientExpression
method isBinaryExpression (line 1660) | auto isBinaryExpression() const -> bool { return m_isBinaryExpressio...
method getResult (line 1661) | auto getResult() const -> bool { return m_result; }
method ITransientExpression (line 1664) | ITransientExpression( bool isBinaryExpression, bool result )
type IGeneratorTracker (line 1825) | struct IGeneratorTracker
type IResultCapture (line 1827) | struct IResultCapture {
type TestFailureException (line 1884) | struct TestFailureException{}
type AssertionResultData (line 1885) | struct AssertionResultData
method AssertionResultData (line 4140) | AssertionResultData() = delete;
type IResultCapture (line 1886) | struct IResultCapture
class RunContext (line 1887) | class RunContext
method RunContext (line 5591) | RunContext( RunContext const& ) = delete;
method RunContext (line 5592) | RunContext& operator =( RunContext const& ) = delete;
class LazyExpression (line 1889) | class LazyExpression {
method LazyExpression (line 1899) | LazyExpression& operator = ( LazyExpression const& ) = delete;
type AssertionReaction (line 1906) | struct AssertionReaction {
class AssertionHandler (line 1911) | class AssertionHandler {
method handleExpr (line 1930) | void handleExpr( ExprLhs<T> const& expr ) {
type MessageInfo (line 1962) | struct MessageInfo {
type MessageStream (line 1979) | struct MessageStream {
method MessageStream (line 1982) | MessageStream& operator << ( T const& value ) {
type MessageBuilder (line 1990) | struct MessageBuilder : MessageStream {
method MessageBuilder (line 1996) | MessageBuilder& operator << ( T const& value ) {
class ScopedMessage (line 2004) | class ScopedMessage {
class Capturer (line 2012) | class Capturer {
method captureValues (line 2023) | void captureValues( size_t index, T const& value ) {
method captureValues (line 2028) | void captureValues( size_t index, T const& value, Ts const&... value...
type Counts (line 2184) | struct Counts {
type Totals (line 2197) | struct Totals {
type SectionInfo (line 2215) | struct SectionInfo {
method SectionInfo (line 2221) | SectionInfo
type SectionEndInfo (line 2231) | struct SectionEndInfo {
class Timer (line 2249) | class Timer {
class Section (line 2266) | class Section : NonCopyable {
class BenchmarkLooper (line 2303) | class BenchmarkLooper {
method BenchmarkLooper (line 2314) | BenchmarkLooper( StringRef name )
method increment (line 2328) | void increment() {
class TestCase (line 2351) | class TestCase
type ITestCaseRegistry (line 2352) | struct ITestCaseRegistry
type IExceptionTranslatorRegistry (line 2353) | struct IExceptionTranslatorRegistry
type IExceptionTranslator (line 2354) | struct IExceptionTranslator
type IReporterRegistry (line 2355) | struct IReporterRegistry
type IReporterFactory (line 2356) | struct IReporterFactory
type ITagAliasRegistry (line 2357) | struct ITagAliasRegistry
class StartupExceptionRegistry (line 2358) | class StartupExceptionRegistry
type IRegistryHub (line 2362) | struct IRegistryHub {
type IMutableRegistryHub (line 2374) | struct IMutableRegistryHub {
type IExceptionTranslator (line 2404) | struct IExceptionTranslator
type IExceptionTranslator (line 2407) | struct IExceptionTranslator {
type IExceptionTranslatorRegistry (line 2412) | struct IExceptionTranslatorRegistry {
class ExceptionTranslatorRegistrar (line 2418) | class ExceptionTranslatorRegistrar {
class ExceptionTranslator (line 2420) | class ExceptionTranslator : public IExceptionTranslator {
method ExceptionTranslator (line 2423) | ExceptionTranslator( std::string(*translateFunction)( T& ) )
method translate (line 2427) | std::string translate( ExceptionTranslators::const_iterator it, Ex...
method ExceptionTranslatorRegistrar (line 2445) | ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) {
type Detail (line 2468) | namespace Detail {
function rawMemoryToString (line 1064) | std::string rawMemoryToString( const T& object ) {
class IsStreamInsertable (line 1069) | class IsStreamInsertable {
function convertUnstreamable (line 1085) | typename std::enable_if<
function convertUnstreamable (line 1091) | typename std::enable_if<
function convertUnstreamable (line 1098) | typename std::enable_if<
function stringify (line 1149) | std::string stringify(const T& e) {
function convertUnknownEnumToString (line 1154) | std::string convertUnknownEnumToString( E e ) {
function rangeToString (line 1325) | std::string rangeToString(InputIterator first, InputIterator last) {
function stringify (line 1355) | inline std::string stringify( NSString* nsstring ) {
type TupleElementPrinter (line 1404) | struct TupleElementPrinter {
method print (line 1405) | static void print(const Tuple& tuple, std::ostream& os) {
type TupleElementPrinter<Tuple, N, false> (line 1416) | struct TupleElementPrinter<Tuple, N, false> {
method print (line 1417) | static void print(const Tuple&, std::ostream&) {}
class Approx (line 2470) | class Approx {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5349) | Approx Approx::custom() {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5353) | Approx Approx::operator-() const {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
type Endianness (line 11804) | struct Endianness {
type Arch (line 11805) | enum Arch { Big, Little }
method Arch (line 11807) | static Arch which() {
function rawMemoryToString (line 11819) | std::string rawMemoryToString( const void *object, std::size_t size ) {
type literals (line 2571) | namespace literals {
type StringMaker<Catch::Detail::Approx> (line 2577) | struct StringMaker<Catch::Detail::Approx> {
type pluralise (line 2601) | struct pluralise {
type Matchers (line 2621) | namespace Matchers {
type Impl (line 2622) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 2775) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Generic (line 2817) | namespace Generic {
type Detail (line 2819) | namespace Detail {
class PredicateMatcher (line 2824) | class PredicateMatcher : public MatcherBase<T> {
method PredicateMatcher (line 2829) | PredicateMatcher(std::function<bool(T const&)> const& elem, std:...
method match (line 2834) | bool match( T const& item ) const override {
method describe (line 2838) | std::string describe() const override {
function Predicate (line 2850) | Generic::PredicateMatcher<T> Predicate(std::function<bool(T const&)>...
type StdString (line 2865) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
type Vector (line 2934) | namespace Vector {
type Detail (line 2935) | namespace Detail {
function count (line 2937) | size_t count(InputIterator first, InputIterator last, T const& i...
function contains (line 2947) | bool contains(InputIterator first, InputIterator last, T const& ...
type ContainsElementMatcher (line 2958) | struct ContainsElementMatcher : MatcherBase<std::vector<T>> {
method ContainsElementMatcher (line 2960) | ContainsElementMatcher(T const &comparator) : m_comparator( comp...
method match (line 2962) | bool match(std::vector<T> const &v) const override {
method describe (line 2971) | std::string describe() const override {
type ContainsMatcher (line 2979) | struct ContainsMatcher : MatcherBase<std::vector<T>> {
method ContainsMatcher (line 2981) | ContainsMatcher(std::vector<T> const &comparator) : m_comparator...
method match (line 2983) | bool match(std::vector<T> const &v) const override {
method describe (line 3001) | std::string describe() const override {
type EqualsMatcher (line 3009) | struct EqualsMatcher : MatcherBase<std::vector<T>> {
method EqualsMatcher (line 3011) | EqualsMatcher(std::vector<T> const &comparator) : m_comparator( ...
method match (line 3013) | bool match(std::vector<T> const &v) const override {
method describe (line 3025) | std::string describe() const override {
type UnorderedEqualsMatcher (line 3032) | struct UnorderedEqualsMatcher : MatcherBase<std::vector<T>> {
method UnorderedEqualsMatcher (line 3033) | UnorderedEqualsMatcher(std::vector<T> const& target) : m_target(...
method match (line 3034) | bool match(std::vector<T> const& vec) const override {
method describe (line 3064) | std::string describe() const override {
function Contains (line 3077) | Vector::ContainsMatcher<T> Contains( std::vector<T> const& comparato...
function VectorContains (line 3082) | Vector::ContainsElementMatcher<T> VectorContains( T const& comparato...
function Equals (line 3087) | Vector::EqualsMatcher<T> Equals( std::vector<T> const& comparator ) {
function UnorderedEquals (line 3092) | Vector::UnorderedEqualsMatcher<T> UnorderedEquals(std::vector<T> con...
type Impl (line 8698) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 8750) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Floating (line 8811) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
function WithinULP (line 8861) | Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff) {
function WithinULP (line 8865) | Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff) {
function WithinAbs (line 8869) | Floating::WithinAbsMatcher WithinAbs(double target, double margin) {
type StdString (line 8894) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
function Equals (line 8969) | StdString::EqualsMatcher Equals( std::string const& str, CaseSensiti...
function Contains (line 8972) | StdString::ContainsMatcher Contains( std::string const& str, CaseSen...
function EndsWith (line 8975) | StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSen...
function StartsWith (line 8978) | StdString::StartsWithMatcher StartsWith( std::string const& str, Cas...
function Matches (line 8982) | StdString::RegexMatcher Matches(std::string const& regex, CaseSensit...
type Matchers (line 2773) | namespace Matchers {
type Impl (line 2622) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 2775) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Generic (line 2817) | namespace Generic {
type Detail (line 2819) | namespace Detail {
class PredicateMatcher (line 2824) | class PredicateMatcher : public MatcherBase<T> {
method PredicateMatcher (line 2829) | PredicateMatcher(std::function<bool(T const&)> const& elem, std:...
method match (line 2834) | bool match( T const& item ) const override {
method describe (line 2838) | std::string describe() const override {
function Predicate (line 2850) | Generic::PredicateMatcher<T> Predicate(std::function<bool(T const&)>...
type StdString (line 2865) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
type Vector (line 2934) | namespace Vector {
type Detail (line 2935) | namespace Detail {
function count (line 2937) | size_t count(InputIterator first, InputIterator last, T const& i...
function contains (line 2947) | bool contains(InputIterator first, InputIterator last, T const& ...
type ContainsElementMatcher (line 2958) | struct ContainsElementMatcher : MatcherBase<std::vector<T>> {
method ContainsElementMatcher (line 2960) | ContainsElementMatcher(T const &comparator) : m_comparator( comp...
method match (line 2962) | bool match(std::vector<T> const &v) const override {
method describe (line 2971) | std::string describe() const override {
type ContainsMatcher (line 2979) | struct ContainsMatcher : MatcherBase<std::vector<T>> {
method ContainsMatcher (line 2981) | ContainsMatcher(std::vector<T> const &comparator) : m_comparator...
method match (line 2983) | bool match(std::vector<T> const &v) const override {
method describe (line 3001) | std::string describe() const override {
type EqualsMatcher (line 3009) | struct EqualsMatcher : MatcherBase<std::vector<T>> {
method EqualsMatcher (line 3011) | EqualsMatcher(std::vector<T> const &comparator) : m_comparator( ...
method match (line 3013) | bool match(std::vector<T> const &v) const override {
method describe (line 3025) | std::string describe() const override {
type UnorderedEqualsMatcher (line 3032) | struct UnorderedEqualsMatcher : MatcherBase<std::vector<T>> {
method UnorderedEqualsMatcher (line 3033) | UnorderedEqualsMatcher(std::vector<T> const& target) : m_target(...
method match (line 3034) | bool match(std::vector<T> const& vec) const override {
method describe (line 3064) | std::string describe() const override {
function Contains (line 3077) | Vector::ContainsMatcher<T> Contains( std::vector<T> const& comparato...
function VectorContains (line 3082) | Vector::ContainsElementMatcher<T> VectorContains( T const& comparato...
function Equals (line 3087) | Vector::EqualsMatcher<T> Equals( std::vector<T> const& comparator ) {
function UnorderedEquals (line 3092) | Vector::UnorderedEqualsMatcher<T> UnorderedEquals(std::vector<T> con...
type Impl (line 8698) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 8750) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Floating (line 8811) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
function WithinULP (line 8861) | Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff) {
function WithinULP (line 8865) | Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff) {
function WithinAbs (line 8869) | Floating::WithinAbsMatcher WithinAbs(double target, double margin) {
type StdString (line 8894) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
function Equals (line 8969) | StdString::EqualsMatcher Equals( std::string const& str, CaseSensiti...
function Contains (line 8972) | StdString::ContainsMatcher Contains( std::string const& str, CaseSen...
function EndsWith (line 8975) | StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSen...
function StartsWith (line 8978) | StdString::StartsWithMatcher StartsWith( std::string const& str, Cas...
function Matches (line 8982) | StdString::RegexMatcher Matches(std::string const& regex, CaseSensit...
type Matchers (line 2816) | namespace Matchers {
type Impl (line 2622) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 2775) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Generic (line 2817) | namespace Generic {
type Detail (line 2819) | namespace Detail {
class PredicateMatcher (line 2824) | class PredicateMatcher : public MatcherBase<T> {
method PredicateMatcher (line 2829) | PredicateMatcher(std::function<bool(T const&)> const& elem, std:...
method match (line 2834) | bool match( T const& item ) const override {
method describe (line 2838) | std::string describe() const override {
function Predicate (line 2850) | Generic::PredicateMatcher<T> Predicate(std::function<bool(T const&)>...
type StdString (line 2865) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
type Vector (line 2934) | namespace Vector {
type Detail (line 2935) | namespace Detail {
function count (line 2937) | size_t count(InputIterator first, InputIterator last, T const& i...
function contains (line 2947) | bool contains(InputIterator first, InputIterator last, T const& ...
type ContainsElementMatcher (line 2958) | struct ContainsElementMatcher : MatcherBase<std::vector<T>> {
method ContainsElementMatcher (line 2960) | ContainsElementMatcher(T const &comparator) : m_comparator( comp...
method match (line 2962) | bool match(std::vector<T> const &v) const override {
method describe (line 2971) | std::string describe() const override {
type ContainsMatcher (line 2979) | struct ContainsMatcher : MatcherBase<std::vector<T>> {
method ContainsMatcher (line 2981) | ContainsMatcher(std::vector<T> const &comparator) : m_comparator...
method match (line 2983) | bool match(std::vector<T> const &v) const override {
method describe (line 3001) | std::string describe() const override {
type EqualsMatcher (line 3009) | struct EqualsMatcher : MatcherBase<std::vector<T>> {
method EqualsMatcher (line 3011) | EqualsMatcher(std::vector<T> const &comparator) : m_comparator( ...
method match (line 3013) | bool match(std::vector<T> const &v) const override {
method describe (line 3025) | std::string describe() const override {
type UnorderedEqualsMatcher (line 3032) | struct UnorderedEqualsMatcher : MatcherBase<std::vector<T>> {
method UnorderedEqualsMatcher (line 3033) | UnorderedEqualsMatcher(std::vector<T> const& target) : m_target(...
method match (line 3034) | bool match(std::vector<T> const& vec) const override {
method describe (line 3064) | std::string describe() const override {
function Contains (line 3077) | Vector::ContainsMatcher<T> Contains( std::vector<T> const& comparato...
function VectorContains (line 3082) | Vector::ContainsElementMatcher<T> VectorContains( T const& comparato...
function Equals (line 3087) | Vector::EqualsMatcher<T> Equals( std::vector<T> const& comparator ) {
function UnorderedEquals (line 3092) | Vector::UnorderedEqualsMatcher<T> UnorderedEquals(std::vector<T> con...
type Impl (line 8698) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 8750) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Floating (line 8811) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
function WithinULP (line 8861) | Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff) {
function WithinULP (line 8865) | Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff) {
function WithinAbs (line 8869) | Floating::WithinAbsMatcher WithinAbs(double target, double margin) {
type StdString (line 8894) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
function Equals (line 8969) | StdString::EqualsMatcher Equals( std::string const& str, CaseSensiti...
function Contains (line 8972) | StdString::ContainsMatcher Contains( std::string const& str, CaseSen...
function EndsWith (line 8975) | StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSen...
function StartsWith (line 8978) | StdString::StartsWithMatcher StartsWith( std::string const& str, Cas...
function Matches (line 8982) | StdString::RegexMatcher Matches(std::string const& regex, CaseSensit...
type Matchers (line 2863) | namespace Matchers {
type Impl (line 2622) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 2775) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Generic (line 2817) | namespace Generic {
type Detail (line 2819) | namespace Detail {
class PredicateMatcher (line 2824) | class PredicateMatcher : public MatcherBase<T> {
method PredicateMatcher (line 2829) | PredicateMatcher(std::function<bool(T const&)> const& elem, std:...
method match (line 2834) | bool match( T const& item ) const override {
method describe (line 2838) | std::string describe() const override {
function Predicate (line 2850) | Generic::PredicateMatcher<T> Predicate(std::function<bool(T const&)>...
type StdString (line 2865) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
type Vector (line 2934) | namespace Vector {
type Detail (line 2935) | namespace Detail {
function count (line 2937) | size_t count(InputIterator first, InputIterator last, T const& i...
function contains (line 2947) | bool contains(InputIterator first, InputIterator last, T const& ...
type ContainsElementMatcher (line 2958) | struct ContainsElementMatcher : MatcherBase<std::vector<T>> {
method ContainsElementMatcher (line 2960) | ContainsElementMatcher(T const &comparator) : m_comparator( comp...
method match (line 2962) | bool match(std::vector<T> const &v) const override {
method describe (line 2971) | std::string describe() const override {
type ContainsMatcher (line 2979) | struct ContainsMatcher : MatcherBase<std::vector<T>> {
method ContainsMatcher (line 2981) | ContainsMatcher(std::vector<T> const &comparator) : m_comparator...
method match (line 2983) | bool match(std::vector<T> const &v) const override {
method describe (line 3001) | std::string describe() const override {
type EqualsMatcher (line 3009) | struct EqualsMatcher : MatcherBase<std::vector<T>> {
method EqualsMatcher (line 3011) | EqualsMatcher(std::vector<T> const &comparator) : m_comparator( ...
method match (line 3013) | bool match(std::vector<T> const &v) const override {
method describe (line 3025) | std::string describe() const override {
type UnorderedEqualsMatcher (line 3032) | struct UnorderedEqualsMatcher : MatcherBase<std::vector<T>> {
method UnorderedEqualsMatcher (line 3033) | UnorderedEqualsMatcher(std::vector<T> const& target) : m_target(...
method match (line 3034) | bool match(std::vector<T> const& vec) const override {
method describe (line 3064) | std::string describe() const override {
function Contains (line 3077) | Vector::ContainsMatcher<T> Contains( std::vector<T> const& comparato...
function VectorContains (line 3082) | Vector::ContainsElementMatcher<T> VectorContains( T const& comparato...
function Equals (line 3087) | Vector::EqualsMatcher<T> Equals( std::vector<T> const& comparator ) {
function UnorderedEquals (line 3092) | Vector::UnorderedEqualsMatcher<T> UnorderedEquals(std::vector<T> con...
type Impl (line 8698) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 8750) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Floating (line 8811) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
function WithinULP (line 8861) | Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff) {
function WithinULP (line 8865) | Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff) {
function WithinAbs (line 8869) | Floating::WithinAbsMatcher WithinAbs(double target, double margin) {
type StdString (line 8894) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
function Equals (line 8969) | StdString::EqualsMatcher Equals( std::string const& str, CaseSensiti...
function Contains (line 8972) | StdString::ContainsMatcher Contains( std::string const& str, CaseSen...
function EndsWith (line 8975) | StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSen...
function StartsWith (line 8978) | StdString::StartsWithMatcher StartsWith( std::string const& str, Cas...
function Matches (line 8982) | StdString::RegexMatcher Matches(std::string const& regex, CaseSensit...
type Matchers (line 2932) | namespace Matchers {
type Impl (line 2622) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 2775) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Generic (line 2817) | namespace Generic {
type Detail (line 2819) | namespace Detail {
class PredicateMatcher (line 2824) | class PredicateMatcher : public MatcherBase<T> {
method PredicateMatcher (line 2829) | PredicateMatcher(std::function<bool(T const&)> const& elem, std:...
method match (line 2834) | bool match( T const& item ) const override {
method describe (line 2838) | std::string describe() const override {
function Predicate (line 2850) | Generic::PredicateMatcher<T> Predicate(std::function<bool(T const&)>...
type StdString (line 2865) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
type Vector (line 2934) | namespace Vector {
type Detail (line 2935) | namespace Detail {
function count (line 2937) | size_t count(InputIterator first, InputIterator last, T const& i...
function contains (line 2947) | bool contains(InputIterator first, InputIterator last, T const& ...
type ContainsElementMatcher (line 2958) | struct ContainsElementMatcher : MatcherBase<std::vector<T>> {
method ContainsElementMatcher (line 2960) | ContainsElementMatcher(T const &comparator) : m_comparator( comp...
method match (line 2962) | bool match(std::vector<T> const &v) const override {
method describe (line 2971) | std::string describe() const override {
type ContainsMatcher (line 2979) | struct ContainsMatcher : MatcherBase<std::vector<T>> {
method ContainsMatcher (line 2981) | ContainsMatcher(std::vector<T> const &comparator) : m_comparator...
method match (line 2983) | bool match(std::vector<T> const &v) const override {
method describe (line 3001) | std::string describe() const override {
type EqualsMatcher (line 3009) | struct EqualsMatcher : MatcherBase<std::vector<T>> {
method EqualsMatcher (line 3011) | EqualsMatcher(std::vector<T> const &comparator) : m_comparator( ...
method match (line 3013) | bool match(std::vector<T> const &v) const override {
method describe (line 3025) | std::string describe() const override {
type UnorderedEqualsMatcher (line 3032) | struct UnorderedEqualsMatcher : MatcherBase<std::vector<T>> {
method UnorderedEqualsMatcher (line 3033) | UnorderedEqualsMatcher(std::vector<T> const& target) : m_target(...
method match (line 3034) | bool match(std::vector<T> const& vec) const override {
method describe (line 3064) | std::string describe() const override {
function Contains (line 3077) | Vector::ContainsMatcher<T> Contains( std::vector<T> const& comparato...
function VectorContains (line 3082) | Vector::ContainsElementMatcher<T> VectorContains( T const& comparato...
function Equals (line 3087) | Vector::EqualsMatcher<T> Equals( std::vector<T> const& comparator ) {
function UnorderedEquals (line 3092) | Vector::UnorderedEqualsMatcher<T> UnorderedEquals(std::vector<T> con...
type Impl (line 8698) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 8750) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Floating (line 8811) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
function WithinULP (line 8861) | Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff) {
function WithinULP (line 8865) | Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff) {
function WithinAbs (line 8869) | Floating::WithinAbsMatcher WithinAbs(double target, double margin) {
type StdString (line 8894) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
function Equals (line 8969) | StdString::EqualsMatcher Equals( std::string const& str, CaseSensiti...
function Contains (line 8972) | StdString::ContainsMatcher Contains( std::string const& str, CaseSen...
function EndsWith (line 8975) | StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSen...
function StartsWith (line 8978) | StdString::StartsWithMatcher StartsWith( std::string const& str, Cas...
function Matches (line 8982) | StdString::RegexMatcher Matches(std::string const& regex, CaseSensit...
class MatchExpr (line 3103) | class MatchExpr : public ITransientExpression {
method MatchExpr (line 3108) | MatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef const...
method streamReconstructedExpression (line 3115) | void streamReconstructedExpression( std::ostream &os ) const override {
function makeMatchExpr (line 3130) | auto makeMatchExpr( ArgT const& arg, MatcherT const& matcher, StringRe...
type Generators (line 3177) | namespace Generators {
class GeneratorBase (line 3178) | class GeneratorBase {
method GeneratorBase (line 3183) | GeneratorBase( size_t size ) : m_size( size ) {}
method size (line 3185) | auto size() const -> size_t { return m_size; }
type pf (line 3241) | namespace pf{
function make_unique (line 3243) | std::unique_ptr<T> make_unique( Args&&... args ) {
type IGenerator (line 3249) | struct IGenerator {
class SingleValueGenerator (line 3255) | class SingleValueGenerator : public IGenerator<T> {
method SingleValueGenerator (line 3258) | SingleValueGenerator( T const& value ) : m_value( value ) {}
method get (line 3260) | auto get( size_t ) const -> T override {
class FixedValuesGenerator (line 3266) | class FixedValuesGenerator : public IGenerator<T> {
method FixedValuesGenerator (line 3270) | FixedValuesGenerator( std::initializer_list<T> values ) : m_values...
method get (line 3272) | auto get( size_t index ) const -> T override {
class RangeGenerator (line 3278) | class RangeGenerator : public IGenerator<T> {
method RangeGenerator (line 3283) | RangeGenerator( T const& first, T const& last ) : m_first( first )...
method get (line 3287) | auto get( size_t index ) const -> T override {
type NullGenerator (line 3294) | struct NullGenerator : IGenerator<T> {
method get (line 3295) | auto get( size_t ) const -> T override {
class Generator (line 3301) | class Generator {
method Generator (line 3306) | Generator( size_t size, std::unique_ptr<IGenerator<T>> generator )
method size (line 3311) | auto size() const -> size_t { return m_size; }
class GeneratorRandomiser (line 3321) | class GeneratorRandomiser : public IGenerator<T> {
method GeneratorRandomiser (line 3326) | GeneratorRandomiser( Generator<T>&& baseGenerator, size_t numberOf...
method get (line 3331) | auto get( size_t index ) const -> T override {
type RequiresASpecialisationFor (line 3337) | struct RequiresASpecialisationFor
function all (line 3340) | auto all() -> Generator<T> { return RequiresASpecialisationFor<T>(); }
function range (line 3346) | auto range( T const& first, T const& last ) -> Generator<T> {
function random (line 3351) | auto random( T const& first, T const& last ) -> Generator<T> {
function random (line 3358) | auto random( size_t size ) -> Generator<T> {
function values (line 3363) | auto values( std::initializer_list<T> values ) -> Generator<T> {
function value (line 3367) | auto value( T const& val ) -> Generator<T> {
function as (line 3372) | auto as() -> Generator<T> {
function table (line 3377) | auto table( std::initializer_list<std::tuple<Ts...>>&& tuples ) -> G...
type Generators (line 3382) | struct Generators : GeneratorBase {
method Generators (line 3387) | Generators() : GeneratorBase( 0 ) {}
method populate (line 3389) | void populate( T&& val ) {
method populate (line 3394) | void populate( U&& val ) {
method populate (line 3397) | void populate( Generator<T>&& generator ) {
method populate (line 3403) | void populate( U&& valueOrGenerator, Gs... moreGenerators ) {
function makeGenerators (line 3421) | auto makeGenerators( Generator<T>&& generator, Gs... moreGenerators ...
function makeGenerators (line 3428) | auto makeGenerators( Generator<T>&& generator ) -> Generators<T> {
function makeGenerators (line 3434) | auto makeGenerators( T&& val, Gs... moreGenerators ) -> Generators<T> {
function makeGenerators (line 3438) | auto makeGenerators( U&& val, Gs... moreGenerators ) -> Generators<T> {
function generate (line 3448) | auto generate( SourceLineInfo const& lineInfo, L const& generatorExp...
function randomiseIndices (line 8268) | std::vector<size_t> randomiseIndices( size_t selectionSize, size_t s...
function acquireGeneratorTracker (line 8285) | auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IG...
type GeneratorTracker (line 9673) | struct GeneratorTracker : TestCaseTracking::TrackerBase, IGeneratorT...
method GeneratorTracker (line 9677) | GeneratorTracker( TestCaseTracking::NameAndLocation const& nameAnd...
method GeneratorTracker (line 9682) | static GeneratorTracker& acquire( TrackerContext& ctx, TestCaseTra...
method moveNext (line 9705) | void moveNext() {
method isIndexTracker (line 9711) | bool isIndexTracker() const override { return true; }
method hasGenerator (line 9712) | auto hasGenerator() const -> bool override {
method close (line 9715) | void close() override {
method getGenerator (line 9722) | auto getGenerator() const -> GeneratorBasePtr const& override {
method setGenerator (line 9725) | void setGenerator( GeneratorBasePtr&& generator ) override {
method getIndex (line 9728) | auto getIndex() const -> size_t override {
type IGeneratorTracker (line 3191) | struct IGeneratorTracker {
function throw_exception (line 3209) | [[noreturn]]
type Generators (line 3238) | namespace Generators {
class GeneratorBase (line 3178) | class GeneratorBase {
method GeneratorBase (line 3183) | GeneratorBase( size_t size ) : m_size( size ) {}
method size (line 3185) | auto size() const -> size_t { return m_size; }
type pf (line 3241) | namespace pf{
function make_unique (line 3243) | std::unique_ptr<T> make_unique( Args&&... args ) {
type IGenerator (line 3249) | struct IGenerator {
class SingleValueGenerator (line 3255) | class SingleValueGenerator : public IGenerator<T> {
method SingleValueGenerator (line 3258) | SingleValueGenerator( T const& value ) : m_value( value ) {}
method get (line 3260) | auto get( size_t ) const -> T override {
class FixedValuesGenerator (line 3266) | class FixedValuesGenerator : public IGenerator<T> {
method FixedValuesGenerator (line 3270) | FixedValuesGenerator( std::initializer_list<T> values ) : m_values...
method get (line 3272) | auto get( size_t index ) const -> T override {
class RangeGenerator (line 3278) | class RangeGenerator : public IGenerator<T> {
method RangeGenerator (line 3283) | RangeGenerator( T const& first, T const& last ) : m_first( first )...
method get (line 3287) | auto get( size_t index ) const -> T override {
type NullGenerator (line 3294) | struct NullGenerator : IGenerator<T> {
method get (line 3295) | auto get( size_t ) const -> T override {
class Generator (line 3301) | class Generator {
method Generator (line 3306) | Generator( size_t size, std::unique_ptr<IGenerator<T>> generator )
method size (line 3311) | auto size() const -> size_t { return m_size; }
class GeneratorRandomiser (line 3321) | class GeneratorRandomiser : public IGenerator<T> {
method GeneratorRandomiser (line 3326) | GeneratorRandomiser( Generator<T>&& baseGenerator, size_t numberOf...
method get (line 3331) | auto get( size_t index ) const -> T override {
type RequiresASpecialisationFor (line 3337) | struct RequiresASpecialisationFor
function all (line 3340) | auto all() -> Generator<T> { return RequiresASpecialisationFor<T>(); }
function range (line 3346) | auto range( T const& first, T const& last ) -> Generator<T> {
function random (line 3351) | auto random( T const& first, T const& last ) -> Generator<T> {
function random (line 3358) | auto random( size_t size ) -> Generator<T> {
function values (line 3363) | auto values( std::initializer_list<T> values ) -> Generator<T> {
function value (line 3367) | auto value( T const& val ) -> Generator<T> {
function as (line 3372) | auto as() -> Generator<T> {
function table (line 3377) | auto table( std::initializer_list<std::tuple<Ts...>>&& tuples ) -> G...
type Generators (line 3382) | struct Generators : GeneratorBase {
method Generators (line 3387) | Generators() : GeneratorBase( 0 ) {}
method populate (line 3389) | void populate( T&& val ) {
method populate (line 3394) | void populate( U&& val ) {
method populate (line 3397) | void populate( Generator<T>&& generator ) {
method populate (line 3403) | void populate( U&& valueOrGenerator, Gs... moreGenerators ) {
function makeGenerators (line 3421) | auto makeGenerators( Generator<T>&& generator, Gs... moreGenerators ...
function makeGenerators (line 3428) | auto makeGenerators( Generator<T>&& generator ) -> Generators<T> {
function makeGenerators (line 3434) | auto makeGenerators( T&& val, Gs... moreGenerators ) -> Generators<T> {
function makeGenerators (line 3438) | auto makeGenerators( U&& val, Gs... moreGenerators ) -> Generators<T> {
function generate (line 3448) | auto generate( SourceLineInfo const& lineInfo, L const& generatorExp...
function randomiseIndices (line 8268) | std::vector<size_t> randomiseIndices( size_t selectionSize, size_t s...
function acquireGeneratorTracker (line 8285) | auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IG...
type GeneratorTracker (line 9673) | struct GeneratorTracker : TestCaseTracking::TrackerBase, IGeneratorT...
method GeneratorTracker (line 9677) | GeneratorTracker( TestCaseTracking::NameAndLocation const& nameAnd...
method GeneratorTracker (line 9682) | static GeneratorTracker& acquire( TrackerContext& ctx, TestCaseTra...
method moveNext (line 9705) | void moveNext() {
method isIndexTracker (line 9711) | bool isIndexTracker() const override { return true; }
method hasGenerator (line 9712) | auto hasGenerator() const -> bool override {
method close (line 9715) | void close() override {
method getGenerator (line 9722) | auto getGenerator() const -> GeneratorBasePtr const& override {
method setGenerator (line 9725) | void setGenerator( GeneratorBasePtr&& generator ) override {
method getIndex (line 9728) | auto getIndex() const -> size_t override {
type ITestInvoker (line 3482) | struct ITestInvoker
type TestCaseInfo (line 3484) | struct TestCaseInfo {
type SpecialProperties (line 3485) | enum SpecialProperties{
class TestCase (line 3519) | class TestCase : public TestCaseInfo {
type IRunner (line 3552) | struct IRunner {
class WildcardPattern (line 3791) | class WildcardPattern {
type WildcardPosition (line 3792) | enum WildcardPosition {
class TestSpec (line 3820) | class TestSpec {
type Pattern (line 3821) | struct Pattern {
class NamePattern (line 3827) | class NamePattern : public Pattern {
class TagPattern (line 3836) | class TagPattern : public Pattern {
class ExcludedPattern (line 3845) | class ExcludedPattern : public Pattern {
type Filter (line 3854) | struct Filter {
type TagAlias (line 3882) | struct TagAlias
type ITagAliasRegistry (line 3884) | struct ITagAliasRegistry {
class TestSpecParser (line 3898) | class TestSpecParser {
type Mode (line 3899) | enum Mode{ None, Name, QuotedName, Tag, EscapedName }
method addPattern (line 3922) | void addPattern() {
type Verbosity (line 3961) | enum class Verbosity {
type WarnAbout (line 3967) | struct WarnAbout { enum What {
type What (line 3967) | enum What {
type ShowDurations (line 3973) | struct ShowDurations { enum OrNot {
type OrNot (line 3973) | enum OrNot {
type RunTests (line 3978) | struct RunTests { enum InWhatOrder {
type InWhatOrder (line 3978) | enum InWhatOrder {
type UseColour (line 3983) | struct UseColour { enum YesOrNo {
type YesOrNo (line 3983) | enum YesOrNo {
type WaitForKeypress (line 3988) | struct WaitForKeypress { enum When {
type When (line 3988) | enum When {
class TestSpec (line 3995) | class TestSpec
type Pattern (line 3821) | struct Pattern {
class NamePattern (line 3827) | class NamePattern : public Pattern {
class TagPattern (line 3836) | class TagPattern : public Pattern {
class ExcludedPattern (line 3845) | class ExcludedPattern : public Pattern {
type Filter (line 3854) | struct Filter {
type IConfig (line 3997) | struct IConfig : NonCopyable {
type IStream (line 4037) | struct IStream
type ConfigData (line 4039) | struct ConfigData {
class Config (line 4077) | class Config : public IConfig {
method Config (line 4080) | Config() = default;
type AssertionResultData (line 4138) | struct AssertionResultData
method AssertionResultData (line 4140) | AssertionResultData() = delete;
class AssertionResult (line 4152) | class AssertionResult {
method AssertionResult (line 4154) | AssertionResult() = delete;
class Option (line 4184) | class Option {
method Option (line 4186) | Option() : nullableValue( nullptr ) {}
method Option (line 4187) | Option( T const& _value )
method Option (line 4190) | Option( Option const& _other )
method Option (line 4198) | Option& operator= ( Option const& _other ) {
method Option (line 4206) | Option& operator = ( T const& _value ) {
method reset (line 4212) | void reset() {
method T (line 4218) | T& operator*() { return *nullableValue; }
method T (line 4219) | T const& operator*() const { return *nullableValue; }
method T (line 4220) | T* operator->() { return nullableValue; }
method T (line 4221) | const T* operator->() const { return nullableValue; }
method T (line 4223) | T valueOr( T const& defaultValue ) const {
method some (line 4227) | bool some() const { return nullableValue != nullptr; }
method none (line 4228) | bool none() const { return nullableValue == nullptr; }
type ReporterConfig (line 4251) | struct ReporterConfig {
type ReporterPreferences (line 4264) | struct ReporterPreferences {
type LazyStat (line 4270) | struct LazyStat : Option<T> {
method LazyStat (line 4271) | LazyStat& operator=( T const& _value ) {
method reset (line 4276) | void reset() {
type TestRunInfo (line 4283) | struct TestRunInfo {
type GroupInfo (line 4287) | struct GroupInfo {
type AssertionStats (line 4297) | struct AssertionStats {
method AssertionStats (line 4302) | AssertionStats( AssertionStats const& ) = default;
method AssertionStats (line 4303) | AssertionStats( AssertionStats && ) = default;
method AssertionStats (line 4304) | AssertionStats& operator = ( AssertionStats const& ) = default;
method AssertionStats (line 4305) | AssertionStats& operator = ( AssertionStats && ) = default;
type SectionStats (line 4313) | struct SectionStats {
method SectionStats (line 4318) | SectionStats( SectionStats const& ) = default;
method SectionStats (line 4319) | SectionStats( SectionStats && ) = default;
method SectionStats (line 4320) | SectionStats& operator = ( SectionStats const& ) = default;
method SectionStats (line 4321) | SectionStats& operator = ( SectionStats && ) = default;
type TestCaseStats (line 4330) | struct TestCaseStats {
method TestCaseStats (line 4337) | TestCaseStats( TestCaseStats const& ) = default;
method TestCaseStats (line 4338) | TestCaseStats( TestCaseStats && ) = default;
method TestCaseStats (line 4339) | TestCaseStats& operator = ( TestCaseStats const& ) = default;
method TestCaseStats (line 4340) | TestCaseStats& operator = ( TestCaseStats && ) = default;
type TestGroupStats (line 4350) | struct TestGroupStats {
method TestGroupStats (line 4356) | TestGroupStats( TestGroupStats const& ) = default;
method TestGroupStats (line 4357) | TestGroupStats( TestGroupStats && ) = default;
method TestGroupStats (line 4358) | TestGroupStats& operator = ( TestGroupStats const& ) = default;
method TestGroupStats (line 4359) | TestGroupStats& operator = ( TestGroupStats && ) = default;
type TestRunStats (line 4367) | struct TestRunStats {
method TestRunStats (line 4372) | TestRunStats( TestRunStats const& ) = default;
method TestRunStats (line 4373) | TestRunStats( TestRunStats && ) = default;
method TestRunStats (line 4374) | TestRunStats& operator = ( TestRunStats const& ) = default;
method TestRunStats (line 4375) | TestRunStats& operator = ( TestRunStats && ) = default;
type BenchmarkInfo (line 4383) | struct BenchmarkInfo {
type BenchmarkStats (line 4386) | struct BenchmarkStats {
type IStreamingReporter (line 4392) | struct IStreamingReporter {
method benchmarkStarting (line 4410) | virtual void benchmarkStarting( BenchmarkInfo const& ) {}
method benchmarkEnded (line 4418) | virtual void benchmarkEnded( BenchmarkStats const& ) {}
type IReporterFactory (line 4434) | struct IReporterFactory {
type IReporterRegistry (line 4441) | struct IReporterRegistry {
type StreamingReporterBase (line 4469) | struct StreamingReporterBase : IStreamingReporter {
method StreamingReporterBase (line 4471) | StreamingReporterBase( ReporterConfig const& _config )
method ReporterPreferences (line 4480) | ReporterPreferences getPreferences() const override {
method getSupportedVerbosities (line 4484) | static std::set<Verbosity> getSupportedVerbosities() {
method noMatchingTestCases (line 4490) | void noMatchingTestCases(std::string const&) override {}
method testRunStarting (line 4492) | void testRunStarting(TestRunInfo const& _testRunInfo) override {
method testGroupStarting (line 4495) | void testGroupStarting(GroupInfo const& _groupInfo) override {
method testCaseStarting (line 4499) | void testCaseStarting(TestCaseInfo const& _testInfo) override {
method sectionStarting (line 4502) | void sectionStarting(SectionInfo const& _sectionInfo) override {
method sectionEnded (line 4506) | void sectionEnded(SectionStats const& /* _sectionStats */) override {
method testCaseEnded (line 4509) | void testCaseEnded(TestCaseStats const& /* _testCaseStats */) overri...
method testGroupEnded (line 4512) | void testGroupEnded(TestGroupStats const& /* _testGroupStats */) ove...
method testRunEnded (line 4515) | void testRunEnded(TestRunStats const& /* _testRunStats */) override {
method skipTest (line 4521) | void skipTest(TestCaseInfo const&) override {
type CumulativeReporterBase (line 4538) | struct CumulativeReporterBase : IStreamingReporter {
type Node (line 4540) | struct Node {
method Node (line 4541) | explicit Node( T const& _value ) : value( _value ) {}
type SectionNode (line 4548) | struct SectionNode {
method SectionNode (line 4549) | explicit SectionNode(SectionStats const& _stats) : stats(_stats) {}
type BySectionInfo (line 4568) | struct BySectionInfo {
method BySectionInfo (line 4569) | BySectionInfo( SectionInfo const& other ) : m_other( other ) {}
method BySectionInfo (line 4570) | BySectionInfo( BySectionInfo const& other ) : m_other( other.m_oth...
method CumulativeReporterBase (line 4585) | CumulativeReporterBase( ReporterConfig const& _config )
method ReporterPreferences (line 4595) | ReporterPreferences getPreferences() const override {
method getSupportedVerbosities (line 4599) | static std::set<Verbosity> getSupportedVerbosities() {
method testRunStarting (line 4603) | void testRunStarting( TestRunInfo const& ) override {}
method testGroupStarting (line 4604) | void testGroupStarting( GroupInfo const& ) override {}
method testCaseStarting (line 4606) | void testCaseStarting( TestCaseInfo const& ) override {}
method sectionStarting (line 4608) | void sectionStarting( SectionInfo const& sectionInfo ) override {
method assertionStarting (line 4633) | void assertionStarting(AssertionInfo const&) override {}
method assertionEnded (line 4635) | bool assertionEnded(AssertionStats const& assertionStats) override {
method sectionEnded (line 4647) | void sectionEnded(SectionStats const& sectionStats) override {
method testCaseEnded (line 4653) | void testCaseEnded(TestCaseStats const& testCaseStats) override {
method testGroupEnded (line 4664) | void testGroupEnded(TestGroupStats const& testGroupStats) override {
method testRunEnded (line 4669) | void testRunEnded(TestRunStats const& testRunStats) override {
method skipTest (line 4677) | void skipTest(TestCaseInfo const&) override {}
type TestEventListenerBase (line 4704) | struct TestEventListenerBase : StreamingReporterBase<TestEventListener...
type Colour (line 4720) | struct Colour {
type Code (line 4721) | enum Code {
class ReporterRegistrar (line 4781) | class ReporterRegistrar {
class ReporterFactory (line 4783) | class ReporterFactory : public IReporterFactory {
method IStreamingReporterPtr (line 4785) | virtual IStreamingReporterPtr create( ReporterConfig const& config...
method getDescription (line 4789) | virtual std::string getDescription() const override {
method ReporterRegistrar (line 4796) | explicit ReporterRegistrar( std::string const& name ) {
class ListenerRegistrar (line 4802) | class ListenerRegistrar {
class ListenerFactory (line 4804) | class ListenerFactory : public IReporterFactory {
method IStreamingReporterPtr (line 4806) | virtual IStreamingReporterPtr create( ReporterConfig const& config...
method getDescription (line 4809) | virtual std::string getDescription() const override {
method ListenerRegistrar (line 4816) | ListenerRegistrar() {
type CompactReporter (line 4846) | struct CompactReporter : StreamingReporterBase<CompactReporter> {
type SummaryColumn (line 4882) | struct SummaryColumn
method SummaryColumn (line 13287) | SummaryColumn( std::string _label, Colour::Code _colour )
method SummaryColumn (line 13290) | SummaryColumn addRow( std::size_t count ) {
class TablePrinter (line 4883) | class TablePrinter
method TablePrinter (line 13032) | TablePrinter( std::ostream& os, std::vector<ColumnInfo> columnInfos )
method columnInfos (line 13036) | auto columnInfos() const -> std::vector<ColumnInfo> const& {
method open (line 13040) | void open() {
method close (line 13050) | void close() {
method TablePrinter (line 13059) | TablePrinter& operator << (TablePrinter& tp, T const& value) {
method TablePrinter (line 13064) | TablePrinter& operator << (TablePrinter& tp, ColumnBreak) {
method TablePrinter (line 13087) | TablePrinter& operator << (TablePrinter& tp, RowBreak) {
type ConsoleReporter (line 4885) | struct ConsoleReporter : StreamingReporterBase<ConsoleReporter> {
class XmlEncode (line 4949) | class XmlEncode {
type ForWhat (line 4951) | enum ForWhat { ForTextNodes, ForAttributes }
class XmlWriter (line 4964) | class XmlWriter {
class ScopedElement (line 4967) | class ScopedElement {
method ScopedElement (line 4979) | ScopedElement& writeAttribute( std::string const& name, T const& a...
method XmlWriter (line 4991) | XmlWriter( XmlWriter const& ) = delete;
method XmlWriter (line 4992) | XmlWriter& operator=( XmlWriter const& ) = delete;
method XmlWriter (line 5005) | XmlWriter& writeAttribute( std::string const& name, T const& attribu...
class JunitReporter (line 5039) | class JunitReporter : public CumulativeReporterBase<JunitReporter> {
class XmlReporter (line 5087) | class XmlReporter : public StreamingReporterBase<XmlReporter> {
type TestCaseTracking (line 5154) | namespace TestCaseTracking {
type NameAndLocation (line 5156) | struct NameAndLocation {
type ITracker (line 5163) | struct ITracker
type ITracker (line 5167) | struct ITracker {
class TrackerContext (line 5195) | class TrackerContext {
type RunState (line 5197) | enum RunState {
class TrackerBase (line 5222) | class TrackerBase : public ITracker {
type CycleState (line 5224) | enum CycleState {
class SectionTracker (line 5270) | class SectionTracker : public TrackerBase {
class IndexTracker (line 5285) | class IndexTracker : public TrackerBase {
function TrackerContext (line 11303) | TrackerContext& TrackerContext::instance() {
type RunState (line 5197) | enum RunState {
function ITracker (line 11308) | ITracker& TrackerContext::startRun() {
function ITracker (line 11332) | ITracker& TrackerContext::currentTracker() {
function NameAndLocation (line 11345) | NameAndLocation const& TrackerBase::nameAndLocation() const {
function ITrackerPtr (line 11365) | ITrackerPtr TrackerBase::findChild( NameAndLocation const& nameAndLo...
function ITracker (line 11376) | ITracker& TrackerBase::parent() {
function SectionTracker (line 11461) | SectionTracker& SectionTracker::acquire( TrackerContext& ctx, NameAn...
function IndexTracker (line 11503) | IndexTracker& IndexTracker::acquire( TrackerContext& ctx, NameAndLoc...
type LeakDetector (line 5316) | struct LeakDetector {
type Detail (line 5340) | namespace Detail {
function rawMemoryToString (line 1064) | std::string rawMemoryToString( const T& object ) {
class IsStreamInsertable (line 1069) | class IsStreamInsertable {
function convertUnstreamable (line 1085) | typename std::enable_if<
function convertUnstreamable (line 1091) | typename std::enable_if<
function convertUnstreamable (line 1098) | typename std::enable_if<
function stringify (line 1149) | std::string stringify(const T& e) {
function convertUnknownEnumToString (line 1154) | std::string convertUnknownEnumToString( E e ) {
function rangeToString (line 1325) | std::string rangeToString(InputIterator first, InputIterator last) {
function stringify (line 1355) | inline std::string stringify( NSString* nsstring ) {
type TupleElementPrinter (line 1404) | struct TupleElementPrinter {
method print (line 1405) | static void print(const Tuple& tuple, std::ostream& os) {
type TupleElementPrinter<Tuple, N, false> (line 1416) | struct TupleElementPrinter<Tuple, N, false> {
method print (line 1417) | static void print(const Tuple&, std::ostream&) {}
class Approx (line 2470) | class Approx {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5349) | Approx Approx::custom() {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
function Approx (line 5353) | Approx Approx::operator-() const {
method Approx (line 2488) | Approx operator()( T const& value ) {
method Approx (line 2497) | explicit Approx( T const& value ): Approx(static_cast<double>(value))
method Approx (line 2542) | Approx& epsilon( T const& newEpsilon ) {
method Approx (line 2549) | Approx& margin( T const& newMargin ) {
method Approx (line 2556) | Approx& scale( T const& newScale ) {
type Endianness (line 11804) | struct Endianness {
type Arch (line 11805) | enum Arch { Big, Little }
method Arch (line 11807) | static Arch which() {
function rawMemoryToString (line 11819) | std::string rawMemoryToString( const void *object, std::size_t size ) {
type literals (line 5387) | namespace literals {
type IResultCapture (line 5410) | struct IResultCapture
type IRunner (line 5411) | struct IRunner
type IConfig (line 5412) | struct IConfig
type IMutableContext (line 5413) | struct IMutableContext
type IContext (line 5417) | struct IContext
type IMutableContext (line 5426) | struct IMutableContext : IContext
function IMutableContext (line 5440) | inline IMutableContext& getCurrentMutableContext()
function IContext (line 5447) | inline IContext& getCurrentContext()
function doNothing (line 5488) | inline void doNothing() {}
type FatalConditionHandler (line 5532) | struct FatalConditionHandler {
type sigaction (line 5556) | struct sigaction
type FatalConditionHandler (line 5553) | struct FatalConditionHandler {
type sigaction (line 5556) | struct sigaction
type FatalConditionHandler (line 5572) | struct FatalConditionHandler {
type sigaction (line 5556) | struct sigaction
type IMutableContext (line 5584) | struct IMutableContext
class RunContext (line 5588) | class RunContext : public IResultCapture, public IRunner {
method RunContext (line 5591) | RunContext( RunContext const& ) = delete;
method RunContext (line 5592) | RunContext& operator =( RunContext const& ) = delete;
function handleExceptionMatchExpr (line 5802) | void handleExceptionMatchExpr( AssertionHandler& handler, std::string ...
function SourceLineInfo (line 5889) | SourceLineInfo AssertionResult::getSourceInfo() const {
method SourceLineInfo (line 404) | SourceLineInfo() = delete;
method SourceLineInfo (line 405) | SourceLineInfo( char const* _file, std::size_t _line ) noexcept
method SourceLineInfo (line 410) | SourceLineInfo( SourceLineInfo const& other ) = default;
method SourceLineInfo (line 411) | SourceLineInfo( SourceLineInfo && ) = default;
method SourceLineInfo (line 412) | SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
method SourceLineInfo (line 413) | SourceLineInfo& operator = ( SourceLineInfo && ) = default;
function StringRef (line 5893) | StringRef AssertionResult::getTestMacroName() const {
method StringRef (line 529) | StringRef() noexcept
method StringRef (line 533) | StringRef( StringRef const& other ) noexcept
method StringRef (line 538) | StringRef( StringRef&& other ) noexcept
method StringRef (line 548) | StringRef( char const* rawChars, size_type size ) noexcept
method StringRef (line 553) | StringRef( std::string const& stdString ) noexcept
method empty (line 581) | auto empty() const noexcept -> bool {
method size (line 584) | auto size() const noexcept -> size_type {
function handleExceptionMatchExpr (line 5934) | void handleExceptionMatchExpr( AssertionHandler& handler, StringMatche...
type clara (line 6012) | namespace clara {
type TextFlow (line 6013) | namespace TextFlow {
function isWhitespace (line 6015) | inline auto isWhitespace(char c) -> bool {
function isBreakableBefore (line 6019) | inline auto isBreakableBefore(char c) -> bool {
function isBreakableAfter (line 6023) | inline auto isBreakableAfter(char c) -> bool {
class Columns (line 6028) | class Columns
class iterator (line 6209) | class iterator {
type EndTag (line 6211) | struct EndTag {}
method iterator (line 6217) | iterator(Columns const& columns, EndTag)
method iterator (line 6233) | explicit iterator(Columns const& columns)
method begin (line 6281) | auto begin() const -> iterator { return iterator(*this); }
method end (line 6282) | auto end() const -> iterator { return { *this, iterator::EndTag(...
method friend (line 6294) | inline friend std::ostream& operator << (std::ostream& os, Colum...
method toString (line 6307) | auto toString() const -> std::string {
class Column (line 6030) | class Column {
class iterator (line 6037) | class iterator {
method iterator (line 6048) | iterator(Column const& column, size_t stringIndex)
method line (line 6052) | auto line() const -> std::string const& { return m_column.m_st...
method isBoundary (line 6054) | auto isBoundary(size_t at) const -> bool {
method calcLength (line 6064) | void calcLength() {
method indent (line 6091) | auto indent() const -> size_t {
method addIndentAndSuffix (line 6096) | auto addIndentAndSuffix(std::string const &plain) const -> std...
method iterator (line 6107) | explicit iterator(Column const& column) : m_column(column) {
method Column (line 6155) | explicit Column(std::string const& text) { m_strings.push_back(t...
method width (line 6157) | auto width(size_t newWidth) -> Column& {
method indent (line 6162) | auto indent(size_t newIndent) -> Column& {
method initialIndent (line 6166) | auto initialIndent(size_t newIndent) -> Column& {
method width (line 6171) | auto width() const -> size_t { return m_width; }
method begin (line 6172) | auto begin() const -> iterator { return iterator(*this); }
method end (line 6173) | auto end() const -> iterator { return { *this, m_strings.size() ...
method friend (line 6175) | inline friend std::ostream& operator << (std::ostream& os, Colum...
method toString (line 6189) | auto toString() const -> std::string {
class Spacer (line 6196) | class Spacer : public Column {
method Spacer (line 6199) | explicit Spacer(size_t spaceWidth) : Column("") {
class Columns (line 6204) | class Columns {
class iterator (line 6209) | class iterator {
type EndTag (line 6211) | struct EndTag {}
method iterator (line 6217) | iterator(Columns const& columns, EndTag)
method iterator (line 6233) | explicit iterator(Columns const& columns)
method begin (line 6281) | auto begin() const -> iterator { return iterator(*this); }
method end (line 6282) | auto end() const -> iterator { return { *this, iterator::EndTag(...
method friend (line 6294) | inline friend std::ostream& operator << (std::ostream& os, Colum...
method toString (line 6307) | auto toString() const -> std::string {
type detail (line 6338) | namespace detail {
type UnaryLambdaTraits (line 6342) | struct UnaryLambdaTraits : UnaryLambdaTraits<decltype( &L::operato...
type UnaryLambdaTraits<ReturnT( ClassT::* )( ArgT ) const> (line 6350) | struct UnaryLambdaTraits<ReturnT( ClassT::* )( ArgT ) const> {
class TokenStream (line 6356) | class TokenStream
method loadBuffer (line 6404) | void loadBuffer() {
method TokenStream (line 6436) | explicit TokenStream( Args const &args ) : TokenStream( args.m_a...
method TokenStream (line 6438) | TokenStream( Iterator it, Iterator itEnd ) : it( it ), itEnd( it...
method count (line 6446) | auto count() const -> size_t { return m_tokenBuffer.size() + (it...
class Args (line 6359) | class Args {
method Args (line 6365) | Args( int argc, char const* const* argv )
method Args (line 6369) | Args( std::initializer_list<std::string> args )
method exeName (line 6374) | auto exeName() const -> std::string {
type TokenType (line 6381) | enum class TokenType {
type Token (line 6384) | struct Token {
function isOptPrefix (line 6389) | inline auto isOptPrefix( char c ) -> bool {
class TokenStream (line 6398) | class TokenStream {
method loadBuffer (line 6404) | void loadBuffer() {
method TokenStream (line 6436) | explicit TokenStream( Args const &args ) : TokenStream( args.m_a...
method TokenStream (line 6438) | TokenStream( Iterator it, Iterator itEnd ) : it( it ), itEnd( it...
method count (line 6446) | auto count() const -> size_t { return m_tokenBuffer.size() + (it...
class ResultBase (line 6470) | class ResultBase {
type Type (line 6472) | enum Type {
method ResultBase (line 6477) | ResultBase( Type type ) : m_type( type ) {}
class ResultValueBase (line 6486) | class ResultValueBase : public ResultBase {
method value (line 6488) | auto value() const -> T const & {
method ResultValueBase (line 6494) | ResultValueBase( Type type ) : ResultBase( type ) {}
method ResultValueBase (line 6496) | ResultValueBase( ResultValueBase const &other ) : ResultBase( ot...
method ResultValueBase (line 6501) | ResultValueBase( Type, T const &value ) : ResultBase( Ok ) {
class ResultValueBase<void> (line 6525) | class ResultValueBase<void> : public ResultBase {
class BasicResult (line 6531) | class BasicResult : public ResultValueBase<T> {
method BasicResult (line 6534) | explicit BasicResult( BasicResult<U> const &other )
method ok (line 6542) | static auto ok( U const &value ) -> BasicResult { return { Resul...
method ok (line 6543) | static auto ok() -> BasicResult { return { ResultBase::Ok }; }
method logicError (line 6544) | static auto logicError( std::string const &message ) -> BasicRes...
method runtimeError (line 6545) | static auto runtimeError( std::string const &message ) -> BasicR...
method type (line 6548) | auto type() const -> ResultBase::Type { return m_type; }
method errorMessage (line 6549) | auto errorMessage() const -> std::string { return m_errorMessage; }
method enforceOk (line 6552) | void enforceOk() const override {
method BasicResult (line 6564) | BasicResult( ResultBase::Type type, std::string const &message )
type ParseResultType (line 6575) | enum class ParseResultType {
class ParseState (line 6579) | class ParseState {
method ParseState (line 6582) | ParseState( ParseResultType type, TokenStream const &remainingTo...
method type (line 6587) | auto type() const -> ParseResultType { return m_type; }
method remainingTokens (line 6588) | auto remainingTokens() const -> TokenStream { return m_remaining...
type HelpColumns (line 6599) | struct HelpColumns {
function convertInto (line 6605) | inline auto convertInto( std::string const &source, T& target ) ->...
function convertInto (line 6614) | inline auto convertInto( std::string const &source, std::string& t...
function convertInto (line 6618) | inline auto convertInto( std::string const &source, bool &target )...
function convertInto (line 6631) | inline auto convertInto( std::string const &source, CLARA_CONFIG_O...
type NonCopyable (line 6640) | struct NonCopyable {
method NonCopyable (line 6641) | NonCopyable() = default;
method NonCopyable (line 6642) | NonCopyable( NonCopyable const & ) = delete;
method NonCopyable (line 6643) | NonCopyable( NonCopyable && ) = delete;
method NonCopyable (line 6644) | NonCopyable &operator=( NonCopyable const & ) = delete;
method NonCopyable (line 6645) | NonCopyable &operator=( NonCopyable && ) = delete;
type BoundRef (line 6648) | struct BoundRef : NonCopyable {
method isContainer (line 6650) | virtual auto isContainer() const -> bool { return false; }
method isFlag (line 6651) | virtual auto isFlag() const -> bool { return false; }
type BoundValueRefBase (line 6653) | struct BoundValueRefBase : BoundRef {
type BoundFlagRefBase (line 6656) | struct BoundFlagRefBase : BoundRef {
method isFlag (line 6658) | virtual auto isFlag() const -> bool { return true; }
type BoundValueRef (line 6662) | struct BoundValueRef : BoundValueRefBase {
method BoundValueRef (line 6665) | explicit BoundValueRef( T &ref ) : m_ref( ref ) {}
method setValue (line 6667) | auto setValue( std::string const &arg ) -> ParserResult override {
type BoundValueRef<std::vector<T>> (line 6673) | struct BoundValueRef<std::vector<T>> : BoundValueRefBase {
method BoundValueRef (line 6676) | explicit BoundValueRef( std::vector<T> &ref ) : m_ref( ref ) {}
method isContainer (line 6678) | auto isContainer() const -> bool override { return true; }
method setValue (line 6680) | auto setValue( std::string const &arg ) -> ParserResult override {
type BoundFlagRef (line 6689) | struct BoundFlagRef : BoundFlagRefBase {
method BoundFlagRef (line 6692) | explicit BoundFlagRef( bool &ref ) : m_ref( ref ) {}
method setFlag (line 6694) | auto setFlag( bool flag ) -> ParserResult override {
type LambdaInvoker (line 6701) | struct LambdaInvoker {
method invoke (line 6705) | static auto invoke( L const &lambda, ArgType const &arg ) -> Par...
type LambdaInvoker<void> (line 6711) | struct LambdaInvoker<void> {
method invoke (line 6713) | static auto invoke( L const &lambda, ArgType const &arg ) -> Par...
function invokeLambda (line 6720) | inline auto invokeLambda( L const &lambda, std::string const &arg ...
type BoundLambda (line 6729) | struct BoundLambda : BoundValueRefBase {
method BoundLambda (line 6733) | explicit BoundLambda( L const &lambda ) : m_lambda( lambda ) {}
method setValue (line 6735) | auto setValue( std::string const &arg ) -> ParserResult override {
type BoundFlagLambda (line 6741) | struct BoundFlagLambda : BoundFlagRefBase {
method BoundFlagLambda (line 6747) | explicit BoundFlagLambda( L const &lambda ) : m_lambda( lambda ) {}
method setFlag (line 6749) | auto setFlag( bool flag ) -> ParserResult override {
type Optionality (line 6754) | enum class Optionality { Optional, Required }
type Parser (line 6756) | struct Parser
method getHelpColumns (line 7062) | auto getHelpColumns() const -> std::vector<HelpColumns> {
method writeToStream (line 7071) | void writeToStream( std::ostream &os ) const {
method validate (line 7117) | auto validate() const -> Result override {
method parse (line 7133) | auto parse( std::string const& exeName, TokenStream const &token...
class ParserBase (line 6758) | class ParserBase {
method validate (line 6761) | virtual auto validate() const -> Result { return Result::ok(); }
method cardinality (line 6763) | virtual auto cardinality() const -> size_t { return 1; }
method parse (line 6765) | auto parse( Args const &args ) const -> InternalParseResult {
class ComposableParserImpl (line 6771) | class ComposableParserImpl : public ParserBase {
class ParserRefImpl (line 6782) | class ParserRefImpl : public ComposableParserImpl<DerivedT> {
method ParserRefImpl (line 6789) | explicit ParserRefImpl( std::shared_ptr<BoundRef> const &ref ) :...
method ParserRefImpl (line 6793) | ParserRefImpl( T &ref, std::string const &hint )
method ParserRefImpl (line 6799) | ParserRefImpl( LambdaT const &ref, std::string const &hint )
method optional (line 6809) | auto optional() -> DerivedT & {
method required (line 6814) | auto required() -> DerivedT & {
method isOptional (line 6819) | auto isOptional() const -> bool {
method cardinality (line 6823) | auto cardinality() const -> size_t override {
method hint (line 6830) | auto hint() const -> std::string { return m_hint; }
class ExeName (line 6833) | class ExeName : public ComposableParserImpl<ExeName> {
method makeRef (line 6838) | static auto makeRef(LambdaT const &lambda) -> std::shared_ptr<Bo...
method ExeName (line 6843) | ExeName() : m_name( std::make_shared<std::string>( "<executable>...
method ExeName (line 6845) | explicit ExeName( std::string &ref ) : ExeName() {
method ExeName (line 6850) | explicit ExeName( LambdaT const& lambda ) : ExeName() {
method parse (line 6855) | auto parse( std::string const&, TokenStream const &tokens ) cons...
method name (line 6859) | auto name() const -> std::string { return *m_name; }
method set (line 6860) | auto set( std::string const& newName ) -> ParserResult {
class Arg (line 6875) | class Arg : public ParserRefImpl<Arg> {
method parse (line 6879) | auto parse( std::string const &, TokenStream const &tokens ) con...
function normaliseOpt (line 6900) | inline auto normaliseOpt( std::string const &optName ) -> std::str...
class Opt (line 6909) | class Opt : public ParserRefImpl<Opt> {
method Opt (line 6915) | explicit Opt( LambdaT const &ref ) : ParserRefImpl( std::make_sh...
method Opt (line 6917) | explicit Opt( bool &ref ) : ParserRefImpl( std::make_shared<Boun...
method Opt (line 6920) | Opt( LambdaT const &ref, std::string const &hint ) : ParserRefIm...
method Opt (line 6923) | Opt( T &ref, std::string const &hint ) : ParserRefImpl( ref, hin...
method getHelpColumns (line 6930) | auto getHelpColumns() const -> std::vector<HelpColumns> {
method isMatch (line 6945) | auto isMatch( std::string const &optToken ) const -> bool {
method parse (line 6956) | auto parse( std::string const&, TokenStream const &tokens ) cons...
method validate (line 6992) | auto validate() const -> Result override {
type Help (line 7010) | struct Help : Opt {
method Help (line 7011) | Help( bool &showHelpFlag )
type Parser (line 7024) | struct Parser : ParserBase {
method getHelpColumns (line 7062) | auto getHelpColumns() const -> std::vector<HelpColumns> {
method writeToStream (line 7071) | void writeToStream( std::ostream &os ) const {
method validate (line 7117) | auto validate() const -> Result override {
method parse (line 7133) | auto parse( std::string const& exeName, TokenStream const &token...
type clara (line 6337) | namespace clara {
type TextFlow (line 6013) | namespace TextFlow {
function isWhitespace (line 6015) | inline auto isWhitespace(char c) -> bool {
function isBreakableBefore (line 6019) | inline auto isBreakableBefore(char c) -> bool {
function isBreakableAfter (line 6023) | inline auto isBreakableAfter(char c) -> bool {
class Columns (line 6028) | class Columns
class iterator (line 6209) | class iterator {
type EndTag (line 6211) | struct EndTag {}
method iterator (line 6217) | iterator(Columns const& columns, EndTag)
method iterator (line 6233) | explicit iterator(Columns const& columns)
method begin (line 6281) | auto begin() const -> iterator { return iterator(*this); }
method end (line 6282) | auto end() const -> iterator { return { *this, iterator::EndTag(...
method friend (line 6294) | inline friend std::ostream& operator << (std::ostream& os, Colum...
method toString (line 6307) | auto toString() const -> std::string {
class Column (line 6030) | class Column {
class iterator (line 6037) | class iterator {
method iterator (line 6048) | iterator(Column const& column, size_t stringIndex)
method line (line 6052) | auto line() const -> std::string const& { return m_column.m_st...
method isBoundary (line 6054) | auto isBoundary(size_t at) const -> bool {
method calcLength (line 6064) | void calcLength() {
method indent (line 6091) | auto indent() const -> size_t {
method addIndentAndSuffix (line 6096) | auto addIndentAndSuffix(std::string const &plain) const -> std...
method iterator (line 6107) | explicit iterator(Column const& column) : m_column(column) {
method Column (line 6155) | explicit Column(std::string const& text) { m_strings.push_back(t...
method width (line 6157) | auto width(size_t newWidth) -> Column& {
method indent (line 6162) | auto indent(size_t newIndent) -> Column& {
method initialIndent (line 6166) | auto initialIndent(size_t newIndent) -> Column& {
method width (line 6171) | auto width() const -> size_t { return m_width; }
method begin (line 6172) | auto begin() const -> iterator { return iterator(*this); }
method end (line 6173) | auto end() const -> iterator { return { *this, m_strings.size() ...
method friend (line 6175) | inline friend std::ostream& operator << (std::ostream& os, Colum...
method toString (line 6189) | auto toString() const -> std::string {
class Spacer (line 6196) | class Spacer : public Column {
method Spacer (line 6199) | explicit Spacer(size_t spaceWidth) : Column("") {
class Columns (line 6204) | class Columns {
class iterator (line 6209) | class iterator {
type EndTag (line 6211) | struct EndTag {}
method iterator (line 6217) | iterator(Columns const& columns, EndTag)
method iterator (line 6233) | explicit iterator(Columns const& columns)
method begin (line 6281) | auto begin() const -> iterator { return iterator(*this); }
method end (line 6282) | auto end() const -> iterator { return { *this, iterator::EndTag(...
method friend (line 6294) | inline friend std::ostream& operator << (std::ostream& os, Colum...
method toString (line 6307) | auto toString() const -> std::string {
type detail (line 6338) | namespace detail {
type UnaryLambdaTraits (line 6342) | struct UnaryLambdaTraits : UnaryLambdaTraits<decltype( &L::operato...
type UnaryLambdaTraits<ReturnT( ClassT::* )( ArgT ) const> (line 6350) | struct UnaryLambdaTraits<ReturnT( ClassT::* )( ArgT ) const> {
class TokenStream (line 6356) | class TokenStream
method loadBuffer (line 6404) | void loadBuffer() {
method TokenStream (line 6436) | explicit TokenStream( Args const &args ) : TokenStream( args.m_a...
method TokenStream (line 6438) | TokenStream( Iterator it, Iterator itEnd ) : it( it ), itEnd( it...
method count (line 6446) | auto count() const -> size_t { return m_tokenBuffer.size() + (it...
class Args (line 6359) | class Args {
method Args (line 6365) | Args( int argc, char const* const* argv )
method Args (line 6369) | Args( std::initializer_list<std::string> args )
method exeName (line 6374) | auto exeName() const -> std::string {
type TokenType (line 6381) | enum class TokenType {
type Token (line 6384) | struct Token {
function isOptPrefix (line 6389) | inline auto isOptPrefix( char c ) -> bool {
class TokenStream (line 6398) | class TokenStream {
method loadBuffer (line 6404) | void loadBuffer() {
method TokenStream (line 6436) | explicit TokenStream( Args const &args ) : TokenStream( args.m_a...
method TokenStream (line 6438) | TokenStream( Iterator it, Iterator itEnd ) : it( it ), itEnd( it...
method count (line 6446) | auto count() const -> size_t { return m_tokenBuffer.size() + (it...
class ResultBase (line 6470) | class ResultBase {
type Type (line 6472) | enum Type {
method ResultBase (line 6477) | ResultBase( Type type ) : m_type( type ) {}
class ResultValueBase (line 6486) | class ResultValueBase : public ResultBase {
method value (line 6488) | auto value() const -> T const & {
method ResultValueBase (line 6494) | ResultValueBase( Type type ) : ResultBase( type ) {}
method ResultValueBase (line 6496) | ResultValueBase( ResultValueBase const &other ) : ResultBase( ot...
method ResultValueBase (line 6501) | ResultValueBase( Type, T const &value ) : ResultBase( Ok ) {
class ResultValueBase<void> (line 6525) | class ResultValueBase<void> : public ResultBase {
class BasicResult (line 6531) | class BasicResult : public ResultValueBase<T> {
method BasicResult (line 6534) | explicit BasicResult( BasicResult<U> const &other )
method ok (line 6542) | static auto ok( U const &value ) -> BasicResult { return { Resul...
method ok (line 6543) | static auto ok() -> BasicResult { return { ResultBase::Ok }; }
method logicError (line 6544) | static auto logicError( std::string const &message ) -> BasicRes...
method runtimeError (line 6545) | static auto runtimeError( std::string const &message ) -> BasicR...
method type (line 6548) | auto type() const -> ResultBase::Type { return m_type; }
method errorMessage (line 6549) | auto errorMessage() const -> std::string { return m_errorMessage; }
method enforceOk (line 6552) | void enforceOk() const override {
method BasicResult (line 6564) | BasicResult( ResultBase::Type type, std::string const &message )
type ParseResultType (line 6575) | enum class ParseResultType {
class ParseState (line 6579) | class ParseState {
method ParseState (line 6582) | ParseState( ParseResultType type, TokenStream const &remainingTo...
method type (line 6587) | auto type() const -> ParseResultType { return m_type; }
method remainingTokens (line 6588) | auto remainingTokens() const -> TokenStream { return m_remaining...
type HelpColumns (line 6599) | struct HelpColumns {
function convertInto (line 6605) | inline auto convertInto( std::string const &source, T& target ) ->...
function convertInto (line 6614) | inline auto convertInto( std::string const &source, std::string& t...
function convertInto (line 6618) | inline auto convertInto( std::string const &source, bool &target )...
function convertInto (line 6631) | inline auto convertInto( std::string const &source, CLARA_CONFIG_O...
type NonCopyable (line 6640) | struct NonCopyable {
method NonCopyable (line 6641) | NonCopyable() = default;
method NonCopyable (line 6642) | NonCopyable( NonCopyable const & ) = delete;
method NonCopyable (line 6643) | NonCopyable( NonCopyable && ) = delete;
method NonCopyable (line 6644) | NonCopyable &operator=( NonCopyable const & ) = delete;
method NonCopyable (line 6645) | NonCopyable &operator=( NonCopyable && ) = delete;
type BoundRef (line 6648) | struct BoundRef : NonCopyable {
method isContainer (line 6650) | virtual auto isContainer() const -> bool { return false; }
method isFlag (line 6651) | virtual auto isFlag() const -> bool { return false; }
type BoundValueRefBase (line 6653) | struct BoundValueRefBase : BoundRef {
type BoundFlagRefBase (line 6656) | struct BoundFlagRefBase : BoundRef {
method isFlag (line 6658) | virtual auto isFlag() const -> bool { return true; }
type BoundValueRef (line 6662) | struct BoundValueRef : BoundValueRefBase {
method BoundValueRef (line 6665) | explicit BoundValueRef( T &ref ) : m_ref( ref ) {}
method setValue (line 6667) | auto setValue( std::string const &arg ) -> ParserResult override {
type BoundValueRef<std::vector<T>> (line 6673) | struct BoundValueRef<std::vector<T>> : BoundValueRefBase {
method BoundValueRef (line 6676) | explicit BoundValueRef( std::vector<T> &ref ) : m_ref( ref ) {}
method isContainer (line 6678) | auto isContainer() const -> bool override { return true; }
method setValue (line 6680) | auto setValue( std::string const &arg ) -> ParserResult override {
type BoundFlagRef (line 6689) | struct BoundFlagRef : BoundFlagRefBase {
method BoundFlagRef (line 6692) | explicit BoundFlagRef( bool &ref ) : m_ref( ref ) {}
method setFlag (line 6694) | auto setFlag( bool flag ) -> ParserResult override {
type LambdaInvoker (line 6701) | struct LambdaInvoker {
method invoke (line 6705) | static auto invoke( L const &lambda, ArgType const &arg ) -> Par...
type LambdaInvoker<void> (line 6711) | struct LambdaInvoker<void> {
method invoke (line 6713) | static auto invoke( L const &lambda, ArgType const &arg ) -> Par...
function invokeLambda (line 6720) | inline auto invokeLambda( L const &lambda, std::string const &arg ...
type BoundLambda (line 6729) | struct BoundLambda : BoundValueRefBase {
method BoundLambda (line 6733) | explicit BoundLambda( L const &lambda ) : m_lambda( lambda ) {}
method setValue (line 6735) | auto setValue( std::string const &arg ) -> ParserResult override {
type BoundFlagLambda (line 6741) | struct BoundFlagLambda : BoundFlagRefBase {
method BoundFlagLambda (line 6747) | explicit BoundFlagLambda( L const &lambda ) : m_lambda( lambda ) {}
method setFlag (line 6749) | auto setFlag( bool flag ) -> ParserResult override {
type Optionality (line 6754) | enum class Optionality { Optional, Required }
type Parser (line 6756) | struct Parser
method getHelpColumns (line 7062) | auto getHelpColumns() const -> std::vector<HelpColumns> {
method writeToStream (line 7071) | void writeToStream( std::ostream &os ) const {
method validate (line 7117) | auto validate() const -> Result override {
method parse (line 7133) | auto parse( std::string const& exeName, TokenStream const &token...
class ParserBase (line 6758) | class ParserBase {
method validate (line 6761) | virtual auto validate() const -> Result { return Result::ok(); }
method cardinality (line 6763) | virtual auto cardinality() const -> size_t { return 1; }
method parse (line 6765) | auto parse( Args const &args ) const -> InternalParseResult {
class ComposableParserImpl (line 6771) | class ComposableParserImpl : public ParserBase {
class ParserRefImpl (line 6782) | class ParserRefImpl : public ComposableParserImpl<DerivedT> {
method ParserRefImpl (line 6789) | explicit ParserRefImpl( std::shared_ptr<BoundRef> const &ref ) :...
method ParserRefImpl (line 6793) | ParserRefImpl( T &ref, std::string const &hint )
method ParserRefImpl (line 6799) | ParserRefImpl( LambdaT const &ref, std::string const &hint )
method optional (line 6809) | auto optional() -> DerivedT & {
method required (line 6814) | auto required() -> DerivedT & {
method isOptional (line 6819) | auto isOptional() const -> bool {
method cardinality (line 6823) | auto cardinality() const -> size_t override {
method hint (line 6830) | auto hint() const -> std::string { return m_hint; }
class ExeName (line 6833) | class ExeName : public ComposableParserImpl<ExeName> {
method makeRef (line 6838) | static auto makeRef(LambdaT const &lambda) -> std::shared_ptr<Bo...
method ExeName (line 6843) | ExeName() : m_name( std::make_shared<std::string>( "<executable>...
method ExeName (line 6845) | explicit ExeName( std::string &ref ) : ExeName() {
method ExeName (line 6850) | explicit ExeName( LambdaT const& lambda ) : ExeName() {
method parse (line 6855) | auto parse( std::string const&, TokenStream const &tokens ) cons...
method name (line 6859) | auto name() const -> std::string { return *m_name; }
method set (line 6860) | auto set( std::string const& newName ) -> ParserResult {
class Arg (line 6875) | class Arg : public ParserRefImpl<Arg> {
method parse (line 6879) | auto parse( std::string const &, TokenStream const &tokens ) con...
function normaliseOpt (line 6900) | inline auto normaliseOpt( std::string const &optName ) -> std::str...
class Opt (line 6909) | class Opt : public ParserRefImpl<Opt> {
method Opt (line 6915) | explicit Opt( LambdaT const &ref ) : ParserRefImpl( std::make_sh...
method Opt (line 6917) | explicit Opt( bool &ref ) : ParserRefImpl( std::make_shared<Boun...
method Opt (line 6920) | Opt( LambdaT const &ref, std::string const &hint ) : ParserRefIm...
method Opt (line 6923) | Opt( T &ref, std::string const &hint ) : ParserRefImpl( ref, hin...
method getHelpColumns (line 6930) | auto getHelpColumns() const -> std::vector<HelpColumns> {
method isMatch (line 6945) | auto isMatch( std::string const &optToken ) const -> bool {
method parse (line 6956) | auto parse( std::string const&, TokenStream const &tokens ) cons...
method validate (line 6992) | auto validate() const -> Result override {
type Help (line 7010) | struct Help : Opt {
method Help (line 7011) | Help( bool &showHelpFlag )
type Parser (line 7024) | struct Parser : ParserBase {
method getHelpColumns (line 7062) | auto getHelpColumns() const -> std::vector<HelpColumns> {
method writeToStream (line 7071) | void writeToStream( std::ostream &os ) const {
method validate (line 7117) | auto validate() const -> Result override {
method parse (line 7133) | auto parse( std::string const& exeName, TokenStream const &token...
function makeCommandLineParser (line 7237) | clara::Parser makeCommandLineParser( ConfigData& config ) {
function TestSpec (line 7499) | TestSpec const& Config::testSpec() const { return m_testSpec; }
type Pattern (line 3821) | struct Pattern {
class NamePattern (line 3827) | class NamePattern : public Pattern {
class TagPattern (line 3836) | class TagPattern : public Pattern {
class ExcludedPattern (line 3845) | class ExcludedPattern : public Pattern {
type Filter (line 3854) | struct Filter {
function Verbosity (line 7519) | Verbosity Config::verbosity() const { return m_data.ver...
function IStream (line 7521) | IStream const* Config::openStream() {
class ErrnoGuard (line 7538) | class ErrnoGuard {
type IColourImpl (line 7554) | struct IColourImpl {
type NoColourImpl (line 7559) | struct NoColourImpl : IColourImpl {
method use (line 7560) | void use( Colour::Code ) {}
method IColourImpl (line 7562) | static IColourImpl* instance() {
class Win32ColourImpl (line 7584) | class Win32ColourImpl : public IColourImpl {
method Win32ColourImpl (line 7586) | Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) )
method use (line 7594) | virtual void use( Colour::Code _colourCode ) override {
method setTextAttribute (line 7619) | void setTextAttribute( WORD _textAttribute ) {
function IColourImpl (line 7627) | IColourImpl* platformColourInstance() {
class PosixColourImpl (line 7655) | class PosixColourImpl : public IColourImpl {
method use (line 7657) | virtual void use( Colour::Code _colourCode ) override {
method IColourImpl (line 7678) | static IColourImpl* instance() {
method setColour (line 7684) | void setColour( const char* _escapeCode ) {
function useColourOnPlatform (line 7689) | bool useColourOnPlatform() {
function IColourImpl (line 7701) | IColourImpl* platformColourInstance() {
function IColourImpl (line 7723) | static IColourImpl* platformColourInstance() { return NoColourImpl::in...
function Colour (line 7736) | Colour& Colour::operator=( Colour&& rhs ) noexcept {
type Code (line 4721) | enum Code {
class Context (line 7764) | class Context : public IMutableContext, NonCopyable {
method IResultCapture (line 7767) | virtual IResultCapture* getResultCapture() override {
method IRunner (line 7770) | virtual IRunner* getRunner() override {
method IConfigPtr (line 7774) | virtual IConfigPtr const& getConfig() const override {
method setResultCapture (line 7781) | virtual void setResultCapture( IResultCapture* resultCapture ) overr...
method setRunner (line 7784) | virtual void setRunner( IRunner* runner ) override {
method setConfig (line 7787) | virtual void setConfig( IConfigPtr const& config ) override {
function cleanUpContext (line 7806) | void cleanUpContext() {
function writeToDebugConsole (line 7829) | void writeToDebugConsole( std::string const& text ) {
function writeToDebugConsole (line 7837) | void writeToDebugConsole( std::string const& text ) {
function isDebuggerActive (line 7864) | bool isDebuggerActive(){
function isDebuggerActive (line 7909) | bool isDebuggerActive(){
function isDebuggerActive (line 7930) | bool isDebuggerActive() {
function isDebuggerActive (line 7937) | bool isDebuggerActive() {
function isDebuggerActive (line 7943) | bool isDebuggerActive() { return false; }
function formatReconstructedExpression (line 7953) | void formatReconstructedExpression( std::ostream &os, std::string cons...
function throw_exception (line 7967) | [[noreturn]]
class ExceptionTranslatorRegistry (line 7995) | class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {
type SignalDefs (line 8099) | struct SignalDefs { DWORD id; const char* name; }
function LONG (line 8111) | LONG CALLBACK FatalConditionHandler::handleVectoredException(PEXCEPTIO...
type SignalDefs (line 8157) | struct SignalDefs {
type sigaction (line 8195) | struct sigaction
type sigaction (line 8221) | struct sigaction
type IConfig (line 8248) | struct IConfig
type Generators (line 8264) | namespace Generators {
class GeneratorBase (line 3178) | class GeneratorBase {
method GeneratorBase (line 3183) | GeneratorBase( size_t size ) : m_size( size ) {}
method size (line 3185) | auto size() const -> size_t { return m_size; }
type pf (line 3241) | namespace pf{
function make_unique (line 3243) | std::unique_ptr<T> make_unique( Args&&... args ) {
type IGenerator (line 3249) | struct IGenerator {
class SingleValueGenerator (line 3255) | class SingleValueGenerator : public IGenerator<T> {
method SingleValueGenerator (line 3258) | SingleValueGenerator( T const& value ) : m_value( value ) {}
method get (line 3260) | auto get( size_t ) const -> T override {
class FixedValuesGenerator (line 3266) | class FixedValuesGenerator : public IGenerator<T> {
method FixedValuesGenerator (line 3270) | FixedValuesGenerator( std::initializer_list<T> values ) : m_values...
method get (line 3272) | auto get( size_t index ) const -> T override {
class RangeGenerator (line 3278) | class RangeGenerator : public IGenerator<T> {
method RangeGenerator (line 3283) | RangeGenerator( T const& first, T const& last ) : m_first( first )...
method get (line 3287) | auto get( size_t index ) const -> T override {
type NullGenerator (line 3294) | struct NullGenerator : IGenerator<T> {
method get (line 3295) | auto get( size_t ) const -> T override {
class Generator (line 3301) | class Generator {
method Generator (line 3306) | Generator( size_t size, std::unique_ptr<IGenerator<T>> generator )
method size (line 3311) | auto size() const -> size_t { return m_size; }
class GeneratorRandomiser (line 3321) | class GeneratorRandomiser : public IGenerator<T> {
method GeneratorRandomiser (line 3326) | GeneratorRandomiser( Generator<T>&& baseGenerator, size_t numberOf...
method get (line 3331) | auto get( size_t index ) const -> T override {
type RequiresASpecialisationFor (line 3337) | struct RequiresASpecialisationFor
function all (line 3340) | auto all() -> Generator<T> { return RequiresASpecialisationFor<T>(); }
function range (line 3346) | auto range( T const& first, T const& last ) -> Generator<T> {
function random (line 3351) | auto random( T const& first, T const& last ) -> Generator<T> {
function random (line 3358) | auto random( size_t size ) -> Generator<T> {
function values (line 3363) | auto values( std::initializer_list<T> values ) -> Generator<T> {
function value (line 3367) | auto value( T const& val ) -> Generator<T> {
function as (line 3372) | auto as() -> Generator<T> {
function table (line 3377) | auto table( std::initializer_list<std::tuple<Ts...>>&& tuples ) -> G...
type Generators (line 3382) | struct Generators : GeneratorBase {
method Generators (line 3387) | Generators() : GeneratorBase( 0 ) {}
method populate (line 3389) | void populate( T&& val ) {
method populate (line 3394) | void populate( U&& val ) {
method populate (line 3397) | void populate( Generator<T>&& generator ) {
method populate (line 3403) | void populate( U&& valueOrGenerator, Gs... moreGenerators ) {
function makeGenerators (line 3421) | auto makeGenerators( Generator<T>&& generator, Gs... moreGenerators ...
function makeGenerators (line 3428) | auto makeGenerators( Generator<T>&& generator ) -> Generators<T> {
function makeGenerators (line 3434) | auto makeGenerators( T&& val, Gs... moreGenerators ) -> Generators<T> {
function makeGenerators (line 3438) | auto makeGenerators( U&& val, Gs... moreGenerators ) -> Generators<T> {
function generate (line 3448) | auto generate( SourceLineInfo const& lineInfo, L const& generatorExp...
function randomiseIndices (line 8268) | std::vector<size_t> randomiseIndices( size_t selectionSize, size_t s...
function acquireGeneratorTracker (line 8285) | auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IG...
type GeneratorTracker (line 9673) | struct GeneratorTracker : TestCaseTracking::TrackerBase, IGeneratorT...
method GeneratorTracker (line 9677) | GeneratorTracker( TestCaseTracking::NameAndLocation const& nameAnd...
method GeneratorTracker (line 9682) | static GeneratorTracker& acquire( TrackerContext& ctx, TestCaseTra...
method moveNext (line 9705) | void moveNext() {
method isIndexTracker (line 9711) | bool isIndexTracker() const override { return true; }
method hasGenerator (line 9712) | auto hasGenerator() const -> bool override {
method close (line 9715) | void close() override {
method getGenerator (line 9722) | auto getGenerator() const -> GeneratorBasePtr const& override {
method setGenerator (line 9725) | void setGenerator( GeneratorBasePtr&& generator ) override {
method getIndex (line 9728) | auto getIndex() const -> size_t override {
class ListeningReporter (line 8329) | class ListeningReporter : public IStreamingReporter {
function IConfigPtr (line 8382) | IConfigPtr ReporterConfig::fullConfig() const { return m_fullConfig; }
type TagInfo (line 8529) | struct TagInfo {
function listTests (line 8559) | std::size_t listTests( Config const& config ) {
function listTestsNamesOnly (line 8593) | std::size_t listTestsNamesOnly( Config const& config ) {
function listTags (line 8622) | std::size_t listTags( Config const& config ) {
function listReporters (line 8657) | std::size_t listReporters() {
function list (line 8679) | Option<std::size_t> list( Config const& config ) {
type Matchers (line 8697) | namespace Matchers {
type Impl (line 2622) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 2775) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Generic (line 2817) | namespace Generic {
type Detail (line 2819) | namespace Detail {
class PredicateMatcher (line 2824) | class PredicateMatcher : public MatcherBase<T> {
method PredicateMatcher (line 2829) | PredicateMatcher(std::function<bool(T const&)> const& elem, std:...
method match (line 2834) | bool match( T const& item ) const override {
method describe (line 2838) | std::string describe() const override {
function Predicate (line 2850) | Generic::PredicateMatcher<T> Predicate(std::function<bool(T const&)>...
type StdString (line 2865) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
type Vector (line 2934) | namespace Vector {
type Detail (line 2935) | namespace Detail {
function count (line 2937) | size_t count(InputIterator first, InputIterator last, T const& i...
function contains (line 2947) | bool contains(InputIterator first, InputIterator last, T const& ...
type ContainsElementMatcher (line 2958) | struct ContainsElementMatcher : MatcherBase<std::vector<T>> {
method ContainsElementMatcher (line 2960) | ContainsElementMatcher(T const &comparator) : m_comparator( comp...
method match (line 2962) | bool match(std::vector<T> const &v) const override {
method describe (line 2971) | std::string describe() const override {
type ContainsMatcher (line 2979) | struct ContainsMatcher : MatcherBase<std::vector<T>> {
method ContainsMatcher (line 2981) | ContainsMatcher(std::vector<T> const &comparator) : m_comparator...
method match (line 2983) | bool match(std::vector<T> const &v) const override {
method describe (line 3001) | std::string describe() const override {
type EqualsMatcher (line 3009) | struct EqualsMatcher : MatcherBase<std::vector<T>> {
method EqualsMatcher (line 3011) | EqualsMatcher(std::vector<T> const &comparator) : m_comparator( ...
method match (line 3013) | bool match(std::vector<T> const &v) const override {
method describe (line 3025) | std::string describe() const override {
type UnorderedEqualsMatcher (line 3032) | struct UnorderedEqualsMatcher : MatcherBase<std::vector<T>> {
method UnorderedEqualsMatcher (line 3033) | UnorderedEqualsMatcher(std::vector<T> const& target) : m_target(...
method match (line 3034) | bool match(std::vector<T> const& vec) const override {
method describe (line 3064) | std::string describe() const override {
function Contains (line 3077) | Vector::ContainsMatcher<T> Contains( std::vector<T> const& comparato...
function VectorContains (line 3082) | Vector::ContainsElementMatcher<T> VectorContains( T const& comparato...
function Equals (line 3087) | Vector::EqualsMatcher<T> Equals( std::vector<T> const& comparator ) {
function UnorderedEquals (line 3092) | Vector::UnorderedEqualsMatcher<T> UnorderedEquals(std::vector<T> con...
type Impl (line 8698) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 8750) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Floating (line 8811) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
function WithinULP (line 8861) | Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff) {
function WithinULP (line 8865) | Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff) {
function WithinAbs (line 8869) | Floating::WithinAbsMatcher WithinAbs(double target, double margin) {
type StdString (line 8894) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
function Equals (line 8969) | StdString::EqualsMatcher Equals( std::string const& str, CaseSensiti...
function Contains (line 8972) | StdString::ContainsMatcher Contains( std::string const& str, CaseSen...
function EndsWith (line 8975) | StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSen...
function StartsWith (line 8978) | StdString::StartsWithMatcher StartsWith( std::string const& str, Cas...
function Matches (line 8982) | StdString::RegexMatcher Matches(std::string const& regex, CaseSensit...
function to_string (line 8732) | std::string to_string(T const& t) {
type Matchers (line 8749) | namespace Matchers {
type Impl (line 2622) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 2775) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Generic (line 2817) | namespace Generic {
type Detail (line 2819) | namespace Detail {
class PredicateMatcher (line 2824) | class PredicateMatcher : public MatcherBase<T> {
method PredicateMatcher (line 2829) | PredicateMatcher(std::function<bool(T const&)> const& elem, std:...
method match (line 2834) | bool match( T const& item ) const override {
method describe (line 2838) | std::string describe() const override {
function Predicate (line 2850) | Generic::PredicateMatcher<T> Predicate(std::function<bool(T const&)>...
type StdString (line 2865) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
type Vector (line 2934) | namespace Vector {
type Detail (line 2935) | namespace Detail {
function count (line 2937) | size_t count(InputIterator first, InputIterator last, T const& i...
function contains (line 2947) | bool contains(InputIterator first, InputIterator last, T const& ...
type ContainsElementMatcher (line 2958) | struct ContainsElementMatcher : MatcherBase<std::vector<T>> {
method ContainsElementMatcher (line 2960) | ContainsElementMatcher(T const &comparator) : m_comparator( comp...
method match (line 2962) | bool match(std::vector<T> const &v) const override {
method describe (line 2971) | std::string describe() const override {
type ContainsMatcher (line 2979) | struct ContainsMatcher : MatcherBase<std::vector<T>> {
method ContainsMatcher (line 2981) | ContainsMatcher(std::vector<T> const &comparator) : m_comparator...
method match (line 2983) | bool match(std::vector<T> const &v) const override {
method describe (line 3001) | std::string describe() const override {
type EqualsMatcher (line 3009) | struct EqualsMatcher : MatcherBase<std::vector<T>> {
method EqualsMatcher (line 3011) | EqualsMatcher(std::vector<T> const &comparator) : m_comparator( ...
method match (line 3013) | bool match(std::vector<T> const &v) const override {
method describe (line 3025) | std::string describe() const override {
type UnorderedEqualsMatcher (line 3032) | struct UnorderedEqualsMatcher : MatcherBase<std::vector<T>> {
method UnorderedEqualsMatcher (line 3033) | UnorderedEqualsMatcher(std::vector<T> const& target) : m_target(...
method match (line 3034) | bool match(std::vector<T> const& vec) const override {
method describe (line 3064) | std::string describe() const override {
function Contains (line 3077) | Vector::ContainsMatcher<T> Contains( std::vector<T> const& comparato...
function VectorContains (line 3082) | Vector::ContainsElementMatcher<T> VectorContains( T const& comparato...
function Equals (line 3087) | Vector::EqualsMatcher<T> Equals( std::vector<T> const& comparator ) {
function UnorderedEquals (line 3092) | Vector::UnorderedEqualsMatcher<T> UnorderedEquals(std::vector<T> con...
type Impl (line 8698) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 8750) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Floating (line 8811) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
function WithinULP (line 8861) | Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff) {
function WithinULP (line 8865) | Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff) {
function WithinAbs (line 8869) | Floating::WithinAbsMatcher WithinAbs(double target, double margin) {
type StdString (line 8894) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
function Equals (line 8969) | StdString::EqualsMatcher Equals( std::string const& str, CaseSensiti...
function Contains (line 8972) | StdString::ContainsMatcher Contains( std::string const& str, CaseSen...
function EndsWith (line 8975) | StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSen...
function StartsWith (line 8978) | StdString::StartsWithMatcher StartsWith( std::string const& str, Cas...
function Matches (line 8982) | StdString::RegexMatcher Matches(std::string const& regex, CaseSensit...
type Matchers (line 8810) | namespace Matchers {
type Impl (line 2622) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 2775) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Generic (line 2817) | namespace Generic {
type Detail (line 2819) | namespace Detail {
class PredicateMatcher (line 2824) | class PredicateMatcher : public MatcherBase<T> {
method PredicateMatcher (line 2829) | PredicateMatcher(std::function<bool(T const&)> const& elem, std:...
method match (line 2834) | bool match( T const& item ) const override {
method describe (line 2838) | std::string describe() const override {
function Predicate (line 2850) | Generic::PredicateMatcher<T> Predicate(std::function<bool(T const&)>...
type StdString (line 2865) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
type Vector (line 2934) | namespace Vector {
type Detail (line 2935) | namespace Detail {
function count (line 2937) | size_t count(InputIterator first, InputIterator last, T const& i...
function contains (line 2947) | bool contains(InputIterator first, InputIterator last, T const& ...
type ContainsElementMatcher (line 2958) | struct ContainsElementMatcher : MatcherBase<std::vector<T>> {
method ContainsElementMatcher (line 2960) | ContainsElementMatcher(T const &comparator) : m_comparator( comp...
method match (line 2962) | bool match(std::vector<T> const &v) const override {
method describe (line 2971) | std::string describe() const override {
type ContainsMatcher (line 2979) | struct ContainsMatcher : MatcherBase<std::vector<T>> {
method ContainsMatcher (line 2981) | ContainsMatcher(std::vector<T> const &comparator) : m_comparator...
method match (line 2983) | bool match(std::vector<T> const &v) const override {
method describe (line 3001) | std::string describe() const override {
type EqualsMatcher (line 3009) | struct EqualsMatcher : MatcherBase<std::vector<T>> {
method EqualsMatcher (line 3011) | EqualsMatcher(std::vector<T> const &comparator) : m_comparator( ...
method match (line 3013) | bool match(std::vector<T> const &v) const override {
method describe (line 3025) | std::string describe() const override {
type UnorderedEqualsMatcher (line 3032) | struct UnorderedEqualsMatcher : MatcherBase<std::vector<T>> {
method UnorderedEqualsMatcher (line 3033) | UnorderedEqualsMatcher(std::vector<T> const& target) : m_target(...
method match (line 3034) | bool match(std::vector<T> const& vec) const override {
method describe (line 3064) | std::string describe() const override {
function Contains (line 3077) | Vector::ContainsMatcher<T> Contains( std::vector<T> const& comparato...
function VectorContains (line 3082) | Vector::ContainsElementMatcher<T> VectorContains( T const& comparato...
function Equals (line 3087) | Vector::EqualsMatcher<T> Equals( std::vector<T> const& comparator ) {
function UnorderedEquals (line 3092) | Vector::UnorderedEqualsMatcher<T> UnorderedEquals(std::vector<T> con...
type Impl (line 8698) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2625) | struct MatchAnyOf
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2626) | struct MatchNotOf
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
class MatcherUntypedBase (line 2628) | class MatcherUntypedBase {
method MatcherUntypedBase (line 2630) | MatcherUntypedBase() = default;
method MatcherUntypedBase (line 2631) | MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
method MatcherUntypedBase (line 2632) | MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = d...
type MatcherMethod (line 2647) | struct MatcherMethod {
type MatcherBase (line 2656) | struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
type MatchAllOf (line 2664) | struct MatchAllOf : MatcherBase<ArgT> {
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (line 2672) | std::string describe() const override {
type MatchAnyOf (line 2696) | struct MatchAnyOf : MatcherBase<ArgT> {
method match (line 2698) | bool match( ArgT const& arg ) const override {
method describe (line 2705) | std::string describe() const override {
type MatchNotOf (line 2730) | struct MatchNotOf : MatcherBase<ArgT> {
method MatchNotOf (line 2732) | MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_und...
method match (line 2734) | bool match( ArgT const& arg ) const override {
method describe (line 2738) | std::string describe() const override {
type Floating (line 8750) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
type Floating (line 8811) | namespace Floating {
type FloatingPointKind (line 2777) | enum class FloatingPointKind : uint8_t
type WithinAbsMatcher (line 2779) | struct WithinAbsMatcher : MatcherBase<double> {
type WithinUlpsMatcher (line 2788) | struct WithinUlpsMatcher : MatcherBase<double> {
type FloatingPointKind (line 8751) | enum class FloatingPointKind : uint8_t {
function WithinULP (line 8861) | Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff) {
function WithinULP (line 8865) | Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff) {
function WithinAbs (line 8869) | Floating::WithinAbsMatcher WithinAbs(double target, double margin) {
type StdString (line 8894) | namespace StdString {
type CasedString (line 2867) | struct CasedString
type StringMatcherBase (line 2877) | struct StringMatcherBase : MatcherBase<std::string> {
type EqualsMatcher (line 2885) | struct EqualsMatcher : StringMatcherBase {
type ContainsMatcher (line 2889) | struct ContainsMatcher : StringMatcherBase {
type StartsWithMatcher (line 2893) | struct StartsWithMatcher : StringMatcherBase {
type EndsWithMatcher (line 2897) | struct EndsWithMatcher : StringMatcherBase {
type RegexMatcher (line 2902) | struct RegexMatcher : MatcherBase<std::string> {
function Equals (line 8969) | StdString::EqualsMatcher Equals( std::string const& str, CaseSensiti...
function Contains (line 8972) | StdString::ContainsMatcher Contains( std::string const& str, CaseSen...
function EndsWith (line 8975) | StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSen...
function StartsWith (line 8978) | StdString::StartsWithMatcher StartsWith( std::string const& str, Cas...
function Matches (line 8982) | StdString::RegexMatcher Matches(std::string const& regex, CaseSensit...
type Matchers (line 8892) | namespace Matchers {
type Impl (line 2622) | namespace Impl {
type MatchAllOf (line 2624) | struct MatchAllOf
method match (line 2665) | bool match( ArgT const& arg ) const override {
method describe (l
Condensed preview — 184 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (794K chars).
[
{
"path": ".gitignore",
"chars": 733,
"preview": "CMakeCache.txt\nCMakeFiles\nMakefile\ncmake_install.cmake\ninstall_manifest.txt\n\n#\n# Sublime Test\n#\n# cache files for sublim"
},
{
"path": ".travis.yml",
"chars": 502,
"preview": "language: cpp\nservices:\n - docker\nsudo: required\ncompiler:\n- gcc\nbefore_install:\n- docker pull matrim/cmake-examples:3."
},
{
"path": "01-basic/A-hello-cmake/CMakeLists.txt",
"chars": 244,
"preview": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_re"
},
{
"path": "01-basic/A-hello-cmake/README.adoc",
"chars": 7301,
"preview": "= Hello CMake\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nShows a very basic hello world example.\n\nThe files in thi"
},
{
"path": "01-basic/A-hello-cmake/main.cpp",
"chars": 115,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n std::cout << \"Hello CMake!\" << std::endl;\n return 0;\n}"
},
{
"path": "01-basic/B-hello-headers/CMakeLists.txt",
"chars": 633,
"preview": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_re"
},
{
"path": "01-basic/B-hello-headers/README.adoc",
"chars": 7677,
"preview": "= Hello Headers\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n\n# Introduction\n\nShows a hello world example which uses a different fol"
},
{
"path": "01-basic/B-hello-headers/include/Hello.h",
"chars": 92,
"preview": "#ifndef __HELLO_H__\n#define __HELLO_H__\n\nclass Hello\n{\npublic:\n void print();\n};\n\n#endif\n"
},
{
"path": "01-basic/B-hello-headers/src/Hello.cpp",
"chars": 113,
"preview": "#include <iostream>\n\n#include \"Hello.h\"\n\nvoid Hello::print()\n{\n std::cout << \"Hello Headers!\" << std::endl;\n}\n"
},
{
"path": "01-basic/B-hello-headers/src/main.cpp",
"chars": 100,
"preview": "#include \"Hello.h\"\n\nint main(int argc, char *argv[])\n{\n Hello hi;\n hi.print();\n return 0;\n}"
},
{
"path": "01-basic/C-static-library/CMakeLists.txt",
"chars": 783,
"preview": "cmake_minimum_required(VERSION 3.5)\n\nproject(hello_library)\n\n###########################################################"
},
{
"path": "01-basic/C-static-library/README.adoc",
"chars": 4461,
"preview": "= Static Library\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nShows a hello world example which first creates and li"
},
{
"path": "01-basic/C-static-library/include/static/Hello.h",
"chars": 92,
"preview": "#ifndef __HELLO_H__\n#define __HELLO_H__\n\nclass Hello\n{\npublic:\n void print();\n};\n\n#endif\n"
},
{
"path": "01-basic/C-static-library/src/Hello.cpp",
"chars": 127,
"preview": "#include <iostream>\n\n#include \"static/Hello.h\"\n\nvoid Hello::print()\n{\n std::cout << \"Hello Static Library!\" << std::e"
},
{
"path": "01-basic/C-static-library/src/main.cpp",
"chars": 108,
"preview": "#include \"static/Hello.h\"\n\nint main(int argc, char *argv[])\n{\n Hello hi;\n hi.print();\n return 0;\n}\n"
},
{
"path": "01-basic/D-shared-library/CMakeLists.txt",
"chars": 830,
"preview": "cmake_minimum_required(VERSION 3.5)\n\nproject(hello_library)\n\n###########################################################"
},
{
"path": "01-basic/D-shared-library/README.adoc",
"chars": 3453,
"preview": "= Shared Library\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nShows a hello world example which first creates and li"
},
{
"path": "01-basic/D-shared-library/include/shared/Hello.h",
"chars": 92,
"preview": "#ifndef __HELLO_H__\n#define __HELLO_H__\n\nclass Hello\n{\npublic:\n void print();\n};\n\n#endif\n"
},
{
"path": "01-basic/D-shared-library/src/Hello.cpp",
"chars": 127,
"preview": "#include <iostream>\n\n#include \"shared/Hello.h\"\n\nvoid Hello::print()\n{\n std::cout << \"Hello Shared Library!\" << std::e"
},
{
"path": "01-basic/D-shared-library/src/main.cpp",
"chars": 108,
"preview": "#include \"shared/Hello.h\"\n\nint main(int argc, char *argv[])\n{\n Hello hi;\n hi.print();\n return 0;\n}\n"
},
{
"path": "01-basic/E-installing/CMakeLists.txt",
"chars": 1302,
"preview": "cmake_minimum_required(VERSION 3.5)\n\nproject(cmake_examples_install)\n\n##################################################"
},
{
"path": "01-basic/E-installing/README.adoc",
"chars": 6323,
"preview": "= Installing\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to generate a `make install` target"
},
{
"path": "01-basic/E-installing/cmake-examples.conf",
"chars": 52,
"preview": "# Sample configuration file that could be installed\n"
},
{
"path": "01-basic/E-installing/include/installing/Hello.h",
"chars": 92,
"preview": "#ifndef __HELLO_H__\n#define __HELLO_H__\n\nclass Hello\n{\npublic:\n void print();\n};\n\n#endif\n"
},
{
"path": "01-basic/E-installing/src/Hello.cpp",
"chars": 124,
"preview": "#include <iostream>\n\n#include \"installing/Hello.h\"\n\nvoid Hello::print()\n{\n std::cout << \"Hello Install!\" << std::endl"
},
{
"path": "01-basic/E-installing/src/main.cpp",
"chars": 112,
"preview": "#include \"installing/Hello.h\"\n\nint main(int argc, char *argv[])\n{\n Hello hi;\n hi.print();\n return 0;\n}\n"
},
{
"path": "01-basic/F-build-type/CMakeLists.txt",
"chars": 699,
"preview": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_re"
},
{
"path": "01-basic/F-build-type/README.adoc",
"chars": 9646,
"preview": "= Build Type\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nCMake has a number of built in build configurations which "
},
{
"path": "01-basic/F-build-type/main.cpp",
"chars": 121,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n std::cout << \"Hello Build Type!\" << std::endl;\n return 0;\n}"
},
{
"path": "01-basic/G-compile-flags/CMakeLists.txt",
"chars": 362,
"preview": "cmake_minimum_required(VERSION 3.5)\n\n# Set a default C++ compile flag\nset (CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -DEX2\" CA"
},
{
"path": "01-basic/G-compile-flags/README.adoc",
"chars": 6953,
"preview": "= Compile Flags\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nCMake supports setting compile flags in a number of dif"
},
{
"path": "01-basic/G-compile-flags/main.cpp",
"chars": 310,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n std::cout << \"Hello Compile Flags!\" << std::endl;\n\n // only"
},
{
"path": "01-basic/H-third-party-library/CMakeLists.txt",
"chars": 539,
"preview": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (third_party_include)\n\n\n# find a boost install with "
},
{
"path": "01-basic/H-third-party-library/README.adoc",
"chars": 6878,
"preview": "= Including Third Party Library\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nNearly all non-trivial projects will ha"
},
{
"path": "01-basic/H-third-party-library/main.cpp",
"chars": 540,
"preview": "#include <iostream>\n#include <boost/shared_ptr.hpp>\n#include <boost/filesystem.hpp>\n\nint main(int argc, char *argv[])\n{\n"
},
{
"path": "01-basic/I-compiling-with-clang/CMakeLists.txt",
"chars": 244,
"preview": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_re"
},
{
"path": "01-basic/I-compiling-with-clang/README.adoc",
"chars": 6275,
"preview": "= Compiling with clang\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nWhen building with CMake it is possible to set t"
},
{
"path": "01-basic/I-compiling-with-clang/main.cpp",
"chars": 115,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n std::cout << \"Hello CMake!\" << std::endl;\n return 0;\n}"
},
{
"path": "01-basic/I-compiling-with-clang/pre_test.sh",
"chars": 179,
"preview": "#!/bin/bash\n\nROOT_DIR=`pwd`\ndir=\"01-basic/I-compiling-with-clang\"\n\nif [ -d \"$ROOT_DIR/$dir/build.clang\" ]; then\n echo"
},
{
"path": "01-basic/I-compiling-with-clang/run_test.sh",
"chars": 611,
"preview": "#!/bin/bash\n# Ubuntu supports multiple versions of clang to be installed at the same time.\n# The tests need to determine"
},
{
"path": "01-basic/J-building-with-ninja/CMakeLists.txt",
"chars": 244,
"preview": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_re"
},
{
"path": "01-basic/J-building-with-ninja/README.adoc",
"chars": 4693,
"preview": "= Building with ninja\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nAs mentioned, CMake is a meta-build system that c"
},
{
"path": "01-basic/J-building-with-ninja/main.cpp",
"chars": 115,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n std::cout << \"Hello CMake!\" << std::endl;\n return 0;\n}"
},
{
"path": "01-basic/J-building-with-ninja/pre_test.sh",
"chars": 178,
"preview": "#!/bin/bash\n\nROOT_DIR=`pwd`\ndir=\"01-basic/J-building-with-ninja\"\n\nif [ -d \"$ROOT_DIR/$dir/build.ninja\" ]; then\n echo "
},
{
"path": "01-basic/J-building-with-ninja/run_test.sh",
"chars": 291,
"preview": "#!/bin/bash\n# Travis-ci cmake version doesn't support ninja, so first check if it's supported\nninja_supported=`cmake --h"
},
{
"path": "01-basic/K-imported-targets/CMakeLists.txt",
"chars": 530,
"preview": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (imported_targets)\n\n\n# find a boost install with the"
},
{
"path": "01-basic/K-imported-targets/README.adoc",
"chars": 2284,
"preview": "= Imported Targets\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nAs previously mentioned in the link:../H-third-party"
},
{
"path": "01-basic/K-imported-targets/main.cpp",
"chars": 540,
"preview": "#include <iostream>\n#include <boost/shared_ptr.hpp>\n#include <boost/filesystem.hpp>\n\nint main(int argc, char *argv[])\n{\n"
},
{
"path": "01-basic/K-imported-targets/run_test.sh",
"chars": 333,
"preview": "#!/bin/bash\n# Make sure we have the minimum cmake version\ncmake_version=`cmake --version | grep version | cut -d\" \" -f3`"
},
{
"path": "01-basic/L-cpp-standard/README.adoc",
"chars": 728,
"preview": "= C++ Standard\n\nSince the release of C+\\+11 and C++14 a common use case is to invoke the compiler to use these standards"
},
{
"path": "01-basic/L-cpp-standard/i-common-method/CMakeLists.txt",
"chars": 766,
"preview": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_re"
},
{
"path": "01-basic/L-cpp-standard/i-common-method/README.adoc",
"chars": 5763,
"preview": "= C++ Standard Common Method\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows a common method to set "
},
{
"path": "01-basic/L-cpp-standard/i-common-method/main.cpp",
"chars": 145,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n auto message = \"Hello C++11\";\n std::cout << message << st"
},
{
"path": "01-basic/L-cpp-standard/ii-cxx-standard/CMakeLists.txt",
"chars": 305,
"preview": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_re"
},
{
"path": "01-basic/L-cpp-standard/ii-cxx-standard/README.adoc",
"chars": 4347,
"preview": "= Set C++ Standard\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to set the C++ standard using"
},
{
"path": "01-basic/L-cpp-standard/ii-cxx-standard/main.cpp",
"chars": 145,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n auto message = \"Hello C++11\";\n std::cout << message << st"
},
{
"path": "01-basic/L-cpp-standard/iii-compile-features/CMakeLists.txt",
"chars": 506,
"preview": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_re"
},
{
"path": "01-basic/L-cpp-standard/iii-compile-features/README.adoc",
"chars": 6366,
"preview": "= Set C++ Standard\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to set the C++ standard using"
},
{
"path": "01-basic/L-cpp-standard/iii-compile-features/main.cpp",
"chars": 145,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n auto message = \"Hello C++11\";\n std::cout << message << st"
},
{
"path": "01-basic/README.adoc",
"chars": 1364,
"preview": "= Basic Examples\n\nThe basic examples in this directory show how the setup a CMake project,\nset compile flags, create and"
},
{
"path": "02-sub-projects/A-basic/CMakeLists.txt",
"chars": 170,
"preview": "cmake_minimum_required (VERSION 3.5)\n\nproject(subprojects)\n\n# Add sub directories\nadd_subdirectory(sublibrary1)\nadd_subd"
},
{
"path": "02-sub-projects/A-basic/README.adoc",
"chars": 6516,
"preview": "= Basic Sub-Project\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to setup a CMake project tha"
},
{
"path": "02-sub-projects/A-basic/subbinary/CMakeLists.txt",
"chars": 383,
"preview": "project(subbinary)\n\n# Create the executable\nadd_executable(${PROJECT_NAME} main.cpp)\n\n# Link the static library from sub"
},
{
"path": "02-sub-projects/A-basic/subbinary/main.cpp",
"chars": 186,
"preview": "#include \"sublib1/sublib1.h\"\n#include \"sublib2/sublib2.h\"\n\nint main(int argc, char *argv[])\n{\n sublib1 hi;\n hi.pri"
},
{
"path": "02-sub-projects/A-basic/sublibrary1/CMakeLists.txt",
"chars": 263,
"preview": "# Set the project name\nproject (sublibrary1)\n\n# Add a library with the above sources\nadd_library(${PROJECT_NAME} src/sub"
},
{
"path": "02-sub-projects/A-basic/sublibrary1/include/sublib1/sublib1.h",
"chars": 100,
"preview": "#ifndef __SUBLIB_1_H__\n#define __SUBLIB_1_H__\n\nclass sublib1\n{\npublic:\n void print();\n};\n\n#endif\n"
},
{
"path": "02-sub-projects/A-basic/sublibrary1/src/sublib1.cpp",
"chars": 131,
"preview": "#include <iostream>\n\n#include \"sublib1/sublib1.h\"\n\nvoid sublib1::print()\n{\n std::cout << \"Hello sub-library 1!\" << st"
},
{
"path": "02-sub-projects/A-basic/sublibrary2/CMakeLists.txt",
"chars": 228,
"preview": "# Set the project name\nproject (sublibrary2)\n\nadd_library(${PROJECT_NAME} INTERFACE)\nadd_library(sub::lib2 ALIAS ${PROJE"
},
{
"path": "02-sub-projects/A-basic/sublibrary2/include/sublib2/sublib2.h",
"chars": 202,
"preview": "#ifndef __SUBLIB_2_H__\n#define __SUBLIB_2_H__\n\n#include <iostream>\n\nclass sublib2\n{\npublic:\n void print()\n {\n "
},
{
"path": "02-sub-projects/README.adoc",
"chars": 318,
"preview": "= Sub-Project Examples\n\nMany large projects are made up of different libraries and binaries. These\ncan be organised into"
},
{
"path": "03-code-generation/README.adoc",
"chars": 506,
"preview": "= Code Generation\n\nCode generation can be useful to create source code in different languages from a common description "
},
{
"path": "03-code-generation/configure-files/CMakeLists.txt",
"chars": 815,
"preview": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (cf_example)\n\n# set a project version\nset (cf_exampl"
},
{
"path": "03-code-generation/configure-files/README.adoc",
"chars": 3031,
"preview": "= Configure Files Generation\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nDuring the call to cmake it is possible to"
},
{
"path": "03-code-generation/configure-files/main.cpp",
"chars": 218,
"preview": "#include <iostream>\n#include \"ver.h\"\n#include \"path.h\"\n\nint main(int argc, char *argv[])\n{\n std::cout << \"Hello Versi"
},
{
"path": "03-code-generation/configure-files/path.h.in",
"chars": 193,
"preview": "#ifndef __PATH_H__\n#define __PATH_H__\n\n// version variable that will be substituted by cmake\n// This shows an example us"
},
{
"path": "03-code-generation/configure-files/ver.h.in",
"chars": 193,
"preview": "#ifndef __VER_H__\n#define __VER_H__\n\n// version variable that will be substituted by cmake\n// This shows an example usin"
},
{
"path": "03-code-generation/protobuf/AddressBook.proto",
"chars": 389,
"preview": "package tutorial;\n\nmessage Person {\n required string name = 1;\n required int32 id = 2;\n optional string email = 3;\n\n "
},
{
"path": "03-code-generation/protobuf/CMakeLists.txt",
"chars": 854,
"preview": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (protobuf_example)\n\n# find the protobuf compiler and"
},
{
"path": "03-code-generation/protobuf/README.adoc",
"chars": 13144,
"preview": "= Protobuf Code Generation\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to generate source fi"
},
{
"path": "03-code-generation/protobuf/main.cpp",
"chars": 2558,
"preview": "#include <iostream>\n#include <fstream>\n#include <string>\n#include \"AddressBook.pb.h\"\nusing namespace std;\n\n// This funct"
},
{
"path": "04-static-analysis/README.adoc",
"chars": 839,
"preview": "= Static Analysis\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nStatic analysis is the analysis of code without execu"
},
{
"path": "04-static-analysis/clang-analyzer/CMakeLists.txt",
"chars": 288,
"preview": "cmake_minimum_required (VERSION 3.5)\n\nproject(cppcheck_analysis)\n\n# Use debug build as recommended\nset(CMAKE_BUILD_TYPE "
},
{
"path": "04-static-analysis/clang-analyzer/README.adoc",
"chars": 4813,
"preview": "= clang-analyzer\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to call the\nhttps://clang-analy"
},
{
"path": "04-static-analysis/clang-analyzer/run_test.sh",
"chars": 130,
"preview": "#!/bin/bash\nmkdir -p build \\\n\t&& cd build \\\n\t&& scan-build-3.6 -o scanbuildout cmake .. \\\n\t&& scan-build-3.6 -o scanbuil"
},
{
"path": "04-static-analysis/clang-analyzer/subproject1/CMakeLists.txt",
"chars": 131,
"preview": "# Set the project name\nproject (subproject1)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} "
},
{
"path": "04-static-analysis/clang-analyzer/subproject1/main1.cpp",
"chars": 115,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n std::cout << \"Hello Main1!\" << std::endl;\n return 0;\n}"
},
{
"path": "04-static-analysis/clang-analyzer/subproject2/CMakeLists.txt",
"chars": 131,
"preview": "# Set the project name\nproject (subproject2)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} "
},
{
"path": "04-static-analysis/clang-analyzer/subproject2/main2.cpp",
"chars": 167,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n std::cout << \"Hello Main2!\" << std::endl;\n int* x = NULL;\n "
},
{
"path": "04-static-analysis/clang-format/.clang-format",
"chars": 1845,
"preview": "---\nLanguage: Cpp\n# BasedOnStyle: LLVM\nAccessModifierOffset: -4\nAlignEscapedNewlinesLeft: false\nAlignOperands: "
},
{
"path": "04-static-analysis/clang-format/CMakeLists.txt",
"chars": 424,
"preview": "cmake_minimum_required (VERSION 3.5)\n\nproject(cppcheck_analysis)\n\n# Add a custom CMake Modules directory\nset(CMAKE_MODUL"
},
{
"path": "04-static-analysis/clang-format/README.adoc",
"chars": 5051,
"preview": "= clang-format\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to call the\nhttps://clang.llvm.or"
},
{
"path": "04-static-analysis/clang-format/cmake/modules/FindClangFormat.cmake",
"chars": 780,
"preview": "# Find Clang format\n# \n# \nif(NOT CLANG_FORMAT_BIN_NAME)\n\tset(CLANG_FORMAT_BIN_NAME clang-format)\nendif()\n\n# if custom pa"
},
{
"path": "04-static-analysis/clang-format/cmake/modules/clang-format.cmake",
"chars": 2078,
"preview": "# A CMake script to find all source files and setup clang-format targets for them\n\n# Find all source files\nset(CLANG_FOR"
},
{
"path": "04-static-analysis/clang-format/cmake/scripts/clang-format-check-changed",
"chars": 429,
"preview": "#!/bin/bash\n\n# Required because cmake root isn't git root in this example\nCLANG_FORMAT_BIN=$1\nGIT_ROOT=`git rev-parse --"
},
{
"path": "04-static-analysis/clang-format/cmake/scripts/clang-format-check-changed.py",
"chars": 5095,
"preview": "#!/usr/bin/env python\n\nimport argparse\nimport os\nimport sys\nimport subprocess\n\n\ndef check_file(filename, excludes, exten"
},
{
"path": "04-static-analysis/clang-format/run_test.sh",
"chars": 232,
"preview": "#!/bin/bash\nmkdir -p build && cd build && cmake .. && make format-check\nRET=$?\necho \"return code was ${RET}\"\nif [ ${RET}"
},
{
"path": "04-static-analysis/clang-format/subproject1/CMakeLists.txt",
"chars": 131,
"preview": "# Set the project name\nproject (subproject1)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} "
},
{
"path": "04-static-analysis/clang-format/subproject1/main1.cpp",
"chars": 117,
"preview": "#include <iostream>\n\nint main(int argc, char* argv[])\n{\n std::cout << \"Hello Main1!\" << std::endl;\n return 0;\n}"
},
{
"path": "04-static-analysis/clang-format/subproject2/CMakeLists.txt",
"chars": 131,
"preview": "# Set the project name\nproject (subproject2)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} "
},
{
"path": "04-static-analysis/clang-format/subproject2/main2.cpp",
"chars": 247,
"preview": "#include <iostream>\n\nclass TestClass {\npublic:\n TestClass();\n};\n\nTestClass::TestClass() {\n\n}\n\nint main(int argc, char"
},
{
"path": "04-static-analysis/cppcheck/CMakeLists.txt",
"chars": 711,
"preview": "cmake_minimum_required (VERSION 3.5)\n\nproject(cppcheck_analysis)\n\n# Add a custom CMake Modules directory\nset(CMAKE_MODUL"
},
{
"path": "04-static-analysis/cppcheck/README.adoc",
"chars": 10489,
"preview": "= CppCheck Static Analysis\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to call the\nhttp://cp"
},
{
"path": "04-static-analysis/cppcheck/cmake/analysis.cmake",
"chars": 2084,
"preview": "# Make sure cppcheck binary is available\nif( NOT CPPCHECK_FOUND )\n find_package(CppCheck)\nendif()\n\n# add a target for"
},
{
"path": "04-static-analysis/cppcheck/cmake/modules/FindCppCheck.cmake",
"chars": 1208,
"preview": "# Locate cppcheck\n#\n# This module defines\n# CPPCHECK_FOUND, if false, do not try to link to cppcheck --- if (CPPCHECK_F"
},
{
"path": "04-static-analysis/cppcheck/run_test.sh",
"chars": 68,
"preview": "#!/bin/bash\nmkdir -p build && cd build && cmake .. && make analysis\n"
},
{
"path": "04-static-analysis/cppcheck/subproject1/CMakeLists.txt",
"chars": 374,
"preview": "# Set the project name\nproject (subproject1)\n\n# Create a sources variable with a link to all cpp files to compile\nset(SO"
},
{
"path": "04-static-analysis/cppcheck/subproject1/main1.cpp",
"chars": 115,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n std::cout << \"Hello Main1!\" << std::endl;\n return 0;\n}"
},
{
"path": "04-static-analysis/cppcheck/subproject2/CMakeLists.txt",
"chars": 374,
"preview": "# Set the project name\nproject (subproject2)\n\n# Create a sources variable with a link to all cpp files to compile\nset(SO"
},
{
"path": "04-static-analysis/cppcheck/subproject2/main2.cpp",
"chars": 150,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n std::cout << \"Hello Main2!\" << std::endl;\n char tmp[10];\n "
},
{
"path": "04-static-analysis/cppcheck-compile-commands/.cppcheck_suppressions",
"chars": 0,
"preview": ""
},
{
"path": "04-static-analysis/cppcheck-compile-commands/CMakeLists.txt",
"chars": 417,
"preview": "cmake_minimum_required (VERSION 3.5)\n\nproject(cppcheck_analysis)\n\n# Have cmake create a compile database\nset(CMAKE_EXPOR"
},
{
"path": "04-static-analysis/cppcheck-compile-commands/README.adoc",
"chars": 6235,
"preview": "= CppCheck Static Analysis using Compile Commands\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows ho"
},
{
"path": "04-static-analysis/cppcheck-compile-commands/cmake/modules/FindCppCheck.cmake",
"chars": 4471,
"preview": "# Locate cppcheck\n#\n# This module defines\n# CPPCHECK_BIN, where to find cppcheck\n#\n# To help find the binary you can se"
},
{
"path": "04-static-analysis/cppcheck-compile-commands/run_test.sh",
"chars": 110,
"preview": "#!/bin/bash\nmkdir -p build && cd build && cmake -DCPPCHECK_ERROR_EXITCODE_ARG=\"\" .. && make cppcheck-analysis\n"
},
{
"path": "04-static-analysis/cppcheck-compile-commands/subproject1/CMakeLists.txt",
"chars": 131,
"preview": "# Set the project name\nproject (subproject1)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} "
},
{
"path": "04-static-analysis/cppcheck-compile-commands/subproject1/main1.cpp",
"chars": 115,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n std::cout << \"Hello Main1!\" << std::endl;\n return 0;\n}"
},
{
"path": "04-static-analysis/cppcheck-compile-commands/subproject2/CMakeLists.txt",
"chars": 131,
"preview": "# Set the project name\nproject (subproject2)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} "
},
{
"path": "04-static-analysis/cppcheck-compile-commands/subproject2/main2.cpp",
"chars": 150,
"preview": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n std::cout << \"Hello Main2!\" << std::endl;\n char tmp[10];\n "
},
{
"path": "05-unit-testing/README.adoc",
"chars": 1108,
"preview": "= Unit Testing\n\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n[[intro]]\nIntroduction\n------------\n\nUnit testing is a software develop"
},
{
"path": "05-unit-testing/boost/CMakeLists.txt",
"chars": 892,
"preview": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (boost_unit_test)\n\n\n# find a boost install with the "
},
{
"path": "05-unit-testing/boost/Palindrome.cpp",
"chars": 202,
"preview": "#include \"Palindrome.h\"\n\nbool Palindrome::isPalindrome(const std::string& toCheck)\n{\n\n if (toCheck == std::string(toC"
},
{
"path": "05-unit-testing/boost/Palindrome.h",
"chars": 222,
"preview": "#ifndef __PALINDROME_H__\n#define __PALINDROME_H__\n\n#include <string>\n\n/**\n * Trivial class to check if a string is a pal"
},
{
"path": "05-unit-testing/boost/README.adoc",
"chars": 4404,
"preview": "= Boost Unit Testing Framework\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n\n# Introduction\n\nUsing link:https://cmake.org/Wiki/CMake"
},
{
"path": "05-unit-testing/boost/Reverse.cpp",
"chars": 258,
"preview": "#include \"Reverse.h\"\n\nstd::string Reverse::reverse(std::string& toReverse)\n{\n std::string ret;\n\n for(std::string::"
},
{
"path": "05-unit-testing/boost/Reverse.h",
"chars": 291,
"preview": "#ifndef __REVERSE_H__\n#define __REVERSE_H__\n\n#include <string>\n\n/**\n * Trivial class whose only function is to reverse a"
},
{
"path": "05-unit-testing/boost/main.cpp",
"chars": 540,
"preview": "#include <iostream>\n#include <boost/shared_ptr.hpp>\n#include <boost/filesystem.hpp>\n\nint main(int argc, char *argv[])\n{\n"
},
{
"path": "05-unit-testing/boost/post_test.sh",
"chars": 23,
"preview": "#!/bin/bash\n\nmake test\n"
},
{
"path": "05-unit-testing/boost/unit_tests.cpp",
"chars": 759,
"preview": "#include <string>\n#include \"Reverse.h\"\n#include \"Palindrome.h\"\n\n#define BOOST_TEST_MODULE VsidCommonTest\n#include <boost"
},
{
"path": "05-unit-testing/catch2-vendored/3rd_party/catch2/CMakeLists.txt",
"chars": 245,
"preview": "cmake_minimum_required(VERSION 3.0)\n\nproject(catch2)\n\n# Prepare \"Catch2\" library for other executables\nadd_library(Catch"
},
{
"path": "05-unit-testing/catch2-vendored/3rd_party/catch2/catch2/catch.hpp",
"chars": 491929,
"preview": "/*\n * Catch v2.5.0\n * Generated: 2018-11-26 20:46:12.165372\n * ------------------------------------------------------"
},
{
"path": "05-unit-testing/catch2-vendored/CMakeLists.txt",
"chars": 579,
"preview": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (catch2_unit_test)\n\n\nset(CMAKE_CXX_STANDARD 11)\n\n# a"
},
{
"path": "05-unit-testing/catch2-vendored/Palindrome.cpp",
"chars": 202,
"preview": "#include \"Palindrome.h\"\n\nbool Palindrome::isPalindrome(const std::string& toCheck)\n{\n\n if (toCheck == std::string(toC"
},
{
"path": "05-unit-testing/catch2-vendored/Palindrome.h",
"chars": 222,
"preview": "#ifndef __PALINDROME_H__\n#define __PALINDROME_H__\n\n#include <string>\n\n/**\n * Trivial class to check if a string is a pal"
},
{
"path": "05-unit-testing/catch2-vendored/README.adoc",
"chars": 5376,
"preview": "= Catch2 Unit Testing Framework\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n\n# Introduction\n\nUsing link:https://cmake.org/Wiki/CMak"
},
{
"path": "05-unit-testing/catch2-vendored/Reverse.cpp",
"chars": 258,
"preview": "#include \"Reverse.h\"\n\nstd::string Reverse::reverse(std::string& toReverse)\n{\n std::string ret;\n\n for(std::string::"
},
{
"path": "05-unit-testing/catch2-vendored/Reverse.h",
"chars": 291,
"preview": "#ifndef __REVERSE_H__\n#define __REVERSE_H__\n\n#include <string>\n\n/**\n * Trivial class whose only function is to reverse a"
},
{
"path": "05-unit-testing/catch2-vendored/main.cpp",
"chars": 540,
"preview": "#include <iostream>\n#include <boost/shared_ptr.hpp>\n#include <boost/filesystem.hpp>\n\nint main(int argc, char *argv[])\n{\n"
},
{
"path": "05-unit-testing/catch2-vendored/post_test.sh",
"chars": 23,
"preview": "#!/bin/bash\n\nmake test\n"
},
{
"path": "05-unit-testing/catch2-vendored/unit_tests.cpp",
"chars": 542,
"preview": "#include <string>\n#include \"Reverse.h\"\n#include \"Palindrome.h\"\n\n#define CATCH_CONFIG_MAIN\n#include \"catch2/catch.hpp\"\n\n\n"
},
{
"path": "05-unit-testing/google-test-download/3rd_party/google-test/CMakeLists.txt",
"chars": 2036,
"preview": "# Download and unpack googletest at configure time\n# See: http://crascit.com/2015/07/25/cmake-gtest/\nconfigure_file(CMak"
},
{
"path": "05-unit-testing/google-test-download/3rd_party/google-test/CMakeLists.txt.in",
"chars": 758,
"preview": "cmake_minimum_required(VERSION 3.0)\n\nproject(googletest-download NONE)\n\ninclude(ExternalProject)\n\n# Version bfc0ffc8a698"
},
{
"path": "05-unit-testing/google-test-download/CMakeLists.txt",
"chars": 540,
"preview": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (google_test_example)\n\n# Add an library for the exam"
},
{
"path": "05-unit-testing/google-test-download/Palindrome.cpp",
"chars": 202,
"preview": "#include \"Palindrome.h\"\n\nbool Palindrome::isPalindrome(const std::string& toCheck)\n{\n\n if (toCheck == std::string(toC"
},
{
"path": "05-unit-testing/google-test-download/Palindrome.h",
"chars": 222,
"preview": "#ifndef __PALINDROME_H__\n#define __PALINDROME_H__\n\n#include <string>\n\n/**\n * Trivial class to check if a string is a pal"
},
{
"path": "05-unit-testing/google-test-download/README.adoc",
"chars": 9077,
"preview": "= Google Test Unit Testing Framework\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n\n# Introduction\n\nUsing link:https://cmake.org/Wiki"
},
{
"path": "05-unit-testing/google-test-download/Reverse.cpp",
"chars": 258,
"preview": "#include \"Reverse.h\"\n\nstd::string Reverse::reverse(std::string& toReverse)\n{\n std::string ret;\n\n for(std::string::"
},
{
"path": "05-unit-testing/google-test-download/Reverse.h",
"chars": 291,
"preview": "#ifndef __REVERSE_H__\n#define __REVERSE_H__\n\n#include <string>\n\n/**\n * Trivial class whose only function is to reverse a"
},
{
"path": "05-unit-testing/google-test-download/main.cpp",
"chars": 540,
"preview": "#include <iostream>\n#include <boost/shared_ptr.hpp>\n#include <boost/filesystem.hpp>\n\nint main(int argc, char *argv[])\n{\n"
},
{
"path": "05-unit-testing/google-test-download/post_test.sh",
"chars": 96,
"preview": "#!/bin/bash\n\necho \"Disabled for now because of issue with libcurl and https\"\nexit 0\n\n#make test\n"
},
{
"path": "05-unit-testing/google-test-download/run_test.sh",
"chars": 84,
"preview": "#!/bin/bash\n\necho \"Disabled for now because of issue with libcurl and https\"\nexit 0\n"
},
{
"path": "05-unit-testing/google-test-download/unit_tests.cpp",
"chars": 580,
"preview": "#include <string>\n#include \"Reverse.h\"\n#include \"Palindrome.h\"\n\n#include <gtest/gtest.h>\n\nclass ReverseTests : public ::"
},
{
"path": "06-installer/README.adoc",
"chars": 421,
"preview": "= Installers\n\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n[[intro]]\nIntroduction\n------------\n\nCMake has the ability to create inst"
},
{
"path": "06-installer/deb/CMakeLists.txt",
"chars": 1837,
"preview": "cmake_minimum_required(VERSION 3.5)\n\nproject(cmake_examples_deb)\n\n# set a project version\nset (deb_example_VERSION_MAJOR"
},
{
"path": "06-installer/deb/README.adoc",
"chars": 4551,
"preview": "= Creating deb files\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to generate a Linux install"
},
{
"path": "06-installer/deb/cmake-examples.conf",
"chars": 52,
"preview": "# Sample configuration file that could be installed\n"
},
{
"path": "06-installer/deb/include/Hello.h",
"chars": 92,
"preview": "#ifndef __HELLO_H__\n#define __HELLO_H__\n\nclass Hello\n{\npublic:\n void print();\n};\n\n#endif\n"
},
{
"path": "06-installer/deb/post_test.sh",
"chars": 26,
"preview": "#!/bin/bash\n\nmake package\n"
},
{
"path": "06-installer/deb/src/Hello.cpp",
"chars": 113,
"preview": "#include <iostream>\n\n#include \"Hello.h\"\n\nvoid Hello::print()\n{\n std::cout << \"Hello Install!\" << std::endl;\n}\n"
},
{
"path": "06-installer/deb/src/main.cpp",
"chars": 100,
"preview": "#include \"Hello.h\"\n\nint main(int argc, char *argv[])\n{\n Hello hi;\n hi.print();\n return 0;\n}"
},
{
"path": "07-package-management/A-using-system-provide-packages/README.adoc",
"chars": 745,
"preview": "= Using System Provided Package Manager\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nUsing your system provided pack"
},
{
"path": "07-package-management/B-vendoring-code/README.adoc",
"chars": 1666,
"preview": "= Vendoring Code\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nVendoring code means to include the third party code i"
},
{
"path": "07-package-management/C-external-project-add/README.adoc",
"chars": 2030,
"preview": "= External Project\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nCMake supports downloading and building an external "
},
{
"path": "07-package-management/D-conan/README.adoc",
"chars": 4541,
"preview": "= Conan\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nlink:https://conan.io[Conan] is an open source, decentralized, "
},
{
"path": "07-package-management/D-conan/i-basic/CMakeLists.txt",
"chars": 402,
"preview": "cmake_minimum_required(VERSION 3.5)\nproject (conan_third_party_include)\n\nset(CMAKE_CXX_STANDARD 11)\n\n# Included the cona"
},
{
"path": "07-package-management/D-conan/i-basic/README.adoc",
"chars": 8645,
"preview": "= Conan Basic Example\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nlink:http://conan.io[Conan] supports downloading "
},
{
"path": "07-package-management/D-conan/i-basic/conanfile.txt",
"chars": 60,
"preview": "[requires]\nfmt/5.3.0@bincrafters/stable\n\n[generators]\ncmake\n"
},
{
"path": "07-package-management/D-conan/i-basic/main.cpp",
"chars": 159,
"preview": "#include <iostream>\n#include <fmt/format.h>\n\nint main(int argc, char *argv[])\n{\n fmt::print(\"Hello, {}. This is {}!\\n"
},
{
"path": "07-package-management/D-conan/i-basic/run_test.sh",
"chars": 388,
"preview": "#!/bin/bash\n\nconan_bin=`which conan`\n\nif [ -z $conan_bin ]; then\n exit 0\nfi\n\nconan profile show default || {\n cona"
},
{
"path": "07-package-management/D-conan/ii-basic-targets/CMakeLists.txt",
"chars": 411,
"preview": "cmake_minimum_required(VERSION 3.5)\nproject (conan_third_party_include)\n\nset(CMAKE_CXX_STANDARD 11)\n\n# Included the cona"
},
{
"path": "07-package-management/D-conan/ii-basic-targets/README.adoc",
"chars": 7879,
"preview": "= Conan Basic Example\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nModern CMake recommends to use a target based app"
},
{
"path": "07-package-management/D-conan/ii-basic-targets/conanfile.txt",
"chars": 60,
"preview": "[requires]\nfmt/5.3.0@bincrafters/stable\n\n[generators]\ncmake\n"
},
{
"path": "07-package-management/D-conan/ii-basic-targets/main.cpp",
"chars": 159,
"preview": "#include <iostream>\n#include <fmt/format.h>\n\nint main(int argc, char *argv[])\n{\n fmt::print(\"Hello, {}. This is {}!\\n"
},
{
"path": "07-package-management/D-conan/ii-basic-targets/run_test.sh",
"chars": 388,
"preview": "#!/bin/bash\n\nconan_bin=`which conan`\n\nif [ -z $conan_bin ]; then\n exit 0\nfi\n\nconan profile show default || {\n cona"
},
{
"path": "07-package-management/README.adoc",
"chars": 435,
"preview": "= Package Management\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n[[intro]]\nIntroduction\n------------\n\nFor C++ and CMake there is cu"
},
{
"path": "LICENSE",
"chars": 1077,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2015 Thom Troy\n\nPermission is hereby granted, free of charge, to any person obtaini"
},
{
"path": "README.adoc",
"chars": 4114,
"preview": "\n= CMake Examples\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nhttps://cmake.org/[CMake] is a cross-platform open-so"
},
{
"path": "cmake-examples.sublime-project",
"chars": 45,
"preview": "{\n\t\"folders\":\n\t[\n\t\t{\n\t\t\t\"path\": \".\"\n\t\t}\n\t]\n}\n"
},
{
"path": "dockerfiles/README.adoc",
"chars": 2689,
"preview": "\n= CMake Examples with Docker\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Docker\n\nhttps://www.docker.com/[Docker] allows you to p"
},
{
"path": "dockerfiles/setup.sh",
"chars": 688,
"preview": "#!/bin/bash\n# Setup script for the cmake-examples repository\n# Will create a non root user using the UID and GID passed "
},
{
"path": "dockerfiles/ubuntu14.04-cmake-3.4.3",
"chars": 1227,
"preview": "# Container for building and testing cmake-examples with cmake v3.4.3\nFROM ubuntu:14.04\nMAINTAINER Thom Troy\n\nRUN apt-ge"
},
{
"path": "dockerfiles/ubuntu14.04-default-2.8.12.2",
"chars": 1098,
"preview": "# Container for building and testing cmake-examples with default cmake v2.8.12.2\nFROM ubuntu:14.04\nMAINTAINER Thom Troy\n"
},
{
"path": "dockerfiles/ubuntu16.04-cmake-3.10.3",
"chars": 1271,
"preview": "# Container for building and testing cmake-examples with CMake 3.10.3\nFROM ubuntu:16.04\nMAINTAINER Thom Troy\n\nRUN apt-ge"
},
{
"path": "dockerfiles/ubuntu16.04-default-cmake-3.5.1",
"chars": 1033,
"preview": "# Container for building and testing cmake-examples with default cmake v3.5.1\nFROM ubuntu:16.04\nMAINTAINER Thom Troy\n\nRU"
},
{
"path": "test.sh",
"chars": 2403,
"preview": "#!/bin/bash\n\n# print out cmake information to help with debugging.\n\ncmake --version\ncmake --help\n\n# Find the directory t"
}
]
About this extraction
This page contains the full source code of the ttroy50/cmake-examples GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 184 files (736.6 KB), approximately 185.1k tokens, and a symbol index with 1245 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.