Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/CMakeLists.txt: don't build shared libraries when not enabled #355

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tpetazzoni
Copy link

BUILD_SHARED_LIBS is a standard CMake option [1] that specifies whether shared libraries should be built or not. This commit adjusts src/CMakeLists.txt to observe this variable to decide whether the shared library variant should be built or not. This allows check to only build a static library in environments where only a static library can be compiled.

This needs a bit of refactoring to avoid duplication:

  • Additional source files from libcompat are directly added to the ${SOURCES} variable as needed

  • Additional libraries are collected into ${ADDITIONAL_LIBS} before being associated to the static library and shared library (if enabled)

[1] https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html

Fixes:

__uClibc_main.c:(.text+0x12c): undefined reference to __fini_array_end' /home/autobuild/autobuild/instance-20/output-1/host/lib/gcc/sparc-buildroot-linux-uclibc/13.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: __uClibc_main.c:(.text+0x130): undefined reference to __fini_array_start'
/home/autobuild/autobuild/instance-20/output-1/host/lib/gcc/sparc-buildroot-linux-uclibc/13.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: __uClibc_main.c:(.text+0x134): undefined reference to `__fini_array_end'

BUILD_SHARED_LIBS is a standard CMake option [1] that specifies
whether shared libraries should be built or not. This commit adjusts
src/CMakeLists.txt to observe this variable to decide whether the
shared library variant should be built or not. This allows check to
only build a static library in environments where only a static
library can be compiled.

This needs a bit of refactoring to avoid duplication:

- Additional source files from libcompat are directly added to the
  ${SOURCES} variable as needed

- Additional libraries are collected into ${ADDITIONAL_LIBS} before
  being associated to the static library and shared library (if enabled)

[1] https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html

Fixes:

__uClibc_main.c:(.text+0x12c): undefined reference to `__fini_array_end'
/home/autobuild/autobuild/instance-20/output-1/host/lib/gcc/sparc-buildroot-linux-uclibc/13.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: __uClibc_main.c:(.text+0x130): undefined reference to `__fini_array_start'
/home/autobuild/autobuild/instance-20/output-1/host/lib/gcc/sparc-buildroot-linux-uclibc/13.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: __uClibc_main.c:(.text+0x134): undefined reference to `__fini_array_end'

Signed-off-by: Thomas Petazzoni <[email protected]>
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