forked from swoole/phpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
59 lines (43 loc) · 1.64 KB
/
CMakeLists.txt
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
55
56
57
58
59
cmake_minimum_required(VERSION 3.16)
project(phpy)
#set(CMAKE_BUILD_TYPE Released)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -g")
if (NOT DEFINED PHP_CONFIG)
set(PHP_CONFIG "php-config")
endif()
if (NOT DEFINED PYTHON_CONFIG)
set(PYTHON_CONFIG "python3-config")
endif()
file(GLOB_RECURSE SOURCE_FILES FOLLOW_SYMLINKS src/*.cc)
execute_process(COMMAND ${PHP_CONFIG} --includes
OUTPUT_VARIABLE PHP_INCLUDES
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${PHP_CONFIG} --prefix
OUTPUT_VARIABLE PHP_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${PYTHON_CONFIG} --includes
OUTPUT_VARIABLE PYTHON_INCLUDES
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${PYTHON_CONFIG} --ldflags
OUTPUT_VARIABLE PYTHON_LDFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PHP_INCLUDES} ${PYTHON_INCLUDES}")
set(CMAKE_LDFLAGS "${CMAKE_LDFLAGS} ${PYTHON_LDFLAGS}")
set(phpy_includes ./ ./include/ /opt/anaconda3/include/python3.11)
set(phpy_libraries php)
set(phpy_link_directories /usr/local/lib /opt/anaconda3/lib ${PHP_PREFIX}/lib)
if (DEFINED enable_asan)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif()
set(CMAKE_SHARED_LIBRARY_PREFIX "")
add_definitions(-DHAVE_PHP_EMBED)
include_directories(BEFORE ${phpy_includes})
link_directories(${phpy_link_directories})
add_library(phpy SHARED ${SOURCE_FILES})
set_target_properties(phpy PROPERTIES OUTPUT_NAME "lib/phpy")
target_link_libraries(phpy ${phpy_libraries})