- [Install using CMake locally and use it in CMake](#install-using-cmake-locally-and-use-it-in-cmake)
`eventpp` package is available in C++ package managers Vcpkg, Conan, and Hunter.
`eventpp` is header only and not requires building. There are various methods to use `eventpp`.
Here lists all possible methods to use `eventpp`.
## Include the source code in your project directly
eventpp is header only library. Just clone the source code, or use git submodule, then add the 'include' folder inside eventpp to your project include directory, then you can use the library.
Then run `conan install . --output-folder=build --build=missing` in your project folder (assuming the default conan profile exists and is okay).
Then cd into folder build, run `cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -G "Whatever generator you want" -DCMAKE_BUILD_TYPE=Release`, alternatively it can also use cmake presets instead of passing the toolchain file on cmake >=3.23
There are [more information here](https://github.com/wqking/eventpp/issues/70).
## Use Hunter package manager
You may follow the example code on [Hunter document](https://hunter.readthedocs.io/en/latest/packages/pkg/eventpp.html). Below is the code snippet from that document,
```
hunter_add_package(eventpp)
find_package(eventpp CONFIG REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main eventpp::eventpp)
include_directories(${EVENTPP_INCLUDE_DIR})
```
## Install using CMake locally and use it in CMake
Note: this is only an alternative, you should use the FetchContent method instead of this.
If you are going to use eventpp in CMake managed project, you can install eventpp then use it in CMake.
In eventpp root folder, run the commands,
```
mkdir build
cd build
cmake ..
sudo make install
```
Then in the project CMakeLists.txt,
```
# the project target is mytest, just for example
add_executable(mytest test.cpp)
find_package(eventpp)
if(eventpp_FOUND)
target_link_libraries(mytest eventpp::eventpp)
else(eventpp_FOUND)
message(FATAL_ERROR "eventpp library is not found")
Note: when using this method with MingW on Windows, by default CMake will install eventpp in non-writable system folder and get error. You should specify another folder to install. To do so, replace `cmake ..` with `cmake .. -DCMAKE_INSTALL_PREFIX="YOUR_NEW_LIB_FOLDER"`.