machinezone / IXWebSocket

websocket and http client and server library, with TLS support and very few dependencies
BSD 3-Clause "New" or "Revised" License
512 stars 167 forks source link

Fix bad version variable #510

Closed LunarWatcher closed 3 months ago

LunarWatcher commented 3 months ago

397bb5d18a6fa5c37cf999339959efa1f58080c3 introduced a bug by using CMAKE_PROJECT_VERSION. While a valid variable, to quote the documentation,

This variable holds the version of the project as specified in the top level CMakeLists.txt file by a project() command

This is a problem if using IXWebSocket as a submodule, as IXWebSocket is no longer the top-level project in this scenario. Best-case, the version for the resulting shared library is wrong. Worst-case, which happened to a project of mine, no version is defined, and everything explodes. Because the variable is then interpreted to be empty, a set_target_properties call explodes, because it thinks it's missing an argument:

CMake Error at build/_deps/ixwebsocket-src/CMakeLists.txt:171 (set_target_properties):
    set_target_properties called with incorrect number of arguments. 

The correct variable to use is PROJECT_VERSION, which returns the VERSION option for the last project command, i.e. the one defined by IXWebSocket

LunarWatcher commented 3 months ago

Also, I'm not sure if whatever ixwebsocket.pc.in also needs an update with this change, but can do that if needed.