Build: link unit test statically

Link plugins statically for unit tests even if plugins enabled for
UltraGrid build. It allows to test functions more easily without the
hassle of runtime loading the functions from the dynamic libraries.
This commit is contained in:
Martin Pulec
2020-03-02 15:44:06 +01:00
parent 5bae8aaac2
commit 1386ffe50f
2 changed files with 15 additions and 4 deletions

View File

@@ -53,7 +53,7 @@ GENERATED_HEADERS = @GENERATED_HEADERS@
ALL_INCLUDES = $(wildcard $(srcdir)/src/*.h $(srcdir)/src/*/*.h $(srcdir)/src/*/*/*.h) $(wildcard $(srcdir)/unittest/*.h)
OBJS = @OBJS@ \
COMMON_OBJS = \
src/bitstream.o \
src/control_socket.o \
src/debug.o \
@@ -189,6 +189,9 @@ OBJS = @OBJS@ \
ldgm/matrix-gen/ldpc-matrix.o \
rs/fec.o \
OBJS = @OBJS@ \
$(COMMON_OBJS)
ULTRAGRID_OBJS = src/main.o \
REFLECTOR_OBJS = src/hd-rum-translator/hd-rum-decompress.o \
@@ -459,7 +462,9 @@ gui/QT/uv-qt: $(wildcard $(srcdir)/gui/QT/*.cpp $(srcdir)/gui/QT/*.hpp) $(srcdir
cd gui/QT && $(QMAKE) $(srcdir)/../../gui/QT && make -j 4
# -------------------------------------------------------------------------------------------------
TEST_OBJS = test/get_framerate_test.o \
TEST_OBJS = $(COMMON_OBJS) \
@TEST_OBJS@ \
test/get_framerate_test.o \
test/video_desc_test.o \
test/test_bitstream.o \
test/test_aes.o \
@@ -473,9 +478,9 @@ TEST_OBJS = test/get_framerate_test.o \
test/test_rtp.o \
test/run_tests.o
$(TEST_TARGET): $(TEST_OBJS) $(OBJS)
$(TEST_TARGET): $(TEST_OBJS) @TEST_OBJS@
$(MKDIR_P) $(dir $@)
$(LINKER) $(CFLAGS) $(TEST_OBJS) $(OBJS) $(LIBS) @CPPUNIT_LIBS@ -o $@
$(LINKER) $(LDFLAGS) $(TEST_OBJS) @TEST_LIBS@ @CPPUNIT_LIBS@ -o $@
ifeq ($(SYSTEM),Windows)
if [ -n "@DLL_LIBS@" ]; then $(INSTALL) -m 644 @DLL_LIBS@ bin; fi
endif

View File

@@ -3115,6 +3115,8 @@ AC_SUBST(CPPUNIT_LIBS)
# -------------------------------------------------------------------------------------------------
# We need to add libraries then
# -------------------------------------------------------------------------------------------------
TEST_LIBS="$LIB_MODULES $LIBS"
TEST_OBJS="$OBJS $LIB_OBJS $X_OBJ"
# this is only needed when passing to "clean" make target
if test "$build_libraries" != yes
@@ -3130,13 +3132,17 @@ fi
# remove duplicite objs
OBJS=`echo $OBJS | tr ' ' '\n' | sort | uniq | tr '\n' ' '`
TEST_OBJS=`echo $TEST_OBJS | tr ' ' '\n' | sort | uniq | tr '\n' ' '`
AC_SUBST(BIN_DEPS)
AC_SUBST(GENERATED_HEADERS)
AC_SUBST(LIB_GENERATED_HEADERS)
AC_SUBST(LIB_MODULES)
AC_SUBST(LIB_OBJS)
AC_SUBST(MODULES)
AC_SUBST(TARGETS)
AC_SUBST(TEST_LIBS)
AC_SUBST(TEST_OBJS)
# -------------------------------------------------------------------------------------------------
# Finally, substitute things into the Makefile and config.h