Disable /Zend/tests/inter_06.php in repo mode
[hiphop-php.git] / CMake / ExtZendCompat.cmake
blobc4640c2b9641bf7256365f1270db4a6d26539af3
1 option(ENABLE_ZEND_COMPAT "Enable Zend source compatibility (beta)" OFF)
3 set(ZEND_COMPAT_PROJECTS)
4 set(ZEND_COMPAT_BUILD_DIRS)
5 set(ZEND_COMPAT_EXCLUDE_IDLS)
6 set(ZEND_COMPAT_LINK_LIBRARIES)
8 # Look for projects
9 set(EZC_DIR "${HPHP_HOME}/hphp/runtime/ext_zend_compat/")
10 file(GLOB ezc_projects RELATIVE ${EZC_DIR} "${EZC_DIR}/*")
11 foreach(ezc_project ${ezc_projects})
12         get_filename_component(ezc_name ${ezc_project} NAME)
13         if ((NOT ${ezc_name} STREQUAL "php-src") AND (IS_DIRECTORY "${EZC_DIR}/${ezc_name}"))
14                 list(APPEND ZEND_COMPAT_PROJECTS ${ezc_name})
15         endif()
16 endforeach()
18 if (ENABLE_ZEND_COMPAT)
19         foreach(ezc_project ${ZEND_COMPAT_PROJECTS})
20                 if (${ezc_project} STREQUAL "yaml")
21                         find_package(LibYaml)
22                         if (LibYaml_INCLUDE_DIRS)
23                                 list(APPEND ZEND_COMPAT_BUILD_DIRS "${EZC_DIR}/yaml")
24                                 include_directories(${LibYaml_INCLUDE_DIRS})
25                                 list(APPEND ZEND_COMPAT_LINK_LIBRARIES ${LibYaml_LIBRARIES})
26                         else()
27                                 list(APPEND ZEND_COMPAT_EXCLUDE_IDLS "yaml.idl.json")
28                         endif()
29                 elseif (${ezc_project} STREQUAL "mongo")
30                         include_directories("${EZC_DIR}/mongo/mcon")
31                         list(APPEND ZEND_COMPAT_BUILD_DIRS "${EZC_DIR}/mongo")
32                 else()
33                         list(APPEND ZEND_COMPAT_BUILD_DIRS "${EZC_DIR}/${ezc_project}")
34                 endif()
35         endforeach()
37         if (ZEND_COMPAT_BUILD_DIRS)
38                 list(APPEND ZEND_COMPAT_BUILD_DIRS "${EZC_DIR}/php-src")
39                 include_directories("${EZC_DIR}/php-src")
40                 include_directories("${EZC_DIR}/php-src/main")
41                 include_directories("${EZC_DIR}/php-src/Zend")
42                 include_directories("${EZC_DIR}/php-src/TSRM")
43         endif()
44 else()
45         foreach(ezc_project ${ZEND_COMPAT_PROJECTS})
46                 list(APPEND ZEND_COMPAT_EXCLUDE_IDLS "${ezc_project}.idl.json")
47         endforeach()
48 endif()
50 # This is really ugly, but cmake's list(FIND)
51 # doesn't entirely work the way it should
52 macro(ZEND_COMPAT_STRIP_IDLS IDLS)
53         foreach(idl ${${IDLS}})
54                 get_filename_component(idl_name ${idl} NAME)
55                 foreach(f ${ARGV})
56                         if (${idl_name} STREQUAL ${f})
57                                 list(REMOVE_ITEM ${IDLS} ${idl})
58                         endif()
59                 endforeach()
60         endforeach()
61 endmacro()