TRIQS/itertools 1.3.0
C++ range library
|
itertools is a header only library. To use it in your own C++
code, you simply have to include the following header
and tell your compiler/build system where it can find the necessary files. In the following, we describe some common ways to achieve this (with special focus on CMake).
If you use CMake to build your source code, it is recommended to fetch the source code directly from the Github repository using CMake's FetchContent module:
Note that the above will also build goolgetest and the unit tests for itertools. To disable this, you can put set(Build_Tests OFF CACHE BOOL "" FORCE)
before fetching the content.
If you have already installed itertools on your system by following the instructions from the Installation page, you can also make use of CMake's find_package command. This has the advantage that you don't need to download anything, i.e. no internet connection is required.
Let's assume that itertools has been installed to path_to_install_dir
. Then linking your project to itertools with CMake is as easy as
In case, CMake cannot find the package, you might have to tell it where to look for the itertools-config.cmake
file by setting the variable itertools_DIR
to path_to_install_dir/lib/cmake/itertools
or by sourcing the provided itertoolsvars.sh
before running CMake:
You can also integrate itertools into our CMake project by placing the entire source tree in a subdirectory and call add_subdirectory()
:
Here, it is assumed that the itertools source tree is in a subdirectory deps/itertools
relative to your CMakeLists.txt
file.
Since itertools is header-only, you can also simply copy the relevant files directly into our project. For example, you could place the c++/itertools
directory from the itertools source tree into the include path of your project. You can then build or compile it with any available method.