libspatialaudio icon indicating copy to clipboard operation
libspatialaudio copied to clipboard

Library is built twice

Open sergiogf93 opened this issue 3 years ago • 3 comments

When using this library as a dependency called from a higher CMakeLists, when compiling with ninja an error is raised because the library is built both as a shared and a static library:

https://github.com/videolabs/libspatialaudio/blob/master/CMakeLists.txt#L15

Is there a way to avoid this and have it only built as shared for example?

sergiogf93 avatar Nov 01 '21 13:11 sergiogf93

Ah it seems I can overcome it by defining

set(BUILD_SHARED_LIBS OFF)

on the parent CMakeLists

sergiogf93 avatar Nov 01 '21 15:11 sergiogf93

Well, I notice that I need BUILD_SHARED_LIBS ON for the parent CMakeLists

sergiogf93 avatar Nov 02 '21 09:11 sergiogf93

I am having the same issue here. As we are integrating libspatialaudio through git submodule, any usage of global cmake flag (specifically, BUILD_SHARED_LIBS and BUILD_STATIC_LIBS) could lead to destructive conflicts to our project.

There seems to be a logical flaw as your team keep both default values to ON here https://github.com/videolabs/libspatialaudio/blob/6e158835a96df9d89aacea54b4792a8d092e34e4/CMakeLists.txt#L15-L16 The ninja compiler of Visual Studio 2019 will error out saying there are multiple build rules for libspatialaudio

If setting these Cmake options both ON are your intention, did you consider using a private option like BUILD_SPATIALAUDIO_AS_SHARED_LIBS and BUILD_SPATIALAUDIO_AS_STATIC_LIBS?

Stan230211 avatar Feb 08 '22 11:02 Stan230211