Compare commits

...

1 Commits

Author SHA1 Message Date
Brendan Le Foll
b24468b010 php: quick little hack to enable php bindings for libmraa
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-09-28 10:24:28 +01:00
5 changed files with 71 additions and 0 deletions

View File

@@ -50,6 +50,7 @@ option (GTEST "Build all gtests." OFF)
option (BUILDDOC "Build all doc." OFF)
option (BUILDSWIG "Build swig modules." ON)
option (BUILDSWIGPYTHON "Build swig python modules." ON)
option (BUILDSWIGPHP "Build swig php module." ON)
option (BUILDSWIGNODE "Build swig node modules." ON)
option (IPK "Generate IPK using CPack" OFF)

View File

@@ -0,0 +1,46 @@
# - FindPHPLibs
# Find PHP interpreter includes and library
#
# PHPLIBS_FOUND - True if PHP libs found
# PHP_VERSION_STRING - The version of PHP found (x.y.z)
# PHP_LIBRARIES - Libaries (standard variable)
# PHP_INCLUDE_DIRS - List of include directories
# PHP_INCLUDE_DIR - Main include directory prefix
# PHP_EXTENSION_DIR - Location of PHP extension DSO-s
# PHP_EXECUTABLE - PHP executable
# PHP_INSTALL_PREFIX - PHP install prefix, as reported
INCLUDE(CMakeFindFrameworks)
IF( NOT PHP_CONFIG_EXECUTABLE )
FIND_PROGRAM(PHP_CONFIG_EXECUTABLE
NAMES php5-config php-config
)
ENDIF( NOT PHP_CONFIG_EXECUTABLE )
MACRO(GET_FROM_PHP_CONFIG args variable)
EXECUTE_PROCESS(COMMAND ${PHP_CONFIG_EXECUTABLE} ${args}
OUTPUT_VARIABLE ${variable})
STRING(REPLACE "\n" "" ${variable} "${${variable}}")
ENDMACRO(GET_FROM_PHP_CONFIG cmd variable)
IF(PHP_CONFIG_EXECUTABLE)
GET_FROM_PHP_CONFIG("--version" PHP_VERSION_STRING)
GET_FROM_PHP_CONFIG("--php-binary" PHP_EXECUTABLE)
GET_FROM_PHP_CONFIG("--include-dir" PHP_INCLUDE_DIR)
GET_FROM_PHP_CONFIG("--extension-dir" PHP_EXTENSION_DIR)
GET_FROM_PHP_CONFIG("--includes" PHP_INCLUDE_DIRS)
GET_FROM_PHP_CONFIG("--prefix" PHP_INSTALL_PREFIX)
STRING(REPLACE "-I" "" PHP_INCLUDE_DIRS "${PHP_INCLUDE_DIRS}")
STRING(REPLACE " " ";" PHP_INCLUDE_DIRS "${PHP_INCLUDE_DIRS}")
ENDIF(PHP_CONFIG_EXECUTABLE)
# FIXME: Maybe we need all this crap that php-config --libs puts out,
# however after building a few swig bindings without them,
# I seriously doubt it.
SET(PHP_LIBRARIES "")
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PHPLibs DEFAULT_MSG PHP_INCLUDE_DIRS)
MARK_AS_ADVANCED(PHP_LIBRARIES PHP_INCLUDE_DIRS)

View File

@@ -94,5 +94,6 @@ if (BUILDSWIG)
if (BUILDSWIGNODE)
add_subdirectory (javascript)
endif ()
add_subdirectory (php)
endif ()
endif ()

17
src/php/CMakeLists.txt Normal file
View File

@@ -0,0 +1,17 @@
FIND_PACKAGE (PHPLibs)
INCLUDE_DIRECTORIES(${PHP_INCLUDE_DIRS})
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
${PHP_INCLUDE_DIRS}
)
set_source_files_properties (php-mraa.i PROPERTIES CPLUSPLUS ON)
set_source_files_properties (php-mraa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
swig_add_module (php-mraa php php-mraa.i ${mraa_LIB_SRCS})
swig_link_libraries (php-mraa ${PHP_LIBRARIES})
set_target_properties (${SWIG_MODULE_php-mraa_REAL_NAME} PROPERTIES
OUTPUT_NAME _mraa
COMPILE_FLAGS "${CMAKE_C_FLAGS} -DSWIGPHP=${SWIG_FOUND}"
)

6
src/php/php-mraa.i Normal file
View File

@@ -0,0 +1,6 @@
%module(docstring="PHP interface to libmraa") mraa
%feature("autodoc", "3");
%include ../mraa.i