Emit service request stubs after relocation
[hiphop-php.git] / CMake / FindLibXed.cmake
blobf05ddc7dc12bbb059a31496868f7f03523332a94
1 find_path(LibXed_INCLUDE_DIR xed-interface.h)
2 find_library(LibXed_LIBRARY NAMES xed)
4 if (LibXed_INCLUDE_DIR AND LibXed_LIBRARY)
5   include(CheckCSourceRuns)
6   set(CMAKE_REQUIRED_INCLUDES ${LibXed_INCLUDE_DIR})
7   set(CMAKE_REQUIRED_LIBRARIES ${LibXed_LIBRARY})
8   check_c_source_runs("
9     #include <xed-interface.h>
10     #include <stdlib.h>
11     #include <string.h>
12     int main() {
13       const char* version = xed_get_version();
14       if(strlen(version) < 2) {
15         return -1;
16       }
17       // Format is Vxx.yy*
18       // we're only interested in the major version number
19       return !(atoi(version + 1) >= 10);
20     }"
21     LibXed_GOOD_VERSION)
22   set(CMAKE_REQUIRED_INCLUDES)
23   set(CMAKE_REQUIRED_LIBRARIES)
25   if (NOT LibXed_GOOD_VERSION)
26     message(STATUS "LibXed version check failed")
27   endif()
28 endif()
30 include(FindPackageHandleStandardArgs)
31 FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXed
32                                   DEFAULT_MSG
33                                   LibXed_LIBRARY
34                                   LibXed_INCLUDE_DIR
35                                   LibXed_GOOD_VERSION)
36 if (NOT LibXed_FOUND)
37   message(STATUS "Using third-party bundled LibXed")
38 else()
39   message(STATUS "Using LibXed from: ${LibXed_LIBRARY}")
40 endif()
42 mark_as_advanced(LibXed_INCLUDE_DIR LibXed_LIBRARY)