socketio / socket.io-client-cpp

C++11 implementation of Socket.IO client
MIT License
2.26k stars 730 forks source link

Fix building issue on vcpkg #416

Closed Nukoooo closed 10 months ago

Nukoooo commented 11 months ago

I guess you forgot to add BUILD_TESTING check when making this change :^)

jmigual commented 11 months ago

Hi @Nukoooo I don't think I forgot. This is on purpose so the tests are build by default if this is the main project, i.e., if it's not an imported project. This code is extracted from the examples of the modern CMake book (https://gitlab.com/CLIUtils/modern-cmake/-/blob/master/examples/extended-project/CMakeLists.txt).

Why do you think it's an issue?

Nukoooo commented 11 months ago

Because I was trying to update the library in vcpkg with commit 0dc2f7afea17a0e5bfb5e9b1e6d6f26ab1455cef, and it threw this error:

CMake Error at test/CMakeLists.txt:13 (target_link_libraries):
  Target "sio_test" links to:

    Catch2::Catch2WithMain

From what I understand is that vcpkg pulls the source code and builds it as a main project, which passes the CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME, hence the error is thrown. Currently I can't think of a better way to fix tihs problem but adding BUILD_TEST check

Nukoooo commented 10 months ago

Closing as someone created this PR https://github.com/microsoft/vcpkg/pull/36226