Skip to content

Commit

Permalink
Merge pull request #359 from redboltz/add_cmake_option_to_build_separ…
Browse files Browse the repository at this point in the history
…ate_example

Added ASYNC_MQTT_BUILD_EXAMPLES_SEPARATE cmake option.
  • Loading branch information
redboltz authored Oct 12, 2024
2 parents d0966f1 + e11b369 commit 51a97ad
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
41 changes: 22 additions & 19 deletions .github/workflows/gha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ jobs:
export CFLAGS=${NS_CFLAGS} && export CXXFLAGS=${NS_CXXFLAGS} && export LDFLAGS=${NS_LDFLAGS}
[ ${{ matrix.pattern }} == 3 ] && \
export CFLAGS=${NS_CFLAGS} && export CXXFLAGS="${PROF_CXXFLAGS} "&& export LDFLAGS=${NS_LDFLAGS}
[ ${{ matrix.pattern }} == 0 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=ON -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=ON "
[ ${{ matrix.pattern }} == 1 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=ON -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=OFF -DASYNC_MQTT_BUILD_EXAMPLES=ON "
[ ${{ matrix.pattern }} == 2 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=ON -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=ON "
[ ${{ matrix.pattern }} == 0 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=ON -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=ON -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE=ON "
[ ${{ matrix.pattern }} == 1 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=ON -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=OFF -DASYNC_MQTT_BUILD_EXAMPLES=ON -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE=ON "
[ ${{ matrix.pattern }} == 2 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=ON -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=ON -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE=ON "
[ ${{ matrix.pattern }} == 3 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=ON -DASYNC_MQTT_USE_WS=ON -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=OFF "
FLAGS="${FLAGS} -DASYNC_MQTT_BUILD_TOOLS=ON -DASYNC_MQTT_BUILD_UNIT_TESTS=ON -DASYNC_MQTT_BUILD_SYSTEM_TESTS=ON"
cmake -S ${{ github.workspace }} -B ${{ runner.temp }} ${FLAGS} -DCMAKE_C_FLAGS="${CFLAGS}" -DCMAKE_CXX_FLAGS="${CXXFLAGS}" -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}"
Expand Down Expand Up @@ -106,9 +106,9 @@ jobs:
export CFLAGS=${NS_CFLAGS} && export CXXFLAGS=${NS_CXXFLAGS} && export LDFLAGS=${NS_LDFLAGS}
[ ${{ matrix.pattern }} == 3 ] && \
export CFLAGS=${NS_CFLAGS} && export CXXFLAGS=${NS_CXXFLAGS_GCC} && export LDFLAGS=${NS_LDFLAGS}
[ ${{ matrix.pattern }} == 0 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=ON -DASYNC_MQTT_PRINT_PAYLOAD=OFF -DASYNC_MQTT_BUILD_EXAMPLES=ON "
[ ${{ matrix.pattern }} == 1 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=ON -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=ON "
[ ${{ matrix.pattern }} == 2 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=ON -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=ON "
[ ${{ matrix.pattern }} == 0 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=ON -DASYNC_MQTT_PRINT_PAYLOAD=OFF -DASYNC_MQTT_BUILD_EXAMPLES=ON -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE=ON "
[ ${{ matrix.pattern }} == 1 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=ON -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=ON -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE=ON "
[ ${{ matrix.pattern }} == 2 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=ON -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=ON -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE=ON "
[ ${{ matrix.pattern }} == 3 ] && FLAGS="-DCMAKE_CXX_COMPILER=g++ -DASYNC_MQTT_USE_TLS=ON -DASYNC_MQTT_USE_WS=ON -DASYNC_MQTT_USE_STR_CHECK=OFF -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=OFF -DASYNC_MQTT_BUILD_EXAMPLES=OFF "
FLAGS="$FLAGS -DASYNC_MQTT_BUILD_TOOLS=ON -DASYNC_MQTT_BUILD_UNIT_TESTS=ON -DASYNC_MQTT_BUILD_SYSTEM_TESTS=ON"
BOOST_ROOT=/home/runner/work/async_mqtt/async_mqtt/usr cmake -S ${{ github.workspace }} -B ${{ runner.temp }} ${FLAGS} -DCMAKE_C_FLAGS="${CFLAGS}" -DCMAKE_CXX_FLAGS="${CXXFLAGS}" -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}"
Expand Down Expand Up @@ -152,29 +152,32 @@ jobs:
run: |
echo ${{ matrix.pattern }}
if (${{ matrix.pattern }} -eq 0) {
$BUILD_TOOLS = "OFF"
$BUILD_EXAMPLES = "OFF"
$BUILD_UNIT_TESTS = "ON"
$BUILD_SYSTEM_TESTS = "OFF"
$BUILD_TOOLS = "OFF"
$BUILD_EXAMPLES = "OFF"
$BUILD_EXAMPLES_SEPARATE = "OFF"
$BUILD_UNIT_TESTS = "ON"
$BUILD_SYSTEM_TESTS = "OFF"
}
if (${{ matrix.pattern }} -eq 1) {
$BUILD_TOOLS = "ON"
$BUILD_EXAMPLES = "OFF"
$BUILD_UNIT_TESTS = "OFF"
$BUILD_SYSTEM_TESTS = "ON"
$BUILD_TOOLS = "ON"
$BUILD_EXAMPLES = "OFF"
$BUILD_EXAMPLES_SEPARATE = "OFF"
$BUILD_UNIT_TESTS = "OFF"
$BUILD_SYSTEM_TESTS = "ON"
}
if (${{ matrix.pattern }} -eq 2) {
$BUILD_TOOLS = "OFF"
$BUILD_EXAMPLES = "ON"
$BUILD_UNIT_TESTS = "OFF"
$BUILD_SYSTEM_TESTS = "OFF"
$BUILD_TOOLS = "OFF"
$BUILD_EXAMPLES = "ON"
$BUILD_EXAMPLES_SEPARATE = "ON"
$BUILD_UNIT_TESTS = "OFF"
$BUILD_SYSTEM_TESTS = "OFF"
}
$env:BOOST_ROOT="$PWD\boost"
mkdir build
cd build
$env:CL="/D_WIN32_WINNT#0x0A00 /DBOOST_THREAD_VERSION#3 /DBOOST_ASIO_NO_DEPRECATED /bigobj /EHsc /Zc:preprocessor"
$env:PATH="$env:BOOST_ROOT\lib;"+$env:PATH
cmake -A x64 -G "Visual Studio 16 2019" -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_LOG=ON -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_SYSTEM_TESTS="$BUILD_SYSTEM_TESTS" -DASYNC_MQTT_BUILD_UNIT_TESTS="$BUILD_UNIT_TESTS" -DASYNC_MQTT_BUILD_EXAMPLES="$BUILD_EXAMPLES" -DASYNC_MQTT_BUILD_TOOLS="$BUILD_TOOLS" ..
cmake -A x64 -G "Visual Studio 16 2019" -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_LOG=ON -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_SYSTEM_TESTS="$BUILD_SYSTEM_TESTS" -DASYNC_MQTT_BUILD_UNIT_TESTS="$BUILD_UNIT_TESTS" -DASYNC_MQTT_BUILD_EXAMPLES="$BUILD_EXAMPLES" -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE="$BUILD_EXAMPLES_SEPARATE" -DASYNC_MQTT_BUILD_TOOLS="$BUILD_TOOLS" ..
if (!$?) {
return Write-Error "cmake failed"
}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
= History

== 9.0.2
* Added ASYNC_MQTT_BUILD_EXAMPLES_SEPARATE option to enable library separate build example. #359
* Fixed TLS timeout logic. #357
* Fixed broker auth file for docker. #356

Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ option(ASYNC_MQTT_BUILD_UNIT_TESTS "Enable building unit tests" OFF)
option(ASYNC_MQTT_BUILD_SYSTEM_TESTS "Enable building system tests" OFF)
option(ASYNC_MQTT_BUILD_TOOLS "Enable building tools (broker, bench, etc.." OFF)
option(ASYNC_MQTT_BUILD_EXAMPLES "Enable building example applications" OFF)
option(ASYNC_MQTT_BUILD_EXAMPLES_SEPARATE "Enable building separate library build example applications(It requires much memory)" OFF)
option(ASYNC_MQTT_BUILD_LIB "Enable building separate compilation library" OFF)

# Not implemented yet
Expand Down
3 changes: 3 additions & 0 deletions doc/CHANGELOG.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ <h2 id="_9_0_2">9.0.2</h2>
<div class="ulist">
<ul>
<li>
<p>Added ASYNC_MQTT_BUILD_EXAMPLES_SEPARATE option to enable library separate build example. #359</p>
</li>
<li>
<p>Fixed TLS timeout logic. #357</p>
</li>
<li>
Expand Down
4 changes: 4 additions & 0 deletions doc/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ <h2 id="_cmake">cmake</h2>
<td class="tableblock halign-left valign-top"><p class="tableblock">Build examples</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">ASYNC_MQTT_BUILD_EXAMPLES_SEPARATE</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Build examples for separate library build. It requires much memory.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">ASYNC_MQTT_BUILD_LIB</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Build separate compiled library</p></td>
</tr>
Expand Down
7 changes: 4 additions & 3 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ if("cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
cl_cpp20coro_mqtt_sub.cpp
ep_cpp20coro_mqtt_client.cpp
)

add_subdirectory(separate_client)
add_subdirectory(separate_endpoint)
if(ASYNC_MQTT_BUILD_EXAMPLE_SEPARATE)
add_subdirectory(separate_client)
add_subdirectory(separate_endpoint)
endif()
endif()

if(ASYNC_MQTT_USE_TLS)
Expand Down

0 comments on commit 51a97ad

Please sign in to comment.