@@ -39,13 +39,17 @@ if(CMAKE_SYSTEM_NAME MATCHES "Android")
39
39
# Mac Catalyst build is the only scenario we have where the target system name
40
40
# is Darwin.
41
41
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin" )
42
- set (PCRE2_TARGET --target pcre2-8-static )
43
42
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -target x86_64-apple-ios-macabi" )
44
43
set (
45
44
EXTRA_BUILD_ARGS
46
45
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
47
46
-DCMAKE_OSX_ARCHITECTURES=${ESCAPED_ARCHS}
48
47
)
48
+ # This allows to not sign compiled PCRE2 executables for iOS / macOS builds,
49
+ # we don't really use them anyway, but we need them build for the install
50
+ # command below to work.
51
+ set (EXTRA_INSTALL_ARGS "--;CODE_SIGNING_ALLOWED=NO" )
52
+
49
53
elseif (CMAKE_SYSTEM_NAME MATCHES "iOS" )
50
54
set (
51
55
EXTRA_BUILD_ARGS
@@ -55,7 +59,10 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "iOS")
55
59
-DCMAKE_IOS_INSTALL_COMBINED=${CMAKE_IOS_INSTALL_COMBINED}
56
60
-GXcode
57
61
)
58
- set (PCRE2_TARGET --target pcre2-8-static )
62
+ # This allows to not sign compiled PCRE2 executables for iOS / macOS builds,
63
+ # we don't really use them anyway, but we need them build for the install
64
+ # command below to work.
65
+ set (EXTRA_INSTALL_ARGS "--;CODE_SIGNING_ALLOWED=NO" )
59
66
endif ()
60
67
61
68
if (CMAKE_SYSTEM_NAME MATCHES "Android|Windows" )
@@ -75,21 +82,10 @@ execute_process(
75
82
76
83
execute_process (
77
84
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} /pcre2
78
- --config Release
79
- ${PCRE2_TARGET}
85
+ --config Release ${EXTRA_INSTALL_ARGS}
80
86
)
81
87
82
- if (
83
- NOT CMAKE_SYSTEM_NAME MATCHES "iOS"
84
-
85
- # TODO: We wanna say "and not Mac Catalyst build", for which the current
86
- # condition is not specific enough, but will do for now, as Mac Catalyst
87
- # build is the only scenario we gonna have Darwin as the target platform
88
- # as of now.
89
- AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin"
90
- )
91
- execute_process (COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} /pcre2 )
92
- endif ()
88
+ execute_process (COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} /pcre2 )
93
89
94
90
# Copies shared PCRE2 library into the folder from where Gradle automatically
95
91
# will bundle it in the host app package.
@@ -104,21 +100,18 @@ if(CMAKE_SYSTEM_NAME MATCHES "Android|Windows")
104
100
set (BUILD_SHARED_LIBS 1 )
105
101
endif ()
106
102
107
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPCRE2_CODE_UNIT_WIDTH=8 -I${CMAKE_BINARY_DIR} /sysroot/include -L${CMAKE_BINARY_DIR} /sysroot/lib" )
108
-
109
- # To find PCRE2 Lighttpd first of all tries to use pkg_check_modules().
110
- # It seems that on Linux it ends up relying on pkg-config utility of the host
111
- # system, which find the host's version of PCRE2. With CMake 3.18.1 it was fine,
112
- # as it used to output the linker flag for PCRE2 just as "-lpcre2-8",
113
- # and just above we set the correct -L flag with the path of PCRE2
114
- # cross-compiled for Android. However, with CMake 3.22.1 the CMake's default
115
- # output is "-L/usr/lib/x86_64-linux-gnu;-lpcre2-8", which ends up forcing
116
- # Lighttpd to try linking against the host's PCRE2, which fails. The flag set
117
- # below instructs pkg-config to not include -L flag into outputs,
118
- # thus restoring the correct linking. However, it is not the best fix,
119
- # I guess.
120
- # TODO: Find a better fix.
121
- set (PKG_CONFIG_ARGN --libs-only-l )
103
+ # Above we have build & installed a local version of PCRE2 library, now we want
104
+ # to enforce Lighttpd build to see and use it (rather than any system-wide
105
+ # installation of another PCRE2 version). On Ubuntu / macOS it can be done
106
+ # by setting CMAKE_PREFIX_PATH; somehow it has no effect in Msys2 / UCRT64
107
+ # builds for Windows (beyond by current understanding), but there setting
108
+ # the PKG_CONFIG_PATH environment variable, which is picked up by pkg-config
109
+ # does the trick.
110
+ if (CMAKE_SYSTEM_NAME MATCHES "Windows" )
111
+ set (ENV{PKG_CONFIG_PATH} "${CMAKE_BINARY_DIR} /sysroot/lib/pkgconfig" )
112
+ else ()
113
+ set (CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR} /sysroot" )
114
+ endif ()
122
115
123
116
add_subdirectory (lighttpd1.4 )
124
117
0 commit comments