roehling / postsrsd

Postfix Sender Rewriting Scheme daemon
319 stars 38 forks source link

Build-error against local check/subunit - find_path() instead of find_library() #176

Closed ametzler closed 3 months ago

ametzler commented 3 months ago

Building 2.0.8 against check/subunit in /usr/lib (-DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=ALWAYS) fails with

cd /tmp/blah/postsrsd-2.0.8/obj-x86_64-linux-gnu/tests/unit && /usr/bin/cmake -E cmake_link_script CMakeFiles/test_netstring_executable.dir/link.txt --verbose=1
/usr/lib/ccache/cc -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/tmp/blah/postsrsd-2.0.8=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -O3 -DNDEBUG -Wl,-z,relro -Wl,-z,now -fsanitize=address,undefined CMakeFiles/test_netstring_executable.dir/test_netstring.c.o CMakeFiles/test_netstring_executable.dir/__/__/src/netstring.c.o -o test_netstring_executable  /usr/lib/x86_64-linux-gnu/libcheck_pic.a -lm /usr/lib/x86_64-linux-gnu/librt.a 
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libcheck_pic.a(check_log.o): in function `subunit_lfun':
(.text+0x606): undefined reference to `subunit_test_start'
/usr/bin/ld: (.text+0x61e): undefined reference to `subunit_test_pass'
/usr/bin/ld: (.text+0x639): undefined reference to `subunit_test_error'
/usr/bin/ld: (.text+0x651): undefined reference to `subunit_test_fail'

Afaict cmake/FindCheck.cmake has a bug:

find_path(Check_subunit_LIBRARY subunit HINTS ${PC_SUBUNIT_LIBRARY_DIRS})
...
        if(Check_subunit_LIBRARY)
            list(APPEND Check_DEPS "${Check_subunit_LIBRARY}")
        endif()

find_path(... subunit ...) will not succeed (there is no file named "subunit" in libdir) and if it did it would return the directory instead of the library. This should read

-    find_path(Check_subunit_LIBRARY subunit HINTS ${PC_SUBUNIT_LIBRARY_DIRS})
+    find_library(Check_subunit_LIBRARY subunit HINTS ${PC_SUBUNIT_LIBRARY_DIRS})
roehling commented 3 months ago

Thanks for the report! Fixed in d61379d2f745e56bccd3f437179b254669acfd25