forked from amphp/ext-uv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
104 lines (76 loc) · 2.51 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
cmake_minimum_required(VERSION 3.24)
if (POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif ()
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif ()
if (POLICY CMP0079)
cmake_policy(SET CMP0079 NEW)
endif ()
if (POLICY CMP0108)
cmake_policy(SET CMP0108 NEW)
endif ()
if (POLICY CMP0109)
cmake_policy(SET CMP0109 NEW)
endif ()
if (POLICY CMP0128)
cmake_policy(SET CMP0128 NEW)
endif ()
project(php-uv)
enable_language(C)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake" "${CMAKE_SOURCE_DIR}/externals/sanitizers-cmake/cmake")
# if build type is not set, default to debug
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Debug")
endif ()
set(PHP_UV_VERSION "1.0.0-dev")
set(CUSTOM_PHP_CONFIG "" CACHE STRING "Custom PHP config path")
set(PHP_VERSION_FOR_PHP_CONFIG "8.3" CACHE STRING "PHP version")
option(PHP_DEBUG_FOR_PHP_CONFIG "Debug or Release" ON)
option(PHP_THREAD_SAFE_FOR_PHP_CONFIG "ZTS(zts) or NTS(nts)" OFF)
option(ENABLE_SANITIZERS "Enable sanitizers" OFF)
option(LIBUV_STATIC "Statically link libuv" OFF)
option(LIBUV_FROM_SRC "Build LibUV from Source" OFF)
set(LIBUV_SRC_VERSION "1.48.0" CACHE STRING "Tag for LibUV source")
find_package(PHP REQUIRED)
include(cmake/Clean.cmake)
include(cmake/CPM.cmake)
include(CTest)
enable_testing()
if (ENABLE_SANITIZERS)
find_package(Sanitizers REQUIRED)
endif ()
set(SRC_LIST src/uv.c src/php_uv.c)
add_library(ext-uv SHARED)
find_package(Libuv REQUIRED)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
configure_file(version.in.h version.h USE_SOURCE_PERMISSIONS NEWLINE_STYLE UNIX)
target_sources(ext-uv PRIVATE ${SRC_LIST})
target_compile_features(ext-uv PRIVATE c_std_23 c_restrict c_static_assert c_function_prototypes c_variadic_macros)
target_compile_definitions(
ext-uv
PUBLIC HAVE_VERSION_H
PUBLIC _POSIX_C_SOURCE=200809L
PUBLIC _GNU_SOURCE
PUBLIC _FILE_OFFSET_BITS=64
PUBLIC _LARGEFILE_SOURCE
PUBLIC _LARGEFILE64_SOURCE
PUBLIC COMPILE_DL_UV
)
target_include_directories(ext-uv PUBLIC ${PHP_INCLUDES} ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/include)
set_target_properties(
ext-uv PROPERTIES
POSITION_INDEPENDENT_CODE ON
PREFIX ""
OUTPUT_NAME "uv"
C_STANDARD 23
C_STANDARD_REQUIRED ON
C_EXTENSIONS ON
)
if(CMAKE_INSTALL_PREFIX STREQUAL "")
set(CMAKE_INSTALL_PREFIX "${PHP_EXTENSION_DIR}")
endif()
install(TARGETS ext-uv DESTINATION ${CMAKE_INSTALL_PREFIX})