standalone asio test is complied even if only CLI_UseBoostAsio=ON
Overview
It seems that test_standaloneasioscheduler.cpp is to test non boost asio scheduler. However, it is compiled end outputs error with only CLI_UseBoostAsio=ON.
Environment
cli version
master af87753d86e5b2e16e5aebd07da7cd839a7fc4d
OS
Linux archlinux 6.8.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 16 Mar 2024 17:15:35 +0000 x86_64 GNU/Linux
Compiler
clang version 17.0.6 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
Reproduce
mkdir build
cd build
cmake -DCMAKE_CXX_COMPILER=clang++ -DCLI_UseBoostAsio=ON -DCLI_BuildTests=ON -DCLI_BuildExamples=ON .. && make
Error
[ 91%] Building CXX object test/CMakeFiles/test_suite.dir/test_standaloneasioscheduler.cpp.o
In file included from /home/kondo/work/cli/test/test_standaloneasioscheduler.cpp:31:
In file included from /home/kondo/work/cli/include/cli/standaloneasioscheduler.h:34:
/home/kondo/work/cli/include/cli/detail/standaloneasiolib.h:38:10: fatal error: 'asio/version.hpp' file not found
38 | #include <asio/version.hpp>
| ^~~~~~~~~~~~~~~~~~
1 error generated.
You're correct: currently, all tests are compiled regardless of the value of the CLI_UseBoostAsio option.
This was intentional to ensure that all parts of the library (both with boost and standalone asio) are thoroughly tested using a single build and test suite.
However, in this scenario, you need to provide both libraries to the compiler (I provide both ASIO_INCLUDEDIR and BOOST_ROOT to cmake).
Please let me know if you foresee any issues with this approach.
When I provide ASIO_INCLUDEDIR (/usr/include/boosr), then the include error is disappeared. It's nice.
However, the following new error is reported.
[ 54%] Building CXX object test/CMakeFiles/test_suite.dir/test_standaloneasioscheduler.cpp.o
In file included from /home/kondo/work/cli/test/test_standaloneasioscheduler.cpp:31:
In file included from /home/kondo/work/cli/include/cli/standaloneasioscheduler.h:34:
In file included from /home/kondo/work/cli/include/cli/detail/standaloneasiolib.h:41:
/home/kondo/work/cli/include/cli/detail/oldstandaloneasiolib.h:42:21: error: no namespace named 'asio'; did you mean 'boost::asio'?
42 | namespace asiolib = asio;
| ^~~~
| boost::asio
I think that in order to support boost asio and standalone asio, not only path fix but also namespace. Something like cli_asio.hpp as adaptor for both boost asio and standalone asio.
For the tests to build, you need to provide both libraries:
-DASIO_INCLUDEDIR=${ASIO_PATH} -DBOOST_ROOT=${BOOST_PATH}
this does not work:
-DASIO_INCLUDEDIR=${BOOST_PATH} -DBOOST_ROOT=${BOOST_PATH}