1 # - Set of macros and functions that are useful for building the EFL port.
3 # The following functions are currently defined:
4 # FIND_EFL_LIBRARY(<name> HEADERS <header1> ... HEADER_PREFIXES <prefix1> ... LIBRARY <libname>)
5 # Looks for the header files inside the given prefix directories, and for the library
6 # passed to the LIBRARY parameter.
7 # Two #defines in the form <UPPERCASED_NAME>_VERSION_MAJOR and <UPPERCASED_NAME>_VERSION_MINOR
8 # are looked for in all the given headers, and the first occurrence is used to build the library's
10 # This function defines the following variables:
11 # - <UPPERCASED_NAME>_INCLUDE_DIRS: All the directories required by this library's headers.
12 # - <UPPERCASED_NAME>_LIBRARIES: All the libraries required to link against this library.
13 # - <UPPERCASED_NAME>_VERSION: The library's version in the format "major.minor".
15 # Copyright (C) 2012 Intel Corporation. All rights reserved.
17 # Redistribution and use in source and binary forms, with or without
18 # modification, are permitted provided that the following conditions
20 # 1. Redistributions of source code must retain the above copyright
21 # notice, this list of conditions and the following disclaimer.
22 # 2. Redistributions in binary form must reproduce the above copyright
23 # notice, this list of conditions and the following disclaimer in the
24 # documentation and/or other materials provided with the distribution.
26 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
27 # IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
30 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
33 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
35 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 INCLUDE(CMakeParseArguments)
40 FUNCTION(FIND_EFL_LIBRARY _name)
41 CMAKE_PARSE_ARGUMENTS(PARAM "" "LIBRARY" "HEADERS;HEADER_PREFIXES" ${ARGN})
43 STRING(TOUPPER ${_name} _name_upper)
44 SET(_version_found FALSE)
46 FOREACH (_current_header ${PARAM_HEADERS})
47 FIND_PATH(${_current_header}_INCLUDE_DIR NAMES ${_current_header} PATH_SUFFIXES ${PARAM_HEADER_PREFIXES})
48 LIST(APPEND ${_name}_INCLUDE_DIRS "${${_current_header}_INCLUDE_DIR}")
50 IF (NOT _version_found)
51 SET (_header_path "${${_current_header}_INCLUDE_DIR}/${_current_header}")
52 IF (EXISTS ${_header_path})
53 FILE(READ "${_header_path}" _header_contents)
55 STRING(REGEX MATCH "#define +${_name_upper}_VERSION_MAJOR +([0-9]+)" _dummy "${_header_contents}")
56 SET(_version_major "${CMAKE_MATCH_1}")
57 STRING(REGEX MATCH "#define +${_name_upper}_VERSION_MINOR +([0-9]+)" _dummy "${_header_contents}")
58 SET(_version_minor "${CMAKE_MATCH_1}")
60 IF (_version_major AND _version_minor)
61 SET(_version_found TRUE)
67 FIND_LIBRARY(${_name}_LIBRARIES NAMES ${PARAM_LIBRARY})
69 SET(${_name}_INCLUDE_DIRS ${${_name}_INCLUDE_DIRS} PARENT_SCOPE)
70 SET(${_name}_LIBRARIES ${${_name}_LIBRARIES} PARENT_SCOPE)
71 SET(${_name}_VERSION "${_version_major}.${_version_minor}" PARENT_SCOPE)