Skip to content

Commit 6363a49

Browse files
committed
ext/pcntl: Use php_search_libraries(SOURCE_RUNS)
1 parent f74b90d commit 6363a49

File tree

1 file changed

+19
-37
lines changed

1 file changed

+19
-37
lines changed

cmake/ext/pcntl/CMakeLists.txt

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
3838
endif()
3939

4040
include(CheckSourceCompiles)
41-
include(CheckSourceRuns)
4241
include(CheckSymbolExists)
4342
include(CheckTypeSize)
4443
include(CMakeDependentOption)
@@ -217,47 +216,30 @@ if(HAVE_PHP_EXT_PCNTL_STRUCT_SIGINFO_T)
217216
target_compile_definitions(php_ext_pcntl PRIVATE HAVE_STRUCT_SIGINFO_T)
218217
endif()
219218

219+
# Check if sched_getcpu() is supported. Value -1 means ENOSYS in this context.
220220
cmake_push_check_state(RESET)
221221
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
222222

223-
# Check if sched_getcpu() is supported. Value -1 means ENOSYS in this context.
224-
block(PROPAGATE HAVE_SCHED_GETCPU)
225-
php_search_libraries(
226-
SYMBOL sched_getcpu
227-
HEADERS sched.h
228-
LIBRARIES
229-
gnu # Haiku
230-
RESULT_VARIABLE PHP_EXT_PCNTL_HAVE_SCHED_GETCPU_SYMBOL
231-
LIBRARY_VARIABLE PHP_EXT_PCNTL_HAVE_SCHED_GETCPU_LIBRARY
232-
)
233-
234-
if(PHP_EXT_PCNTL_HAVE_SCHED_GETCPU_SYMBOL)
235-
if(PHP_EXT_PCNTL_HAVE_SCHED_GETCPU_LIBRARY)
236-
set(CMAKE_REQUIRED_LIBRARIES ${PHP_EXT_PCNTL_HAVE_SCHED_GETCPU_LIBRARY})
237-
endif()
238-
check_source_runs(C [[
239-
#include <sched.h>
240-
int main(void)
241-
{
242-
if (sched_getcpu() == -1) {
243-
return 1;
244-
}
245-
return 0;
223+
php_search_libraries(
224+
SOURCE_RUNS [[
225+
#include <sched.h>
226+
int main(void)
227+
{
228+
if (sched_getcpu() == -1) {
229+
return 1;
246230
}
247-
]] PHP_EXT_PCNTL_HAVE_SCHED_GETCPU)
248-
endif()
249-
250-
if(PHP_EXT_PCNTL_HAVE_SCHED_GETCPU)
251-
if(PHP_EXT_PCNTL_HAVE_SCHED_GETCPU_LIBRARY)
252-
target_link_libraries(
253-
php_ext_pcntl
254-
PRIVATE ${PHP_EXT_PCNTL_HAVE_SCHED_GETCPU_LIBRARY}
255-
)
256-
endif()
231+
return 0;
232+
}
233+
]]
234+
HEADERS sched.h
235+
LIBRARIES
236+
gnu # Haiku
237+
RESULT_VARIABLE PHP_EXT_PCNTL_HAVE_SCHED_GETCPU
238+
LIBRARY_VARIABLE PHP_EXT_PCNTL_HAVE_SCHED_GETCPU_LIBRARY
239+
TARGET php_ext_pcntl PRIVATE
240+
)
257241

258-
set(HAVE_SCHED_GETCPU TRUE)
259-
endif()
260-
endblock()
242+
set(HAVE_SCHED_GETCPU ${PHP_EXT_PCNTL_HAVE_SCHED_GETCPU})
261243
cmake_pop_check_state()
262244

263245
configure_file(cmake/config.h.in config.h)

0 commit comments

Comments
 (0)