andreiavrammsd / cpp-channel

Thread-safe container for sharing data between threads
https://blog.andreiavram.ro/cpp-channel-thread-safe-container-share-data-threads/
MIT License
400 stars 28 forks source link

Minor fix #21

Closed tenheadedlion closed 2 years ago

tenheadedlion commented 2 years ago

Hi, the library is great, thanks!

I ran into some trivial problems when including this library, in my CMakeLists.txt I have the following statements:

include(FetchContent)
FetchContent_Declare(
  channel
  URL https://github.com/andreiavrammsd/cpp-channel/archive/refs/tags/v0.7.2.zip
)
FetchContent_MakeAvailable(channel)
include_directories(${channel_SOURCE_DIR}/include)

I noticed using FetchContent_MakeAvailable instead of FetchContent_Populate as in the example CMakeLists will give way to building tests and examples, which blocked the cmake for downloading and building googletest and generated a lot of binaries irrelevant to my project

So I wonder if it's appropriate to add some conditionals to CMakeLists.txt to control the building process, this PR will turn off the examples and tests building in default mode. After that, if the library users happen to use FetchContent_MakeAvailable incidentally, they won't have to build the tests and examples by default. The test is slow to initialize in regions with poor networks.

To enable them, we can run the following command:

cmake -Dcpp_channel_build_examples=ON -Dcpp_channel_build_tests=ON -Bbuild -H.

Also, when building my project with this library for the first time, I noticed the example code has an include problem, I am not using any IDE, so perhaps this is caused by IDEs?

Best regards!

andreiavrammsd commented 2 years ago

Thank you for using the library!