Skip to content

Commit

Permalink
Add Plugin: Fix linking of plugin test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sanssecours committed Oct 26, 2018
1 parent ae16c4e commit 601171e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
21 changes: 10 additions & 11 deletions cmake/Modules/LibAddPlugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<no>")
set (PLUGIN_TARGET_OBJS "$<TARGET_OBJECTS:elektra-${ARG_LINK_PLUGIN}-objects>")
endif ()
else ()
set (PLUGIN_TARGET_OBJS "$<TARGET_OBJECTS:elektra-${testname}-objects>") # assume that testcase+plugin to be
# tested have same name:
set (PLUGIN_TARGET_OBJS "")
if (ARG_LINK_PLUGIN)
if (NOT ARG_LINK_PLUGIN STREQUAL "<no>")
set (PLUGIN_TARGET_OBJS "$<TARGET_OBJECTS:elektra-${ARG_LINK_PLUGIN}-objects>")
endif ()
list (APPEND TEST_SOURCES
"${PLUGIN_TARGET_OBJS}")
else ()
set (PLUGIN_TARGET_OBJS "$<TARGET_OBJECTS:elektra-${testname}-objects>") # 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)
Expand Down
11 changes: 1 addition & 10 deletions src/plugins/base64/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)

0 comments on commit 601171e

Please sign in to comment.