summaryrefslogtreecommitdiffstats
path: root/cmake/modules/Findfstrcmp.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/modules/Findfstrcmp.cmake')
-rw-r--r--cmake/modules/Findfstrcmp.cmake80
1 files changed, 80 insertions, 0 deletions
diff --git a/cmake/modules/Findfstrcmp.cmake b/cmake/modules/Findfstrcmp.cmake
new file mode 100644
index 0000000..f0c15d3
--- /dev/null
+++ b/cmake/modules/Findfstrcmp.cmake
@@ -0,0 +1,80 @@
1#.rst:
2# Findfstrcmp
3# --------
4# Finds the fstrcmp library
5#
6# This will define the following variables::
7#
8# FSTRCMP_FOUND - system has libfstrcmp
9# FSTRCMP_INCLUDE_DIRS - the libfstrcmp include directory
10# FSTRCMP_LIBRARIES - the libfstrcmp libraries
11#
12
13if(ENABLE_INTERNAL_FSTRCMP)
14 include(ExternalProject)
15 file(STRINGS ${CMAKE_SOURCE_DIR}/tools/depends/target/libfstrcmp/Makefile VER)
16 string(REGEX MATCH "VERSION=[^ ]*" FSTRCMP_VER "${VER}")
17 list(GET FSTRCMP_VER 0 FSTRCMP_VER)
18 string(SUBSTRING "${FSTRCMP_VER}" 8 -1 FSTRCMP_VER)
19
20 # allow user to override the download URL with a local tarball
21 # needed for offline build envs
22 if(FSTRCMP_URL)
23 get_filename_component(FSTRCMP_URL "${FSTRCMP_URL}" ABSOLUTE)
24 else()
25 set(FSTRCMP_URL http://mirrors.kodi.tv/build-deps/sources/fstrcmp-${FSTRCMP_VER}.tar.gz)
26 endif()
27 if(VERBOSE)
28 message(STATUS "FSTRCMPURL: ${FSTRCMP_URL}")
29 endif()
30
31 set(FSTRCMP_LIBRARY ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/lib/libfstrcmp.a)
32 set(FSTRCMP_INCLUDE_DIR ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/include)
33 externalproject_add(fstrcmp
34 URL ${FSTRCMP_URL}
35 DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/download
36 PREFIX ${CORE_BUILD_DIR}/fstrcmp
37 CONFIGURE_COMMAND autoreconf -vif && ./configure --prefix ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}
38 BUILD_BYPRODUCTS ${FSTRCMP_LIBRARY}
39 BUILD_IN_SOURCE 1)
40 set_target_properties(fstrcmp PROPERTIES FOLDER "External Projects")
41
42 include(FindPackageHandleStandardArgs)
43 find_package_handle_standard_args(fstrcmp
44 REQUIRED_VARS FSTRCMP_LIBRARY FSTRCMP_INCLUDE_DIR
45 VERSION_VAR FSTRCMP_VER)
46
47 set(FSTRCMP_LIBRARIES -Wl,-Bstatic ${FSTRCMP_LIBRARY} -Wl,-Bdynamic)
48 set(FSTRCMP_INCLUDE_DIRS ${FSTRCMP_INCLUDE_DIR})
49else()
50 if(PKG_CONFIG_FOUND)
51 pkg_check_modules(PC_FSTRCMP fstrcmp QUIET)
52 endif()
53
54 find_path(FSTRCMP_INCLUDE_DIR NAMES fstrcmp.h
55 PATHS ${PC_FSTRCMP_INCLUDEDIR})
56
57 find_library(FSTRCMP_LIBRARY NAMES fstrcmp
58 PATHS ${PC_FSTRCMP_LIBDIR})
59
60 set(FSTRCMP_VERSION ${PC_FSTRCMP_VERSION})
61
62 include(FindPackageHandleStandardArgs)
63 find_package_handle_standard_args(fstrcmp
64 REQUIRED_VARS FSTRCMP_LIBRARY FSTRCMP_INCLUDE_DIR
65 VERSION_VAR FSTRCMP_VERSION)
66
67 if(FSTRCMP_FOUND)
68 set(FSTRCMP_INCLUDE_DIRS ${FSTRCMP_INCLUDE_DIR})
69 set(FSTRCMP_LIBRARIES ${FSTRCMP_LIBRARY})
70 endif()
71
72 if(NOT TARGET fstrcmp)
73 add_library(fstrcmp UNKNOWN IMPORTED)
74 set_target_properties(fstrcmp PROPERTIES
75 IMPORTED_LOCATION "${FSTRCMP_LIBRARY}"
76 INTERFACE_INCLUDE_DIRECTORIES "${FSTRCMP_INCLUDE_DIR}")
77 endif()
78endif()
79
80mark_as_advanced(FSTRCMP_INCLUDE_DIR FSTRCMP_LIBRARY)