summaryrefslogtreecommitdiff
path: root/libkolabxml/lib/php/CMakeLists.txt
blob: 2d95c363c3244e6769b9f32a0baf502a5181456e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#Generate PHP wrapper
include_directories(../)

set(KOLAB_SWIG_PHP_SOURCE_FILE php_kolabformat_wrapper.cpp)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_PHP_SOURCE_FILE}
    COMMAND ${SWIG} -v -c++ -php -o ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_PHP_SOURCE_FILE}  ../kolabformat.i
    COMMENT "Generating php bindings"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    DEPENDS ../kolabformat.i kolabxml
    VERBATIM
    )
SET_SOURCE_FILES_PROPERTIES(${KOLAB_SWIG_PHP_SOURCE_FILE} PROPERTIES GENERATED 1)
ADD_CUSTOM_TARGET(generate_php_bindings ALL DEPENDS ${KOLAB_SWIG_PHP_SOURCE_FILE})


#Compile PHP Bindings
# Since there is no php library we can't compile with -Wl,--no-undefined
if (APPLE)
    set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flat_namespace -undefined suppress" )
endif()

find_package(PHP4)
include_directories(${PHP4_INCLUDE_PATH})
add_library(phpbindings SHARED ${KOLAB_SWIG_PHP_SOURCE_FILE})
target_link_libraries(phpbindings kolabxml ${PHP_LIBRARIES})
SET_TARGET_PROPERTIES(phpbindings PROPERTIES OUTPUT_NAME "kolabformat")
SET_TARGET_PROPERTIES(phpbindings PROPERTIES PREFIX "")

configure_file(test.php ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)

install(TARGETS phpbindings LIBRARY DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/phpbindings)

install( FILES
  ${CMAKE_CURRENT_BINARY_DIR}/kolabformat.php
  test.php
  DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/phpbindings)