summaryrefslogtreecommitdiff
path: root/3rdparty/cmake/FindFunctionLibrary.cmake
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-10-07 21:35:12 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-10-07 21:35:12 +0000
commit033373a5a75599f8607107cb28b97cc6a653b0b5 (patch)
treec520e925018ac7de37d05f690d357fcf55b56ec4 /3rdparty/cmake/FindFunctionLibrary.cmake
parent692dd1e5737b01ef26ba889f60d013cb992c3cec (diff)
downloadhercules-033373a5a75599f8607107cb28b97cc6a653b0b5.tar.gz
hercules-033373a5a75599f8607107cb28b97cc6a653b0b5.tar.bz2
hercules-033373a5a75599f8607107cb28b97cc6a653b0b5.tar.xz
hercules-033373a5a75599f8607107cb28b97cc6a653b0b5.zip
* Merged changes from trunk [14895:14966/trunk].
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/renewal@14967 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to '3rdparty/cmake/FindFunctionLibrary.cmake')
-rw-r--r--3rdparty/cmake/FindFunctionLibrary.cmake47
1 files changed, 47 insertions, 0 deletions
diff --git a/3rdparty/cmake/FindFunctionLibrary.cmake b/3rdparty/cmake/FindFunctionLibrary.cmake
new file mode 100644
index 000000000..f1d32001e
--- /dev/null
+++ b/3rdparty/cmake/FindFunctionLibrary.cmake
@@ -0,0 +1,47 @@
+# - Check which library is needed to link a C function
+# find_function_library( <function> <variable> [<library> ...] )
+#
+# Check which library provides the <function>.
+# Sets <variable> to 0 if found in the global libraries.
+# Sets <variable> to the library path if found in the provided libraries.
+# Raises a FATAL_ERROR if not found.
+#
+# The following variables may be set before calling this macro to
+# modify the way the check is run:
+#
+# CMAKE_REQUIRED_FLAGS = string of compile command line flags
+# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+# CMAKE_REQUIRED_INCLUDES = list of include directories
+# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+include( CheckFunctionExists )
+
+macro( find_function_library FUNC VAR )
+ if( "${VAR}" MATCHES "^${VAR}$" )
+ CHECK_FUNCTION_EXISTS( ${FUNC} ${VAR} )
+ if( ${VAR} )
+ message( STATUS "Found ${FUNC} in global libraries" )
+ set( ${VAR} 0 CACHE INTERNAL "Found ${FUNC} in global libraries" )# global
+ else()
+ foreach( LIB IN ITEMS ${ARGN} )
+ message( STATUS "Looking for ${FUNC} in ${LIB}" )
+ find_library( ${LIB}_LIBRARY ${LIB} )
+ mark_as_advanced( ${LIB}_LIBRARY )
+ if( ${LIB}_LIBRARY )
+ unset( ${VAR} CACHE )
+ set( CMAKE_REQUIRED_LIBRARIES ${${LIB}_LIBRARY} )
+ CHECK_FUNCTION_EXISTS( ${FUNC} ${VAR} )
+ set( CMAKE_REQUIRED_LIBRARIES )
+ if( ${VAR} )
+ message( STATUS "Found ${FUNC} in ${LIB}: ${${LIB}_LIBRARY}" )
+ set( ${VAR} ${${LIB}_LIBRARY} CACHE INTERNAL "Found ${FUNC} in ${LIB}" )# lib
+ break()
+ endif()
+ endif()
+ endforeach()
+ if( NOT ${VAR} )
+ message( FATAL_ERROR "Function ${FUNC} not found" )
+ endif()
+ endif()
+ endif()
+endmacro( find_function_library )
+