From 601171e427168ddff22da3793b945e208ebcd1d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rene=CC=81=20Schwaiger?= Date: Fri, 26 Oct 2018 18:51:43 +0200 Subject: [PATCH] Add Plugin: Fix linking of plugin test Before this update linking the unit test of the Base64 plugin would fail on Linux, reporting undefined references to `base64Decode` and `base64Encode`, if only `BUILD_FULL` was enabled. --- cmake/Modules/LibAddPlugin.cmake | 21 ++++++++++----------- src/plugins/base64/CMakeLists.txt | 11 +---------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/cmake/Modules/LibAddPlugin.cmake b/cmake/Modules/LibAddPlugin.cmake index e9f45288529..c3415b6bb63 100644 --- a/cmake/Modules/LibAddPlugin.cmake +++ b/cmake/Modules/LibAddPlugin.cmake @@ -107,19 +107,18 @@ function (add_plugintest testname) "${CMAKE_CURRENT_SOURCE_DIR}/testmod_${testname}.c") endif (ARG_CPP) - if (BUILD_SHARED) - set (PLUGIN_TARGET_OBJS "") - if (ARG_LINK_PLUGIN) - if (NOT ARG_LINK_PLUGIN STREQUAL "") - set (PLUGIN_TARGET_OBJS "$") - endif () - else () - set (PLUGIN_TARGET_OBJS "$") # assume that testcase+plugin to be - # tested have same name: + set (PLUGIN_TARGET_OBJS "") + if (ARG_LINK_PLUGIN) + if (NOT ARG_LINK_PLUGIN STREQUAL "") + set (PLUGIN_TARGET_OBJS "$") endif () - list (APPEND TEST_SOURCES - "${PLUGIN_TARGET_OBJS}") + else () + set (PLUGIN_TARGET_OBJS "$") # assume that testcase+plugin to be tested + # have same name: endif () + list (APPEND TEST_SOURCES + "${PLUGIN_TARGET_OBJS}") + set (testexename testmod_${testname}) add_executable (${testexename} ${TEST_SOURCES}) add_dependencies (${testexename} kdberrors_generated) diff --git a/src/plugins/base64/CMakeLists.txt b/src/plugins/base64/CMakeLists.txt index ddbb491639d..4ca1983d332 100644 --- a/src/plugins/base64/CMakeLists.txt +++ b/src/plugins/base64/CMakeLists.txt @@ -1,14 +1,5 @@ include (LibAddPlugin) -# We disable the test on Linux, if only `BUILD_FULL` is enabled. Otherwise the compiler reports errors about undefined references to -# `base64Encode` and `base64Decode`. See also: https://travis-ci.org/sanssecours/elektra/jobs/445799127. -set (DISABLE_TEST ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND ${BUILD_FULL} AND NOT ${BUILD_SHARED}) -if (${DISABLE_TEST}) - set (TEST_ARGUMENTS "") -else (${DISABLE_TEST}) - set (TEST_ARGUMENTS ADD_TEST) -endif (${DISABLE_TEST}) - add_plugin (base64 SOURCES base64_functions.h base64_functions.c @@ -17,5 +8,5 @@ add_plugin (base64 COMPILE_DEFINITIONS ELEKTRA_PLUGIN_NAME=\"base64\" ELEKTRA_PLUGIN_NAME_C=base64 TEST_README - ${TEST_ARGUMENTS} + ADD_TEST TEST_REQUIRED_PLUGINS ini)