Skip to content

Commit 7d42c93

Browse files
committed
Move __alignof__ check into a separate file
1 parent e57f408 commit 7d42c93

File tree

3 files changed

+38
-20
lines changed

3 files changed

+38
-20
lines changed

cmake/cmake/ConfigureChecks.cmake

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ include_guard(GLOBAL)
1212

1313
include(CheckFunctionExists)
1414
include(CheckIncludeFiles)
15-
include(CheckSourceCompiles)
1615
include(CheckStructHasMember)
1716
include(CheckSymbolExists)
1817
include(CheckTypeSize)
@@ -438,24 +437,6 @@ else()
438437
message(CHECK_PASS "using system default")
439438
endif()
440439

441-
message(CHECK_START "Checking whether the compiler supports __alignof__")
442-
cmake_push_check_state(RESET)
443-
set(CMAKE_REQUIRED_QUIET TRUE)
444-
check_source_compiles(C [[
445-
int main(void)
446-
{
447-
int align = __alignof__(int);
448-
(void)align;
449-
return 0;
450-
}
451-
]] HAVE_ALIGNOF)
452-
cmake_pop_check_state()
453-
if(HAVE_ALIGNOF)
454-
message(CHECK_PASS "yes")
455-
else()
456-
message(CHECK_FAIL "no")
457-
endif()
458-
459440
# Check for GCC function attributes on all systems except ones without glibc.
460441
# Fix for these systems is already included in GCC 7, but not on GCC 6. At least
461442
# some versions of FreeBSD seem to have buggy ifunc support, see
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#[=============================================================================[
2+
This check determines whether the compiler supports __alignof__.
3+
4+
Result variables:
5+
6+
* HAVE_ALIGNOF
7+
#]=============================================================================]
8+
9+
include(CheckSourceCompiles)
10+
include(CMakePushCheckState)
11+
12+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
13+
set(HAVE_ALIGNOF FALSE)
14+
return()
15+
endif()
16+
17+
# Skip in consecutive configuration phases.
18+
if(NOT DEFINED PHP_HAS_ALIGNOF)
19+
message(CHECK_START "Checking whether the compiler supports __alignof__")
20+
cmake_push_check_state(RESET)
21+
set(CMAKE_REQUIRED_QUIET TRUE)
22+
check_source_compiles(C [[
23+
int main(void)
24+
{
25+
int align = __alignof__(int);
26+
(void)align;
27+
return 0;
28+
}
29+
]] PHP_HAS_ALIGNOF)
30+
cmake_pop_check_state()
31+
if(PHP_HAS_ALIGNOF)
32+
message(CHECK_PASS "yes")
33+
else()
34+
message(CHECK_FAIL "no")
35+
endif()
36+
endif()
37+
38+
set(HAVE_ALIGNOF ${PHP_HAS_ALIGNOF})

cmake/cmake/platforms/Windows.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
5454
# known on Windows targets.
5555
##############################################################################
5656

57-
set(HAVE_ALIGNOF FALSE)
5857
set(HAVE_ALPHASORT FALSE)
5958
set(HAVE_ARPA_INET_H FALSE)
6059
set(HAVE_ARPA_NAMESER_H FALSE)

0 commit comments

Comments
 (0)