orc icon indicating copy to clipboard operation
orc copied to clipboard

Fix CMake modules for finding external libraries

Open lahwaacz opened this issue 7 months ago • 5 comments

What changes were proposed in this pull request?

  • allow finding header files in default paths - this is consistent with the logic for finding the library files
  • replace undefined variables ${SNAPPY_LIB_NAME} and ${LZ4_LIB_NAME} with the actual names

Why are the changes needed?

The CMake modules are broken. Building anything that depends on orc using cmake (e.g. Apache Arrow) does not work.

How was this patch tested?

Better than the original files :smirk:

Was this patch authored or co-authored using generative AI tooling?

No

lahwaacz avatar May 24 '25 14:05 lahwaacz

cc @wgtmac

dongjoon-hyun avatar May 24 '25 15:05 dongjoon-hyun

Thanks for creating this PR!

The CMake modules are broken. Building anything that depends on orc using cmake (e.g. Apache Arrow) does not work.

Could you elaborate this? I was thinking to remove these obsolete FindXXX.cmake files to use config mode of find_package so we don't have to maintain them.

wgtmac avatar May 26 '25 02:05 wgtmac

Could you elaborate this?

Try to build the latest orc version and then arrow using the following cmake options (notice especially -DARROW_DEPENDENCY_SOURCE=SYSTEM and -DARROW_ORC=ON)

https://gitlab.archlinux.org/archlinux/packaging/packages/arrow/-/blob/main/PKGBUILD?ref_type=heads#L80-120

I was thinking to remove these obsolete FindXXX.cmake files to use config mode of find_package so we don't have to maintain them.

The "config mode" is still looking for some .cmake file provided by the library you are finding. Many packages do that, including protobuf, snappy, and zstd, but some don't (e.g. lz4, zlib). But cmake also has its standard FindZLIB module so you don't have to reimplement your own.

lahwaacz avatar May 26 '25 05:05 lahwaacz

I think lz4 and zlib have exported their packages to be used by config mode:

  • https://github.com/lz4/lz4/blob/dev/build/cmake/lz4Config.cmake.in
  • https://github.com/madler/zlib/blob/develop/CMakeLists.txt#L240

wgtmac avatar May 26 '25 06:05 wgtmac

  • https://github.com/lz4/lz4/blob/dev/build/cmake/lz4Config.cmake.in

But if you install lz4 using a different build system (e.g. Arch Linux uses meson), the CMake integration files are not installed.

lahwaacz avatar May 26 '25 07:05 lahwaacz