Introduce Type "Phases" By Utilizing GADTs
[hiphop-php.git] / CMake / HPHPIZEFunctions.cmake
blob53d9c5d1926b8e2654bf0cb93b0111f7ebc0055d
1 # Functions for use when building extensions dynamically
3 # These functions also exist in CMake/EXTFunctions.cmake
4 # Their signatures should be kept consistent, though their behavior
5 # will differ slightly.
7 function(HHVM_LINK_LIBRARIES EXTNAME)
8   target_link_libraries(${EXTNAME} ${ARGN})
9 endfunction()
11 function(HHVM_ADD_INCLUDES EXTNAME)
12   include_directories(${ARGN})
13 endfunction()
15 # Add an extension
16 function(HHVM_EXTENSION EXTNAME)
17   set(EXTENSION_NAME ${EXTNAME} CACHE INTERNAL "")
18   add_library(${EXTNAME} SHARED ${ARGN})
19   set_target_properties(${EXTNAME} PROPERTIES PREFIX "")
20   set_target_properties(${EXTNAME} PROPERTIES SUFFIX ".so")
21   install(TARGETS ${EXTNAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}/hhvm/extensions/${HHVM_API_VERSION}")
22 endfunction()
24 # Add an extension that uses the Zend compatibility layer.
25 function(HHVM_COMPAT_EXTENSION EXTNAME)
26   if(NOT ENABLE_ZEND_COMPAT)
27     message(FATAL_ERROR "HHVM was not configured with ENABLE_ZEND_COMPAT, "
28       "and so cannot be used to compile Zend-compatible extensions")
29   endif()
30   HHVM_EXTENSION(${EXTNAME} ${ARGN})
31   # Compile all source files as C++
32   set_source_files_properties(${ARGN} PROPERTIES LANGUAGE "CXX")
33   # Define COMPILE_DL_<EXTNAME> so that ZEND_GET_MODULE() will be invoked
34   string(TOUPPER ${EXTNAME} EXTNAME_UPPER)
35   add_definitions("-DCOMPILE_DL_${EXTNAME_UPPER}")
36   # Add extra include directories
37   set(EZC_DIR "${CMAKE_INSTALL_PREFIX}/include/hphp/runtime/ext_zend_compat")
38   include_directories("${EZC_DIR}/php-src")
39   include_directories("${EZC_DIR}/php-src/main")
40   include_directories("${EZC_DIR}/php-src/Zend")
41   include_directories("${EZC_DIR}/php-src/TSRM")
42 endfunction()
44 function(HHVM_SYSTEMLIB EXTNAME)
45   foreach (SLIB ${ARGN})
46     embed_systemlib_byname(${EXTNAME} ${SLIB})
47   endforeach()
48   embed_systemlibs(${EXTNAME} "${EXTNAME}.so")
49 endfunction()
51 function(HHVM_DEFINE EXTNAME)
52   add_definitions(${ARGN})
53 endfunction()