1
+ #-------------------------------------------------------------------------------
2
+ # Copyright (c) 2013-2013, Lars Baehren <[email protected] >
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without modification,
6
+ # are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above copyright notice,
11
+ # this list of conditions and the following disclaimer in the documentation
12
+ # and/or other materials provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ #-------------------------------------------------------------------------------
25
+
26
+ # - Check for the presence of LIBMAGIC
27
+ #
28
+ # The following variables are set when LIBMAGIC is found:
29
+ # LIBMAGIC_FOUND = Set to true, if all components of LIBMAGIC have been
30
+ # found.
31
+ # LIBMAGIC_INCLUDES = Include path for the header files of LIBMAGIC
32
+ # LIBMAGIC_LIBRARIES = Link these to use LIBMAGIC
33
+ # LIBMAGIC_LFLAGS = Linker flags (optional)
34
+
35
+ if (NOT LIBMAGIC_FOUND)
36
+
37
+ if (NOT LIBMAGIC_ROOT_DIR)
38
+ set (LIBMAGIC_ROOT_DIR ${CMAKE_INSTALL_PREFIX} )
39
+ endif (NOT LIBMAGIC_ROOT_DIR)
40
+
41
+ ##____________________________________________________________________________
42
+ ## Check for the header files
43
+
44
+ find_path (LIBMAGIC_FILE_H
45
+ NAMES file/file.h
46
+ HINTS ${LIBMAGIC_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
47
+ PATH_SUFFIXES include
48
+ )
49
+ if (LIBMAGIC_FILE_H)
50
+ list (APPEND LIBMAGIC_INCLUDES ${LIBMAGIC_FILE_H} )
51
+ endif (LIBMAGIC_FILE_H)
52
+
53
+ find_path (LIBMAGIC_MAGIC_H
54
+ NAMES magic.h
55
+ HINTS ${LIBMAGIC_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
56
+ PATH_SUFFIXES include include /linux
57
+ )
58
+ if (LIBMAGIC_MAGIC_H)
59
+ list (APPEND LIBMAGIC_INCLUDES ${LIBMAGIC_MAGIC_H} )
60
+ endif (LIBMAGIC_MAGIC_H)
61
+
62
+ list (REMOVE_DUPLICATES LIBMAGIC_INCLUDES)
63
+
64
+ ##____________________________________________________________________________
65
+ ## Check for the library
66
+
67
+ find_library (LIBMAGIC_LIBRARIES magic
68
+ HINTS ${LIBMAGIC_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
69
+ PATH_SUFFIXES lib
70
+ )
71
+
72
+ ##____________________________________________________________________________
73
+ ## Actions taken when all components have been found
74
+
75
+ find_package_handle_standard_args (LIBMAGIC DEFAULT_MSG LIBMAGIC_LIBRARIES LIBMAGIC_INCLUDES)
76
+
77
+ if (LIBMAGIC_FOUND)
78
+ if (NOT LIBMAGIC_FIND_QUIETLY)
79
+ message (STATUS "Found components for LIBMAGIC" )
80
+ message (STATUS "LIBMAGIC_ROOT_DIR = ${LIBMAGIC_ROOT_DIR} " )
81
+ message (STATUS "LIBMAGIC_INCLUDES = ${LIBMAGIC_INCLUDES} " )
82
+ message (STATUS "LIBMAGIC_LIBRARIES = ${LIBMAGIC_LIBRARIES} " )
83
+ endif (NOT LIBMAGIC_FIND_QUIETLY)
84
+ else (LIBMAGIC_FOUND)
85
+ if (LIBMAGIC_FIND_REQUIRED)
86
+ message (FATAL_ERROR "Could not find LIBMAGIC!" )
87
+ endif (LIBMAGIC_FIND_REQUIRED)
88
+ endif (LIBMAGIC_FOUND)
89
+
90
+ ##____________________________________________________________________________
91
+ ## Mark advanced variables
92
+
93
+ mark_as_advanced (
94
+ LIBMAGIC_ROOT_DIR
95
+ LIBMAGIC_INCLUDES
96
+ LIBMAGIC_LIBRARIES
97
+ )
98
+
99
+ endif (NOT LIBMAGIC_FOUND)
0 commit comments