Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / FindPHP4.cmake
1 # - Find PHP4
2 # This module finds if PHP4 is installed and determines where the include files
3 # and libraries are. It also determines what the name of the library is. This
4 # code sets the following variables:
5 #
6 #  PHP4_INCLUDE_PATH       = path to where php.h can be found
7 #  PHP4_EXECUTABLE         = full path to the php4 binary
8 #
9
10 #=============================================================================
11 # Copyright 2004-2009 Kitware, Inc.
12 #
13 # Distributed under the OSI-approved BSD License (the "License");
14 # see accompanying file Copyright.txt for details.
15 #
16 # This software is distributed WITHOUT ANY WARRANTY; without even the
17 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 # See the License for more information.
19 #=============================================================================
20 # (To distribute this file outside of CMake, substitute the full
21 #  License text for the above reference.)
22
23 set(PHP4_POSSIBLE_INCLUDE_PATHS
24   /usr/include/php4
25   /usr/local/include/php4
26   /usr/include/php
27   /usr/local/include/php
28   /usr/local/apache/php
29   )
30
31 set(PHP4_POSSIBLE_LIB_PATHS
32   /usr/lib
33   )
34
35 find_path(PHP4_FOUND_INCLUDE_PATH main/php.h
36   ${PHP4_POSSIBLE_INCLUDE_PATHS})
37
38 if(PHP4_FOUND_INCLUDE_PATH)
39   set(php4_paths "${PHP4_POSSIBLE_INCLUDE_PATHS}")
40   foreach(php4_path Zend main TSRM)
41     set(php4_paths ${php4_paths} "${PHP4_FOUND_INCLUDE_PATH}/${php4_path}")
42   endforeach()
43   set(PHP4_INCLUDE_PATH "${php4_paths}" INTERNAL "PHP4 include paths")
44 endif()
45
46 find_program(PHP4_EXECUTABLE NAMES php4 php )
47
48 mark_as_advanced(
49   PHP4_EXECUTABLE
50   PHP4_FOUND_INCLUDE_PATH
51   )
52
53 if(APPLE)
54 # this is a hack for now
55   set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
56    "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -Wl,-flat_namespace")
57   foreach(symbol
58     __efree
59     __emalloc
60     __estrdup
61     __object_init_ex
62     __zend_get_parameters_array_ex
63     __zend_list_find
64     __zval_copy_ctor
65     _add_property_zval_ex
66     _alloc_globals
67     _compiler_globals
68     _convert_to_double
69     _convert_to_long
70     _zend_error
71     _zend_hash_find
72     _zend_register_internal_class_ex
73     _zend_register_list_destructors_ex
74     _zend_register_resource
75     _zend_rsrc_list_get_rsrc_type
76     _zend_wrong_param_count
77     _zval_used_for_init
78     )
79     set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
80       "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS},-U,${symbol}")
81   endforeach()
82 endif()
83
84 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
85 FIND_PACKAGE_HANDLE_STANDARD_ARGS(PHP4 DEFAULT_MSG PHP4_EXECUTABLE PHP4_INCLUDE_PATH)