diff --git a/CMakeLists.txt b/CMakeLists.txt index d05d87fb..bd9a2887 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,15 +5,17 @@ PROJECT(phpcpp) # Use CMake File with following options # PHPCPP_COMPILE_TS Set flag if PHP was compiled with thread safe # PHPCPP_MSVCRT_STATIC Set flag if you want to compile the MSVC runtime as a static library +# PHPCPP_SHARED Set flag if you want to compile shared library # PHPCPP_ARCH Set to "x86_64" if architecture and PHP was compiled under x64 or "x86" for 32 bit # PHPCPP_PHP_PATH The path to PHP sources +set(CMAKE_CXX_STANDARD 11) LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}) IF(CMAKE_BUILD_TYPE MATCHES DEBUG) - ADD_DEFINITIONS(-DZEND_DEBUG=1) + ADD_DEFINITIONS(-DZEND_DEBUG=1) ELSE() - ADD_DEFINITIONS(-DZEND_DEBUG=0) + ADD_DEFINITIONS(-DZEND_DEBUG=0) ENDIF() IF (PHPCPP_COMPILE_TS) @@ -25,6 +27,10 @@ ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) ADD_DEFINITIONS(-DBUILDING_PHPCPP) ADD_DEFINITIONS(-DZEND_WIN32_KEEP_INLINE) +IF (NOT EXISTS "${PHPCPP_PHP_PATH}/main/php.h") + message(SEND_ERROR "The PHPCPP_PHP_PATH variable does not contain PHP sources path") +ENDIF() + IF (MSVC) # Should compile MSVC runtime static or dll IF (PHPCPP_MSVCRT_STATIC) @@ -54,13 +60,13 @@ IF (MSVC) ENDIF () INCLUDE_DIRECTORIES( - "${PHPCPP_PHP_PATH}/" - "${PHPCPP_PHP_PATH}/main" - "${PHPCPP_PHP_PATH}/Zend" - "${PHPCPP_PHP_PATH}/TSRM" - "${PHPCPP_PHP_PATH}/ext" - "${PHPCPP_PHP_PATH}/build/main" - "${PHPCPP_PHP_PATH}/build/Zend" + "${PHPCPP_PHP_PATH}/" + "${PHPCPP_PHP_PATH}/main" + "${PHPCPP_PHP_PATH}/Zend" + "${PHPCPP_PHP_PATH}/TSRM" + "${PHPCPP_PHP_PATH}/ext" + "${PHPCPP_PHP_PATH}/build/main" + "${PHPCPP_PHP_PATH}/build/Zend" ) SET(PHP_LIBS "php") SET(PHP_LIB_PATH "") @@ -87,179 +93,38 @@ ELSE() ENDIF() ENDIF() -SET(PHPCPP_COMMON_SOURCES - common/modifiers.cpp - common/streambuf.cpp -) +FILE(GLOB PHPCPP_COMMON_SOURCES common/*.cpp) +FILE(GLOB PHPCPP_COMMON_HEADERS common/*.h) +FILE(GLOB PHPCPP_ZEND_SOURCES zend/*.cpp) +FILE(GLOB PHPCPP_ZEND_HEADERS zend/*.h) +FILE(GLOB PHPCPP_HEADERS_INCLUDE include/phpcpp/*.h) -SET(PHPCPP_COMMON_HEADERS - common/extensionbase.h - common/includes.h - common/streambuf.h -) - -ADD_LIBRARY(phpcpp-common STATIC - ${PHPCPP_COMMON_HEADERS} - ${PHPCPP_COMMON_SOURCES} -) - -set_target_properties(phpcpp-common - PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" -) - -SET(PHPCPP_ZEND_SOURCES - zend/base.cpp - zend/callable.cpp - zend/classbase.cpp - zend/classimpl.cpp - zend/constant.cpp - zend/constantfuncs.cpp - zend/eval.cpp - zend/exception_handler.cpp - zend/exists.cpp - zend/extension.cpp - zend/extensionimpl.cpp - zend/fatalerror.cpp - zend/file.cpp - zend/function.cpp - zend/functor.cpp - zend/global.cpp - zend/globals.cpp - zend/hashmember.cpp - zend/ini.cpp - zend/inivalue.cpp - zend/iteratorimpl.cpp - zend/members.cpp - zend/module.cpp - zend/namespace.cpp - zend/object.cpp - zend/sapi.cpp - zend/script.cpp - zend/streambuf.cpp - zend/streams.cpp - zend/super.cpp - zend/value.cpp - zend/valueiterator.cpp - zend/zendcallable.cpp - zend/zval.cpp -) - -SET(PHPCPP_ZEND_HEADERS - zend/arithmetic.h - zend/boolmember.h - zend/callable.h - zend/classimpl.h - zend/compileroptions.h - zend/constantimpl.h - zend/delayedfree.h - zend/executestate.h - zend/extensionimpl.h - zend/extensionpath.h - zend/floatmember.h - zend/functor.h - zend/hashiterator.h - zend/includes.h - zend/init.h - zend/invaliditerator.h - zend/iteratorimpl.h - zend/lowercase.h - zend/member.h - zend/method.h - zend/module.h - zend/nativefunction.h - zend/notimplemented.h - zend/nullmember.h - zend/numericmember.h - zend/objectimpl.h - zend/opcodes.h - zend/origexception.h - zend/parametersimpl.h - zend/property.h - zend/string.h - zend/stringmember.h - zend/symbol.h - zend/symbol.h - zend/traverseiterator.h - zend/valueiteratorimpl.h -) - -SET(PHPCPP_HEADERS_INCLUDE - include/argument.h - include/array.h - include/arrayaccess.h - include/base.h - include/byref.h - include/byval.h - include/call.h - include/class.h - include/classbase.h - include/classtype.h - include/constant.h - include/countable.h - include/deprecated.h - include/errors.h - include/exception.h - include/extension.h - include/fatalerror.h - include/file.h - include/function.h - include/global.h - include/globals.h - include/hashmember.h - include/hashparent.h - include/ini.h - include/inivalue.h - include/interface.h - include/iterator.h - include/modifiers.h - include/namespace.h - include/noexcept.h - include/object.h - include/parameters.h - include/platform.h - include/script.h - include/serializable.h - include/streams.h - include/super.h - include/thread_local.h - include/traversable.h - include/type.h - include/value.h - include/valueiterator.h - include/version.h - include/visibility.h - include/zendcallable.h - include/zval.h -) LINK_DIRECTORIES(${PHP_LIB_PATH}) IF (PHPCPP_SHARED) ADD_LIBRARY(phpcpp SHARED - ${PHPCPP_HEADERS_INCLUDE} - ${PHPCPP_ZEND_HEADERS} - ${PHPCPP_ZEND_SOURCES} - phpcpp.h - ) - - TARGET_LINK_LIBRARIES(phpcpp phpcpp-common ${PHP_LIBS}) + ${PHPCPP_COMMON_HEADERS} + ${PHPCPP_COMMON_SOURCES} + ${PHPCPP_HEADERS_INCLUDE} + ${PHPCPP_ZEND_HEADERS} + ${PHPCPP_ZEND_SOURCES} + phpcpp.h + ) ELSE() ADD_LIBRARY(phpcpp STATIC - ${PHPCPP_HEADERS_INCLUDE} - ${PHPCPP_ZEND_HEADERS} - ${PHPCPP_ZEND_SOURCES} - phpcpp.h - ) - - TARGET_LINK_LIBRARIES(phpcpp STATIC phpcpp-common ${PHP_LIBS}) + ${PHPCPP_COMMON_HEADERS} + ${PHPCPP_COMMON_SOURCES} + ${PHPCPP_HEADERS_INCLUDE} + ${PHPCPP_ZEND_HEADERS} + ${PHPCPP_ZEND_SOURCES} + phpcpp.h + ) ENDIF() SET_TARGET_PROPERTIES(phpcpp - PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" -) + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + ) diff --git a/Makefile b/Makefile index eff5725d..1220ba45 100644 --- a/Makefile +++ b/Makefile @@ -221,7 +221,7 @@ install: ${MKDIR} ${INSTALL_HEADERS}/phpcpp ${MKDIR} ${INSTALL_LIB} ${CP} phpcpp.h ${INSTALL_HEADERS} - ${CP} include/*.h ${INSTALL_HEADERS}/phpcpp + ${CP} include/phpcpp/*.h ${INSTALL_HEADERS}/phpcpp if [ -e ${PHP_SHARED_LIBRARY} ]; then \ ${CP} ${PHP_SHARED_LIBRARY} ${INSTALL_LIB}/; \ ${LN} ${INSTALL_LIB}/${PHP_SHARED_LIBRARY} ${INSTALL_LIB}/libphpcpp.so.$(SONAME); \ diff --git a/common/includes.h b/common/includes.h index 437f73ec..30a5494d 100644 --- a/common/includes.h +++ b/common/includes.h @@ -15,8 +15,8 @@ /** * Public include files */ -#include "../include/visibility.h" -#include "../include/modifiers.h" +#include "../include/phpcpp/visibility.h" +#include "../include/phpcpp/modifiers.h" /** * Generic implementation header files diff --git a/documentation/install.html b/documentation/install.html index 753de5d9..87aaa765 100644 --- a/documentation/install.html +++ b/documentation/install.html @@ -86,3 +86,44 @@

