DanBloomberg / leptonica

Leptonica is an open source library containing software that is broadly useful for image processing and image analysis applications. The official github repository for Leptonica is: danbloomberg/leptonica. See leptonica.org for more documentation.
Other
1.74k stars 387 forks source link

cmake build on systems with lib in lib64 is broken #693

Open satmandu opened 1 year ago

satmandu commented 1 year ago

I'm hacking up the cmake build files to get this to build correctly on x86_64 chromebrew, modifying these files, where #{ARCH_LIB} is either lib or lib64 on the relevant systems, but ideally we wouldn't have to engage in this hackery. 😅

sed -i 's,lib/cmake/leptonica,#{ARCH_LIB}/cmake/leptonica,g' CMakeLists.txt
sed -i 's,lib/pkgconfig,#{ARCH_LIB}/pkgconfig,g' CMakeLists.txt
sed -i 's,prefix}/lib,prefix}/#{ARCH_LIB},g' lept.pc.cmake
stweil commented 1 year ago

Do you want to send a pull request which fixes that? What about the automake build, does it also require a fix?

satmandu commented 1 year ago

The automake build is fine, but we prefer CMAKE as it tends to make for cleaner builds.

I think you need to support the cmake CMAKE_INSTALL_LIBDIR variable. Most packages do, but this isn't the only package that we've had to massage.

satmandu commented 1 year ago

Actually, CMAKE_LIBRARY_PATH seems to be the more universally used variable...

satmandu commented 1 year ago

See also https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html

satmandu commented 1 year ago

This might be sufficient:

# use GNU install dirs (e.g. lib64 instead of lib)
INCLUDE(GNUInstallDirs)

As per https://github.com/facebook/hhvm/blob/fdad0855eb63f528a357f11c5307df0ab29cec9b/CMakeLists.txt#L80

satmandu commented 1 year ago

Oops! I missed some! src/CMakeLists.txt also needs modification. set(lib ${CMAKE_SHARED_LIBRARY_PREFIX}) looks like it needs changing as does install(TARGETS leptonica EXPORT LeptonicaTargets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)

zdenop commented 1 year ago

Please make PR so we can test it. GNUInstallDirs could be useful for linux, not sure about Mac but I have doubt about Windows...