Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
beef9999 committed Nov 15, 2023
1 parent b089754 commit 67c5c13
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
14 changes: 12 additions & 2 deletions doc/docs/introduction/how-to-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,18 @@ ctest

#### Example

If there is any shared lib you don't want Photon to link to on local host, build its static from source.
Build all the dependencies from source, so you can distribute Photon binary anywhere, as long as libc and libc++ versions suffice.

```bash
cmake -B build -D PHOTON_BUILD_DEPENDENCIES=ON -D PHOTON_GFLAGS_SOURCE=https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz
cmake -B build -D CMAKE_BUILD_TYPE=RelWithDebInfo \
-D PHOTON_BUILD_TESTING=ON \
-D PHOTON_BUILD_DEPENDENCIES=ON \
-D PHOTON_ENABLE_URING=ON \
-D PHOTON_AIO_SOURCE=https://pagure.io/libaio/archive/libaio-0.3.113/libaio-0.3.113.tar.gz \
-D PHOTON_ZLIB_SOURCE=https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.gz \
-D PHOTON_URING_SOURCE=https://github.com/axboe/liburing/archive/refs/tags/liburing-2.3.tar.gz \
-D PHOTON_CURL_SOURCE=https://github.com/curl/curl/archive/refs/tags/curl-7_42_1.tar.gz \
-D PHOTON_OPENSSL_SOURCE=https://github.com/openssl/openssl/archive/refs/heads/OpenSSL_1_0_2-stable.tar.gz \
-D PHOTON_GFLAGS_SOURCE=https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz \
-D PHOTON_GOOGLETEST_SOURCE=https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz
```
16 changes: 7 additions & 9 deletions doc/docs/introduction/how-to-integrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toc_max_heading_level: 4

We recommend using CMake's `FetchContent` to integrate Photon into your existing C++ project.

It will download source code from the remote repo and track along with the dependencies (for example, liburing).
It will download source code from the remote repo and track along with the third-party dependencies.

### Modify your `CMakeLists.txt`

Expand All @@ -30,42 +30,40 @@ FetchContent_Declare(
GIT_TAG main
)
FetchContent_MakeAvailable(photon)
set(PHOTON_INCLUDE_DIR ${photon_SOURCE_DIR}/include/)
```

### Case 1: Statically linking your app with Photon

```cmake
add_executable(my_app ${SOURCES})
target_include_directories(my_app PRIVATE ${PHOTON_INCLUDE_DIR})
target_link_libraries(my_app photon_static)
```

### Case 2: Dynamically linking your app with Photon

```cmake
add_executable(my_app ${SOURCES})
target_include_directories(my_app PRIVATE ${PHOTON_INCLUDE_DIR})
target_link_libraries(my_app photon_shared)
```

### Case 3: Add Photon into your static lib

```cmake
add_library(my_lib STATIC ${SOURCES})
target_include_directories(my_lib PRIVATE ${PHOTON_INCLUDE_DIR})
target_link_libraries(my_lib photon_static)
target_link_libraries(my_lib PRIVATE photon_static)
```

### Case 4: Add Photon into your shared lib

```cmake
add_library(my_lib SHARED ${SOURCES})
target_include_directories(my_lib PRIVATE ${PHOTON_INCLUDE_DIR})
target_link_libraries(my_lib -Wl,--whole-archive photon_static -Wl,--no-whole-archive)
target_link_libraries(my_lib PRIVATE -Wl,--whole-archive libphoton.a -Wl,--no-whole-archive)
```

:::note
The `photon_static` and `photon_shared` targets have already configured include directories for you.
:::

:::note

If your lib needs to be installed via CMake's `install(EXPORT)`, you should change `photon_static` to `$<BUILD_INTERFACE:photon_static>` to avoid exporting libphoton.a
Expand Down
3 changes: 0 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ target_link_libraries(rpc-example-server PRIVATE photon_static)
add_executable(sync-primitive sync-primitive/sync-primitive.cpp)
target_link_libraries(sync-primitive PRIVATE photon_static)

add_executable(sync-primitive sync-primitive/sync-primitive.cpp)
target_link_libraries(sync-primitive PRIVATE photon_static ${testing_libs})

if (ENABLE_FSTACK_DPDK)
add_executable(fstack-dpdk-demo fstack-dpdk/fstack-dpdk-demo.cpp)
target_link_libraries(fstack-dpdk-demo PRIVATE fstack_dpdk photon_static)
Expand Down

0 comments on commit 67c5c13

Please sign in to comment.