Compiling on OSX?

be added to it.

+ +

Compiling using cmake

+

+ You could use PHP-CPP as a part of your project. You can install it into your source tree using command +

+

+

git submodule add git://github.com/CopernicaMarketingSoftware/PHP-CPP.git
+
+

+

+ For example, part of your CMakeLists.txt may look like this: +

+

+

FIND_PROGRAM(PHP_CONFIG NAMES php-config)
+
+execute_process(
+    COMMAND ${PHP_CONFIG} --include-dir
+    OUTPUT_VARIABLE PHPCPP_PHP_PATH
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+# or: SET(PHPCPP_PHP_PATH "/usr/include/php/20160303" CACHE STRING "")
+SET(PHPCPP_ARCH "x86_64" CACHE STRING "")
+
+include_directories(PHP-CPP include)
+add_subdirectory(PHP-CPP)
+target_link_libraries(YourTarget PRIVATE phpcpp)
+
+

+

+ For full list of options look through CMakeLists.txt file comments. +

+

+ Or you could compile and install PHP-CPP using Makefile and then reference it in your CMakeLists.txt like this: +

+ +

+

find_library(phpcpp REQUIRED)
+target_link_libraries(YourTarget PRIVATE phpcpp)
+
+

+ diff --git a/include/argument.h b/include/phpcpp/argument.h similarity index 100% rename from include/argument.h rename to include/phpcpp/argument.h diff --git a/include/array.h b/include/phpcpp/array.h similarity index 100% rename from include/array.h rename to include/phpcpp/array.h diff --git a/include/arrayaccess.h b/include/phpcpp/arrayaccess.h similarity index 100% rename from include/arrayaccess.h rename to include/phpcpp/arrayaccess.h diff --git a/include/base.h b/include/phpcpp/base.h similarity index 100% rename from include/base.h rename to include/phpcpp/base.h diff --git a/include/byref.h b/include/phpcpp/byref.h similarity index 100% rename from include/byref.h rename to include/phpcpp/byref.h diff --git a/include/byval.h b/include/phpcpp/byval.h similarity index 100% rename from include/byval.h rename to include/phpcpp/byval.h diff --git a/include/call.h b/include/phpcpp/call.h similarity index 100% rename from include/call.h rename to include/phpcpp/call.h diff --git a/include/class.h b/include/phpcpp/class.h similarity index 100% rename from include/class.h rename to include/phpcpp/class.h diff --git a/include/classbase.h b/include/phpcpp/classbase.h similarity index 100% rename from include/classbase.h rename to include/phpcpp/classbase.h diff --git a/include/classtype.h b/include/phpcpp/classtype.h similarity index 100% rename from include/classtype.h rename to include/phpcpp/classtype.h diff --git a/include/constant.h b/include/phpcpp/constant.h similarity index 100% rename from include/constant.h rename to include/phpcpp/constant.h diff --git a/include/countable.h b/include/phpcpp/countable.h similarity index 100% rename from include/countable.h rename to include/phpcpp/countable.h diff --git a/include/deprecated.h b/include/phpcpp/deprecated.h similarity index 100% rename from include/deprecated.h rename to include/phpcpp/deprecated.h diff --git a/include/errors.h b/include/phpcpp/errors.h similarity index 100% rename from include/errors.h rename to include/phpcpp/errors.h diff --git a/include/exception.h b/include/phpcpp/exception.h similarity index 100% rename from include/exception.h rename to include/phpcpp/exception.h diff --git a/include/extension.h b/include/phpcpp/extension.h similarity index 100% rename from include/extension.h rename to include/phpcpp/extension.h diff --git a/include/fatalerror.h b/include/phpcpp/fatalerror.h similarity index 100% rename from include/fatalerror.h rename to include/phpcpp/fatalerror.h diff --git a/include/file.h b/include/phpcpp/file.h similarity index 100% rename from include/file.h rename to include/phpcpp/file.h diff --git a/include/function.h b/include/phpcpp/function.h similarity index 100% rename from include/function.h rename to include/phpcpp/function.h diff --git a/include/global.h b/include/phpcpp/global.h similarity index 100% rename from include/global.h rename to include/phpcpp/global.h diff --git a/include/globals.h b/include/phpcpp/globals.h similarity index 100% rename from include/globals.h rename to include/phpcpp/globals.h diff --git a/include/hashmember.h b/include/phpcpp/hashmember.h similarity index 100% rename from include/hashmember.h rename to include/phpcpp/hashmember.h diff --git a/include/hashparent.h b/include/phpcpp/hashparent.h similarity index 100% rename from include/hashparent.h rename to include/phpcpp/hashparent.h diff --git a/include/ini.h b/include/phpcpp/ini.h similarity index 100% rename from include/ini.h rename to include/phpcpp/ini.h diff --git a/include/inivalue.h b/include/phpcpp/inivalue.h similarity index 100% rename from include/inivalue.h rename to include/phpcpp/inivalue.h diff --git a/include/interface.h b/include/phpcpp/interface.h similarity index 100% rename from include/interface.h rename to include/phpcpp/interface.h diff --git a/include/iterator.h b/include/phpcpp/iterator.h similarity index 100% rename from include/iterator.h rename to include/phpcpp/iterator.h diff --git a/include/modifiers.h b/include/phpcpp/modifiers.h similarity index 100% rename from include/modifiers.h rename to include/phpcpp/modifiers.h diff --git a/include/namespace.h b/include/phpcpp/namespace.h similarity index 100% rename from include/namespace.h rename to include/phpcpp/namespace.h diff --git a/include/noexcept.h b/include/phpcpp/noexcept.h similarity index 100% rename from include/noexcept.h rename to include/phpcpp/noexcept.h diff --git a/include/object.h b/include/phpcpp/object.h similarity index 100% rename from include/object.h rename to include/phpcpp/object.h diff --git a/include/parameters.h b/include/phpcpp/parameters.h similarity index 100% rename from include/parameters.h rename to include/phpcpp/parameters.h diff --git a/include/platform.h b/include/phpcpp/platform.h similarity index 100% rename from include/platform.h rename to include/phpcpp/platform.h diff --git a/include/script.h b/include/phpcpp/script.h similarity index 100% rename from include/script.h rename to include/phpcpp/script.h diff --git a/include/serializable.h b/include/phpcpp/serializable.h similarity index 100% rename from include/serializable.h rename to include/phpcpp/serializable.h diff --git a/include/streams.h b/include/phpcpp/streams.h similarity index 100% rename from include/streams.h rename to include/phpcpp/streams.h diff --git a/include/super.h b/include/phpcpp/super.h similarity index 100% rename from include/super.h rename to include/phpcpp/super.h diff --git a/include/thread_local.h b/include/phpcpp/thread_local.h similarity index 100% rename from include/thread_local.h rename to include/phpcpp/thread_local.h diff --git a/include/traversable.h b/include/phpcpp/traversable.h similarity index 100% rename from include/traversable.h rename to include/phpcpp/traversable.h diff --git a/include/type.h b/include/phpcpp/type.h similarity index 100% rename from include/type.h rename to include/phpcpp/type.h diff --git a/include/value.h b/include/phpcpp/value.h similarity index 100% rename from include/value.h rename to include/phpcpp/value.h diff --git a/include/valueiterator.h b/include/phpcpp/valueiterator.h similarity index 100% rename from include/valueiterator.h rename to include/phpcpp/valueiterator.h diff --git a/include/version.h b/include/phpcpp/version.h similarity index 100% rename from include/version.h rename to include/phpcpp/version.h diff --git a/include/visibility.h b/include/phpcpp/visibility.h similarity index 100% rename from include/visibility.h rename to include/phpcpp/visibility.h diff --git a/include/zendcallable.h b/include/phpcpp/zendcallable.h similarity index 100% rename from include/zendcallable.h rename to include/phpcpp/zendcallable.h diff --git a/include/zval.h b/include/phpcpp/zval.h similarity index 100% rename from include/zval.h rename to include/phpcpp/zval.h diff --git a/zend/includes.h b/zend/includes.h index 121c0a20..f4435d58 100644 --- a/zend/includes.h +++ b/zend/includes.h @@ -59,51 +59,51 @@ /** * Include other files from this library */ -#include "../include/visibility.h" -#include "../include/deprecated.h" -#include "../include/noexcept.h" -#include "../include/thread_local.h" -#include "../include/platform.h" -#include "../include/version.h" -#include "../include/inivalue.h" -#include "../include/ini.h" -#include "../include/exception.h" -#include "../include/fatalerror.h" -#include "../include/streams.h" -#include "../include/type.h" -#include "../include/errors.h" -#include "../include/hashparent.h" -#include "../include/value.h" -#include "../include/valueiterator.h" -#include "../include/array.h" -#include "../include/object.h" -#include "../include/globals.h" -#include "../include/argument.h" -#include "../include/byval.h" -#include "../include/byref.h" -#include "../include/global.h" -#include "../include/hashmember.h" -#include "../include/super.h" -#include "../include/parameters.h" -#include "../include/modifiers.h" -#include "../include/base.h" -#include "../include/countable.h" -#include "../include/arrayaccess.h" -#include "../include/serializable.h" -#include "../include/iterator.h" -#include "../include/traversable.h" -#include "../include/classtype.h" -#include "../include/classbase.h" -#include "../include/interface.h" -#include "../include/constant.h" -#include "../include/zendcallable.h" -#include "../include/class.h" -#include "../include/namespace.h" -#include "../include/extension.h" -#include "../include/call.h" -#include "../include/script.h" -#include "../include/file.h" -#include "../include/function.h" +#include "../include/phpcpp/visibility.h" +#include "../include/phpcpp/deprecated.h" +#include "../include/phpcpp/noexcept.h" +#include "../include/phpcpp/thread_local.h" +#include "../include/phpcpp/platform.h" +#include "../include/phpcpp/version.h" +#include "../include/phpcpp/inivalue.h" +#include "../include/phpcpp/ini.h" +#include "../include/phpcpp/exception.h" +#include "../include/phpcpp/fatalerror.h" +#include "../include/phpcpp/streams.h" +#include "../include/phpcpp/type.h" +#include "../include/phpcpp/errors.h" +#include "../include/phpcpp/hashparent.h" +#include "../include/phpcpp/value.h" +#include "../include/phpcpp/valueiterator.h" +#include "../include/phpcpp/array.h" +#include "../include/phpcpp/object.h" +#include "../include/phpcpp/globals.h" +#include "../include/phpcpp/argument.h" +#include "../include/phpcpp/byval.h" +#include "../include/phpcpp/byref.h" +#include "../include/phpcpp/global.h" +#include "../include/phpcpp/hashmember.h" +#include "../include/phpcpp/super.h" +#include "../include/phpcpp/parameters.h" +#include "../include/phpcpp/modifiers.h" +#include "../include/phpcpp/base.h" +#include "../include/phpcpp/countable.h" +#include "../include/phpcpp/arrayaccess.h" +#include "../include/phpcpp/serializable.h" +#include "../include/phpcpp/iterator.h" +#include "../include/phpcpp/traversable.h" +#include "../include/phpcpp/classtype.h" +#include "../include/phpcpp/classbase.h" +#include "../include/phpcpp/interface.h" +#include "../include/phpcpp/constant.h" +#include "../include/phpcpp/zendcallable.h" +#include "../include/phpcpp/class.h" +#include "../include/phpcpp/namespace.h" +#include "../include/phpcpp/extension.h" +#include "../include/phpcpp/call.h" +#include "../include/phpcpp/script.h" +#include "../include/phpcpp/file.h" +#include "../include/phpcpp/function.h" /** * Common header files for internal use only