Make TAsyncChannelTest more robust
[hiphop-php.git] / CMake / HPHPIZEFunctions.cmake
blobfc4c80bf5ccdb713e741f199ed633901d09592d8
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 include(GNUInstallDirs)
9 function(HHVM_LINK_LIBRARIES EXTNAME)
10   target_link_libraries(${EXTNAME} ${ARGN})
11 endfunction()
13 function(HHVM_ADD_INCLUDES EXTNAME)
14   include_directories(${ARGN})
15 endfunction()
17 # Add an extension
18 function(HHVM_EXTENSION EXTNAME)
19   set(EXTENSION_NAME ${EXTNAME} CACHE INTERNAL "")
20   add_library(${EXTNAME} SHARED ${ARGN})
21   set_target_properties(${EXTNAME} PROPERTIES PREFIX "")
22   set_target_properties(${EXTNAME} PROPERTIES SUFFIX ".so")
24   get_target_property(LOC ${EXTNAME} LOCATION)
25   get_target_property(TY ${EXTNAME} TYPE)
26   # Don't install via target, because it triggers a re-link that doesn't
27   # run the POST_BUILD custom command that embeds the systemlib on Linux.
28   install(CODE "FILE(INSTALL DESTINATION \"${CMAKE_INSTALL_FULL_LIBDIR}/hhvm/extensions/${HHVM_VERSION_BRANCH}\" TYPE ${TY} FILES \"${LOC}\")")
29 endfunction()
31 function(embed_systemlibs TARGET DEST)
32   if (APPLE)
33     target_link_libraries(${TARGET} ${${TARGET}_SLIBS})
34   elseif (MSVC)
35     message(FATAL_ERROR "Shared extensions are not supported on Windows")
36   else()
37     add_custom_command(TARGET ${TARGET} POST_BUILD
38       COMMAND "objcopy"
39       ARGS ${${TARGET}_SLIBS} ${DEST}
40       COMMENT "Embedding php in ${TARGET}")
41   endif()
42 endfunction(embed_systemlibs)
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()