| Summary: | Concatenation of tdegraphics libs string causing build fail due to CMake policy CMP0004 | ||
|---|---|---|---|
| Product: | TDE | Reporter: | David C. Rankin <trin> |
| Component: | tdegraphics | Assignee: | Timothy Pearson <kb9vqf> |
| Status: | RESOLVED FIXED | ||
| Severity: | major | CC: | bugwatch, darrella |
| Priority: | P5 | ||
| Version: | R14.0.0 [Trinity] | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Compiler Version: | TDE Version String: | ||
| Application Version: | Application Name: | ||
| Attachments: |
patch for tdegraphics/libkscan/ConfigureChecks.cmake
patch for tdegraphics/libkscan/ConfigureChecks.cmake (update) patch for tdegraphics/libkscan/ConfigureChecks.cmake (update) |
||
Here is a patch that I think is the way this should be done. This set of regexes leave only a semi-colon separated list of libraries returned by 'sane-config --libs':
--- tdegraphics/libkscan/ConfigureChecks.cmake
+++ tdegraphics/libkscan/ConfigureChecks.cmake 2012-03-08 15:51:30.452794166 -0600
@@ -39,8 +39,14 @@
string( REGEX REPLACE "(^| )-I" ";" SANE_INCLUDE_DIRS "${SANE_INCLUDE_DIRS}" )
endif( )
if( SANE_LIBRARIES )
- string( REGEX REPLACE "(^| )-l" ";" SANE_LIBRARIES "${SANE_LIBRARIES}" )
- string( REPLACE " " "" SANE_LIBRARIES "${SANE_LIBRARIES}" )
+ ## remove all spaces and replace whitespace with ';'
+ string( REGEX REPLACE "[ ]+" ";" SANE_LIBRARIES "${SANE_LIBRARIES}" )
+ ## remove all non-library information
+ string( REGEX REPLACE "[-][^l]([^ ;])+" "" SANE_LIBRARIES "${SANE_LIBRARIES}" )
+ ## remove multiple ';'
+ string( REGEX REPLACE "[;]+" ";" SANE_LIBRARIES "${SANE_LIBRARIES}" )
+ ## remove '-l'
+ string( REGEX REPLACE "-l" "" SANE_LIBRARIES "${SANE_LIBRARIES}" )
endif( )
if( NOT HAVE_SANE )
Created attachment 469 [details]
patch for tdegraphics/libkscan/ConfigureChecks.cmake
Created attachment 470 [details]
patch for tdegraphics/libkscan/ConfigureChecks.cmake (update)
Oops, had to fix this one:
string( REGEX REPLACE ";[-][^l]([^ ;])+" "" SANE_LIBRARIES "${SANE_LIBRARIES}" )
Created attachment 471 [details]
patch for tdegraphics/libkscan/ConfigureChecks.cmake (update)
Uploaded wrong patch last time :)
I have confirmed this patch and it work flawlessly. tdegraphics built without issue using:
# patch ConfigureChecks.cmake
msg "Patching..."
patch -Np0 -i libkscan.patch
# fix libXext inclusion in linker string (gcc >=4.6.2)
msg "fixing libXext inclusion in linker string (gcc >=4.6.2)"
sed -i "/LINK/s|$| Xext|" tdegraphics/ksnapshot/CMakeLists.txt
msg "Creating out-of-source build directory: ${srcdir}/build"
mkdir -p build
cd build
msg "Starting cmake..."
cmake ${srcdir}/${pkgname#*-} \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_INSTALL_PREFIX=${TDEDIR} \
-DWITH_T1LIB=ON \
-DWITH_LIBPAPER=ON \
-DWITH_TIFF=ON \
-DWITH_OPENEXR=ON \
-DWITH_PDF=ON \
-DBUILD_ALL=ON
(In reply to comment #1) > + ## remove all non-library information > + string( REGEX REPLACE "[-][^l]([^ ;])+" "" SANE_LIBRARIES > "${SANE_LIBRARIES}" ) See comment 3 for proper patch, should be: + string( REGEX REPLACE ";[-][^l]([^ ;])+" "" SANE_LIBRARIES "${SANE_LIBRARIES}" ) I ran across this same bug when building tdegraphics on Slackware 13.37 (gcc 4.5.2, cmake 2.8.4). I never saw this bug with Slackware 13.1 (gcc 4.4.4, cmake 2.8.4). The patch was needed to build in 13.37. Patch pushed upstream in GIT hash cd3c62a5. This resolves the bug report. Thank you! |
Tim, Serghei, all tdegraphics fails to build due to a run-together of something like ${LIBS}${LDFLAGS} including libsane resulting in a link string that contains "-lsane-Wl" instead of "-lsane -Wl". After investigation and bug reports filed with Archlinux against net-snmp-config, the crux of the issue was discovered. The problem is NOT sane, NOT net-snmp-config, and not tdegraphics, the problem is the way CMAKE concatenates the library stings to include libsane. (something like ${LIBS}${LDFLAGS}.) The problem appears to start in tdegraphics/libkscan/ConfigureChecks.cmake Example: On Archlinux, sane-config --libs provides the following: -lsane -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -L/usr/lib -lnetsnmp -lcrypto -lm -ldl -lv4l1 -lm -ltiff -ljpeg -lgphoto2 -lgphoto2_port -lm -lexif -lusb -lavahi-common -lavahi-client -lusb After CMake processing with kdegraphics/libkscan/ConfigureChecks.cmake, the following linker string is provided: -lsane-Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu-L/usr/lib -lnetsnmp -lcrypto -lm -ldl -lv4l1 -ltiff -ljpeg -lgphoto2 -lgphoto2_port -lexif -lusb -lavahi-common -lavahi-client <snip /opt/trinity/...> The build then fails with: /usr/bin/ld: cannot find -lsane-Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu-L/usr/lib collect2: ld returned 1 exit status As Serghei pointed out, part of the concatenation occurs in tdegraphics/libkscan/ConfigureChecks.cmake: string( REGEX REPLACE "(^| )-l" ";" SANE_LIBRARIES "${SANE_LIBRARIES}" ) string( REPLACE " " "" SANE_LIBRARIES "${SANE_LIBRARIES}" ) On Arch, the first part of the sane-config libs is: -lsane -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -L/usr/lib -lnetsnmp -lcrypto The build failure is cause by the concatenation to: -lsane-Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu-L/usr/lib -lnetsnmp -lcrypto The string( REGEX REPLACE "(^| )-l" ";... and ... string( REPLACE " " "" ... has resulted in the run-together of both: -lsane-Wl and --hash-style=gnu-L/usr/lib I have looked, but I don't know where the actual concatenation is being done. It looks like a simple solution would be to change substitutions so that they prevent removing required spaces. I'll work on a patch and submit. If someone sees the solution already, feel welcome to provide it. I have tried removing the " " "" substitution, but that results in the error: CMake Error at cmake/modules/TDEMacros.cmake:662 (add_library): Target "kscan-shared" links to item "v4l1 " which has leading or trailing whitespace. This is now an error according to policy CMP0004. Call Stack (most recent call first): libkscan/CMakeLists.txt:38 (tde_add_library) So CMAKE policy CMP0004 seems to be the whole reason for the substitutions to begin with.