libcheck / check

A unit testing framework for C
GNU Lesser General Public License v2.1
1.07k stars 209 forks source link

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

Open tpetazzoni opened 1 month ago

tpetazzoni commented 1 month ago

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:

[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 tofini_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'