summaryrefslogtreecommitdiffstats
path: root/contrib/cmake/FindPHP5.cmake
blob: d449112cc59ad1056bad9d5ac3391060e0cf332f (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
if (UNIX)
	if (NOT PHP_CONFIG)
		find_program(PHP_CONFIG
			NAMES php-config
			PATHS
				/usr/bin
				/usr/local/bin
				/opt/local/bin
		)
	endif()
	if (PHP_CONFIG)
		execute_process(COMMAND ${PHP_CONFIG} --includes
	    OUTPUT_VARIABLE PHP_INCLUDE_DIRS
	    ERROR_VARIABLE PHP_INCLUDE_errors
	    RESULT_VARIABLE PHP_INCLUDE_result)
		string(REGEX REPLACE "-I" "" PHP_INCLUDE_DIRS ${PHP_INCLUDE_DIRS})
		string(REGEX REPLACE "[ \n\r]+" ";" PHP_INCLUDE_DIRS ${PHP_INCLUDE_DIRS})

		execute_process(COMMAND ${PHP_CONFIG} --libs
	    OUTPUT_VARIABLE PHP_LIBRARIES
	    ERROR_VARIABLE PHP_LIBRARIES_errors
	    RESULT_VARIABLE PHP_LIBRARIES_result)
		string(REGEX REPLACE "-l" "" PHP_LIBRARIES ${PHP_LIBRARIES})
		string(REGEX REPLACE "[ \n\r]+" ";" PHP_LIBRARIES ${PHP_LIBRARIES})
		list(REMOVE_DUPLICATES PHP_LIBRARIES)
		
		execute_process(COMMAND ${PHP_CONFIG} --ldflags
	    OUTPUT_VARIABLE PHP_LDFLAGS
	    ERROR_VARIABLE PHP_LDFLAGS_errors
	    RESULT_VARIABLE PHP_LDFLAGS_result)

		execute_process(COMMAND ${PHP_CONFIG} --configure-options
	    OUTPUT_VARIABLE PHP_CONFIGURE_OPTIONS
	    ERROR_VARIABLE PHP_CONFIGURE_OPTIONS_errors
	    RESULT_VARIABLE PHP_CONFIGURE_OPTIONS_result)

		set(PHP_ZTS_ENABLED OFF)
		if (PHP_CONFIGURE_OPTIONS MATCHES ".*enable-maintainer-zts.*")
			set(PHP_ZTS_ENABLED ON)
		endif()
		
		set(PHP_DEBUG_ENABLED OFF)
		if (PHP_CONFIGURE_OPTIONS MATCHES ".*enable-debug.*")
			set(PHP_DEBUG_ENABLED ON)
		endif()
		
	endif()
else()
	message(STATUS "Finding PHP5 on Windows is not supported")
endif()

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PHP5 DEFAULT_MSG PHP_CONFIG PHP_INCLUDE_DIRS PHP_LIBRARIES PHP_LDFLAGS)
MARK_AS_ADVANCED(PHP_LIBRARIES PHP_INCLUDE_DIRS PHP_LDFLAGS PHP_ZTS_ENABLED)