Skip to content

Commit 2504baf

Browse files
committed
Extracted install instructions to separate document. Added Conan usage.
1 parent 7a186e3 commit 2504baf

File tree

2 files changed

+126
-67
lines changed

2 files changed

+126
-67
lines changed

doc/install.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Install and use eventpp in your project
2+
3+
- [Install and use eventpp in your project](#install-and-use-eventpp-in-your-project)
4+
- [Include the source code in your project directly](#include-the-source-code-in-your-project-directly)
5+
- [Use CMake FetchContent](#use-cmake-fetchcontent)
6+
- [Use Vcpkg package manager](#use-vcpkg-package-manager)
7+
- [Use Conan package manager](#use-conan-package-manager)
8+
- [Use Hunter package manager](#use-hunter-package-manager)
9+
- [Install using CMake locally and use it in CMake](#install-using-cmake-locally-and-use-it-in-cmake)
10+
11+
`eventpp` package is available in C++ package managers Vcpkg, Conan, and Hunter.
12+
`eventpp` is header only and not requires building. There are various methods to use `eventpp`.
13+
Here lists all possible methods to use `eventpp`.
14+
15+
## Include the source code in your project directly
16+
17+
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.
18+
You don't need to link to any source code.
19+
20+
## Use CMake FetchContent
21+
22+
Add below code to your CMake file
23+
24+
```
25+
include(FetchContent)
26+
FetchContent_Declare(
27+
eventpp
28+
GIT_REPOSITORY https://github.com/wqking/eventpp
29+
GIT_TAG d2db8af2a46c79f8dc75759019fba487948e9442 # v0.1.3
30+
)
31+
FetchContent_MakeAvailable(eventpp)
32+
```
33+
34+
Then `eventpp` is available to your project. If `GIT_TAG` is omitted, the latest code on master branch will be used.
35+
36+
## Use Vcpkg package manager
37+
38+
```
39+
vcpkg install eventpp
40+
```
41+
42+
Then in your CMake project CMakeLists.txt file, put below code, remember to replace ${TARGET} with your target,
43+
44+
```
45+
find_package(eventpp CONFIG REQUIRED)
46+
target_link_libraries(${TARGET} PRIVATE eventpp::eventpp)
47+
find_path(EVENTPP_INCLUDE_DIR eventpp/eventqueue.h)
48+
include_directories(${EVENTPP_INCLUDE_DIR})
49+
```
50+
51+
Then run cmake, note you need -DCMAKE_TOOLCHAIN_FILE to specify vcpkg, and replace -G with your generator
52+
```
53+
cmake .. -DCMAKE_TOOLCHAIN_FILE=VCPKGDIR/vcpkg/scripts/buildsystems/vcpkg.cmake -G"MinGW Makefiles"
54+
```
55+
56+
Note with vcpkg, only the released version can be used, which may be behind the latest update. You can't use the minor update on the master branch.
57+
58+
## Use Conan package manager
59+
60+
In your CMake project, add a conanlist.txt file that should contain,
61+
62+
```
63+
[requires]
64+
eventpp/0.1.3
65+
66+
[generators]
67+
CMakeDeps
68+
CMakeToolchain
69+
```
70+
71+
Then in your CMakeLists, add,
72+
73+
```
74+
find_package(eventpp CONFIG REQUIRED)
75+
target_link_libraries(${TARGET} PRIVATE eventpp::eventpp)
76+
```
77+
78+
Then run `conan install . --output-folder=build --build=missing` in your project folder (assuming the default conan profile exists and is okay).
79+
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
80+
81+
There are [more information here](https://github.com/wqking/eventpp/issues/70).
82+
83+
## Use Hunter package manager
84+
85+
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,
86+
87+
```
88+
hunter_add_package(eventpp)
89+
find_package(eventpp CONFIG REQUIRED)
90+
91+
add_executable(main main.cpp)
92+
target_link_libraries(main eventpp::eventpp)
93+
include_directories(${EVENTPP_INCLUDE_DIR})
94+
```
95+
96+
## Install using CMake locally and use it in CMake
97+
98+
Note: this is only an alternative, you should use the FetchContent method instead of this.
99+
If you are going to use eventpp in CMake managed project, you can install eventpp then use it in CMake.
100+
In eventpp root folder, run the commands,
101+
```
102+
mkdir build
103+
cd build
104+
cmake ..
105+
sudo make install
106+
```
107+
108+
Then in the project CMakeLists.txt,
109+
```
110+
# the project target is mytest, just for example
111+
add_executable(mytest test.cpp)
112+
113+
find_package(eventpp)
114+
if(eventpp_FOUND)
115+
target_link_libraries(mytest eventpp::eventpp)
116+
else(eventpp_FOUND)
117+
message(FATAL_ERROR "eventpp library is not found")
118+
endif(eventpp_FOUND)
119+
```
120+
121+
Note: when using the method 3 with MingW on Windows, by default CMake will install eventpp in system folder which is not writable. You should specify another folder to install. To do so, replace `cmake ..` with `cmake .. -DCMAKE_INSTALL_PREFIX="YOUR_NEW_LIB_FOLDER"`.

readme.md

Lines changed: 5 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -88,73 +88,8 @@ In brief, MSVC, GCC, Clang that has well support for C++11, or released after 20
8888

8989
### Use eventpp in your project
9090

91-
There are various methods to use eventpp
92-
93-
1, Include the source code in your project directly.
94-
95-
eventpp is header only library. Just clone the source code, then add the 'include' folder inside eventpp to your project include directory, then you can use the library.
96-
You don't need to link to any source code.
97-
98-
2, Or use vcpkg
99-
100-
```
101-
vcpkg install eventpp
102-
```
103-
104-
Then in your project CMakeLists.txt file, put below code, remember to replace ${TARGET} with your target,
105-
106-
```
107-
find_package(eventpp CONFIG REQUIRED)
108-
target_link_libraries(${TARGET} PRIVATE eventpp::eventpp)
109-
find_path(EVENTPP_INCLUDE_DIR eventpp/eventqueue.h)
110-
include_directories(${EVENTPP_INCLUDE_DIR})
111-
```
112-
113-
Then run cmake, note you need -DCMAKE_TOOLCHAIN_FILE to specify vcpkg, and replace -G with your generator
114-
```
115-
cmake .. -DCMAKE_TOOLCHAIN_FILE=VCPKGDIR/vcpkg/scripts/buildsystems/vcpkg.cmake -G"MinGW Makefiles"
116-
```
117-
118-
Note with vcpkg, only the released version can be used, which may be behind the latest update. You can't use the minor update on the master branch.
119-
120-
3, Or install using CMake and use it in CMake
121-
122-
If you are going to use eventpp in CMake managed project, you can install eventpp then use it in CMake.
123-
In eventpp root folder, run the commands,
124-
```
125-
mkdir build
126-
cd build
127-
cmake ..
128-
sudo make install
129-
```
130-
131-
Then in the project CMakeLists.txt,
132-
```
133-
# the project target is mytest, just for example
134-
add_executable(mytest test.cpp)
135-
136-
find_package(eventpp)
137-
if(eventpp_FOUND)
138-
target_link_libraries(mytest eventpp::eventpp)
139-
else(eventpp_FOUND)
140-
message(FATAL_ERROR "eventpp library is not found")
141-
endif(eventpp_FOUND)
142-
```
143-
144-
Note: when using the method 3 with MingW on Windows, by default CMake will install eventpp in system folder which is not writable. You should specify another folder to install. To do so, replace `cmake ..` with `cmake .. -DCMAKE_INSTALL_PREFIX="YOUR_NEW_LIB_FOLDER"`.
145-
146-
4, If you use Hunter package manager
147-
148-
You may follow the example code on [Hunter document](https://hunter.readthedocs.io/en/latest/packages/pkg/eventpp.html). Below is the code snippet I grabbed from that link,
149-
150-
```
151-
hunter_add_package(eventpp)
152-
find_package(eventpp CONFIG REQUIRED)
153-
154-
add_executable(main main.cpp)
155-
target_link_libraries(main eventpp::eventpp)
156-
include_directories(${EVENTPP_INCLUDE_DIR})
157-
```
91+
`eventpp` package is available in C++ package managers Vcpkg, Conan, and Hunter. There are various methods to use eventpp.
92+
Please [read the document](doc/install.md) for details.
15893

15994
### Using CallbackList
16095
```c++
@@ -209,6 +144,8 @@ queue.process();
209144

210145
## Documentations
211146

147+
* Setup
148+
* [Install and use eventpp in your project](doc/install.md)
212149
* Core classes and functions
213150
* [Overview](doc/introduction.md)
214151
* [Tutorials of CallbackList](doc/tutorial_callbacklist.md)
@@ -321,6 +258,7 @@ Added CallbackList, EventDispatcher, EventQueue, CounterRemover, ConditionalRemo
321258
<td align="center"><a href="https://github.com/sr-tream/"><img alt="sr-tream" src="https://github.com/sr-tream.png?s=100" width="100px;" /></a><span>sr-tream</span></td>
322259
<td align="center"><a href="https://github.com/Drise13/"><img alt="Drise13" src="https://github.com/Drise13.png?s=100" width="100px;" /></a><span>Drise13</span></td>
323260
<td align="center"><a href="https://github.com/iamzone/"><img alt="iamzone" src="https://github.com/iamzone.png?s=100" width="100px;" /></a><span>iamzone</span></td>
261+
<td align="center"><a href="https://github.com/RazielXYZ/"><img alt="RazielXYZ" src="https://github.com/RazielXYZ.png?s=100" width="100px;" /></a><span>RazielXYZ</span></td>
324262
</tr>
325263
</table>
326264

0 commit comments

Comments
 (0)