tests CMakeLists references target of samples CMaklists
Description
tests/PubSub/CMakeLists.txt
references target ($<TARGET_FILE:pubsub_server>
) of samples/PubSub_ClientServer
.
It seems wrong on several levels:
- Dependency from tests to samples targets shall be avoided,
tests
are for internal tests of the library whereassamples
are used to build examples based on the library API -
tests/PubSub/CMakeLists.txt
should contain tests on PubSub only, for tests on PubSub+Client/Server create atests/PubSub_ClientServer/CMakeLists.txt
- different combination of build options may lead the target in
samples
not to be available when expected intests
, e.g.:ENABLE_SAMPLES
,WITH_NANO_EXTENDED
,S2OPC_PUBSUB_ONLY
, etc. (some of theses are managed correctly now, other not !)
Fix
Several possibilities:
- As it was done for
toolkit_test_server
, if there is dependency onsample
code fortests
, build a new target intests
using the same sources than insamples
. It provides a way to manage all build options at same place. Moreover, create atests/PubSub_ClientServer
directory if needed to depend on both parts. This solution is only meant if the test is really a library test and not an application (here "sample") test. - If the tests really target to test application (here "samples") based on the libraries, tests shall be defined directly in the
samples
CMake build or in an additionaltest_samples
directory. Moreover those application may be moved in anapplication
directory if those are not really samples.
Edited by Vincent Monfort