Skip to content

Conversation

DLWHI
Copy link

@DLWHI DLWHI commented Aug 5, 2025

When linking project by add_subdirectory(libsoundio_dir) project's include directories are not being propagated to linking project thus giving compilation errors. This can be fixed if in CMakeLists.txt:

include_directories(
   ${libsoundio_SOURCE_DIR}
   ${libsoundio_BINARY_DIR}
   "${libsoundio_SOURCE_DIR}/test"
   "${libsoundio_SOURCE_DIR}/src"

include_directores will be changed to:

target_include_directories(
   soundio
   ${libsoundio_SOURCE_DIR}
   ${libsoundio_BINARY_DIR}
   "${libsoundio_SOURCE_DIR}/test"
   "${libsoundio_SOURCE_DIR}/src"

and moved after add_library line. In order not to open too much interface to linking projects following line can be added after add_library instead of changing:

target_include_directories(
   soundio
   ${libsoundio_SOURCE_DIR}
)

Adding include directory to root of project and moving public includes there adds more protection to includes:

target_include_directories(
   soundio
   ${libsoundio_SOURCE_DIR}/include
)

@DLWHI DLWHI marked this pull request as draft August 5, 2025 07:30
@DLWHI
Copy link
Author

DLWHI commented Aug 5, 2025

After some research I came to conclusion that core changes to static/shared building would be good. I added switch using BUILD_STATIC_LIBS to either build static or shared target named soundio. This allows to add_subdirectory() project and link against one target.

@DLWHI DLWHI marked this pull request as ready for review August 5, 2025 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant