Skip to content

Commit 22ae60b

Browse files
committed
[futurepress#84][futurepress#67] PCRE2 linking fixes
1 parent ef95720 commit 22ae60b

File tree

1 file changed

+13
-29
lines changed

1 file changed

+13
-29
lines changed

CMakeLists.txt

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ if(CMAKE_SYSTEM_NAME MATCHES "Android")
3939
# Mac Catalyst build is the only scenario we have where the target system name
4040
# is Darwin.
4141
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
42-
set(PCRE2_TARGET --target pcre2-8-static)
4342
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -target x86_64-apple-ios-macabi")
4443
set(
4544
EXTRA_BUILD_ARGS
@@ -55,7 +54,6 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "iOS")
5554
-DCMAKE_IOS_INSTALL_COMBINED=${CMAKE_IOS_INSTALL_COMBINED}
5655
-GXcode
5756
)
58-
set(PCRE2_TARGET --target pcre2-8-static)
5957
endif()
6058

6159
if(CMAKE_SYSTEM_NAME MATCHES "Android|Windows")
@@ -76,20 +74,14 @@ execute_process(
7674
execute_process(
7775
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/pcre2
7876
--config Release
79-
${PCRE2_TARGET}
80-
)
81-
82-
if(
83-
NOT CMAKE_SYSTEM_NAME MATCHES "iOS"
8477

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"
78+
# This allows to not sign compiled PCRE2 executables for iOS / macOS builds,
79+
# we don't really use them anyway, but we need them build for the install
80+
# command below to work.
81+
-- CODE_SIGNING_ALLOWED=NO
9082
)
91-
execute_process(COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR}/pcre2)
92-
endif()
83+
84+
execute_process(COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR}/pcre2)
9385

9486
# Copies shared PCRE2 library into the folder from where Gradle automatically
9587
# will bundle it in the host app package.
@@ -104,21 +96,13 @@ if(CMAKE_SYSTEM_NAME MATCHES "Android|Windows")
10496
set(BUILD_SHARED_LIBS 1)
10597
endif()
10698

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)
99+
# These enforce pkg_check_modules(), find_program(), etc. in Lighttpd CMake
100+
# config to look for local build of PCRE2 in the location it was installed to.
101+
set(CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/sysroot")
102+
103+
# TODO: Not sure now, whether this is needed, or already covered by the variable
104+
# above.
105+
set(CMAKE_FIND_ROOT_PATH "${CMAKE_BINARY_DIR}/sysroot")
122106

123107
add_subdirectory(lighttpd1.4)
124108

0 commit comments

Comments
 (0)