Skip to content

Commit

Permalink
Don't require file(1) when checking for libmagic
Browse files Browse the repository at this point in the history
Attempting to compile Twinkle on a system where file(1) is not available
currently produces a confusing error message about libmagic not being
found.

The only reason to require file(1) was to obtain the libmagic version,
as the MAGIC_VERSION constant was apparently only introduced in 5.13.
But since we don't need any particular version, we might as well drop
this requirement.

Using find_program() instead of find_path() avoids picking
/usr/include/file by mistake, which resulted in a (harmless) empty
version string in the CMake output.

(Thanks to https://bro-tracker.atlassian.net/browse/BIT-1096 for
providing some of this information.)
  • Loading branch information
fbriere committed Feb 9, 2018
1 parent a00e899 commit d219c85
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions cmake/FindLibMagic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#
# Variables defined by this module:
#
# LIBMAGIC_FOUND System has libmagic, magic.h, and file
# LibMagic_FILE_EXE Path to the 'file' command
# LibMagic_VERSION Version of libmagic
# LIBMAGIC_FOUND System has libmagic and magic.h
# LibMagic_FILE_EXE Path to the 'file' command (if available)
# LibMagic_VERSION Version of libmagic (if available)
# LibMagic_LIBRARY The libmagic library
# LibMagic_INCLUDE_DIR The location of magic.h

Expand All @@ -31,7 +31,7 @@ else ()
set(libmagic_names magic)
endif ()

find_file(LibMagic_FILE_EXE
find_program(LibMagic_FILE_EXE
NAMES file
HINTS ${LibMagic_ROOT_DIR}/bin
)
Expand Down Expand Up @@ -61,8 +61,6 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibMagic DEFAULT_MSG
LibMagic_LIBRARY
LibMagic_INCLUDE_DIR
LibMagic_FILE_EXE
LibMagic_VERSION
)

mark_as_advanced(
Expand Down

0 comments on commit d219c85

Please sign in to comment.